Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions types/api/address.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

export type Region = {
id: number,
countryId: number,
name: string,
};

export type Address = {
address1: string,
address2?: string,
city: string,
id: number,
name: string,
phoneNumber: string,
region: Region,
zip: string,
};

export type CreateAddressPayload = {
name: string,
regionId: number,
address1: string,
address2?: string,
city: String,
zip: String,
isDefault: boolean,
phoneNumber?: string,
};
4 changes: 2 additions & 2 deletions types/api/attrs.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ export type Currency = {|
t: 'price',
v: {
currency: string,
value: number
value: number,
}
|};

export type String = {|
t: 'string',
v: string
v: string,
|};
4 changes: 4 additions & 0 deletions types/api/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@ export type Context = {|
modality: string,
}
|};

export type Attributes = {
[name: string]: any,
};
26 changes: 26 additions & 0 deletions types/api/cart.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

import type { Address } from './address';
import type { Customer } from './customer';
import type { Promotion } from './promotion';
import type { CordResponseCouponPair } from './cord/promotions';
import type { LineItem, LineItemAdjustment } from './cord/line-items';
import type { PaymentState } from './cord/base';
import type { CartTotals } from './cord/totals';
import type { ShippingMethod } from './shipping-method';
import type { CordPayment } from './cord/payments';

export type Cart = {
referenceNumber: string,
paymentState: PaymentState,
lineItems: {
skus: Array<LineItem>,
},
lineItemAdjustments: Array<LineItemAdjustment>,
promotion?: Promotion,
coupon?: CordResponseCouponPair,
totals: CartTotals,
customer?: Customer,
shippingMethod?: ShippingMethod,
shippingAddress?: Address,
paymentMethods: Array<CordPayment>,
};
2 changes: 2 additions & 0 deletions types/api/cord/base.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

export type PaymentState = 'auth' | 'cart' | 'fullCapture' | 'failedCapture' | 'expiredAuth';
38 changes: 38 additions & 0 deletions types/api/cord/line-items.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@

import type { CreateAddressPayload } from '../address';

export type LineItemAdjustment = {
adjustmentType: string,
subtract: number,
lineItemRefNum?: string,
}

export type LineItemState = 'cart' | 'pending' | 'preOrdered' | 'backOrdered' | 'canceled' | 'shipped';

export type GiftCardLineItemAttributes = {
senderName: string,
recipientName: string,
recipientEmail: string,
message?: string,
code?: string,
}

export type LineItemAttributes = {
giftCard?: GiftCardLineItemAttributes,
subscription?: CreateAddressPayload,
}

export type LineItem = {
imagePath: string,
referenceNumbers: Array<string>,
name?: string,
sku: string,
price: number,
quantity: number,
totalPrice: number,
productFormId: number,
externalId?: string,
trackInventory: boolean,
state: LineItemState,
attributes?: LineItemAttributes,
}
35 changes: 35 additions & 0 deletions types/api/cord/payments.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@

import type { Address } from '../address';

export type CreditCardPayment = {|
id: number,
customerId: number,
holderName: string,
lastFour: string,
expMonth: number,
expYear: number,
brand: string,
address: Address,
type: 'creditCard',
createdAt: string,
|};

export type GiftCardPayment = {|
code: string,
amount: number,
currentBalance: number,
availableBalance: number,
createdAt: string,
type: 'giftCard',
|};

export type StoreCreditPayment = {|
id: number,
amount: number,
currentBalance: number,
availableBalance: number,
createdAt: string,
type: 'storeCredit',
|};

export type CordPayment = CreditCardPayment | GiftCardPayment | StoreCreditPayment;
7 changes: 7 additions & 0 deletions types/api/cord/promotions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

import type { Coupon } from '../coupon';

export type CordResponseCouponPair = {
coupon: Coupon,
code: string,
}
12 changes: 12 additions & 0 deletions types/api/cord/totals.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

export type OrderTotals = {
subTotal: number,
taxes: number,
shipping: number,
adjustments: number,
total: number,
}

export type CartTotals = OrderTotals & {
customersExpenses: number,
}
10 changes: 10 additions & 0 deletions types/api/coupon.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

import type { Context, Attributes } from './base';

export type Coupon = {
id: number,
context: Context,
attributes: Attributes,
archivedAt?: string,
promotion: number,
};
16 changes: 16 additions & 0 deletions types/api/customer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

export type Customer = {
id: number,
createdAt: string,
disabled: boolean,
email: string,
groups: Array<string>,
isBlacklisted: boolean,
isGuest: boolean,
name: string,
totalSales: number,
storeCreditTotals: {
availableBalance: number,
currentBalance: number,
},
};
36 changes: 36 additions & 0 deletions types/api/order.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@

import type { Address } from './address';
import type { Customer } from './customer';
import type { Promotion } from './promotion';
import type { CordResponseCouponPair } from './cord/promotions';
import type { LineItem, LineItemAdjustment } from './cord/line-items';
import type { PaymentState } from './cord/base';
import type { OrderTotals } from './cord/totals';
import type { ShippingMethod } from './shipping-method';
import type { CreditCardPayment, CordPayment } from './cord/payments';

export type OrderState = 'fraudHold' | 'remorseHold' | 'manualHold' | 'canceled' | 'fulfillmentStarted' | 'shipped';

export type Order = {
referenceNumber: string,
paymentState: PaymentState,
lineItems: {
skus: Array<LineItem>
},
lineItemAdjustments: Array<LineItemAdjustment>,
promotion?: Promotion,
coupon?: CordResponseCouponPair,
totals: OrderTotals,
customer: Customer,
shippingMethod: ShippingMethod,
shippingAddress: Address,
billingAddress?: Address,
billingCreditCardInfo?: CreditCardPayment,
paymentMethods: Array<CordPayment>,
// Order-specific
orderState: OrderState,
shippingState?: OrderState,
fraudScore: number,
remorsePeriodEnd?: string,
placedAt: string,
};
19 changes: 19 additions & 0 deletions types/api/promotion.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

import type { Context, Attributes } from './base';

type PromotionApplyType = 'auto' | 'coupon';

type Discount = {
id: number,
context?: Context,
attributes: Attributes, // @TODO, define attributes
};

export type Promotion = {
id: number,
context: Context,
applyType: PromotionApplyType,
attributes: Attributes, // @TODO, define attributes
discounts: Array<Discount>,
archivedAt?: string,
};
8 changes: 8 additions & 0 deletions types/api/shipping-method.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

export type ShippingMethod = {
id: number,
name: string,
code: string,
price: number,
isEnabled: boolean,
};