Skip to content

Commit 0574109

Browse files
committed
cord types
1 parent 1c2b19c commit 0574109

14 files changed

Lines changed: 243 additions & 2 deletions

types/api/address.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
2+
export type Region = {
3+
id: number,
4+
countryId: number,
5+
name: string,
6+
};
7+
8+
export type Address = {
9+
address1: string,
10+
address2?: string,
11+
city: string,
12+
id: number,
13+
name: string,
14+
phoneNumber: string,
15+
region: Region,
16+
zip: string,
17+
};
18+
19+
export type CreateAddressPayload = {
20+
name: string,
21+
regionId: number,
22+
address1: string,
23+
address2?: string,
24+
city: String,
25+
zip: String,
26+
isDefault: boolean,
27+
phoneNumber?: string,
28+
};

types/api/attrs.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ export type Currency = {|
33
t: 'price',
44
v: {
55
currency: string,
6-
value: number
6+
value: number,
77
}
88
|};
99

1010
export type String = {|
1111
t: 'string',
12-
v: string
12+
v: string,
1313
|};

types/api/base.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,7 @@ export type Context = {|
66
modality: string,
77
}
88
|};
9+
10+
export type Attributes = {
11+
[name: string]: any,
12+
};

types/api/cart.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
2+
import type { Address } from './address';
3+
import type { Customer } from './customer';
4+
import type { Promotion } from './promotion';
5+
import type { CordResponseCouponPair } from './cord/promotions';
6+
import type { LineItem, LineItemAdjustment } from './cord/line-items';
7+
import type { PaymentState } from './cord/base';
8+
import type { CartTotals } from './cord/totals';
9+
import type { ShippingMethod } from './shipping-method';
10+
import type { CordPayment } from './cord/payments';
11+
12+
export type Cart = {
13+
referenceNumber: string,
14+
paymentState: PaymentState,
15+
lineItems: {
16+
skus: Array<LineItem>,
17+
},
18+
lineItemAdjustments: Array<LineItemAdjustment>,
19+
promotion?: Promotion,
20+
coupon?: CordResponseCouponPair,
21+
totals: CartTotals,
22+
customer?: Customer,
23+
shippingMethod?: ShippingMethod,
24+
shippingAddress?: Address,
25+
paymentMethods: Array<CordPayment>,
26+
};

types/api/cord/base.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
export type PaymentState = 'auth' | 'cart' | 'fullCapture' | 'failedCapture' | 'expiredAuth';

types/api/cord/line-items.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
2+
import type { CreateAddressPayload } from '../address';
3+
4+
export type LineItemAdjustment = {
5+
adjustmentType: string,
6+
subtract: number,
7+
lineItemRefNum?: string,
8+
}
9+
10+
export type LineItemState = 'cart' | 'pending' | 'preOrdered' | 'backOrdered' | 'canceled' | 'shipped';
11+
12+
export type GiftCardLineItemAttributes = {
13+
senderName: string,
14+
recipientName: string,
15+
recipientEmail: string,
16+
message?: string,
17+
code?: string,
18+
}
19+
20+
export type LineItemAttributes = {
21+
giftCard?: GiftCardLineItemAttributes,
22+
subscription?: CreateAddressPayload,
23+
}
24+
25+
export type LineItem = {
26+
imagePath: string,
27+
referenceNumbers: Array<string>,
28+
name?: string,
29+
sku: string,
30+
price: number,
31+
quantity: number,
32+
totalPrice: number,
33+
productFormId: number,
34+
externalId?: string,
35+
trackInventory: boolean,
36+
state: LineItemState,
37+
attributes?: LineItemAttributes,
38+
}

types/api/cord/payments.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
2+
import type { Address } from '../address';
3+
4+
export type CreditCardPayment = {|
5+
id: number,
6+
customerId: number,
7+
holderName: string,
8+
lastFour: string,
9+
expMonth: number,
10+
expYear: number,
11+
brand: string,
12+
address: Address,
13+
type: 'creditCard',
14+
createdAt: string,
15+
|};
16+
17+
export type GiftCardPayment = {|
18+
code: string,
19+
amount: number,
20+
currentBalance: number,
21+
availableBalance: number,
22+
createdAt: string,
23+
type: 'giftCard',
24+
|};
25+
26+
export type StoreCreditPayment = {|
27+
id: number,
28+
amount: number,
29+
currentBalance: number,
30+
availableBalance: number,
31+
createdAt: string,
32+
type: 'storeCredit',
33+
|};
34+
35+
export type CordPayment = CreditCardPayment | GiftCardPayment | StoreCreditPayment;

types/api/cord/promotions.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
import type { Coupon } from '../coupon';
3+
4+
export type CordResponseCouponPair = {
5+
coupon: Coupon,
6+
code: string,
7+
}

types/api/cord/totals.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
export type OrderTotals = {
3+
subTotal: number,
4+
taxes: number,
5+
shipping: number,
6+
adjustments: number,
7+
total: number,
8+
}
9+
10+
export type CartTotals = OrderTotals & {
11+
customersExpenses: number,
12+
}

types/api/coupon.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
2+
import type { Context, Attributes } from './base';
3+
4+
export type Coupon = {
5+
id: number,
6+
context: Context,
7+
attributes: Attributes,
8+
archivedAt?: string,
9+
promotion: number,
10+
};

0 commit comments

Comments
 (0)