1use crate::{Merchant, MerchantProfile, MerchantProfileDetails, Result, SumUpClient};
2
3impl SumUpClient {
4 pub async fn get_merchant_profile(&self) -> Result<MerchantProfileDetails> {
9 let url = self.build_url("/v0.1/me")?;
10
11 let response = self
12 .http_client
13 .get(url)
14 .bearer_auth(&self.api_key)
15 .send()
16 .await?;
17
18 if response.status().is_success() {
19 let full_profile = response.json::<MerchantProfile>().await?;
20 Ok(full_profile.merchant_profile)
21 } else {
22 self.handle_error(response).await
23 }
24 }
25
26 pub async fn get_merchant(&self, merchant_code: &str) -> Result<Merchant> {
31 let url = self.build_url(&format!("/v0.1/merchants/{}", merchant_code))?;
32
33 let response = self
34 .http_client
35 .get(url)
36 .bearer_auth(&self.api_key)
37 .send()
38 .await?;
39
40 if response.status().is_success() {
41 let merchant = response.json::<Merchant>().await?;
42 Ok(merchant)
43 } else {
44 self.handle_error(response).await
45 }
46 }
47
48 pub async fn list_merchants(&self) -> Result<Vec<crate::Membership>> {
54 self.list_memberships().await
55 }
56}