diff --git a/Cargo.toml b/Cargo.toml index edc1c27..613e000 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "libmaccas" -version = "0.43.0" +version = "0.45.0" edition = "2021" license = "MIT" description = "McDonald's API Client" diff --git a/src/api.rs b/src/api.rs index 6d3640f..7230791 100644 --- a/src/api.rs +++ b/src/api.rs @@ -1,9 +1,11 @@ -use crate::types::request::{ActivateAndSignInRequest, ActivationRequest, RegistrationRequest}; +use crate::types::request::{ + ActivateAndSignInRequest, ActivationRequest, EmailRequest, RegistrationRequest, +}; use crate::types::response::{ ActivateAndSignInResponse, ActivationResponse, CatalogResponse, ClientResponse, - CustomerPointResponse, LoginRefreshResponse, LoginResponse, OfferDealStackResponse, - OfferDetailsResponse, OfferResponse, RegistrationResponse, RestaurantLocationResponse, - RestaurantResponse, TokenResponse, + CustomerPointResponse, EmailResponse, LoginRefreshResponse, LoginResponse, + OfferDealStackResponse, OfferDetailsResponse, OfferResponse, RegistrationResponse, + RestaurantLocationResponse, RestaurantResponse, TokenResponse, }; use crate::ClientResult; use anyhow::Context; @@ -201,6 +203,25 @@ impl ApiClient { ClientResponse::from_response(response).await } + // POST https://ap-prod.api.mcd.com/exp/v1/customer/identity/email + #[instrument] + pub async fn identity_email( + &self, + request: &EmailRequest, + ) -> ClientResult> { + let token = self.login_token.as_ref().context("no login token set")?; + + let request = self + .get_default_request("exp/v1/customer/identity/email", Method::POST) + .bearer_auth(token) + .json(&request); + + let response = request.send().await?; + tracing::debug!("raw response: {:?}", response); + + ClientResponse::from_response(response).await + } + // POST https://ap-prod.api.mcd.com/exp/v1/customer/login #[instrument(skip(sensor_data))] pub async fn customer_login( diff --git a/src/types/request.rs b/src/types/request.rs index a9e3ec9..402e51e 100644 --- a/src/types/request.rs +++ b/src/types/request.rs @@ -1,6 +1,14 @@ use serde_derive::Deserialize; use serde_derive::Serialize; +#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct EmailRequest { + pub customer_identifier: String, + pub device_id: String, + pub registration_type: String, +} + #[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct ActivateAndSignInRequest { diff --git a/src/types/response.rs b/src/types/response.rs index 2144b54..8f27534 100644 --- a/src/types/response.rs +++ b/src/types/response.rs @@ -36,6 +36,12 @@ where } } +#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)] +#[serde(rename_all = "camelCase")] +pub struct EmailResponse { + pub status: Status, +} + #[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)] #[serde(rename_all = "camelCase")] pub struct ActivateAndSignInResponse {