Skip to content
This repository has been archived by the owner on Dec 2, 2019. It is now read-only.

Major release: 2.0 #6

Merged
merged 53 commits into from
Nov 14, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
d92bedc
Restructure files
nozzlegear Sep 22, 2016
930ee04
Switch to using @types
nozzlegear Oct 27, 2016
5d86951
Add Yarn
nozzlegear Oct 27, 2016
e59f0da
Ignore dist file on compilation
nozzlegear Oct 27, 2016
9fe14d5
Do not check in built files.
nozzlegear Oct 27, 2016
a722b02
Removed gulp, use tsc and mocha-cli instead.
nozzlegear Oct 27, 2016
330f5ea
Do not distribute test files.
nozzlegear Oct 27, 2016
ab65d28
Use node 6.9
nozzlegear Oct 27, 2016
4ba1dfe
Generate declaration files.
nozzlegear Oct 27, 2016
8ecbe38
Update node-fetch and fix usage bugs.
nozzlegear Oct 27, 2016
22e0e6b
Fix formatting
nozzlegear Oct 27, 2016
dbd0cf5
[Travis-CI] Only build master branch
nozzlegear Oct 27, 2016
4f4cc70
Change exports to export default
nozzlegear Oct 27, 2016
1bdcc22
Add address model.
nozzlegear Oct 27, 2016
c8fc8f4
Restructuring interface declarations
nozzlegear Oct 27, 2016
15328e0
Finalized declaration structure.
nozzlegear Oct 28, 2016
3405b43
Add ClientDetails declarations
nozzlegear Oct 28, 2016
740e460
Add discount code declaration.
nozzlegear Oct 28, 2016
1b2c90d
Add payment details declaration
nozzlegear Oct 28, 2016
cd3b7c0
Completed Order declaration
nozzlegear Oct 28, 2016
08829a3
Added Order service
nozzlegear Oct 28, 2016
cfc8ef9
Adding tests for Orders service
nozzlegear Oct 28, 2016
cf1e478
Add typings distribution script
nozzlegear Oct 28, 2016
b45ffbf
Use installed tsc to build project
nozzlegear Oct 30, 2016
3f85699
Don't export Enums, Models and Options
nozzlegear Oct 30, 2016
7fddbf9
Finalized custom typings export
nozzlegear Oct 30, 2016
0576d93
Add fulfillment status declaration
nozzlegear Oct 31, 2016
a83b15d
Add customer declaration
nozzlegear Oct 31, 2016
edb60d5
Add transaction declaration.
nozzlegear Oct 31, 2016
98d3f68
Allow adding transactions to order creation.
nozzlegear Oct 31, 2016
2c37fa2
Create test order object.
nozzlegear Oct 31, 2016
4730ceb
Change 'fields' to a string, not string array.
nozzlegear Nov 1, 2016
4dc5f35
Add test for orders
nozzlegear Nov 1, 2016
edd9405
2.0.1-0
nozzlegear Nov 1, 2016
68a8b24
2.0.0 prerelease
nozzlegear Nov 1, 2016
024f99e
2.0.0-1
nozzlegear Nov 1, 2016
e7e7ea6
2.0.0-2
nozzlegear Nov 1, 2016
bffa465
Bugfix: increase test timeout to 30 seconds.
nozzlegear Nov 1, 2016
8b73b16
Add a .apiRateLimitReached flag
nozzlegear Nov 1, 2016
ef5cfdd
Add scripts for all test types
nozzlegear Nov 1, 2016
dd0b1c5
Added handling for 'oauth code used' errors.
nozzlegear Nov 1, 2016
9486b3a
Update readme
nozzlegear Nov 1, 2016
8ece2eb
Update readme
nozzlegear Nov 1, 2016
3e92475
Finalized the finalization of typings exports 😛
nozzlegear Nov 8, 2016
caeb77e
Bugfix: webhooks.list should use FieldOptions
nozzlegear Nov 8, 2016
081f133
Add readme when publishing to npm
nozzlegear Nov 8, 2016
8202dc9
Allow building 2.0
nozzlegear Nov 14, 2016
07b83fb
Add pauses to tests to help empty the API rate limit bucket
nozzlegear Nov 14, 2016
310268a
Only create one webhook for list and count tests
nozzlegear Nov 14, 2016
568920f
Fix prepublish command to only run when actually publishing
nozzlegear Nov 14, 2016
575523a
Add test script to travis build
nozzlegear Nov 14, 2016
7473f80
Attempt fixing tests
nozzlegear Nov 14, 2016
d9e89b7
Bump to 2.0.0
nozzlegear Nov 14, 2016
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
Prev Previous commit
Next Next commit
Added Order service
  • Loading branch information
nozzlegear committed Oct 28, 2016
commit 08829a3900113220a8907e1a691d518f4e949701
4 changes: 2 additions & 2 deletions services/charges.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Charge } from "../typings/models";
import BaseService from "../infrastructure/base_service";
import { FieldOptions, ListOptions } from "../typings/options";
import { FieldOptions, ListOptions, DateOptions } from "../typings/options";

/**
* A service for manipulating Shopify's ApplicationCharge API.
Expand Down Expand Up @@ -30,7 +30,7 @@ export default class Charges extends BaseService {
* Retrieves a list of all past and present charges.
* @param options Options for filtering the result.
*/
public list(options?: ListOptions) {
public list(options?: ListOptions & DateOptions & FieldOptions) {
return this.createRequest<Charge[]>("GET", ".json", "application_charges", options);
}

Expand Down
78 changes: 77 additions & 1 deletion services/orders.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,85 @@
import { Order } from "../typings/models";
import BaseService from "../infrastructure/base_service";
import { FieldOptions, ListOptions, WebhookOptions } from "../typings/options";
import { OrderCountOptions, OrderListOptions, FieldOptions, OrderCreateOptions } from "../typings/options";

export default class Orders extends BaseService {
constructor(shopDomain: string, accessToken: string) {
super(shopDomain, accessToken, "orders");
}

/**
* Gets a count of all of the shop's orders.
* @param options Options for filtering the results.
*/
public count(options?: OrderCountOptions) {
return this.createRequest<number>("GET", "count.json", "count", options);
}

/**
* Gets a list of up to 250 of the shop's orders.
* @param options Options for filtering the results.
*/
public list(options?: OrderListOptions) {
return this.createRequest<Order[]>("GET", ".json", "orders", options);
}

/**
* Gets a list of up to 250 orders from the given customer.
* @param customerId The customer's id.
* @param options Options for filtering the results.
*/
public listForCustomer(customerId: number, options?: OrderListOptions) {
return this.createRequest<Order[]>("GET", ".json", "orders", Object.assign({ customer_id: customerId }, options));
}

/**
* Gets the order with the given id.
* @param orderId The order's id.
* @param options Options for filtering the results.
*/
public get(orderId: number, options?: FieldOptions) {
return this.createRequest<Order>("GET", `${orderId}.json`, "order", options);
}

/**
* Creates an order.
* @param order The order being created.
* @param options Options for creating the order.
*/
public create(order: Order, options?: OrderCreateOptions) {
return this.createRequest<Order>("POST", ".json", "order", { order: Object.assign({}, order, options) });
}

/**
* Updates an order with the given id.
* @param id The order's id.
* @param order The updated order.
*/
public update(id: number, order: Order) {
return this.createRequest<Order>("PUT", `${id}.json`, "order", {order});
}

/**
* Deletes an order with the given id.
* @param id The order's id.
*/
public delete(id: number) {
return this.createRequest<void>("DELETE", `${id}.json`);
}

/**
* Closes an order with the given id.
* @param id The order's id.
*/
public close(id: number) {
return this.createRequest<Order>("POST", `${id}/close.json`, "order");
}

/**
* Opens an order with the given id.
* @param id The order's id.
*/
public open(id: number) {
return this.createRequest<Order>("POST", `${id}/open.json`, "order");
}
}
4 changes: 2 additions & 2 deletions services/recurring_charges.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Charge } from "../typings/models";
import BaseService from "../infrastructure/base_service";
import { FieldOptions, ListOptions } from "../typings/options";
import { FieldOptions, ListOptions, DateOptions } from "../typings/options";

/**
* A service for manipulating Shopify's RecurringCharge API.
Expand Down Expand Up @@ -30,7 +30,7 @@ export default class RecurringCharges extends BaseService {
* Retrieves a list of all past and present charges.
* @param options Options for filtering the result.
*/
public list(options?: ListOptions) {
public list(options?: ListOptions & DateOptions & FieldOptions) {
return this.createRequest<RecurringCharge[]>("GET", ".json", "recurring_application_charges", options);
}

Expand Down
4 changes: 2 additions & 2 deletions services/script_tags.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ScriptTag } from "../typings/models";
import BaseService from "../infrastructure/base_service";
import { FieldOptions, ListOptions, ScriptTagOptions } from "../typings/options";
import { FieldOptions, ListOptions, DateOptions, ScriptTagOptions } from "../typings/options";

/**
* A service for manipulating Shopify script tags.
Expand All @@ -22,7 +22,7 @@ export default class ScriptTags extends BaseService {
* Gets a list of up to 250 of the shop's script tags.
* @param options Options for filtering the results.
*/
public list(options?: ScriptTagOptions & ListOptions) {
public list(options?: ScriptTagOptions & ListOptions & DateOptions & FieldOptions) {
return this.createRequest<ScriptTag[]>("GET", ".json", "script_tags", options);
}

Expand Down
4 changes: 2 additions & 2 deletions services/webhooks.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Webhook } from "../typings/models";
import BaseService from "../infrastructure/base_service";
import { FieldOptions, ListOptions, WebhookOptions } from "../typings/options";
import { FieldOptions, ListOptions, DateOptions, WebhookOptions } from "../typings/options";

/**
* A service for manipulating Shopify webhooks.
Expand All @@ -22,7 +22,7 @@ export default class Webhooks extends BaseService {
* Gets a list of up to 250 of the shop's webhooks.
* @param options Options for filtering the results.
*/
public list(options?: WebhookOptions & ListOptions) {
public list(options?: WebhookOptions & ListOptions & DateOptions) {
return this.createRequest<Webhook[]>("GET", ".json", "webhooks", options);
}

Expand Down
3 changes: 2 additions & 1 deletion typings/enums/auth_scope.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ export type AuthScope = (
"write_shipping" |
"read_analytics" |
"read_users" |
"write_users"
"write_users" |
string
);
11 changes: 10 additions & 1 deletion typings/enums/financial_status.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
export type FinancialStatus = (
""
"authorized" |
"pending" |
"paid" |
"partially_paid" |
"refunded" |
"voided" |
"partially_refunded" |
"unpaid" |
"any" |
string
);
6 changes: 5 additions & 1 deletion typings/enums/fulfillment_status.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
export type FulfillmentStatus = (
""
"shipped" |
"partial" |
"unshipped" |
"any" |
string
);
2 changes: 2 additions & 0 deletions typings/enums/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export { AuthScope } from "./auth_scope";
export { OrderStatus } from "./order_status";
export { WebhookTopic } from "./webhook_topic";
export { FinancialStatus } from "./financial_status";
export { InventoryBehavior } from "./inventory_behavior";
export { FulfillmentStatus } from "./fulfillment_status";
6 changes: 6 additions & 0 deletions typings/enums/inventory_behavior.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export type InventoryBehavior = (
"bypass" |
"decrement_ignoring_policy" |
"decrement_obeying_policy" |
string
);
7 changes: 7 additions & 0 deletions typings/enums/order_status.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export type OrderStatus = (
"open" |
"closed" |
"cancelled" |
"any" |
string
);
3 changes: 2 additions & 1 deletion typings/enums/webhook_topic.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,6 @@ export type WebhookTopic = (
"disputes/create" |
"disputes/update" |
"app/uninstalled" |
"themes/publish"
"themes/publish" |
string
)
4 changes: 2 additions & 2 deletions typings/models/order.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ export interface Order extends ShopifyObject {
/// An array of <see cref="ShopifyFulfillment"/> objects for this order.
fulfillments?: Fulfillment[];

/// The fulfillment status for this order. Known values are 'fulfilled', 'null' and 'partial'.
fulfillment_status?: FulfillmentStatus;
/// The fulfillment status for this order. Known values are 'fulfilled', 'partial' or null.
fulfillment_status?: "fulfilled" | "partial" | string;

/// Tags are additional short descriptors, commonly used for filtering and searching, formatted as a string of comma-separated values.
tags?: string;
Expand Down
6 changes: 0 additions & 6 deletions typings/options/field_options.d.ts

This file was deleted.

63 changes: 60 additions & 3 deletions typings/options/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,61 @@
export { WebhookOptions } from "./webhooks";
export { ListOptions } from "./list_options";
export { FieldOptions } from "./field_options";
export { ScriptTagOptions } from "./script_tags";
export { ScriptTagOptions } from "./script_tags";
export { OrderCountOptions, OrderListOptions, OrderCreateOptions } from "./orders";

export interface FieldOptions {
/**
* Restricts the result to only the fields specified.
*/
fields?: string[];
}

export interface DateOptions {
/**
* Retrieve only objects that were created after the given date and time (format: 2014-04-25T16:15:47-04:00).
*/
created_at_min?: string;

/**
* Retrieve only objects that were created before the given date and time (format: 2014-04-25T16:15:47-04:00).
*/
created_at_max?: string;

/**
* Retrieve only objects that were created after the given date and time (format: 2014-04-25T16:15:47-04:00).
*/
updated_at_min?: string;

/**
* Retrieve only objects that were created before the given date and time (format: 2014-04-25T16:15:47-04:00).
*/
updated_at_max?: string;
}

export interface ProcessedOptions {
/**
* Show objects imported or processed after date (format: 2014-04-25T16:15:47-04:00).
*/
processed_at_min?: string;

/**
* Show objects imported or processed before date (format: 2014-04-25T16:15:47-04:00).
*/
processed_at_max?: string;
}

export interface ListOptions {
/**
* The maximum number of objects that should be returned, up to 250. Setting this parameter above 250 will result in an error.
*/
limit?: number;

/**
* The page number of the result list to retrieve. Use this in tandem with limit to page through the webhooks in a shop.
*/
page?: number;

/**
* Restricts results to those created after the given id.
*/
since_id?: number;
}
38 changes: 0 additions & 38 deletions typings/options/list_options.d.ts

This file was deleted.

25 changes: 25 additions & 0 deletions typings/options/orders.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { FieldOptions, ListOptions, DateOptions, ProcessedOptions } from "./";
import { OrderStatus, FinancialStatus, FulfillmentStatus, InventoryBehavior } from "../enums";

export interface OrderCountOptions extends DateOptions {
status?: OrderStatus;

financial_status?: FinancialStatus;

fulfillment_status?: FulfillmentStatus;
}

export interface OrderListOptions extends FieldOptions, DateOptions, ProcessedOptions, ListOptions, OrderCountOptions {
/**
* A comma-separated list of order ids.
*/
ids?: string;
}

export interface OrderCreateOptions {
send_receipt?: boolean;

send_fulfillment_receipt?: boolean;

inventory_behavior?: InventoryBehavior;
}