primer_api/request/
update_client_side_token_client_session_patch.rs

1use serde_json::json;
2use crate::model::*;
3use crate::PrimerClient;
4/**Create this with the associated client method.
5
6That method takes required values as arguments. Set optional values using builder methods on this struct.*/
7pub struct UpdateClientSideTokenClientSessionPatchRequest<'a> {
8    pub(crate) client: &'a PrimerClient,
9    pub client_token: String,
10    pub customer_id: String,
11    pub order_id: String,
12    pub currency_code: String,
13    pub amount: serde_json::Value,
14    pub metadata: serde_json::Value,
15    pub customer: CheckoutCustomerDetailsApiSchema,
16    pub order: OrderDetailsApiSchema,
17    pub payment_method: CheckoutPaymentMethodOptionsApiSchema,
18}
19impl<'a> UpdateClientSideTokenClientSessionPatchRequest<'a> {
20    pub async fn send(self) -> anyhow::Result<ClientSessionApiResponse> {
21        let mut r = self.client.client.patch("/client-session");
22        r = r.push_json(json!({ "clientToken" : self.client_token }));
23        r = r.push_json(json!({ "customerId" : self.customer_id }));
24        r = r.push_json(json!({ "orderId" : self.order_id }));
25        r = r.push_json(json!({ "currencyCode" : self.currency_code }));
26        r = r.push_json(json!({ "amount" : self.amount }));
27        r = r.push_json(json!({ "metadata" : self.metadata }));
28        r = r.push_json(json!({ "customer" : self.customer }));
29        r = r.push_json(json!({ "order" : self.order }));
30        r = r.push_json(json!({ "paymentMethod" : self.payment_method }));
31        r = self.client.authenticate(r);
32        let res = r.send().await.unwrap().error_for_status();
33        match res {
34            Ok(res) => res.json().await.map_err(|e| anyhow::anyhow!("{:?}", e)),
35            Err(res) => {
36                let text = res.text().await.map_err(|e| anyhow::anyhow!("{:?}", e))?;
37                Err(anyhow::anyhow!("{:?}", text))
38            }
39        }
40    }
41}
42pub struct UpdateClientSideTokenClientSessionPatchRequired<'a> {
43    pub client_token: &'a str,
44    pub customer_id: &'a str,
45    pub order_id: &'a str,
46    pub currency_code: &'a str,
47    pub amount: serde_json::Value,
48    pub metadata: serde_json::Value,
49    pub customer: CheckoutCustomerDetailsApiSchema,
50    pub order: OrderDetailsApiSchema,
51    pub payment_method: CheckoutPaymentMethodOptionsApiSchema,
52}
53impl<'a> UpdateClientSideTokenClientSessionPatchRequired<'a> {}