1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/// see API docs at https://audible.readthedocs.io/en/latest/misc/external_api.html
use serde_json::Value;
use super::Client;
use crate::Result;
impl Client {
/// GET /1.0/wishlist
///
/// Query Parameters:
/// - `num_results` (integer) – (max: 50)
/// - `page` (integer) – (wishlist starts at page 0)
/// - `locale` (string) – e.g. de-DE
/// - `response_groups` (string) – [contributors, media, price, product_attrs, product_desc, product_extended_attrs,
/// product_plan_details, product_plans, rating, sample, sku, customer_rights, relationships]
/// - `sort_by` (string) – [-Author, -DateAdded, -Price, -Rating, -Title, Author, DateAdded, Price, Rating, Title]
pub async fn get_wishlist(&self, params: Option<Value>) -> Result<Value> {
let url = format!("{}/1.0/wishlist", self.base_url);
let mut req = self.client.get(url);
if let Some(params) = params {
req = req.query(¶ms);
}
let req = req.build()?;
let res = self.send_request(req).await?;
let json: Value = res.json().await?;
Ok(json)
}
/// POST /1.0/wishlist
///
/// Request JSON Object:
/// - `asin` (string) – The ASIN of the book to add
///
/// Status Codes:
/// - `201 Created` – Returns the Location to the resource.
pub async fn post_wishlist(&self, params: Option<Value>) -> Result<Value> {
let url = format!("{}/1.0/wishlist", self.base_url);
let mut req = self.client.post(url);
if let Some(params) = params {
req = req.json(¶ms);
}
let req = req.build()?;
let res = self.send_request(req).await?;
let json: Value = res.json().await?;
Ok(json)
}
/// DELETE /1.0/wishlist/(string:asin)
///
/// Parameters:
/// - `asin` (string) – The ASIN of the book
///
/// Status Codes:
/// - `204 No Content` – Removes the item from the wishlist using the given ASIN.
pub async fn delete_from_wishlist(&self, asin: &str, params: Option<Value>) -> Result<Value> {
let url = format!("{}/1.0/wishlist/{}", self.base_url, asin);
let mut req = self.client.post(url);
if let Some(params) = params {
req = req.json(¶ms);
}
let req = req.build()?;
let res = self.send_request(req).await?;
let json: Value = res.json().await?;
Ok(json)
}
}