diff options
| author | David Lönnhager <david.l@mullvad.net> | 2023-12-28 17:06:43 +0100 |
|---|---|---|
| committer | David Lönnhager <david.l@mullvad.net> | 2023-12-29 17:55:11 +0100 |
| commit | cf1a16cf77ab65676e133d896e50096445d53e77 (patch) | |
| tree | 8125c0c5be1941a4dc85fe4e1ad4910d96b4a4fe /mullvad-api | |
| parent | 2d1e643e235db3882ac47f439bf844b45e6ed5d4 (diff) | |
| download | mullvadvpn-cf1a16cf77ab65676e133d896e50096445d53e77.tar.xz mullvadvpn-cf1a16cf77ab65676e133d896e50096445d53e77.zip | |
Fetch account ID from API
Diffstat (limited to 'mullvad-api')
| -rw-r--r-- | mullvad-api/src/lib.rs | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/mullvad-api/src/lib.rs b/mullvad-api/src/lib.rs index c8765ec2b2..d9c3d9e21b 100644 --- a/mullvad-api/src/lib.rs +++ b/mullvad-api/src/lib.rs @@ -1,6 +1,5 @@ #![deny(rust_2018_idioms)] -use chrono::{offset::Utc, DateTime}; #[cfg(target_os = "android")] use futures::channel::mpsc; use futures::Stream; @@ -8,7 +7,7 @@ use hyper::Method; #[cfg(target_os = "android")] use mullvad_types::account::{PlayPurchase, PlayPurchasePaymentToken}; use mullvad_types::{ - account::{AccountToken, VoucherSubmission}, + account::{AccountData, AccountToken, VoucherSubmission}, version::AppVersion, }; use proxy::ApiConnectionMode; @@ -382,15 +381,10 @@ impl AccountsProxy { Self { handle } } - pub fn get_expiry( + pub fn get_data( &self, account: AccountToken, - ) -> impl Future<Output = Result<DateTime<Utc>, rest::Error>> { - #[derive(serde::Deserialize)] - struct AccountExpiryResponse { - expiry: DateTime<Utc>, - } - + ) -> impl Future<Output = Result<AccountData, rest::Error>> { let service = self.handle.service.clone(); let factory = self.handle.factory.clone(); async move { @@ -399,8 +393,7 @@ impl AccountsProxy { .expected_status(&[StatusCode::OK]) .account(account)?; let response = service.request(request).await?; - let account: AccountExpiryResponse = response.deserialize().await?; - Ok(account.expiry) + response.deserialize().await } } |
