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
Next Next commit
Restructure files
  • Loading branch information
nozzlegear committed Sep 22, 2016
commit d92bedc50248b8f82b00547049ec2743df8e3852
36 changes: 26 additions & 10 deletions index.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,35 @@
// Exported definitions should never contain triple-slash references:
// https://www.typescriptlang.org/docs/handbook/typings-for-npm-packages.html

// Import and export models/infrastructure
import * as Enums from "./enums";
import * as Models from "./models";
import * as Options from "./options";
import * as Infrastructure from "./infrastructure";

export {Enums};
export {Options};
export {Infrastructure};
export {Shops, Shop} from "./modules/shops";
export {Charges, Charge} from "./modules/charges";
export {Webhooks, Webhook} from "./modules/webhooks";
export {ScriptTags, ScriptTag} from "./modules/script_tags";
export {UsageCharges, UsageCharge} from "./modules/usage_charges";
export {RecurringCharges, RecurringCharge} from "./modules/recurring_charges";
export {
Enums,
Models,
Options,
Infrastructure,
};

// Import and export services
import Shops from "./services/shops";
import Charges from "./services/charges";
import Webhooks from "./services/webhooks";
import ScriptTags from "./services/script_tags";
import UsageCharges from "./services/usage_charges";
import RecurringCharges from "./services/recurring_charges";

export {
Shops,
Charges,
Webhooks,
ScriptTags,
UsageCharges,
RecurringCharges,
};

// Export auth functions at the top level
export {
Expand All @@ -23,4 +39,4 @@ export {
isAuthenticRequest,
isAuthenticWebhook,
isValidShopifyDomain
} from "./modules/auth";
} from "./services/auth";
46 changes: 46 additions & 0 deletions models/charge.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import {ShopifyObject} from "../infrastructure";

/**
* Represents a one-time application charge.
*/
export interface Charge extends ShopifyObject {
/**
* The URL that the customer should be sent to, to accept or decline the application charge.
*/
confirmation_url?: string;

/**
* The date and time when the application charge was created.
*/
created_at?: string;

/**
* The name of the application charge, e.g. "Super Expensive One-time Charge".
*/
name: string;

/**
* The price of the application charge. Note: Shopify returns this value as a string.
*/
price: string | number;

/**
* The URL the customer is sent to once they accept/decline a charge.
*/
return_url?: string;

/**
* The status of the charge.
*/
status?: "pending" | "accepted" | "active" | "cancelled" | "declined" | "expired";

/**
* Whether or not the application charge is a test transaction.
*/
test?: boolean;

/**
* The date and time when the recurring application charge was last updated.
*/
updated_at?: string;
}
6 changes: 6 additions & 0 deletions models/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export {Shop} from "./shop";
export {Order} from "./order";
export {Charge} from "./charge";
export {Webhook} from "./webhook";
export {ScriptTag} from "./script_tag";
export {UsageCharge} from "./usage_charge";
139 changes: 139 additions & 0 deletions models/order.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
import {ShopifyObject} from "../infrastructure";

export interface Order extends ShopifyObject {
/// The mailing address associated with the payment method. This address is an optional field that will not be available on orders that do not require one.
billing_address?: Address;

/// The IP address of the browser used by the customer when placing the order.
browser_ip?: string;

/// Indicates whether or not the person who placed the order would like to receive email updates from the shop.
/// This is set when checking the "I want to receive occasional emails about new products, promotions and other news" checkbox during checkout.
buyer_accepts_marketing?: boolean;

/// The reason why the order was cancelled. If the order was not cancelled, this value is null. Known values are "customer", "fraud", "inventory" and "other".
cancel_reason?: string;

/// The date and time when the order was cancelled. If the order was not cancelled, this value is null.
cancelled_at?: string;

/// Unique identifier for a particular cart that is attached to a particular order.
cart_token?: string;

/// A <see cref="ShopifyClientDetails"/> object containing information about the client.
client_details?: ClientDetails;

/// The date and time when the order was closed. If the order was not clsoed, this value is null.
closed_at?: string;

/// The customer's contact email address.
contact_email?: string;

/// The date and time when the order was created in Shopify.
created_at?: string;

/// The three letter code (ISO 4217) for the currency used for the payment.
currency?: string;

/// A <see cref="ShopifyCustomer"/> object containing information about the customer. This value may be null if the order was created through Shopify POS.
customer?: Customer;

/// Applicable discount codes that can be applied to the order.
discount_codes?: DiscountCode[];

/// The order's email address. Note?: On and after 2015-11-03, you should be using <see cref="ContactEmail"/> to refer to the customer's email address.
/// Between 2015-11-03 and 2015-12-03, updates to an order's email will also update the customer's email. This is temporary so apps can be migrated over to
/// doing customer updates rather than order updates to change the contact email. After 2015-12-03, updating updating an order's email will no longer update
/// the customer's email and apps will have to use the customer update endpoint to do so.
email?: string;

/// The financial status of an order. Known values are "authorized", "paid", "pending", "partially_paid", "partially_refunded", "refunded" and "voided".
financial_status?: FinancialStatus;

/// 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;

/// Tags are additional short descriptors, commonly used for filtering and searching, formatted as a string of comma-separated values.
tags?: string;

/// The URL for the page where the buyer landed when entering the shop.
landing_site?: string;

/// An array of <see cref="ShopifyLineItem"/> objects, each one containing information about an item in the order.
line_items?: LineItem[];

/// The customer's order name as represented by a number, e.g. '#1001'.
name?: string;

/// The text of an optional note that a shop owner can attach to the order.
note?: string;

/// Extra information that is added to the order.
note_attributes?: NoteAttribute;

/// Numerical identifier unique to the shop. A number is sequential and starts at 1000.
number?: number;

/// A unique numeric identifier for the order. This one is used by the shop owner and customer.
/// This is different from the id property, which is also a unique numeric identifier for the order, but used for API purposes.
order_number?: number;

/// Payment details for this order. May be null if the order was created via API without payment details.
payment_details?: PaymentDetails;

/// The date that the order was processed at.
processed_at?: string;

/// The type of payment processing method. Known values are 'checkout', 'direct', 'manual', 'offsite', 'express', 'free' and 'none'.
processing_method?: string;

/// The website that the customer clicked on to come to the shop.
referring_site?: string;

/// The mailing address to where the order will be shipped. This address is optional and will not be available on orders that do not require one.
shipping_address?: Address;

/// An array of <see cref="ShopifyShippingLine"/> objects, each of which details the shipping methods used.
shipping_lines?: ShippingLine[];

/// Where the order originated. May only be set during creation, and is not writeable thereafter.
/// Orders created via the API may be assigned any string of your choice except for "web", "pos", "iphone", and "android".
/// Default is "api".
source_name?: string;

/// Price of the order before shipping and taxes
subtotal_price?: number;

/// An array of <see cref="ShopifyTaxLine"/> objects, each of which details the total taxes applicable to the order.
tax_lines?: TaxLine[];

/// States whether or not taxes are included in the order subtotal.
taxes_included?: boolean;

/// Unique identifier for a particular order.
token?: string;

/// The total amount of the discounts applied to the price of the order.
total_discounts?: number;

/// The sum of all the prices of all the items in the order.
total_line_items_price?: number;

/// The sum of all the prices of all the items in the order, with taxes and discounts included (must be positive).
total_price?: number;

/// The sum of all the prices of all the items in the order, in USD, with taxes and discounts included (must be positive).
total_price_usd?: number;

/// The sum of all the taxes applied to the order (must be positive).
total_tax?: number;

/// The sum of all the weights of the line items in the order, in grams.
total_weight?: number;

/// The date and time when the order was last modified.
updated_at?: string;
}
26 changes: 26 additions & 0 deletions models/script_tag.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import {ShopifyObject} from "../infrastructure";

/**
* An entity representing a Shopify script tag.
*/
export interface ScriptTag extends ShopifyObject {
/**
* The date and time the script tag was created.
*/
created_at?: string;

/**
* DOM event which triggers the loading of the script. Currently, 'onload' is the only accepted value.
*/
event?: "onload";

/**
* Specifies the src of the script tag, i.e. which URL to load it from.
*/
src: string;

/**
* The date and time the script tag was updated.
*/
updated_at?: string;
}
36 changes: 2 additions & 34 deletions modules/shops.ts → models/shop.ts
Original file line number Diff line number Diff line change
@@ -1,41 +1,9 @@
/// <reference path="./../typings/index.d.ts" />

import {FieldOptions, ListOptions} from "../options";
import {ShopifyObject, BaseService} from "../infrastructure";

/**
* A service for manipulating Shopify shops.
*/
export class Shops extends BaseService
{
constructor(shopDomain: string, accessToken: string)
{
super(shopDomain, accessToken, "");
}

/**
* Returns shop data for the shop.
* @param options Options for filtering the result.
*/
public get(options?: FieldOptions)
{
return this.createRequest<Shop>("GET", "shop.json", "shop", options);
}

/**
* Forces the shop to uninstall your Shopify app. Uninstalling an application is an irreversible operation. Be entirely sure that you no longer need to make API calls for the shop in which the application has been installed.
*/
public forceUninstallApp()
{
return this.createRequest<void>("DELETE", "api_permissions/current.json");
}
}
import {ShopifyObject} from "../infrastructure";

/**
* Represents a Shopify shop.
*/
export interface Shop extends ShopifyObject
{
export interface Shop extends ShopifyObject {
/**
* The shop's street address.
*/
Expand Down
31 changes: 31 additions & 0 deletions models/usage_charge.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import {ShopifyObject} from "../infrastructure";

/**
* Represents a usage charge, a variable monthly fee for an app or a service.
*/
export interface UsageCharge extends ShopifyObject {
/**
* The date and time when the usage charge was created.
*/
created_at?: string;

/**
* The name or description of the usage charge.
*/
description?: string;

/**
* The price of the usage charge.
*/
price?: number;

/**
* The recurring application charge the usage charge belongs to.
*/
recurring_application_charge_id?: number;

/**
* The date and time when the usage charge was last updated.
*/
updated_at?: string;
}
43 changes: 43 additions & 0 deletions models/webhook.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import {WebhookTopic} from "../enums";
import {ShopifyObject} from "../infrastructure";

/**
* An entity representing a Shopify webhook.
*/
export interface Webhook extends ShopifyObject
{
/**
* The URL where the webhook should send the POST request when the event occurs.
*/
address: string;

/**
* The date and time when the webhook was created.
*/
created_at?: string;

/**
* An optional array of fields which should be included in webhooks.
*/
fields?: string[];

/**
* The format in which the webhook should send the data. Valid values are json and xml.
*/
format?: "json" | "xml";

/**
* An optional array of namespaces for metafields that should be included in webhooks.
*/
metafield_namespaces?: string[];

/**
* The event that will trigger the webhook.
*/
topic: WebhookTopic;

/**
* The date and time when the webhook was updated.
*/
updated_at?: string;
}
Loading