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
/// 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/orders
/// Returns order history from at least the past 6 months. Supports pagination.
///
/// Query Parameters:
/// - `unknown` (object) – The structure of the query parameters is not specified
pub async fn get_orders(&self, params: Option<Value>) -> Result<Value> {
let url = format!("{}/1.0/orders", 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/orders
///
/// Request JSON Object:
/// - `asin` (string)
/// - `audiblecreditapplied` (boolean) – Will specify whether to use available credits or default payment method.
pub async fn post_orders(&self, params: Option<Value>) -> Result<Value> {
let url = format!("{}/1.0/orders", 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)
}
}