Skip to content

Commit

Permalink
fix(chowly-api-client): add optional keyfrom order interf
Browse files Browse the repository at this point in the history
  • Loading branch information
tudormd committed May 25, 2020
1 parent ec022aa commit 7c2eade
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 30 deletions.
18 changes: 15 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,21 @@ npm i @goparrot/chowly-api-client
### Simple example

```typescript
import { ChowlyClient, ICreateOrder } from '@goparrot/chowly-api-client';
import { ChowlyApiClient, ICreateOrder } from '@goparrot/chowly-api-client';

const client = new ChowlyClient({
const customer:ICustomer = { /* your customer data */ };

const info:IOrderInfo = { /* your info data */ };

const item:IOrderItem = { /* your item data */ };

const chowlyOrder:ICreateOrder = {
customer,
info,
items: [item],
};

const client = new ChowlyApiClient({
apiKey: 'test',
baseUrl: 'baseurl',
maxRetries: 5
Expand Down Expand Up @@ -51,7 +63,7 @@ client.getOrder(orderId)

## Available Options

### `ChowlyClient` Options
### `ChowlyApiClient` Options
apyKey: string;
baseUrl: string;
maxRetries?: number;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@goparrot/chowly-api-client",
"version": "0.0.2",
"version": "0.0.3",
"description": "Typescript library which implements Chowly API",
"engines": {
"node": ">=12"
Expand Down
23 changes: 12 additions & 11 deletions src/interface/order.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,21 @@ export interface ICustomer {
id: string;
name: string;
phone: string;
email: string | null;
email?: string;
// Required only for service_type - Delivery
address1?: string;
address2: string | null;
address2?: string;
city?: string;
state?: string;
zip?: string;
cross_street: string | null;
special_instructions: string | null;
cross_street?: string;
special_instructions?: string;
}

export interface IOrderInfo {
id: string;
scheduled_time: IScheduledTime[] | null;
pickup_code: string | null;
scheduled_time?: IScheduledTime[];
pickup_code?: string;
service_type: ServiceTypeEnum;
payment_is_cash: boolean;
payment_type: PaymentTypeEnum;
Expand All @@ -29,25 +30,25 @@ export interface IOrderInfo {
sales_tax: string;
tip: string;
total: string;
coupon_description: string | null;
coupon_description?: string;
coupon_amount?: string;
}

export interface IOrderItem {
id: string;
name: string;
external_id: string | null;
external_id?: string;
price: string;
quantity: string;
notes: string | null;
notes?: string;
mods: IMod[];
}

export interface IMod {
id: string;
name: string;
category: string | null;
external_id: string | null;
category?: string;
external_id?: string;
price: string;
quantity: string;
}
Expand Down
26 changes: 13 additions & 13 deletions src/model/create-order.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@ export class Customer implements ICustomer {
id: string;
name: string;
phone: string;
email: string | null;
email?: string;
address1?: string;
address2: string | null;
address2?: string;
city?: string;
state?: string;
zip?: string;
cross_street: string | null;
special_instructions: string | null;
cross_street?: string;
special_instructions?: string;
}

export class Info implements IOrderInfo {
id: string;
scheduled_time: IScheduledTime[] | null;
pickup_code: string | null;
scheduled_time?: IScheduledTime[];
pickup_code?: string;
service_type: ServiceTypeEnum;
payment_is_cash: boolean;
payment_type: PaymentTypeEnum;
Expand All @@ -36,25 +36,25 @@ export class Info implements IOrderInfo {
sales_tax: string;
tip: string;
total: string;
coupon_description: string | null;
coupon_description?: string;
coupon_amount?: string;
}

export class ItemOrder implements IOrderItem {
id: string;
name: string;
external_id: string | null;
external_id?: string;
price: string;
quantity: string;
notes: string | null;
mods: Mods[];
notes?: string;
mods: Mod[];
}

export class Mods implements IMod {
export class Mod implements IMod {
id: string;
name: string;
category: string | null;
external_id: string | null;
category?: string;
external_id?: string;
price: string;
quantity: string;
}
2 changes: 0 additions & 2 deletions test/unit/fixture/chowly-order.fixture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ export const Customer: ICustomer = {
id: 'e',
name: 'w',
phone: '5555555555',
email: null,
address1: '1234 S Main Street',
address2: 'Suite 180',
city: 'New York',
Expand All @@ -19,7 +18,6 @@ export const Customer: ICustomer = {

const Info: IOrderInfo = {
id: '4f20a834-d67b-4c76-bb04-2d79fb4c71f172e71qe7',
scheduled_time: null,
pickup_code: 'AZ45jd9pQckJf078',
service_type: ServiceTypeEnum.DELIVERY,
payment_is_cash: false,
Expand Down

0 comments on commit 7c2eade

Please sign in to comment.