@thorprovider/medusa-extended 1.7.1 → 1.7.3

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.
@@ -768,13 +768,14 @@ export class DropshipperClient {
768
768
  async getCustomers(
769
769
  options: GetDropshipperCustomersOptions = {},
770
770
  ): Promise<GetDropshipperCustomersResponse> {
771
- const { q, has_orders, from, limit = 20, offset = 0 } = options;
771
+ const { q, has_orders, from, limit = 20, offset = 0, order } = options;
772
772
  const qs = new URLSearchParams({
773
773
  limit: String(limit),
774
774
  offset: String(offset),
775
775
  ...(q ? { q } : {}),
776
776
  ...(has_orders !== undefined ? { has_orders: String(has_orders) } : {}),
777
777
  ...(from ? { from } : {}),
778
+ ...(order ? { order } : {}),
778
779
  });
779
780
  return this.request<GetDropshipperCustomersResponse>(
780
781
  'GET',
@@ -841,6 +842,27 @@ export class DropshipperClient {
841
842
  // Customer Addresses (Solo Y) — B-06
842
843
  // -------------------------------------------------------------------------
843
844
 
845
+ /**
846
+ * Transform a raw snake_case address from the API into a camelCase Address.
847
+ */
848
+ private transformAddress(raw: any): import('@thorprovider/types').Address {
849
+ return {
850
+ id: raw.id ?? undefined,
851
+ firstName: raw.first_name ?? '',
852
+ lastName: raw.last_name ?? '',
853
+ company: raw.company ?? undefined,
854
+ address1: raw.address_1 ?? '',
855
+ address2: raw.address_2 ?? undefined,
856
+ city: raw.city ?? '',
857
+ province: raw.province ?? '',
858
+ postalCode: raw.postal_code ?? '',
859
+ countryCode: raw.country_code ?? '',
860
+ phone: raw.phone ?? undefined,
861
+ isDefault: raw.is_default ?? raw.is_default_shipping ?? undefined,
862
+ metadata: raw.metadata ?? undefined,
863
+ };
864
+ }
865
+
844
866
  /**
845
867
  * List addresses for a customer in Y's channel.
846
868
  *
@@ -849,10 +871,15 @@ export class DropshipperClient {
849
871
  async getCustomerAddresses(
850
872
  customerId: string,
851
873
  ): Promise<GetDropshipperAddressesResponse> {
852
- return this.request<GetDropshipperAddressesResponse>(
853
- 'GET',
854
- `/admin/thor/dropshipper/customers/${customerId}/addresses`,
855
- );
874
+ const raw = await this.request<{
875
+ addresses: any[];
876
+ count: number;
877
+ }>('GET', `/admin/thor/dropshipper/customers/${customerId}/addresses`);
878
+
879
+ return {
880
+ addresses: raw.addresses.map((a) => this.transformAddress(a)),
881
+ count: raw.count,
882
+ };
856
883
  }
857
884
 
858
885
  /**
@@ -864,11 +891,13 @@ export class DropshipperClient {
864
891
  customerId: string,
865
892
  body: DropshipperAddressBody,
866
893
  ): Promise<DropshipperAddressResponse> {
867
- return this.request<DropshipperAddressResponse>(
894
+ const raw = await this.request<{ address: any }>(
868
895
  'POST',
869
896
  `/admin/thor/dropshipper/customers/${customerId}/addresses`,
870
897
  body,
871
898
  );
899
+
900
+ return { address: this.transformAddress(raw.address) };
872
901
  }
873
902
 
874
903
  /**
@@ -881,11 +910,13 @@ export class DropshipperClient {
881
910
  addressId: string,
882
911
  body: Partial<DropshipperAddressBody>,
883
912
  ): Promise<DropshipperAddressResponse> {
884
- return this.request<DropshipperAddressResponse>(
913
+ const raw = await this.request<{ address: any }>(
885
914
  'POST',
886
915
  `/admin/thor/dropshipper/customers/${customerId}/addresses/${addressId}`,
887
916
  body,
888
917
  );
918
+
919
+ return { address: this.transformAddress(raw.address) };
889
920
  }
890
921
 
891
922
  /**