@thorprovider/medusa-extended 1.7.0 → 1.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -841,6 +841,27 @@ export class DropshipperClient {
841
841
  // Customer Addresses (Solo Y) — B-06
842
842
  // -------------------------------------------------------------------------
843
843
 
844
+ /**
845
+ * Transform a raw snake_case address from the API into a camelCase Address.
846
+ */
847
+ private transformAddress(raw: any): import('@thorprovider/types').Address {
848
+ return {
849
+ id: raw.id ?? undefined,
850
+ firstName: raw.first_name ?? '',
851
+ lastName: raw.last_name ?? '',
852
+ company: raw.company ?? undefined,
853
+ address1: raw.address_1 ?? '',
854
+ address2: raw.address_2 ?? undefined,
855
+ city: raw.city ?? '',
856
+ province: raw.province ?? '',
857
+ postalCode: raw.postal_code ?? '',
858
+ countryCode: raw.country_code ?? '',
859
+ phone: raw.phone ?? undefined,
860
+ isDefault: raw.is_default ?? raw.is_default_shipping ?? undefined,
861
+ metadata: raw.metadata ?? undefined,
862
+ };
863
+ }
864
+
844
865
  /**
845
866
  * List addresses for a customer in Y's channel.
846
867
  *
@@ -849,10 +870,15 @@ export class DropshipperClient {
849
870
  async getCustomerAddresses(
850
871
  customerId: string,
851
872
  ): Promise<GetDropshipperAddressesResponse> {
852
- return this.request<GetDropshipperAddressesResponse>(
853
- 'GET',
854
- `/admin/thor/dropshipper/customers/${customerId}/addresses`,
855
- );
873
+ const raw = await this.request<{
874
+ addresses: any[];
875
+ count: number;
876
+ }>('GET', `/admin/thor/dropshipper/customers/${customerId}/addresses`);
877
+
878
+ return {
879
+ addresses: raw.addresses.map((a) => this.transformAddress(a)),
880
+ count: raw.count,
881
+ };
856
882
  }
857
883
 
858
884
  /**
@@ -864,11 +890,13 @@ export class DropshipperClient {
864
890
  customerId: string,
865
891
  body: DropshipperAddressBody,
866
892
  ): Promise<DropshipperAddressResponse> {
867
- return this.request<DropshipperAddressResponse>(
893
+ const raw = await this.request<{ address: any }>(
868
894
  'POST',
869
895
  `/admin/thor/dropshipper/customers/${customerId}/addresses`,
870
896
  body,
871
897
  );
898
+
899
+ return { address: this.transformAddress(raw.address) };
872
900
  }
873
901
 
874
902
  /**
@@ -881,11 +909,13 @@ export class DropshipperClient {
881
909
  addressId: string,
882
910
  body: Partial<DropshipperAddressBody>,
883
911
  ): Promise<DropshipperAddressResponse> {
884
- return this.request<DropshipperAddressResponse>(
912
+ const raw = await this.request<{ address: any }>(
885
913
  'POST',
886
914
  `/admin/thor/dropshipper/customers/${customerId}/addresses/${addressId}`,
887
915
  body,
888
916
  );
917
+
918
+ return { address: this.transformAddress(raw.address) };
889
919
  }
890
920
 
891
921
  /**