Skip to content
This repository was archived by the owner on Apr 11, 2024. It is now read-only.

Update REST resources and drop version 2021-04 #343

Merged
merged 2 commits into from
Mar 29, 2022
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

### Added

- ⚠️ [Breaking] Removing API version `2021-04` [#343](https://github.com/Shopify/shopify-node-api/pull/343)
- ⚠️ [Breaking] The `HttpResponseError` error and its flavours (all returned from HTTP requests) have been slightly altered:
- They now take in a hash of values, and will always include the response code, body (as a string if the response is not JSON), and headers
- All response fields are now contained within a `response` object, to make it easier to access them
Expand Down
1 change: 0 additions & 1 deletion src/base-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ export interface ContextParams {
}

export enum ApiVersion {
April21 = '2021-04',
July21 = '2021-07',
October21 = '2021-10',
January22 = '2022-01',
Expand Down
4 changes: 2 additions & 2 deletions src/rest-resources/2021-07/android_pay_key.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ export class AndroidPayKey extends Base {
protected static HAS_ONE: {[key: string]: typeof Base} = {};
protected static HAS_MANY: {[key: string]: typeof Base} = {};
protected static PATHS: ResourcePath[] = [
{"http_method": "post", "operation": "post", "ids": [], "path": "android_pay_keys.json"},
{"http_method": "delete", "operation": "delete", "ids": ["id"], "path": "android_pay_keys/<id>.json"},
{"http_method": "get", "operation": "get", "ids": ["id"], "path": "android_pay_keys/<id>.json"},
{"http_method": "delete", "operation": "delete", "ids": ["id"], "path": "android_pay_keys/<id>.json"}
{"http_method": "post", "operation": "post", "ids": [], "path": "android_pay_keys.json"}
];

public static async find(
Expand Down
8 changes: 4 additions & 4 deletions src/rest-resources/2021-07/apple_pay_certificate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ export class ApplePayCertificate extends Base {
protected static HAS_ONE: {[key: string]: typeof Base} = {};
protected static HAS_MANY: {[key: string]: typeof Base} = {};
protected static PATHS: ResourcePath[] = [
{"http_method": "post", "operation": "post", "ids": [], "path": "apple_pay_certificates.json"},
{"http_method": "get", "operation": "get", "ids": ["id"], "path": "apple_pay_certificates/<id>.json"},
{"http_method": "put", "operation": "put", "ids": ["id"], "path": "apple_pay_certificates/<id>.json"},
{"http_method": "delete", "operation": "delete", "ids": ["id"], "path": "apple_pay_certificates/<id>.json"},
{"http_method": "get", "operation": "csr", "ids": ["id"], "path": "apple_pay_certificates/<id>/csr.json"}
{"http_method": "get", "operation": "csr", "ids": ["id"], "path": "apple_pay_certificates/<id>/csr.json"},
{"http_method": "get", "operation": "get", "ids": ["id"], "path": "apple_pay_certificates/<id>.json"},
{"http_method": "post", "operation": "post", "ids": [], "path": "apple_pay_certificates.json"},
{"http_method": "put", "operation": "put", "ids": ["id"], "path": "apple_pay_certificates/<id>.json"}
];

public static async find(
Expand Down
4 changes: 2 additions & 2 deletions src/rest-resources/2021-07/application_charge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ export class ApplicationCharge extends Base {
protected static HAS_ONE: {[key: string]: typeof Base} = {};
protected static HAS_MANY: {[key: string]: typeof Base} = {};
protected static PATHS: ResourcePath[] = [
{"http_method": "post", "operation": "post", "ids": [], "path": "application_charges.json"},
{"http_method": "get", "operation": "get", "ids": [], "path": "application_charges.json"},
{"http_method": "get", "operation": "get", "ids": ["id"], "path": "application_charges/<id>.json"},
{"http_method": "get", "operation": "get", "ids": [], "path": "application_charges.json"}
{"http_method": "post", "operation": "post", "ids": [], "path": "application_charges.json"}
];

public static async find(
Expand Down
4 changes: 2 additions & 2 deletions src/rest-resources/2021-07/application_credit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ export class ApplicationCredit extends Base {
protected static HAS_ONE: {[key: string]: typeof Base} = {};
protected static HAS_MANY: {[key: string]: typeof Base} = {};
protected static PATHS: ResourcePath[] = [
{"http_method": "post", "operation": "post", "ids": [], "path": "application_credits.json"},
{"http_method": "get", "operation": "get", "ids": [], "path": "application_credits.json"},
{"http_method": "get", "operation": "get", "ids": ["id"], "path": "application_credits/<id>.json"}
{"http_method": "get", "operation": "get", "ids": ["id"], "path": "application_credits/<id>.json"},
{"http_method": "post", "operation": "post", "ids": [], "path": "application_credits.json"}
];

public static async find(
Expand Down
67 changes: 30 additions & 37 deletions src/rest-resources/2021-07/article.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ interface AllArgs {
author?: unknown;
fields?: unknown;
}
interface AuthorsArgs {
[key: string]: unknown;
session: SessionInterface;
}
interface CountArgs {
[key: string]: unknown;
session: SessionInterface;
Expand All @@ -45,16 +49,9 @@ interface CountArgs {
published_at_max?: unknown;
published_status?: unknown;
}
interface AuthorsArgs {
[key: string]: unknown;
session: SessionInterface;
}
interface TagsArgs {
[key: string]: unknown;
session: SessionInterface;
blog_id?: number | string | null;
limit?: unknown;
popular?: unknown;
}

export class Article extends Base {
Expand All @@ -67,15 +64,14 @@ export class Article extends Base {
"metafields": Metafield
};
protected static PATHS: ResourcePath[] = [
{"http_method": "get", "operation": "get", "ids": ["blog_id"], "path": "blogs/<blog_id>/articles.json"},
{"http_method": "post", "operation": "post", "ids": ["blog_id"], "path": "blogs/<blog_id>/articles.json"},
{"http_method": "get", "operation": "count", "ids": ["blog_id"], "path": "blogs/<blog_id>/articles/count.json"},
{"http_method": "get", "operation": "get", "ids": ["blog_id", "id"], "path": "blogs/<blog_id>/articles/<id>.json"},
{"http_method": "put", "operation": "put", "ids": ["blog_id", "id"], "path": "blogs/<blog_id>/articles/<id>.json"},
{"http_method": "delete", "operation": "delete", "ids": ["blog_id", "id"], "path": "blogs/<blog_id>/articles/<id>.json"},
{"http_method": "get", "operation": "authors", "ids": [], "path": "articles/authors.json"},
{"http_method": "get", "operation": "tags", "ids": ["blog_id"], "path": "blogs/<blog_id>/articles/tags.json"},
{"http_method": "get", "operation": "tags", "ids": [], "path": "articles/tags.json"}
{"http_method": "get", "operation": "count", "ids": ["blog_id"], "path": "blogs/<blog_id>/articles/count.json"},
{"http_method": "get", "operation": "get", "ids": ["blog_id"], "path": "blogs/<blog_id>/articles.json"},
{"http_method": "get", "operation": "get", "ids": ["blog_id", "id"], "path": "blogs/<blog_id>/articles/<id>.json"},
{"http_method": "get", "operation": "tags", "ids": [], "path": "articles/tags.json"},
{"http_method": "post", "operation": "post", "ids": ["blog_id"], "path": "blogs/<blog_id>/articles.json"},
{"http_method": "put", "operation": "put", "ids": ["blog_id", "id"], "path": "blogs/<blog_id>/articles/<id>.json"}
];

public static async find(
Expand Down Expand Up @@ -141,45 +137,45 @@ export class Article extends Base {
return response as Article[];
}

public static async count(
public static async authors(
{
session,
blog_id = null,
created_at_min = null,
created_at_max = null,
updated_at_min = null,
updated_at_max = null,
published_at_min = null,
published_at_max = null,
published_status = null,
...otherArgs
}: CountArgs
}: AuthorsArgs
): Promise<unknown> {
const response = await Article.request({
http_method: "get",
operation: "count",
operation: "authors",
session: session,
urlIds: {"blog_id": blog_id},
params: {"created_at_min": created_at_min, "created_at_max": created_at_max, "updated_at_min": updated_at_min, "updated_at_max": updated_at_max, "published_at_min": published_at_min, "published_at_max": published_at_max, "published_status": published_status, ...otherArgs},
urlIds: {},
params: {...otherArgs},
body: {},
entity: null,
});

return response ? response.body : null;
}

public static async authors(
public static async count(
{
session,
blog_id = null,
created_at_min = null,
created_at_max = null,
updated_at_min = null,
updated_at_max = null,
published_at_min = null,
published_at_max = null,
published_status = null,
...otherArgs
}: AuthorsArgs
}: CountArgs
): Promise<unknown> {
const response = await Article.request({
http_method: "get",
operation: "authors",
operation: "count",
session: session,
urlIds: {},
params: {...otherArgs},
urlIds: {"blog_id": blog_id},
params: {"created_at_min": created_at_min, "created_at_max": created_at_max, "updated_at_min": updated_at_min, "updated_at_max": updated_at_max, "published_at_min": published_at_min, "published_at_max": published_at_max, "published_status": published_status, ...otherArgs},
body: {},
entity: null,
});
Expand All @@ -190,18 +186,15 @@ export class Article extends Base {
public static async tags(
{
session,
blog_id = null,
limit = null,
popular = null,
...otherArgs
}: TagsArgs
): Promise<unknown> {
const response = await Article.request({
http_method: "get",
operation: "tags",
session: session,
urlIds: {"blog_id": blog_id},
params: {"limit": limit, "popular": popular, ...otherArgs},
urlIds: {},
params: {...otherArgs},
body: {},
entity: null,
});
Expand Down
4 changes: 2 additions & 2 deletions src/rest-resources/2021-07/asset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ export class Asset extends Base {
protected static HAS_ONE: {[key: string]: typeof Base} = {};
protected static HAS_MANY: {[key: string]: typeof Base} = {};
protected static PATHS: ResourcePath[] = [
{"http_method": "delete", "operation": "delete", "ids": ["theme_id"], "path": "themes/<theme_id>/assets.json"},
{"http_method": "get", "operation": "get", "ids": ["theme_id"], "path": "themes/<theme_id>/assets.json"},
{"http_method": "put", "operation": "put", "ids": ["theme_id"], "path": "themes/<theme_id>/assets.json"},
{"http_method": "get", "operation": "get", "ids": ["theme_id"], "path": "themes/<theme_id>/assets.json"},
{"http_method": "delete", "operation": "delete", "ids": ["theme_id"], "path": "themes/<theme_id>/assets.json"}
{"http_method": "put", "operation": "put", "ids": ["theme_id"], "path": "themes/<theme_id>/assets.json"}
];
protected static PRIMARY_KEY: string = "key";

Expand Down
8 changes: 4 additions & 4 deletions src/rest-resources/2021-07/blog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ export class Blog extends Base {
"metafields": Metafield
};
protected static PATHS: ResourcePath[] = [
{"http_method": "get", "operation": "get", "ids": [], "path": "blogs.json"},
{"http_method": "post", "operation": "post", "ids": [], "path": "blogs.json"},
{"http_method": "delete", "operation": "delete", "ids": ["id"], "path": "blogs/<id>.json"},
{"http_method": "get", "operation": "count", "ids": [], "path": "blogs/count.json"},
{"http_method": "get", "operation": "get", "ids": [], "path": "blogs.json"},
{"http_method": "get", "operation": "get", "ids": ["id"], "path": "blogs/<id>.json"},
{"http_method": "put", "operation": "put", "ids": ["id"], "path": "blogs/<id>.json"},
{"http_method": "delete", "operation": "delete", "ids": ["id"], "path": "blogs/<id>.json"}
{"http_method": "post", "operation": "post", "ids": [], "path": "blogs.json"},
{"http_method": "put", "operation": "put", "ids": ["id"], "path": "blogs/<id>.json"}
];

public static async find(
Expand Down
2 changes: 1 addition & 1 deletion src/rest-resources/2021-07/cancellation_request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ export class CancellationRequest extends Base {
protected static HAS_ONE: {[key: string]: typeof Base} = {};
protected static HAS_MANY: {[key: string]: typeof Base} = {};
protected static PATHS: ResourcePath[] = [
{"http_method": "post", "operation": "post", "ids": ["fulfillment_order_id"], "path": "fulfillment_orders/<fulfillment_order_id>/cancellation_request.json"},
{"http_method": "post", "operation": "accept", "ids": ["fulfillment_order_id"], "path": "fulfillment_orders/<fulfillment_order_id>/cancellation_request/accept.json"},
{"http_method": "post", "operation": "post", "ids": ["fulfillment_order_id"], "path": "fulfillment_orders/<fulfillment_order_id>/cancellation_request.json"},
{"http_method": "post", "operation": "reject", "ids": ["fulfillment_order_id"], "path": "fulfillment_orders/<fulfillment_order_id>/cancellation_request/reject.json"}
];

Expand Down
6 changes: 3 additions & 3 deletions src/rest-resources/2021-07/carrier_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ export class CarrierService extends Base {
protected static HAS_ONE: {[key: string]: typeof Base} = {};
protected static HAS_MANY: {[key: string]: typeof Base} = {};
protected static PATHS: ResourcePath[] = [
{"http_method": "post", "operation": "post", "ids": [], "path": "carrier_services.json"},
{"http_method": "delete", "operation": "delete", "ids": ["id"], "path": "carrier_services/<id>.json"},
{"http_method": "get", "operation": "get", "ids": [], "path": "carrier_services.json"},
{"http_method": "put", "operation": "put", "ids": ["id"], "path": "carrier_services/<id>.json"},
{"http_method": "get", "operation": "get", "ids": ["id"], "path": "carrier_services/<id>.json"},
{"http_method": "delete", "operation": "delete", "ids": ["id"], "path": "carrier_services/<id>.json"}
{"http_method": "post", "operation": "post", "ids": [], "path": "carrier_services.json"},
{"http_method": "put", "operation": "put", "ids": ["id"], "path": "carrier_services/<id>.json"}
];

public static async find(
Expand Down
8 changes: 4 additions & 4 deletions src/rest-resources/2021-07/checkout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ export class Checkout extends Base {
"gift_cards": GiftCard
};
protected static PATHS: ResourcePath[] = [
{"http_method": "post", "operation": "post", "ids": [], "path": "checkouts.json"},
{"http_method": "post", "operation": "complete", "ids": ["token"], "path": "checkouts/<token>/complete.json"},
{"http_method": "get", "operation": "get", "ids": ["token"], "path": "checkouts/<token>.json"},
{"http_method": "put", "operation": "put", "ids": ["token"], "path": "checkouts/<token>.json"},
{"http_method": "get", "operation": "shipping_rates", "ids": ["token"], "path": "checkouts/<token>/shipping_rates.json"}
{"http_method": "get", "operation": "shipping_rates", "ids": ["token"], "path": "checkouts/<token>/shipping_rates.json"},
{"http_method": "post", "operation": "complete", "ids": ["token"], "path": "checkouts/<token>/complete.json"},
{"http_method": "post", "operation": "post", "ids": [], "path": "checkouts.json"},
{"http_method": "put", "operation": "put", "ids": ["token"], "path": "checkouts/<token>.json"}
];
protected static PRIMARY_KEY: string = "token";

Expand Down
6 changes: 3 additions & 3 deletions src/rest-resources/2021-07/collect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ export class Collect extends Base {
protected static HAS_ONE: {[key: string]: typeof Base} = {};
protected static HAS_MANY: {[key: string]: typeof Base} = {};
protected static PATHS: ResourcePath[] = [
{"http_method": "post", "operation": "post", "ids": [], "path": "collects.json"},
{"http_method": "get", "operation": "get", "ids": [], "path": "collects.json"},
{"http_method": "delete", "operation": "delete", "ids": ["id"], "path": "collects/<id>.json"},
{"http_method": "get", "operation": "count", "ids": [], "path": "collects/count.json"},
{"http_method": "get", "operation": "get", "ids": [], "path": "collects.json"},
{"http_method": "get", "operation": "get", "ids": ["id"], "path": "collects/<id>.json"},
{"http_method": "get", "operation": "count", "ids": [], "path": "collects/count.json"}
{"http_method": "post", "operation": "post", "ids": [], "path": "collects.json"}
];

public static async find(
Expand Down
6 changes: 3 additions & 3 deletions src/rest-resources/2021-07/collection_listing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ export class CollectionListing extends Base {
};
protected static HAS_MANY: {[key: string]: typeof Base} = {};
protected static PATHS: ResourcePath[] = [
{"http_method": "delete", "operation": "delete", "ids": ["collection_id"], "path": "collection_listings/<collection_id>.json"},
{"http_method": "get", "operation": "get", "ids": [], "path": "collection_listings.json"},
{"http_method": "get", "operation": "product_ids", "ids": ["collection_id"], "path": "collection_listings/<collection_id>/product_ids.json"},
{"http_method": "get", "operation": "get", "ids": ["collection_id"], "path": "collection_listings/<collection_id>.json"},
{"http_method": "put", "operation": "put", "ids": ["collection_id"], "path": "collection_listings/<collection_id>.json"},
{"http_method": "delete", "operation": "delete", "ids": ["collection_id"], "path": "collection_listings/<collection_id>.json"}
{"http_method": "get", "operation": "product_ids", "ids": ["collection_id"], "path": "collection_listings/<collection_id>/product_ids.json"},
{"http_method": "put", "operation": "put", "ids": ["collection_id"], "path": "collection_listings/<collection_id>.json"}
];
protected static PRIMARY_KEY: string = "collection_id";

Expand Down
Loading