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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/// 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/stats/aggregates
///
/// Query Parameters:
/// - `daily_listening_interval_duration` (string) – ([012]?[0-9])|(30) (0 to 30, inclusive)
/// - `daily_listening_interval_start_date` (string) – YYYY-MM-DD (e.g. 2019-06-16)
/// - `locale` (string) – en_US
/// - `monthly_listening_interval_duration` (string) – 0?[0-9]|1[012] (0 to 12, inclusive)
/// - `monthly_listening_interval_start_date` (string) – YYYY-MM (e.g. 2019-02)
/// - `response_groups` (string) – [total_listening_stats]
/// - `store` (string) – [AudibleForInstitutions, Audible, AmazonEnglish, Rodizio]
pub async fn get_stats_aggregates(&self, params: Option<Value>) -> Result<Value> {
let url = format!("{}/1.0/stats/aggregates", 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)
}
/// GET /1.0/stats/status/finished
///
/// Query Parameters:
/// - `asin` (string) – ASIN
/// - `start_date` (string) – [RFC3339](https://tools.ietf.org/html/rfc3339) (e.g. 2000-01-01T00:00:00Z)
pub async fn get_stats_status_finished(&self, params: Option<Value>) -> Result<Value> {
let url = format!("{}/1.0/stats/status/finished", 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/stats/status/finished
///
/// Request JSON Object:
/// - `start_date` (string)
/// - `status` (string)
/// - `continuation_token` (string)
pub async fn post_stats_status_finished(&self, params: Option<Value>) -> Result<Value> {
let url = format!("{}/1.0/stats/status/finished", 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)
}
/// PUT /1.0/stats/events
///
/// Request JSON Object:
/// - `stats` (object)
///
/// Example:
/// ```json
/// {
/// "stats": [
/// {
/// "download_start": {
/// "country_code": "de",
/// "download_host": "xxxxx.cloudfront.net",
/// "user_agent": "Audible, iPhone, 3.35.1 (644), iPhone XS (iPhone11,2), 238 GB, iOS, 14.1, Wifi",
/// "request_id": "xxxxxxxxxxxx",
/// "codec": "AAX_44_128",
/// "source": "audible_iPhone"
/// },
/// "social_network_site": "Unknown",
/// "event_type": "DownloadStart",
/// "listening_mode": "Offline",
/// "local_timezone": "Europe/Berlin",
/// "asin_owned": false,
/// "playing_immersion_reading": false,
/// "audio_type": "FullTitle",
/// "event_timestamp": "2020-10-23T21:29:06.985Z",
/// "asin": "xxxxxxx",
/// "store": "Audible",
/// "delivery_type": "Download"
/// }
/// ]
/// }
/// ```
pub async fn put_stats_events(&self, params: Option<Value>) -> Result<Value> {
let url = format!("{}/1.0/stats/events", self.base_url);
let mut req = self.client.put(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)
}
}