@misiki/gocommerce-connector 0.4.3 → 0.4.4

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.
@@ -4534,7 +4534,124 @@ declare class OrderService extends BaseService {
4534
4534
  noOfPage: number;
4535
4535
  page: number;
4536
4536
  }>;
4537
- getOrderByEmailAndOTP(): Promise<never>;
4537
+ /**
4538
+ * Sends a 4-digit code to the email or phone on the order, when `contact`
4539
+ * is that email or phone. The engine answers the same either way, so this
4540
+ * resolves whether or not anything was sent.
4541
+ */
4542
+ requestOrderCode({ orderNo, contact }: {
4543
+ orderNo: string;
4544
+ contact: string;
4545
+ }): Promise<{
4546
+ expiresInMinutes: number;
4547
+ }>;
4548
+ /**
4549
+ * Opens an order with the code `requestOrderCode` sent. The token it answers
4550
+ * is kept like an order placed in this browser, so the order page and
4551
+ * `getOrder` read it again without another code.
4552
+ */
4553
+ getOrderByEmailAndOTP({ orderNo, otp }: {
4554
+ orderNo: string;
4555
+ otp: string;
4556
+ email?: string;
4557
+ }): Promise<{
4558
+ data: {
4559
+ id: string;
4560
+ orderNo: string;
4561
+ orderNumber: string;
4562
+ number: string;
4563
+ parentOrderNo: string;
4564
+ status: string;
4565
+ engineStatus: string;
4566
+ paymentStatus: string;
4567
+ paymentMethod: string;
4568
+ currencyCode: string;
4569
+ subtotal: number;
4570
+ shippingCharges: number;
4571
+ discount: number;
4572
+ tax: number;
4573
+ taxIncluded: boolean;
4574
+ total: number;
4575
+ refunded: number;
4576
+ codCharges: number;
4577
+ coupon: {
4578
+ code: string;
4579
+ } | null;
4580
+ userEmail: string;
4581
+ email: string;
4582
+ phone: string | null;
4583
+ shippingAddress: {
4584
+ firstName: string;
4585
+ lastName: string;
4586
+ email: string | null;
4587
+ phone: string | null;
4588
+ address_1: string;
4589
+ address_2: string;
4590
+ city: string;
4591
+ state: string;
4592
+ zip: string;
4593
+ country: string;
4594
+ countryCode: string;
4595
+ } | null;
4596
+ billingAddress: {
4597
+ firstName: string;
4598
+ lastName: string;
4599
+ email: string | null;
4600
+ phone: string | null;
4601
+ address_1: string;
4602
+ address_2: string;
4603
+ city: string;
4604
+ state: string;
4605
+ zip: string;
4606
+ country: string;
4607
+ countryCode: string;
4608
+ } | null;
4609
+ shippingMethod: string | null;
4610
+ shippingRate: {
4611
+ name: string;
4612
+ } | null;
4613
+ lineItems: {
4614
+ id: string;
4615
+ productId: string;
4616
+ variantId: string;
4617
+ sku: string;
4618
+ title: string;
4619
+ name: string;
4620
+ slug: string;
4621
+ thumbnail: string | null;
4622
+ img: string | null;
4623
+ variantTitle: string;
4624
+ qty: number;
4625
+ shippedQty: number;
4626
+ price: number;
4627
+ mrp: number;
4628
+ subtotal: number;
4629
+ total: number;
4630
+ currencyCode: string;
4631
+ status: string;
4632
+ files: never[];
4633
+ usedOptions: never[];
4634
+ }[];
4635
+ fulfillments: {
4636
+ id: string;
4637
+ status: string;
4638
+ carrier: string;
4639
+ trackingNumber: string | null;
4640
+ trackingUrl: string | null;
4641
+ lineItems: {
4642
+ id: string;
4643
+ title: string;
4644
+ qty: number;
4645
+ }[];
4646
+ createdAt: string;
4647
+ }[];
4648
+ tracking: never[];
4649
+ orderHistory: never[];
4650
+ isReplaceOrReturn: boolean;
4651
+ createdAt: string;
4652
+ updatedAt: string;
4653
+ }[];
4654
+ }>;
4538
4655
  }
4539
4656
  declare const orderService: OrderService;
4540
4657
 
@@ -4534,7 +4534,124 @@ declare class OrderService extends BaseService {
4534
4534
  noOfPage: number;
4535
4535
  page: number;
4536
4536
  }>;
4537
- getOrderByEmailAndOTP(): Promise<never>;
4537
+ /**
4538
+ * Sends a 4-digit code to the email or phone on the order, when `contact`
4539
+ * is that email or phone. The engine answers the same either way, so this
4540
+ * resolves whether or not anything was sent.
4541
+ */
4542
+ requestOrderCode({ orderNo, contact }: {
4543
+ orderNo: string;
4544
+ contact: string;
4545
+ }): Promise<{
4546
+ expiresInMinutes: number;
4547
+ }>;
4548
+ /**
4549
+ * Opens an order with the code `requestOrderCode` sent. The token it answers
4550
+ * is kept like an order placed in this browser, so the order page and
4551
+ * `getOrder` read it again without another code.
4552
+ */
4553
+ getOrderByEmailAndOTP({ orderNo, otp }: {
4554
+ orderNo: string;
4555
+ otp: string;
4556
+ email?: string;
4557
+ }): Promise<{
4558
+ data: {
4559
+ id: string;
4560
+ orderNo: string;
4561
+ orderNumber: string;
4562
+ number: string;
4563
+ parentOrderNo: string;
4564
+ status: string;
4565
+ engineStatus: string;
4566
+ paymentStatus: string;
4567
+ paymentMethod: string;
4568
+ currencyCode: string;
4569
+ subtotal: number;
4570
+ shippingCharges: number;
4571
+ discount: number;
4572
+ tax: number;
4573
+ taxIncluded: boolean;
4574
+ total: number;
4575
+ refunded: number;
4576
+ codCharges: number;
4577
+ coupon: {
4578
+ code: string;
4579
+ } | null;
4580
+ userEmail: string;
4581
+ email: string;
4582
+ phone: string | null;
4583
+ shippingAddress: {
4584
+ firstName: string;
4585
+ lastName: string;
4586
+ email: string | null;
4587
+ phone: string | null;
4588
+ address_1: string;
4589
+ address_2: string;
4590
+ city: string;
4591
+ state: string;
4592
+ zip: string;
4593
+ country: string;
4594
+ countryCode: string;
4595
+ } | null;
4596
+ billingAddress: {
4597
+ firstName: string;
4598
+ lastName: string;
4599
+ email: string | null;
4600
+ phone: string | null;
4601
+ address_1: string;
4602
+ address_2: string;
4603
+ city: string;
4604
+ state: string;
4605
+ zip: string;
4606
+ country: string;
4607
+ countryCode: string;
4608
+ } | null;
4609
+ shippingMethod: string | null;
4610
+ shippingRate: {
4611
+ name: string;
4612
+ } | null;
4613
+ lineItems: {
4614
+ id: string;
4615
+ productId: string;
4616
+ variantId: string;
4617
+ sku: string;
4618
+ title: string;
4619
+ name: string;
4620
+ slug: string;
4621
+ thumbnail: string | null;
4622
+ img: string | null;
4623
+ variantTitle: string;
4624
+ qty: number;
4625
+ shippedQty: number;
4626
+ price: number;
4627
+ mrp: number;
4628
+ subtotal: number;
4629
+ total: number;
4630
+ currencyCode: string;
4631
+ status: string;
4632
+ files: never[];
4633
+ usedOptions: never[];
4634
+ }[];
4635
+ fulfillments: {
4636
+ id: string;
4637
+ status: string;
4638
+ carrier: string;
4639
+ trackingNumber: string | null;
4640
+ trackingUrl: string | null;
4641
+ lineItems: {
4642
+ id: string;
4643
+ title: string;
4644
+ qty: number;
4645
+ }[];
4646
+ createdAt: string;
4647
+ }[];
4648
+ tracking: never[];
4649
+ orderHistory: never[];
4650
+ isReplaceOrReturn: boolean;
4651
+ createdAt: string;
4652
+ updatedAt: string;
4653
+ }[];
4654
+ }>;
4538
4655
  }
4539
4656
  declare const orderService: OrderService;
4540
4657
 
package/dist/index.cjs CHANGED
@@ -2044,12 +2044,31 @@ var OrderService = class extends BaseService {
2044
2044
  async listPublic(_args = {}) {
2045
2045
  return emptyPage();
2046
2046
  }
2047
- async getOrderByEmailAndOTP() {
2048
- throw new NotSupportedError(
2049
- "OrderService",
2050
- "getOrderByEmailAndOTP",
2051
- "the engine sends no one-time codes; a guest reads an order with its access token"
2047
+ /**
2048
+ * Sends a 4-digit code to the email or phone on the order, when `contact`
2049
+ * is that email or phone. The engine answers the same either way, so this
2050
+ * resolves whether or not anything was sent.
2051
+ */
2052
+ async requestOrderCode({ orderNo, contact }) {
2053
+ const res = await this.data(
2054
+ `/api/orders/${encodeURIComponent(orderNo.trim())}/code`,
2055
+ { method: "POST", body: { contact: contact.trim() } }
2056
+ );
2057
+ return { expiresInMinutes: res?.expires_in_minutes ?? 10 };
2058
+ }
2059
+ /**
2060
+ * Opens an order with the code `requestOrderCode` sent. The token it answers
2061
+ * is kept like an order placed in this browser, so the order page and
2062
+ * `getOrder` read it again without another code.
2063
+ */
2064
+ async getOrderByEmailAndOTP({ orderNo, otp }) {
2065
+ const number = orderNo.trim();
2066
+ const res = await this.data(
2067
+ `/api/orders/${encodeURIComponent(number)}/code/verify`,
2068
+ { method: "POST", body: { code: String(otp).trim() } }
2052
2069
  );
2070
+ rememberOrder({ number: res.order.number, token: res.access_token, cartId: "" });
2071
+ return { data: [toOrder(res.order)] };
2053
2072
  }
2054
2073
  };
2055
2074
  var clean2 = (v) => v && v !== "undefined" && v !== "null" ? v : void 0;