diff --git a/.eslintrc.js b/.eslintrc.js index 61f8837a8..4f457f897 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -4,18 +4,19 @@ module.exports = { es2021: true, }, extends: ['plugin:@shopify/typescript', 'plugin:@shopify/prettier'], - ignorePatterns: ['dist/'], + ignorePatterns: ['dist/', 'src/rest-resources'], rules: { 'import/no-named-as-default': 0, 'no-mixed-operators': 0, 'no-console': 0, + 'lines-around-comment': 0, }, overrides: [ { files: [ - 'src/rest_resources/__tests__/*.ts', - 'src/rest_resources/base.ts', - 'src/rest_resources/admin*/*.ts', + 'src/__tests__/*.ts', + 'src/base-rest-resource.ts', + 'src/rest-resources/*', ], rules: { '@typescript-eslint/naming-convention': [ diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index d4675c80c..7fcb38dcc 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -14,3 +14,5 @@ jobs: run: yarn lint - name: Test run: yarn test + - name: Test REST resources + run: yarn test_rest_resources diff --git a/jest.config.js b/jest.config.js index 737f1dbfe..7427140e6 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,5 +1,10 @@ module.exports = { - preset: 'ts-jest', + preset: 'ts-jest/presets/default-esm', // or other ESM presets + globals: { + 'ts-jest': { + useESM: true, + }, + }, testEnvironment: 'node', moduleFileExtensions: ['ts', 'js', 'json'], watchPathIgnorePatterns: ['/node_modules/'], diff --git a/package.json b/package.json index 19a9f0b35..5db42e83b 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,8 @@ "types": "dist/index.d.ts", "prettier": "@shopify/prettier-config", "scripts": { - "test": "jest", + "test": "jest --testPathIgnorePatterns=src/rest-resources/__tests__", + "test_rest_resources": "ls src/rest-resources/__tests__ | xargs -I \"{}\" sh -c 'yarn jest --no-coverage --testPathPattern=\\\"{}\\\" || exit 255'", "build": "tsc", "lint": "eslint '**/*.{ts,tsx}' --max-warnings 0", "clean": "rimraf ./dist tsconfig.tsbuildinfo", diff --git a/src/rest_resources/__tests__/base.test.ts b/src/__tests__/base-rest-resource.test.ts similarity index 94% rename from src/rest_resources/__tests__/base.test.ts rename to src/__tests__/base-rest-resource.test.ts index ba61eb368..cbaddd5f9 100644 --- a/src/rest_resources/__tests__/base.test.ts +++ b/src/__tests__/base-rest-resource.test.ts @@ -1,8 +1,10 @@ -import {Session} from '../../auth/session'; -import {RestResourceRequestError} from '../../error'; +import {Session} from '../auth/session'; +import {ApiVersion} from '../base-types'; +import {Context} from '../context'; +import {RestResourceRequestError, RestResourceError} from '../error'; -import FakeResource from './fake_resource'; -import FakeResourceWithCustomPrefix from './fake_resource_with_custom_prefix'; +import FakeResource from './fake-resource'; +import FakeResourceWithCustomPrefix from './fake-resource-with-custom-prefix'; describe('Base REST resource', () => { const domain = 'test-shop.myshopify.io'; @@ -393,4 +395,14 @@ describe('Base REST resource', () => { headers, }).toMatchMadeHttpRequest(); }); + + it('throws an error if the API versions mismatch', async () => { + Context.API_VERSION = ApiVersion.January22; + + await expect(FakeResource.all({session})).rejects.toThrowError( + new RestResourceError( + `Current Context.API_VERSION '${ApiVersion.January22}' does not match resource version ${ApiVersion.Unstable}`, + ), + ); + }); }); diff --git a/src/__tests__/context.test.ts b/src/__tests__/context.test.ts index ff94b253b..ada537462 100644 --- a/src/__tests__/context.test.ts +++ b/src/__tests__/context.test.ts @@ -2,7 +2,7 @@ import Cookies from 'cookies'; import * as ShopifyErrors from '../error'; import {Context} from '../context'; -import {ApiVersion, ContextParams} from '../base_types'; +import {ApiVersion, ContextParams} from '../base-types'; jest.mock('cookies'); diff --git a/src/rest_resources/__tests__/fake_resource_with_custom_prefix.ts b/src/__tests__/fake-resource-with-custom-prefix.ts similarity index 83% rename from src/rest_resources/__tests__/fake_resource_with_custom_prefix.ts rename to src/__tests__/fake-resource-with-custom-prefix.ts index b18526ce4..c3f6270bd 100644 --- a/src/rest_resources/__tests__/fake_resource_with_custom_prefix.ts +++ b/src/__tests__/fake-resource-with-custom-prefix.ts @@ -1,5 +1,6 @@ -import Base, {ResourcePath} from '../base'; -import {SessionInterface} from '../../auth/session/types'; +import Base, {ResourcePath} from '../base-rest-resource'; +import {SessionInterface} from '../auth/session/types'; +import {ApiVersion} from '../base-types'; interface FakeResourceWithCustomPrefixFindArgs { session: SessionInterface; @@ -7,6 +8,7 @@ interface FakeResourceWithCustomPrefixFindArgs { } export default class FakeResourceWithCustomPrefix extends Base { + public static API_VERSION = ApiVersion.Unstable; protected static NAME = 'fake_resource_with_custom_prefix'; protected static PLURAL_NAME = 'fake_resource_with_custom_prefixes'; protected static CUSTOM_PREFIX = '/admin/custom_prefix'; diff --git a/src/rest_resources/__tests__/fake_resource.ts b/src/__tests__/fake-resource.ts similarity index 93% rename from src/rest_resources/__tests__/fake_resource.ts rename to src/__tests__/fake-resource.ts index 9fba6e85d..2036674c5 100644 --- a/src/rest_resources/__tests__/fake_resource.ts +++ b/src/__tests__/fake-resource.ts @@ -1,5 +1,6 @@ -import Base, {ParamSet, ResourcePath} from '../base'; -import {SessionInterface} from '../../auth/session/types'; +import Base, {ParamSet, ResourcePath} from '../base-rest-resource'; +import {SessionInterface} from '../auth/session/types'; +import {ApiVersion} from '../base-types'; interface FakeResourceFindArgs { params?: ParamSet; @@ -20,6 +21,7 @@ interface FakeResourceCustomArgs { } export default class FakeResource extends Base { + public static API_VERSION = ApiVersion.Unstable; protected static NAME = 'fake_resource'; protected static PLURAL_NAME = 'fake_resources'; diff --git a/src/rest_resources/base.ts b/src/base-rest-resource.ts similarity index 93% rename from src/rest_resources/base.ts rename to src/base-rest-resource.ts index 58effcc05..314da7776 100644 --- a/src/rest_resources/base.ts +++ b/src/base-rest-resource.ts @@ -2,11 +2,13 @@ import { HttpResponseError, RestResourceError, RestResourceRequestError, -} from '../error'; -import {SessionInterface} from '../auth/session/types'; -import {RestClient} from '../clients/rest'; -import {RestRequestReturn} from '../clients/rest/types'; -import {DataType, GetRequestParams} from '../clients/http_client/types'; +} from './error'; +import {SessionInterface} from './auth/session/types'; +import {RestClient} from './clients/rest'; +import {RestRequestReturn} from './clients/rest/types'; +import {DataType, GetRequestParams} from './clients/http_client/types'; +import {ApiVersion} from './base-types'; +import {Context} from './context'; export interface IdSet { [id: string]: string | number | null; @@ -56,6 +58,7 @@ class Base { // For instance attributes [key: string]: any; + public static API_VERSION: ApiVersion; public static NEXT_PAGE_INFO: GetRequestParams | undefined; public static PREV_PAGE_INFO: GetRequestParams | undefined; @@ -97,6 +100,12 @@ class Base { body, entity, }: RequestArgs): Promise { + if (Context.API_VERSION !== this.API_VERSION) { + throw new RestResourceError( + `Current Context.API_VERSION '${Context.API_VERSION}' does not match resource version ${this.API_VERSION}`, + ); + } + const client = new RestClient(session.shop, session.accessToken); const path = this.getPath({http_method, operation, urlIds, entity}); diff --git a/src/base_types.ts b/src/base-types.ts similarity index 100% rename from src/base_types.ts rename to src/base-types.ts diff --git a/src/clients/graphql/__tests__/graphql_client.test.ts b/src/clients/graphql/__tests__/graphql_client.test.ts index 0bb322b4c..bb3c0deed 100644 --- a/src/clients/graphql/__tests__/graphql_client.test.ts +++ b/src/clients/graphql/__tests__/graphql_client.test.ts @@ -1,4 +1,4 @@ -import {ShopifyHeader} from '../../../base_types'; +import {ShopifyHeader} from '../../../base-types'; import {GraphqlClient} from '../graphql_client'; import {Context} from '../../../context'; import * as ShopifyErrors from '../../../error'; diff --git a/src/clients/graphql/__tests__/storefront_client.test.ts b/src/clients/graphql/__tests__/storefront_client.test.ts index da691951b..89d3e3238 100644 --- a/src/clients/graphql/__tests__/storefront_client.test.ts +++ b/src/clients/graphql/__tests__/storefront_client.test.ts @@ -1,4 +1,4 @@ -import {ShopifyHeader} from '../../../base_types'; +import {ShopifyHeader} from '../../../base-types'; import {StorefrontClient} from '../storefront_client'; import {Context} from '../../../context'; diff --git a/src/clients/graphql/graphql_client.ts b/src/clients/graphql/graphql_client.ts index 630ea4a7f..2568b43c1 100644 --- a/src/clients/graphql/graphql_client.ts +++ b/src/clients/graphql/graphql_client.ts @@ -1,6 +1,6 @@ import {MissingRequiredArgument} from '../../error'; import {Context} from '../../context'; -import {ShopifyHeader} from '../../base_types'; +import {ShopifyHeader} from '../../base-types'; import {HttpClient} from '../http_client/http_client'; import {DataType, RequestReturn} from '../http_client/types'; import * as ShopifyErrors from '../../error'; diff --git a/src/clients/graphql/storefront_client.ts b/src/clients/graphql/storefront_client.ts index d25c5623e..e9b930b09 100644 --- a/src/clients/graphql/storefront_client.ts +++ b/src/clients/graphql/storefront_client.ts @@ -1,5 +1,5 @@ import {Context} from '../../context'; -import {ShopifyHeader} from '../../base_types'; +import {ShopifyHeader} from '../../base-types'; import {GraphqlClient, AccessTokenHeader} from './graphql_client'; diff --git a/src/clients/rest/__tests__/rest_client.test.ts b/src/clients/rest/__tests__/rest_client.test.ts index 696c180fc..7b2a0a92a 100644 --- a/src/clients/rest/__tests__/rest_client.test.ts +++ b/src/clients/rest/__tests__/rest_client.test.ts @@ -1,6 +1,6 @@ import querystring from 'querystring'; -import {ShopifyHeader} from '../../../base_types'; +import {ShopifyHeader} from '../../../base-types'; import {DataType, GetRequestParams} from '../../http_client/types'; import {RestClient} from '../rest_client'; import {RestRequestReturn, PageInfo} from '../types'; diff --git a/src/clients/rest/rest_client.ts b/src/clients/rest/rest_client.ts index ccd871774..e8dce781c 100644 --- a/src/clients/rest/rest_client.ts +++ b/src/clients/rest/rest_client.ts @@ -1,7 +1,7 @@ import querystring from 'querystring'; import {Context} from '../../context'; -import {ShopifyHeader} from '../../base_types'; +import {ShopifyHeader} from '../../base-types'; import {HttpClient} from '../http_client/http_client'; import {RequestParams, GetRequestParams} from '../http_client/types'; import * as ShopifyErrors from '../../error'; diff --git a/src/context.ts b/src/context.ts index 7b81165ec..953c032d7 100644 --- a/src/context.ts +++ b/src/context.ts @@ -1,7 +1,7 @@ import * as ShopifyErrors from './error'; import {SessionStorage} from './auth/session/session_storage'; import {MemorySessionStorage} from './auth/session/storage/memory'; -import {ApiVersion, ContextParams} from './base_types'; +import {ApiVersion, ContextParams} from './base-types'; import {AuthScopes} from './auth/scopes'; interface ContextInterface extends ContextParams { diff --git a/src/rest-resources/2021-04/abandoned_checkout.ts b/src/rest-resources/2021-04/abandoned_checkout.ts new file mode 100644 index 000000000..bfa5d24aa --- /dev/null +++ b/src/rest-resources/2021-04/abandoned_checkout.ts @@ -0,0 +1,103 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Currency} from './currency'; +import {Customer} from './customer'; +import {DiscountCode} from './discount_code'; + +interface CheckoutsArgs { + [key: string]: unknown; + session: SessionInterface; + since_id?: unknown; + created_at_min?: unknown; + created_at_max?: unknown; + updated_at_min?: unknown; + updated_at_max?: unknown; + status?: unknown; + limit?: unknown; +} + +export class AbandonedCheckout extends Base { + public static API_VERSION = ApiVersion.April21; + + protected static NAME = 'abandoned_checkout'; + protected static PLURAL_NAME = 'abandoned_checkouts'; + protected static HAS_ONE: {[key: string]: typeof Base} = { + currency: Currency, + customer: Customer + }; + protected static HAS_MANY: {[key: string]: typeof Base} = { + discount_codes: DiscountCode + }; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "checkouts", ids: [], path: "checkouts.json"}, + {http_method: "get", operation: "checkouts", ids: [], path: "checkouts.json"} + ]; + + public static async checkouts( + { + session, + since_id = null, + created_at_min = null, + created_at_max = null, + updated_at_min = null, + updated_at_max = null, + status = null, + limit = null, + ...otherArgs + }: CheckoutsArgs + ): Promise { + const response = await AbandonedCheckout.request({ + http_method: "get", + operation: "checkouts", + session: session, + urlIds: {}, + params: {since_id: since_id, created_at_min: created_at_min, created_at_max: created_at_max, updated_at_min: updated_at_min, updated_at_max: updated_at_max, status: status, limit: limit, ...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public abandoned_checkout_url: string | null; + public billing_address: {[key: string]: unknown} | null; + public buyer_accepts_marketing: boolean | null; + public buyer_accepts_sms_marketing: boolean | null; + public cart_token: string | null; + public closed_at: string | null; + public completed_at: string | null; + public created_at: string | null; + public currency: Currency | null | {[key: string]: any}; + public customer: Customer | null | {[key: string]: any}; + public customer_locale: string | null; + public device_id: number | null; + public discount_codes: DiscountCode[] | null | {[key: string]: any}; + public email: string | null; + public gateway: string | null; + public id: number | null; + public landing_site: string | null; + public line_items: {[key: string]: unknown} | null; + public location_id: number | null; + public note: string | null; + public phone: string | null; + public presentment_currency: string | null; + public referring_site: string | null; + public shipping_address: {[key: string]: unknown} | null; + public shipping_lines: {[key: string]: unknown} | null; + public sms_marketing_phone: string | null; + public source_name: string | null; + public subtotal_price: string | null; + public tax_lines: {[key: string]: unknown} | null; + public taxes_included: boolean | null; + public token: string | null; + public total_discounts: string | null; + public total_duties: string | null; + public total_line_items_price: string | null; + public total_price: string | null; + public total_tax: string | null; + public total_weight: number | null; + public updated_at: string | null; + public user_id: number | null; +} diff --git a/src/rest-resources/2021-04/access_scope.ts b/src/rest-resources/2021-04/access_scope.ts new file mode 100644 index 000000000..684ff6fe4 --- /dev/null +++ b/src/rest-resources/2021-04/access_scope.ts @@ -0,0 +1,39 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; +} + +export class AccessScope extends Base { + public static API_VERSION = ApiVersion.April21; + + protected static NAME = 'access_scope'; + protected static PLURAL_NAME = 'access_scopes'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static CUSTOM_PREFIX: string | null = "/admin/oauth"; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "access_scopes.json"} + ]; + + public static async all( + { + session, + ...otherArgs + }: AllArgs + ): Promise { + const response = await AccessScope.baseFind({ + session: session, + urlIds: {}, + params: {...otherArgs}, + }); + + return response as AccessScope[]; + } + + public handle: string | null; + public access_scopes: {[key: string]: unknown}[] | null; +} diff --git a/src/rest-resources/2021-04/android_pay_key.ts b/src/rest-resources/2021-04/android_pay_key.ts new file mode 100644 index 000000000..09e46d219 --- /dev/null +++ b/src/rest-resources/2021-04/android_pay_key.ts @@ -0,0 +1,60 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} + +export class AndroidPayKey extends Base { + public static API_VERSION = ApiVersion.April21; + + protected static NAME = 'android_pay_key'; + protected static PLURAL_NAME = 'android_pay_keys'; + 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: "get", operation: "get", ids: ["id"], path: "android_pay_keys/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "android_pay_keys/.json"} + ]; + + public static async find( + { + session, + id + }: FindArgs + ): Promise { + const result = await AndroidPayKey.baseFind({ + session: session, + urlIds: {id: id}, + params: {}, + }); + return result ? result[0] as AndroidPayKey : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await AndroidPayKey.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public id: number | null; + public public_key: string | null; +} diff --git a/src/rest-resources/2021-04/apple_pay_certificate.ts b/src/rest-resources/2021-04/apple_pay_certificate.ts new file mode 100644 index 000000000..e40103aeb --- /dev/null +++ b/src/rest-resources/2021-04/apple_pay_certificate.ts @@ -0,0 +1,88 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface CsrArgs { + [key: string]: unknown; + session: SessionInterface; + id: number | string; +} + +export class ApplePayCertificate extends Base { + public static API_VERSION = ApiVersion.April21; + + protected static NAME = 'apple_pay_certificate'; + protected static PLURAL_NAME = 'apple_pay_certificates'; + 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/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "apple_pay_certificates/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "apple_pay_certificates/.json"}, + {http_method: "get", operation: "csr", ids: ["id"], path: "apple_pay_certificates//csr.json"} + ]; + + public static async find( + { + session, + id + }: FindArgs + ): Promise { + const result = await ApplePayCertificate.baseFind({ + session: session, + urlIds: {id: id}, + params: {}, + }); + return result ? result[0] as ApplePayCertificate : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await ApplePayCertificate.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async csr( + { + session, + id, + ...otherArgs + }: CsrArgs + ): Promise { + const response = await ApplePayCertificate.request({ + http_method: "get", + operation: "csr", + session: session, + urlIds: {id: id}, + params: {...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public id: number | null; + public merchant_id: string | null; + public status: string | null; +} diff --git a/src/rest-resources/2021-04/application_charge.ts b/src/rest-resources/2021-04/application_charge.ts new file mode 100644 index 000000000..e927e0a94 --- /dev/null +++ b/src/rest-resources/2021-04/application_charge.ts @@ -0,0 +1,71 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + since_id?: unknown; + fields?: unknown; +} + +export class ApplicationCharge extends Base { + public static API_VERSION = ApiVersion.April21; + + protected static NAME = 'application_charge'; + protected static PLURAL_NAME = 'application_charges'; + 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: ["id"], path: "application_charges/.json"}, + {http_method: "get", operation: "get", ids: [], path: "application_charges.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await ApplicationCharge.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as ApplicationCharge : null; + } + + public static async all( + { + session, + since_id = null, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await ApplicationCharge.baseFind({ + session: session, + urlIds: {}, + params: {since_id: since_id, fields: fields, ...otherArgs}, + }); + + return response as ApplicationCharge[]; + } + + public confirmation_url: string | null; + public created_at: string | null; + public id: number | null; + public name: string | null; + public price: string | number | null; + public return_url: string | null; + public status: string | null; + public test: boolean | null; + public updated_at: string | null; +} diff --git a/src/rest-resources/2021-04/application_credit.ts b/src/rest-resources/2021-04/application_credit.ts new file mode 100644 index 000000000..dabcc15a4 --- /dev/null +++ b/src/rest-resources/2021-04/application_credit.ts @@ -0,0 +1,64 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + fields?: unknown; +} + +export class ApplicationCredit extends Base { + public static API_VERSION = ApiVersion.April21; + + protected static NAME = 'application_credit'; + protected static PLURAL_NAME = 'application_credits'; + 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/.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await ApplicationCredit.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as ApplicationCredit : null; + } + + public static async all( + { + session, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await ApplicationCredit.baseFind({ + session: session, + urlIds: {}, + params: {fields: fields, ...otherArgs}, + }); + + return response as ApplicationCredit[]; + } + + public amount: number | null; + public description: string | null; + public id: number | null; + public test: boolean | null; +} diff --git a/src/rest-resources/2021-04/article.ts b/src/rest-resources/2021-04/article.ts new file mode 100644 index 000000000..bd56f4352 --- /dev/null +++ b/src/rest-resources/2021-04/article.ts @@ -0,0 +1,228 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Metafield} from './metafield'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + blog_id?: number | string | null; + fields?: unknown; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; + blog_id?: number | string | null; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + blog_id?: number | string | null; + limit?: unknown; + since_id?: unknown; + created_at_min?: unknown; + created_at_max?: unknown; + updated_at_min?: unknown; + updated_at_max?: unknown; + published_at_min?: unknown; + published_at_max?: unknown; + published_status?: unknown; + handle?: unknown; + tag?: unknown; + author?: unknown; + fields?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; + blog_id?: number | string | null; + created_at_min?: unknown; + created_at_max?: unknown; + updated_at_min?: unknown; + updated_at_max?: unknown; + published_at_min?: unknown; + 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 { + public static API_VERSION = ApiVersion.April21; + + protected static NAME = 'article'; + protected static PLURAL_NAME = 'articles'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = { + metafields: Metafield + }; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: ["blog_id"], path: "blogs//articles.json"}, + {http_method: "post", operation: "post", ids: ["blog_id"], path: "blogs//articles.json"}, + {http_method: "get", operation: "count", ids: ["blog_id"], path: "blogs//articles/count.json"}, + {http_method: "get", operation: "get", ids: ["blog_id", "id"], path: "blogs//articles/.json"}, + {http_method: "put", operation: "put", ids: ["blog_id", "id"], path: "blogs//articles/.json"}, + {http_method: "delete", operation: "delete", ids: ["blog_id", "id"], path: "blogs//articles/.json"}, + {http_method: "get", operation: "authors", ids: [], path: "articles/authors.json"}, + {http_method: "get", operation: "tags", ids: ["blog_id"], path: "blogs//articles/tags.json"}, + {http_method: "get", operation: "tags", ids: [], path: "articles/tags.json"} + ]; + + public static async find( + { + session, + id, + blog_id = null, + fields = null + }: FindArgs + ): Promise
{ + const result = await Article.baseFind({ + session: session, + urlIds: {id: id, blog_id: blog_id}, + params: {fields: fields}, + }); + return result ? result[0] as Article : null; + } + + public static async delete( + { + session, + id, + blog_id = null + }: DeleteArgs + ): Promise { + const response = await Article.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id, blog_id: blog_id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + blog_id = null, + limit = null, + since_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, + handle = null, + tag = null, + author = null, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Article.baseFind({ + session: session, + urlIds: {blog_id: blog_id}, + params: {limit: limit, since_id: since_id, 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, handle: handle, tag: tag, author: author, fields: fields, ...otherArgs}, + }); + + return response as Article[]; + } + + 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 + }: CountArgs + ): Promise { + const response = await Article.request({ + http_method: "get", + operation: "count", + 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}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public static async authors( + { + session, + ...otherArgs + }: AuthorsArgs + ): Promise { + const response = await Article.request({ + http_method: "get", + operation: "authors", + session: session, + urlIds: {}, + params: {...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public static async tags( + { + session, + blog_id = null, + limit = null, + popular = null, + ...otherArgs + }: TagsArgs + ): Promise { + const response = await Article.request({ + http_method: "get", + operation: "tags", + session: session, + urlIds: {blog_id: blog_id}, + params: {limit: limit, popular: popular, ...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public author: string | null; + public blog_id: number | null; + public body_html: string | null; + public created_at: string | null; + public handle: string | null; + public id: number | null; + public image: string | {[key: string]: unknown} | null; + public metafields: Metafield[] | null | {[key: string]: any}; + public published: boolean | null; + public published_at: string | null; + public summary_html: string | null; + public tags: string | null; + public template_suffix: string | null; + public title: string | null; + public updated_at: string | null; + public user_id: number | null; +} diff --git a/src/rest-resources/2021-04/asset.ts b/src/rest-resources/2021-04/asset.ts new file mode 100644 index 000000000..aeb5bbdff --- /dev/null +++ b/src/rest-resources/2021-04/asset.ts @@ -0,0 +1,79 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface DeleteArgs { + session: SessionInterface; + theme_id?: number | string | null; + asset?: {[key: string]: unknown} | null; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + theme_id?: number | string | null; + fields?: unknown; + asset?: {[key: string]: unknown} | null; +} + +export class Asset extends Base { + public static API_VERSION = ApiVersion.April21; + + protected static NAME = 'asset'; + protected static PLURAL_NAME = 'assets'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: ["theme_id"], path: "themes//assets.json"}, + {http_method: "put", operation: "put", ids: ["theme_id"], path: "themes//assets.json"}, + {http_method: "get", operation: "get", ids: ["theme_id"], path: "themes//assets.json"}, + {http_method: "delete", operation: "delete", ids: ["theme_id"], path: "themes//assets.json"} + ]; + protected static PRIMARY_KEY: string = "key"; + + public static async delete( + { + session, + theme_id = null, + asset = null + }: DeleteArgs + ): Promise { + const response = await Asset.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {theme_id: theme_id}, + params: {asset: asset}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + theme_id = null, + fields = null, + asset = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Asset.baseFind({ + session: session, + urlIds: {theme_id: theme_id}, + params: {fields: fields, asset: asset, ...otherArgs}, + }); + + return response as Asset[]; + } + + public attachment: string | null; + public checksum: string | null; + public content_type: string | null; + public created_at: string | null; + public key: string | null; + public public_url: string | null; + public size: number | null; + public theme_id: number | null; + public updated_at: string | null; + public value: string | null; +} diff --git a/src/rest-resources/2021-04/assigned_fulfillment_order.ts b/src/rest-resources/2021-04/assigned_fulfillment_order.ts new file mode 100644 index 000000000..b82b05049 --- /dev/null +++ b/src/rest-resources/2021-04/assigned_fulfillment_order.ts @@ -0,0 +1,48 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + assignment_status?: unknown; + location_ids?: unknown[] | number | string | null; +} + +export class AssignedFulfillmentOrder extends Base { + public static API_VERSION = ApiVersion.April21; + + protected static NAME = 'assigned_fulfillment_order'; + protected static PLURAL_NAME = 'assigned_fulfillment_orders'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "assigned_fulfillment_orders.json"} + ]; + + public static async all( + { + session, + assignment_status = null, + location_ids = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await AssignedFulfillmentOrder.baseFind({ + session: session, + urlIds: {}, + params: {assignment_status: assignment_status, location_ids: location_ids, ...otherArgs}, + }); + + return response as AssignedFulfillmentOrder[]; + } + + public assigned_location_id: number | null; + public destination: {[key: string]: unknown} | null; + public id: number | null; + public line_items: {[key: string]: unknown}[] | null; + public order_id: number | null; + public request_status: string | null; + public shop_id: number | null; + public status: string | null; +} diff --git a/src/rest-resources/2021-04/balance.ts b/src/rest-resources/2021-04/balance.ts new file mode 100644 index 000000000..633a9bb31 --- /dev/null +++ b/src/rest-resources/2021-04/balance.ts @@ -0,0 +1,36 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; +} + +export class Balance extends Base { + public static API_VERSION = ApiVersion.April21; + + protected static NAME = 'balance'; + protected static PLURAL_NAME = 'balances'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "shopify_payments/balance.json"} + ]; + + public static async all( + { + session, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Balance.baseFind({ + session: session, + urlIds: {}, + params: {...otherArgs}, + }); + + return response as Balance[]; + } + +} diff --git a/src/rest-resources/2021-04/blog.ts b/src/rest-resources/2021-04/blog.ts new file mode 100644 index 000000000..4d7a1984b --- /dev/null +++ b/src/rest-resources/2021-04/blog.ts @@ -0,0 +1,129 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Metafield} from './metafield'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + limit?: unknown; + since_id?: unknown; + handle?: unknown; + fields?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; +} + +export class Blog extends Base { + public static API_VERSION = ApiVersion.April21; + + protected static NAME = 'blog'; + protected static PLURAL_NAME = 'blogs'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof 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: "get", operation: "count", ids: [], path: "blogs/count.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "blogs/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "blogs/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "blogs/.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await Blog.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as Blog : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await Blog.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + limit = null, + since_id = null, + handle = null, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Blog.baseFind({ + session: session, + urlIds: {}, + params: {limit: limit, since_id: since_id, handle: handle, fields: fields, ...otherArgs}, + }); + + return response as Blog[]; + } + + public static async count( + { + session, + ...otherArgs + }: CountArgs + ): Promise { + const response = await Blog.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {}, + params: {...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public admin_graphql_api_id: string | null; + public commentable: string | null; + public created_at: string | null; + public feedburner: string | null; + public feedburner_location: string | null; + public handle: string | null; + public id: number | null; + public metafields: Metafield[] | null | {[key: string]: any}; + public tags: string | null; + public template_suffix: string | null; + public title: string | null; + public updated_at: string | null; +} diff --git a/src/rest-resources/2021-04/cancellation_request.ts b/src/rest-resources/2021-04/cancellation_request.ts new file mode 100644 index 000000000..9b0f467d8 --- /dev/null +++ b/src/rest-resources/2021-04/cancellation_request.ts @@ -0,0 +1,69 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {ApiVersion} from '../../base-types'; + +interface AcceptArgs { + [key: string]: unknown; + message?: unknown; + body?: {[key: string]: unknown} | null; +} +interface RejectArgs { + [key: string]: unknown; + message?: unknown; + body?: {[key: string]: unknown} | null; +} + +export class CancellationRequest extends Base { + public static API_VERSION = ApiVersion.April21; + + protected static NAME = 'cancellation_request'; + protected static PLURAL_NAME = 'cancellation_requests'; + 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//cancellation_request.json"}, + {http_method: "post", operation: "accept", ids: ["fulfillment_order_id"], path: "fulfillment_orders//cancellation_request/accept.json"}, + {http_method: "post", operation: "reject", ids: ["fulfillment_order_id"], path: "fulfillment_orders//cancellation_request/reject.json"} + ]; + + public async accept( + { + message = null, + body = null, + ...otherArgs + }: AcceptArgs + ): Promise { + const response = await CancellationRequest.request({ + http_method: "post", + operation: "accept", + session: this.session, + urlIds: {fulfillment_order_id: this.fulfillment_order_id}, + params: {message: message, ...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public async reject( + { + message = null, + body = null, + ...otherArgs + }: RejectArgs + ): Promise { + const response = await CancellationRequest.request({ + http_method: "post", + operation: "reject", + session: this.session, + urlIds: {fulfillment_order_id: this.fulfillment_order_id}, + params: {message: message, ...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public fulfillment_order_id: number | null; +} diff --git a/src/rest-resources/2021-04/carrier_service.ts b/src/rest-resources/2021-04/carrier_service.ts new file mode 100644 index 000000000..f41d439d2 --- /dev/null +++ b/src/rest-resources/2021-04/carrier_service.ts @@ -0,0 +1,87 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; +} + +export class CarrierService extends Base { + public static API_VERSION = ApiVersion.April21; + + protected static NAME = 'carrier_service'; + protected static PLURAL_NAME = 'carrier_services'; + 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: "get", operation: "get", ids: [], path: "carrier_services.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "carrier_services/.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "carrier_services/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "carrier_services/.json"} + ]; + + public static async find( + { + session, + id + }: FindArgs + ): Promise { + const result = await CarrierService.baseFind({ + session: session, + urlIds: {id: id}, + params: {}, + }); + return result ? result[0] as CarrierService : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await CarrierService.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + ...otherArgs + }: AllArgs + ): Promise { + const response = await CarrierService.baseFind({ + session: session, + urlIds: {}, + params: {...otherArgs}, + }); + + return response as CarrierService[]; + } + + public active: boolean | null; + public admin_graphql_api_id: string | null; + public callback_url: string | null; + public carrier_service_type: string | null; + public format: string | null; + public id: number | null; + public name: string | null; + public service_discovery: boolean | null; +} diff --git a/src/rest-resources/2021-04/checkout.ts b/src/rest-resources/2021-04/checkout.ts new file mode 100644 index 000000000..8bddea0d3 --- /dev/null +++ b/src/rest-resources/2021-04/checkout.ts @@ -0,0 +1,130 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Currency} from './currency'; +import {DiscountCode} from './discount_code'; +import {Order} from './order'; +import {GiftCard} from './gift_card'; + +interface FindArgs { + session: SessionInterface; + token: number | string; +} +interface ShippingRatesArgs { + [key: string]: unknown; + session: SessionInterface; + token: number | string; +} +interface CompleteArgs { + [key: string]: unknown; + body?: {[key: string]: unknown} | null; +} + +export class Checkout extends Base { + public static API_VERSION = ApiVersion.April21; + + protected static NAME = 'checkout'; + protected static PLURAL_NAME = 'checkouts'; + protected static HAS_ONE: {[key: string]: typeof Base} = { + currency: Currency, + discount_code: DiscountCode, + order: Order + }; + protected static HAS_MANY: {[key: string]: typeof 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//complete.json"}, + {http_method: "get", operation: "get", ids: ["token"], path: "checkouts/.json"}, + {http_method: "put", operation: "put", ids: ["token"], path: "checkouts/.json"}, + {http_method: "get", operation: "shipping_rates", ids: ["token"], path: "checkouts//shipping_rates.json"} + ]; + protected static PRIMARY_KEY: string = "token"; + + public static async find( + { + session, + token + }: FindArgs + ): Promise { + const result = await Checkout.baseFind({ + session: session, + urlIds: {token: token}, + params: {}, + }); + return result ? result[0] as Checkout : null; + } + + public static async shipping_rates( + { + session, + token, + ...otherArgs + }: ShippingRatesArgs + ): Promise { + const response = await Checkout.request({ + http_method: "get", + operation: "shipping_rates", + session: session, + urlIds: {token: token}, + params: {...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public async complete( + { + body = null, + ...otherArgs + }: CompleteArgs + ): Promise { + const response = await Checkout.request({ + http_method: "post", + operation: "complete", + session: this.session, + urlIds: {token: this.token}, + params: {...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public billing_address: {[key: string]: unknown} | null; + public line_items: {[key: string]: unknown}[] | null; + public applied_discount: {[key: string]: unknown} | null; + public buyer_accepts_marketing: boolean | null; + public created_at: string | null; + public currency: Currency | null | {[key: string]: any}; + public customer_id: number | null; + public discount_code: DiscountCode | null | {[key: string]: any}; + public email: string | null; + public gift_cards: GiftCard[] | null | {[key: string]: any}; + public order: Order | null | {[key: string]: any}; + public payment_due: string | null; + public payment_url: string | null; + public phone: string | null; + public presentment_currency: string | null; + public requires_shipping: boolean | null; + public reservation_time: string | null; + public reservation_time_left: number | null; + public shipping_address: {[key: string]: unknown} | null; + public shipping_line: {[key: string]: unknown} | null; + public shipping_rate: {[key: string]: unknown} | null; + public source_name: string | null; + public subtotal_price: string | null; + public tax_lines: {[key: string]: unknown}[] | null; + public taxes_included: boolean | null; + public token: string | null; + public total_price: string | null; + public total_tax: string | null; + public updated_at: string | null; + public user_id: number | null; + public web_url: string | null; +} diff --git a/src/rest-resources/2021-04/collect.ts b/src/rest-resources/2021-04/collect.ts new file mode 100644 index 000000000..16123fe11 --- /dev/null +++ b/src/rest-resources/2021-04/collect.ts @@ -0,0 +1,117 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + limit?: unknown; + since_id?: unknown; + fields?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; +} + +export class Collect extends Base { + public static API_VERSION = ApiVersion.April21; + + protected static NAME = 'collect'; + protected static PLURAL_NAME = 'collects'; + 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/.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "collects/.json"}, + {http_method: "get", operation: "count", ids: [], path: "collects/count.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await Collect.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as Collect : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await Collect.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + limit = null, + since_id = null, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Collect.baseFind({ + session: session, + urlIds: {}, + params: {limit: limit, since_id: since_id, fields: fields, ...otherArgs}, + }); + + return response as Collect[]; + } + + public static async count( + { + session, + ...otherArgs + }: CountArgs + ): Promise { + const response = await Collect.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {}, + params: {...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public collection_id: number | null; + public created_at: string | null; + public id: number | null; + public position: number | null; + public product_id: number | null; + public sort_value: string | null; + public updated_at: string | null; +} diff --git a/src/rest-resources/2021-04/collection.ts b/src/rest-resources/2021-04/collection.ts new file mode 100644 index 000000000..817da4091 --- /dev/null +++ b/src/rest-resources/2021-04/collection.ts @@ -0,0 +1,79 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Image} from './image'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface ProductsArgs { + [key: string]: unknown; + session: SessionInterface; + id: number | string; + limit?: unknown; +} + +export class Collection extends Base { + public static API_VERSION = ApiVersion.April21; + + protected static NAME = 'collection'; + protected static PLURAL_NAME = 'collections'; + protected static HAS_ONE: {[key: string]: typeof Base} = { + image: Image + }; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: ["id"], path: "collections/.json"}, + {http_method: "get", operation: "products", ids: ["id"], path: "collections//products.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await Collection.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as Collection : null; + } + + public static async products( + { + session, + id, + limit = null, + ...otherArgs + }: ProductsArgs + ): Promise { + const response = await Collection.request({ + http_method: "get", + operation: "products", + session: session, + urlIds: {id: id}, + params: {limit: limit, ...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public title: string | null; + public body_html: string | null; + public handle: string | null; + public id: number | null; + public image: Image | null | {[key: string]: any}; + public published_at: string | null; + public published_scope: string | null; + public sort_order: string | null; + public template_suffix: string | null; + public updated_at: string | null; +} diff --git a/src/rest-resources/2021-04/collection_listing.ts b/src/rest-resources/2021-04/collection_listing.ts new file mode 100644 index 000000000..a1526f0ab --- /dev/null +++ b/src/rest-resources/2021-04/collection_listing.ts @@ -0,0 +1,122 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Image} from './image'; + +interface FindArgs { + session: SessionInterface; + collection_id: number | string; +} +interface DeleteArgs { + session: SessionInterface; + collection_id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + limit?: unknown; +} +interface ProductIdsArgs { + [key: string]: unknown; + session: SessionInterface; + collection_id: number | string; + limit?: unknown; +} + +export class CollectionListing extends Base { + public static API_VERSION = ApiVersion.April21; + + protected static NAME = 'collection_listing'; + protected static PLURAL_NAME = 'collection_listings'; + protected static HAS_ONE: {[key: string]: typeof Base} = { + image: Image + }; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "collection_listings.json"}, + {http_method: "get", operation: "product_ids", ids: ["collection_id"], path: "collection_listings//product_ids.json"}, + {http_method: "get", operation: "get", ids: ["collection_id"], path: "collection_listings/.json"}, + {http_method: "put", operation: "put", ids: ["collection_id"], path: "collection_listings/.json"}, + {http_method: "delete", operation: "delete", ids: ["collection_id"], path: "collection_listings/.json"} + ]; + protected static PRIMARY_KEY: string = "collection_id"; + + public static async find( + { + session, + collection_id + }: FindArgs + ): Promise { + const result = await CollectionListing.baseFind({ + session: session, + urlIds: {collection_id: collection_id}, + params: {}, + }); + return result ? result[0] as CollectionListing : null; + } + + public static async delete( + { + session, + collection_id + }: DeleteArgs + ): Promise { + const response = await CollectionListing.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {collection_id: collection_id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + limit = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await CollectionListing.baseFind({ + session: session, + urlIds: {}, + params: {limit: limit, ...otherArgs}, + }); + + return response as CollectionListing[]; + } + + public static async product_ids( + { + session, + collection_id, + limit = null, + ...otherArgs + }: ProductIdsArgs + ): Promise { + const response = await CollectionListing.request({ + http_method: "get", + operation: "product_ids", + session: session, + urlIds: {collection_id: collection_id}, + params: {limit: limit, ...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public body_html: string | null; + public collection_id: number | null; + public default_product_image: {[key: string]: unknown}[] | null; + public handle: string | null; + public image: Image | null | {[key: string]: any}; + public published_at: string | null; + public sort_order: string | null; + public title: string | null; + public updated_at: string | null; +} diff --git a/src/rest-resources/2021-04/comment.ts b/src/rest-resources/2021-04/comment.ts new file mode 100644 index 000000000..f25361ad4 --- /dev/null +++ b/src/rest-resources/2021-04/comment.ts @@ -0,0 +1,254 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + limit?: unknown; + since_id?: unknown; + created_at_min?: unknown; + created_at_max?: unknown; + updated_at_min?: unknown; + updated_at_max?: unknown; + published_at_min?: unknown; + published_at_max?: unknown; + fields?: unknown; + published_status?: unknown; + status?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; + created_at_min?: unknown; + created_at_max?: unknown; + updated_at_min?: unknown; + updated_at_max?: unknown; + published_at_min?: unknown; + published_at_max?: unknown; + published_status?: unknown; + status?: unknown; +} +interface SpamArgs { + [key: string]: unknown; + body?: {[key: string]: unknown} | null; +} +interface NotSpamArgs { + [key: string]: unknown; + body?: {[key: string]: unknown} | null; +} +interface ApproveArgs { + [key: string]: unknown; + body?: {[key: string]: unknown} | null; +} +interface RemoveArgs { + [key: string]: unknown; + body?: {[key: string]: unknown} | null; +} +interface RestoreArgs { + [key: string]: unknown; + body?: {[key: string]: unknown} | null; +} + +export class Comment extends Base { + public static API_VERSION = ApiVersion.April21; + + protected static NAME = 'comment'; + protected static PLURAL_NAME = 'comments'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "comments.json"}, + {http_method: "get", operation: "count", ids: [], path: "comments/count.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "comments/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "comments/.json"}, + {http_method: "post", operation: "post", ids: [], path: "comments.json"}, + {http_method: "post", operation: "spam", ids: ["id"], path: "comments//spam.json"}, + {http_method: "post", operation: "not_spam", ids: ["id"], path: "comments//not_spam.json"}, + {http_method: "post", operation: "approve", ids: ["id"], path: "comments//approve.json"}, + {http_method: "post", operation: "remove", ids: ["id"], path: "comments//remove.json"}, + {http_method: "post", operation: "restore", ids: ["id"], path: "comments//restore.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await Comment.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as Comment : null; + } + + public static async all( + { + session, + limit = null, + since_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, + fields = null, + published_status = null, + status = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Comment.baseFind({ + session: session, + urlIds: {}, + params: {limit: limit, since_id: since_id, 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, fields: fields, published_status: published_status, status: status, ...otherArgs}, + }); + + return response as Comment[]; + } + + public static async count( + { + session, + 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, + status = null, + ...otherArgs + }: CountArgs + ): Promise { + const response = await Comment.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {}, + 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, status: status, ...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public async spam( + { + body = null, + ...otherArgs + }: SpamArgs + ): Promise { + const response = await Comment.request({ + http_method: "post", + operation: "spam", + session: this.session, + urlIds: {id: this.id}, + params: {...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public async not_spam( + { + body = null, + ...otherArgs + }: NotSpamArgs + ): Promise { + const response = await Comment.request({ + http_method: "post", + operation: "not_spam", + session: this.session, + urlIds: {id: this.id}, + params: {...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public async approve( + { + body = null, + ...otherArgs + }: ApproveArgs + ): Promise { + const response = await Comment.request({ + http_method: "post", + operation: "approve", + session: this.session, + urlIds: {id: this.id}, + params: {...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public async remove( + { + body = null, + ...otherArgs + }: RemoveArgs + ): Promise { + const response = await Comment.request({ + http_method: "post", + operation: "remove", + session: this.session, + urlIds: {id: this.id}, + params: {...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public async restore( + { + body = null, + ...otherArgs + }: RestoreArgs + ): Promise { + const response = await Comment.request({ + http_method: "post", + operation: "restore", + session: this.session, + urlIds: {id: this.id}, + params: {...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public article_id: number | null; + public author: string | null; + public blog_id: number | null; + public body: string | null; + public body_html: string | null; + public created_at: string | null; + public email: string | null; + public id: number | null; + public ip: string | null; + public published_at: string | null; + public status: string | null; + public updated_at: string | null; + public user_agent: string | null; +} diff --git a/src/rest-resources/2021-04/country.ts b/src/rest-resources/2021-04/country.ts new file mode 100644 index 000000000..575b67789 --- /dev/null +++ b/src/rest-resources/2021-04/country.ts @@ -0,0 +1,118 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Province} from './province'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + since_id?: unknown; + fields?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; +} + +export class Country extends Base { + public static API_VERSION = ApiVersion.April21; + + protected static NAME = 'country'; + protected static PLURAL_NAME = 'countries'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = { + provinces: Province + }; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "countries.json"}, + {http_method: "post", operation: "post", ids: [], path: "countries.json"}, + {http_method: "get", operation: "count", ids: [], path: "countries/count.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "countries/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "countries/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "countries/.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await Country.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as Country : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await Country.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + since_id = null, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Country.baseFind({ + session: session, + urlIds: {}, + params: {since_id: since_id, fields: fields, ...otherArgs}, + }); + + return response as Country[]; + } + + public static async count( + { + session, + ...otherArgs + }: CountArgs + ): Promise { + const response = await Country.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {}, + params: {...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public code: string | null; + public id: number | null; + public name: string | null; + public provinces: Province[] | null | {[key: string]: any}; + public tax: number | null; +} diff --git a/src/rest-resources/2021-04/currency.ts b/src/rest-resources/2021-04/currency.ts new file mode 100644 index 000000000..4b7e83472 --- /dev/null +++ b/src/rest-resources/2021-04/currency.ts @@ -0,0 +1,38 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; +} + +export class Currency extends Base { + public static API_VERSION = ApiVersion.April21; + + protected static NAME = 'currency'; + protected static PLURAL_NAME = 'currencies'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "currencies.json"} + ]; + + public static async all( + { + session, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Currency.baseFind({ + session: session, + urlIds: {}, + params: {...otherArgs}, + }); + + return response as Currency[]; + } + + public currency: string | null; + public rate_updated_at: string | null; +} diff --git a/src/rest-resources/2021-04/custom_collection.ts b/src/rest-resources/2021-04/custom_collection.ts new file mode 100644 index 000000000..7751053ca --- /dev/null +++ b/src/rest-resources/2021-04/custom_collection.ts @@ -0,0 +1,154 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + limit?: unknown; + ids?: unknown; + since_id?: unknown; + title?: unknown; + product_id?: unknown; + handle?: unknown; + updated_at_min?: unknown; + updated_at_max?: unknown; + published_at_min?: unknown; + published_at_max?: unknown; + published_status?: unknown; + fields?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; + title?: unknown; + product_id?: unknown; + updated_at_min?: unknown; + updated_at_max?: unknown; + published_at_min?: unknown; + published_at_max?: unknown; + published_status?: unknown; +} + +export class CustomCollection extends Base { + public static API_VERSION = ApiVersion.April21; + + protected static NAME = 'custom_collection'; + protected static PLURAL_NAME = 'custom_collections'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "custom_collections.json"}, + {http_method: "post", operation: "post", ids: [], path: "custom_collections.json"}, + {http_method: "get", operation: "count", ids: [], path: "custom_collections/count.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "custom_collections/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "custom_collections/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "custom_collections/.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await CustomCollection.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as CustomCollection : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await CustomCollection.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + limit = null, + ids = null, + since_id = null, + title = null, + product_id = null, + handle = null, + updated_at_min = null, + updated_at_max = null, + published_at_min = null, + published_at_max = null, + published_status = null, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await CustomCollection.baseFind({ + session: session, + urlIds: {}, + params: {limit: limit, ids: ids, since_id: since_id, title: title, product_id: product_id, handle: handle, 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, fields: fields, ...otherArgs}, + }); + + return response as CustomCollection[]; + } + + public static async count( + { + session, + title = null, + product_id = null, + updated_at_min = null, + updated_at_max = null, + published_at_min = null, + published_at_max = null, + published_status = null, + ...otherArgs + }: CountArgs + ): Promise { + const response = await CustomCollection.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {}, + params: {title: title, product_id: product_id, 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, + }); + + return response ? response.body : null; + } + + public title: string | null; + public body_html: string | null; + public handle: string | null; + public id: number | null; + public image: string | {[key: string]: unknown} | null; + public published: boolean | null; + public published_at: string | null; + public published_scope: string | null; + public sort_order: string | null; + public template_suffix: string | null; + public updated_at: string | null; +} diff --git a/src/rest-resources/2021-04/customer.ts b/src/rest-resources/2021-04/customer.ts new file mode 100644 index 000000000..3107350c3 --- /dev/null +++ b/src/rest-resources/2021-04/customer.ts @@ -0,0 +1,258 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Currency} from './currency'; +import {Metafield} from './metafield'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + ids?: unknown; + since_id?: unknown; + created_at_min?: unknown; + created_at_max?: unknown; + updated_at_min?: unknown; + updated_at_max?: unknown; + limit?: unknown; + fields?: unknown; +} +interface SearchArgs { + [key: string]: unknown; + session: SessionInterface; + order?: unknown; + query?: unknown; + limit?: unknown; + fields?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; +} +interface OrdersArgs { + [key: string]: unknown; + session: SessionInterface; + id: number | string; +} +interface AccountActivationUrlArgs { + [key: string]: unknown; + body?: {[key: string]: unknown} | null; +} +interface SendInviteArgs { + [key: string]: unknown; + body?: {[key: string]: unknown} | null; +} + +export class Customer extends Base { + public static API_VERSION = ApiVersion.April21; + + protected static NAME = 'customer'; + protected static PLURAL_NAME = 'customers'; + protected static HAS_ONE: {[key: string]: typeof Base} = { + currency: Currency, + metafield: Metafield + }; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "customers.json"}, + {http_method: "post", operation: "post", ids: [], path: "customers.json"}, + {http_method: "get", operation: "search", ids: [], path: "customers/search.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "customers/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "customers/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "customers/.json"}, + {http_method: "post", operation: "account_activation_url", ids: ["id"], path: "customers//account_activation_url.json"}, + {http_method: "post", operation: "send_invite", ids: ["id"], path: "customers//send_invite.json"}, + {http_method: "get", operation: "count", ids: [], path: "customers/count.json"}, + {http_method: "get", operation: "orders", ids: ["id"], path: "customers//orders.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await Customer.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as Customer : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await Customer.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + ids = null, + since_id = null, + created_at_min = null, + created_at_max = null, + updated_at_min = null, + updated_at_max = null, + limit = null, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Customer.baseFind({ + session: session, + urlIds: {}, + params: {ids: ids, since_id: since_id, created_at_min: created_at_min, created_at_max: created_at_max, updated_at_min: updated_at_min, updated_at_max: updated_at_max, limit: limit, fields: fields, ...otherArgs}, + }); + + return response as Customer[]; + } + + public static async search( + { + session, + order = null, + query = null, + limit = null, + fields = null, + ...otherArgs + }: SearchArgs + ): Promise { + const response = await Customer.request({ + http_method: "get", + operation: "search", + session: session, + urlIds: {}, + params: {order: order, query: query, limit: limit, fields: fields, ...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public static async count( + { + session, + ...otherArgs + }: CountArgs + ): Promise { + const response = await Customer.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {}, + params: {...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public static async orders( + { + session, + id, + ...otherArgs + }: OrdersArgs + ): Promise { + const response = await Customer.request({ + http_method: "get", + operation: "orders", + session: session, + urlIds: {id: id}, + params: {...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public async account_activation_url( + { + body = null, + ...otherArgs + }: AccountActivationUrlArgs + ): Promise { + const response = await Customer.request({ + http_method: "post", + operation: "account_activation_url", + session: this.session, + urlIds: {id: this.id}, + params: {...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public async send_invite( + { + body = null, + ...otherArgs + }: SendInviteArgs + ): Promise { + const response = await Customer.request({ + http_method: "post", + operation: "send_invite", + session: this.session, + urlIds: {id: this.id}, + params: {...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public accepts_marketing: boolean | null; + public accepts_marketing_updated_at: string | null; + public addresses: {[key: string]: unknown}[] | null; + public created_at: string | null; + public currency: Currency | null | {[key: string]: any}; + public default_address: {[key: string]: unknown} | null; + public email: string | null; + public first_name: string | null; + public id: number | null; + public last_name: string | null; + public last_order_id: number | null; + public last_order_name: string | null; + public marketing_opt_in_level: string | null; + public metafield: Metafield | null | {[key: string]: any}; + public multipass_identifier: string | null; + public note: string | null; + public orders_count: number | null; + public phone: string | null; + public state: string | null; + public tags: string | null; + public tax_exempt: boolean | null; + public tax_exemptions: string[] | null; + public total_spent: string | null; + public updated_at: string | null; + public verified_email: boolean | null; +} diff --git a/src/rest-resources/2021-04/customer_address.ts b/src/rest-resources/2021-04/customer_address.ts new file mode 100644 index 000000000..cb32b8380 --- /dev/null +++ b/src/rest-resources/2021-04/customer_address.ts @@ -0,0 +1,158 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + customer_id?: number | string | null; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; + customer_id?: number | string | null; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + customer_id?: number | string | null; +} +interface SetArgs { + [key: string]: unknown; + address_ids?: unknown[] | number | string | null; + operation?: unknown; + body?: {[key: string]: unknown} | null; +} +interface DefaultArgs { + [key: string]: unknown; + body?: {[key: string]: unknown} | null; +} + +export class CustomerAddress extends Base { + public static API_VERSION = ApiVersion.April21; + + protected static NAME = 'customer_address'; + protected static PLURAL_NAME = 'customer_addresses'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: ["customer_id"], path: "customers//addresses.json"}, + {http_method: "post", operation: "post", ids: ["customer_id"], path: "customers//addresses.json"}, + {http_method: "get", operation: "get", ids: ["customer_id", "id"], path: "customers//addresses/.json"}, + {http_method: "put", operation: "put", ids: ["customer_id", "id"], path: "customers//addresses/.json"}, + {http_method: "delete", operation: "delete", ids: ["customer_id", "id"], path: "customers//addresses/.json"}, + {http_method: "put", operation: "set", ids: ["customer_id"], path: "customers//addresses/set.json"}, + {http_method: "put", operation: "default", ids: ["customer_id", "id"], path: "customers//addresses//default.json"} + ]; + + protected static getJsonBodyName(): string + { + return "address"; + } + + public static async find( + { + session, + id, + customer_id = null + }: FindArgs + ): Promise { + const result = await CustomerAddress.baseFind({ + session: session, + urlIds: {id: id, customer_id: customer_id}, + params: {}, + }); + return result ? result[0] as CustomerAddress : null; + } + + public static async delete( + { + session, + id, + customer_id = null + }: DeleteArgs + ): Promise { + const response = await CustomerAddress.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id, customer_id: customer_id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + customer_id = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await CustomerAddress.baseFind({ + session: session, + urlIds: {customer_id: customer_id}, + params: {...otherArgs}, + }); + + return response as CustomerAddress[]; + } + + public async set( + { + address_ids = null, + operation = null, + body = null, + ...otherArgs + }: SetArgs + ): Promise { + const response = await CustomerAddress.request({ + http_method: "put", + operation: "set", + session: this.session, + urlIds: {customer_id: this.customer_id}, + params: {address_ids: address_ids, operation: operation, ...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public async default( + { + body = null, + ...otherArgs + }: DefaultArgs + ): Promise { + const response = await CustomerAddress.request({ + http_method: "put", + operation: "default", + session: this.session, + urlIds: {id: this.id, customer_id: this.customer_id}, + params: {...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public address1: string | null; + public address2: string | null; + public city: string | null; + public company: string | null; + public country: string | null; + public country_code: string | null; + public country_name: string | null; + public customer_id: number | null; + public first_name: string | null; + public id: number | null; + public last_name: string | null; + public name: string | null; + public phone: string | null; + public province: string | null; + public province_code: string | null; + public zip: string | null; +} diff --git a/src/rest-resources/2021-04/customer_saved_search.ts b/src/rest-resources/2021-04/customer_saved_search.ts new file mode 100644 index 000000000..d4707680a --- /dev/null +++ b/src/rest-resources/2021-04/customer_saved_search.ts @@ -0,0 +1,150 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + limit?: unknown; + since_id?: unknown; + fields?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; + since_id?: unknown; +} +interface CustomersArgs { + [key: string]: unknown; + session: SessionInterface; + id: number | string; + order?: unknown; + limit?: unknown; + fields?: unknown; +} + +export class CustomerSavedSearch extends Base { + public static API_VERSION = ApiVersion.April21; + + protected static NAME = 'customer_saved_search'; + protected static PLURAL_NAME = 'customer_saved_searches'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "customer_saved_searches.json"}, + {http_method: "post", operation: "post", ids: [], path: "customer_saved_searches.json"}, + {http_method: "get", operation: "count", ids: [], path: "customer_saved_searches/count.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "customer_saved_searches/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "customer_saved_searches/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "customer_saved_searches/.json"}, + {http_method: "get", operation: "customers", ids: ["id"], path: "customer_saved_searches//customers.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await CustomerSavedSearch.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as CustomerSavedSearch : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await CustomerSavedSearch.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + limit = null, + since_id = null, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await CustomerSavedSearch.baseFind({ + session: session, + urlIds: {}, + params: {limit: limit, since_id: since_id, fields: fields, ...otherArgs}, + }); + + return response as CustomerSavedSearch[]; + } + + public static async count( + { + session, + since_id = null, + ...otherArgs + }: CountArgs + ): Promise { + const response = await CustomerSavedSearch.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {}, + params: {since_id: since_id, ...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public static async customers( + { + session, + id, + order = null, + limit = null, + fields = null, + ...otherArgs + }: CustomersArgs + ): Promise { + const response = await CustomerSavedSearch.request({ + http_method: "get", + operation: "customers", + session: session, + urlIds: {id: id}, + params: {order: order, limit: limit, fields: fields, ...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public created_at: string | null; + public id: number | null; + public name: string | null; + public query: string | null; + public updated_at: string | null; +} diff --git a/src/rest-resources/2021-04/deprecated_api_call.ts b/src/rest-resources/2021-04/deprecated_api_call.ts new file mode 100644 index 000000000..89f5e7a3e --- /dev/null +++ b/src/rest-resources/2021-04/deprecated_api_call.ts @@ -0,0 +1,38 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; +} + +export class DeprecatedApiCall extends Base { + public static API_VERSION = ApiVersion.April21; + + protected static NAME = 'deprecated_api_call'; + protected static PLURAL_NAME = 'deprecated_api_calls'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "deprecated_api_calls.json"} + ]; + + public static async all( + { + session, + ...otherArgs + }: AllArgs + ): Promise { + const response = await DeprecatedApiCall.baseFind({ + session: session, + urlIds: {}, + params: {...otherArgs}, + }); + + return response as DeprecatedApiCall[]; + } + + public data_updated_at: string | null; + public deprecated_api_calls: {[key: string]: unknown}[] | null; +} diff --git a/src/rest-resources/2021-04/discount_code.ts b/src/rest-resources/2021-04/discount_code.ts new file mode 100644 index 000000000..54485a90e --- /dev/null +++ b/src/rest-resources/2021-04/discount_code.ts @@ -0,0 +1,202 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + price_rule_id?: number | string | null; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; + price_rule_id?: number | string | null; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + price_rule_id?: number | string | null; + batch_id?: number | string | null; +} +interface LookupArgs { + [key: string]: unknown; + session: SessionInterface; + code?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; + times_used?: unknown; + times_used_min?: unknown; + times_used_max?: unknown; +} +interface GetAllArgs { + [key: string]: unknown; + session: SessionInterface; + price_rule_id?: number | string | null; + batch_id?: number | string | null; +} +interface BatchArgs { + [key: string]: unknown; + body?: {[key: string]: unknown} | null; +} + +export class DiscountCode extends Base { + public static API_VERSION = ApiVersion.April21; + + protected static NAME = 'discount_code'; + protected static PLURAL_NAME = 'discount_codes'; + 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: ["price_rule_id"], path: "price_rules//discount_codes.json"}, + {http_method: "get", operation: "get", ids: ["price_rule_id"], path: "price_rules//discount_codes.json"}, + {http_method: "put", operation: "put", ids: ["price_rule_id", "id"], path: "price_rules//discount_codes/.json"}, + {http_method: "get", operation: "get", ids: ["price_rule_id", "id"], path: "price_rules//discount_codes/.json"}, + {http_method: "delete", operation: "delete", ids: ["price_rule_id", "id"], path: "price_rules//discount_codes/.json"}, + {http_method: "get", operation: "lookup", ids: [], path: "discount_codes/lookup.json"}, + {http_method: "get", operation: "count", ids: [], path: "discount_codes/count.json"}, + {http_method: "post", operation: "batch", ids: ["price_rule_id"], path: "price_rules//batch.json"}, + {http_method: "get", operation: "get_all", ids: ["price_rule_id", "batch_id"], path: "price_rules//batch/.json"}, + {http_method: "get", operation: "get", ids: ["price_rule_id", "batch_id"], path: "price_rules//batch//discount_codes.json"} + ]; + + public static async find( + { + session, + id, + price_rule_id = null + }: FindArgs + ): Promise { + const result = await DiscountCode.baseFind({ + session: session, + urlIds: {id: id, price_rule_id: price_rule_id}, + params: {}, + }); + return result ? result[0] as DiscountCode : null; + } + + public static async delete( + { + session, + id, + price_rule_id = null + }: DeleteArgs + ): Promise { + const response = await DiscountCode.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id, price_rule_id: price_rule_id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + price_rule_id = null, + batch_id = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await DiscountCode.baseFind({ + session: session, + urlIds: {price_rule_id: price_rule_id, batch_id: batch_id}, + params: {...otherArgs}, + }); + + return response as DiscountCode[]; + } + + public static async lookup( + { + session, + code = null, + ...otherArgs + }: LookupArgs + ): Promise { + const response = await DiscountCode.request({ + http_method: "get", + operation: "lookup", + session: session, + urlIds: {}, + params: {code: code, ...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public static async count( + { + session, + times_used = null, + times_used_min = null, + times_used_max = null, + ...otherArgs + }: CountArgs + ): Promise { + const response = await DiscountCode.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {}, + params: {times_used: times_used, times_used_min: times_used_min, times_used_max: times_used_max, ...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public static async get_all( + { + session, + price_rule_id = null, + batch_id = null, + ...otherArgs + }: GetAllArgs + ): Promise { + const response = await DiscountCode.request({ + http_method: "get", + operation: "get_all", + session: session, + urlIds: {price_rule_id: price_rule_id, batch_id: batch_id}, + params: {...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public async batch( + { + body = null, + ...otherArgs + }: BatchArgs + ): Promise { + const response = await DiscountCode.request({ + http_method: "post", + operation: "batch", + session: this.session, + urlIds: {price_rule_id: this.price_rule_id}, + params: {...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public code: string | null; + public created_at: string | null; + public id: number | null; + public price_rule_id: number | null; + public updated_at: string | null; + public usage_count: number | null; +} diff --git a/src/rest-resources/2021-04/dispute.ts b/src/rest-resources/2021-04/dispute.ts new file mode 100644 index 000000000..5976e5ecd --- /dev/null +++ b/src/rest-resources/2021-04/dispute.ts @@ -0,0 +1,78 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Currency} from './currency'; + +interface FindArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + since_id?: unknown; + last_id?: unknown; + status?: unknown; + initiated_at?: unknown; +} + +export class Dispute extends Base { + public static API_VERSION = ApiVersion.April21; + + protected static NAME = 'dispute'; + protected static PLURAL_NAME = 'disputes'; + protected static HAS_ONE: {[key: string]: typeof Base} = { + currency: Currency + }; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "shopify_payments/disputes.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "shopify_payments/disputes/.json"} + ]; + + public static async find( + { + session, + id + }: FindArgs + ): Promise { + const result = await Dispute.baseFind({ + session: session, + urlIds: {id: id}, + params: {}, + }); + return result ? result[0] as Dispute : null; + } + + public static async all( + { + session, + since_id = null, + last_id = null, + status = null, + initiated_at = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Dispute.baseFind({ + session: session, + urlIds: {}, + params: {since_id: since_id, last_id: last_id, status: status, initiated_at: initiated_at, ...otherArgs}, + }); + + return response as Dispute[]; + } + + public amount: string | null; + public currency: Currency | null | {[key: string]: any}; + public evidence_due_by: string | null; + public evidence_sent_on: string | null; + public finalized_on: string | null; + public id: number | null; + public network_reason_code: number | null; + public order_id: number | null; + public reason: string | null; + public status: string | null; + public type: string | null; +} diff --git a/src/rest-resources/2021-04/draft_order.ts b/src/rest-resources/2021-04/draft_order.ts new file mode 100644 index 000000000..e941e0452 --- /dev/null +++ b/src/rest-resources/2021-04/draft_order.ts @@ -0,0 +1,210 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Customer} from './customer'; +import {Currency} from './currency'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + fields?: unknown; + limit?: unknown; + since_id?: unknown; + updated_at_min?: unknown; + updated_at_max?: unknown; + ids?: unknown; + status?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; + since_id?: unknown; + status?: unknown; + updated_at_max?: unknown; + updated_at_min?: unknown; +} +interface SendInvoiceArgs { + [key: string]: unknown; + body?: {[key: string]: unknown} | null; +} +interface CompleteArgs { + [key: string]: unknown; + payment_pending?: unknown; + body?: {[key: string]: unknown} | null; +} + +export class DraftOrder extends Base { + public static API_VERSION = ApiVersion.April21; + + protected static NAME = 'draft_order'; + protected static PLURAL_NAME = 'draft_orders'; + protected static HAS_ONE: {[key: string]: typeof Base} = { + customer: Customer, + currency: Currency + }; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "post", operation: "post", ids: [], path: "draft_orders.json"}, + {http_method: "get", operation: "get", ids: [], path: "draft_orders.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "draft_orders/.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "draft_orders/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "draft_orders/.json"}, + {http_method: "get", operation: "count", ids: [], path: "draft_orders/count.json"}, + {http_method: "post", operation: "send_invoice", ids: ["id"], path: "draft_orders//send_invoice.json"}, + {http_method: "put", operation: "complete", ids: ["id"], path: "draft_orders//complete.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await DraftOrder.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as DraftOrder : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await DraftOrder.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + fields = null, + limit = null, + since_id = null, + updated_at_min = null, + updated_at_max = null, + ids = null, + status = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await DraftOrder.baseFind({ + session: session, + urlIds: {}, + params: {fields: fields, limit: limit, since_id: since_id, updated_at_min: updated_at_min, updated_at_max: updated_at_max, ids: ids, status: status, ...otherArgs}, + }); + + return response as DraftOrder[]; + } + + public static async count( + { + session, + since_id = null, + status = null, + updated_at_max = null, + updated_at_min = null, + ...otherArgs + }: CountArgs + ): Promise { + const response = await DraftOrder.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {}, + params: {since_id: since_id, status: status, updated_at_max: updated_at_max, updated_at_min: updated_at_min, ...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public async send_invoice( + { + body = null, + ...otherArgs + }: SendInvoiceArgs + ): Promise { + const response = await DraftOrder.request({ + http_method: "post", + operation: "send_invoice", + session: this.session, + urlIds: {id: this.id}, + params: {...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public async complete( + { + payment_pending = null, + body = null, + ...otherArgs + }: CompleteArgs + ): Promise { + const response = await DraftOrder.request({ + http_method: "put", + operation: "complete", + session: this.session, + urlIds: {id: this.id}, + params: {payment_pending: payment_pending, ...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public applied_discount: {[key: string]: unknown} | null; + public billing_address: {[key: string]: unknown} | null; + public completed_at: string | null; + public created_at: string | null; + public currency: Currency | null | {[key: string]: any}; + public customer: Customer | null | {[key: string]: any}; + public email: string | null; + public id: number | null; + public invoice_sent_at: string | null; + public invoice_url: string | null; + public line_items: {[key: string]: unknown}[] | null; + public name: string | null; + public note: string | null; + public note_attributes: {[key: string]: unknown}[] | null; + public order_id: number | null; + public shipping_address: {[key: string]: unknown} | null; + public shipping_line: {[key: string]: unknown} | null; + public status: string | null; + public subtotal_price: number | null; + public tags: string | null; + public tax_exempt: boolean | null; + public tax_exemptions: string[] | null; + public tax_lines: {[key: string]: unknown}[] | null; + public taxes_included: boolean | null; + public total_price: string | null; + public total_tax: string | null; + public updated_at: string | null; +} diff --git a/src/rest-resources/2021-04/event.ts b/src/rest-resources/2021-04/event.ts new file mode 100644 index 000000000..2751e4854 --- /dev/null +++ b/src/rest-resources/2021-04/event.ts @@ -0,0 +1,115 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + order_id?: number | string | null; + product_id?: number | string | null; + limit?: unknown; + since_id?: unknown; + created_at_min?: unknown; + created_at_max?: unknown; + filter?: unknown; + verb?: unknown; + fields?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; + created_at_min?: unknown; + created_at_max?: unknown; +} + +export class Event extends Base { + public static API_VERSION = ApiVersion.April21; + + protected static NAME = 'event'; + protected static PLURAL_NAME = 'events'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "events.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "events/.json"}, + {http_method: "get", operation: "count", ids: [], path: "events/count.json"}, + {http_method: "get", operation: "get", ids: ["order_id"], path: "orders//events.json"}, + {http_method: "get", operation: "get", ids: ["product_id"], path: "products//events.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await Event.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as Event : null; + } + + public static async all( + { + session, + order_id = null, + product_id = null, + limit = null, + since_id = null, + created_at_min = null, + created_at_max = null, + filter = null, + verb = null, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Event.baseFind({ + session: session, + urlIds: {order_id: order_id, product_id: product_id}, + params: {limit: limit, since_id: since_id, created_at_min: created_at_min, created_at_max: created_at_max, filter: filter, verb: verb, fields: fields, ...otherArgs}, + }); + + return response as Event[]; + } + + public static async count( + { + session, + created_at_min = null, + created_at_max = null, + ...otherArgs + }: CountArgs + ): Promise { + const response = await Event.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {}, + params: {created_at_min: created_at_min, created_at_max: created_at_max, ...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public arguments: string | null; + public body: string | null; + public created_at: string | null; + public description: string | null; + public id: number | null; + public message: string | null; + public path: string | null; + public subject_id: number | null; + public subject_type: string | null; + public verb: string | null; +} diff --git a/src/rest-resources/2021-04/fulfillment.ts b/src/rest-resources/2021-04/fulfillment.ts new file mode 100644 index 000000000..13018c52b --- /dev/null +++ b/src/rest-resources/2021-04/fulfillment.ts @@ -0,0 +1,228 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + order_id?: number | string | null; + fields?: unknown; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + order_id?: number | string | null; + fulfillment_order_id?: number | string | null; + created_at_max?: unknown; + created_at_min?: unknown; + fields?: unknown; + limit?: unknown; + since_id?: unknown; + updated_at_max?: unknown; + updated_at_min?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; + order_id?: number | string | null; + created_at_min?: unknown; + created_at_max?: unknown; + updated_at_min?: unknown; + updated_at_max?: unknown; +} +interface UpdateTrackingArgs { + [key: string]: unknown; + body?: {[key: string]: unknown} | null; +} +interface CompleteArgs { + [key: string]: unknown; + body?: {[key: string]: unknown} | null; +} +interface OpenArgs { + [key: string]: unknown; + body?: {[key: string]: unknown} | null; +} +interface CancelArgs { + [key: string]: unknown; + body?: {[key: string]: unknown} | null; +} + +export class Fulfillment extends Base { + public static API_VERSION = ApiVersion.April21; + + protected static NAME = 'fulfillment'; + protected static PLURAL_NAME = 'fulfillments'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: ["order_id"], path: "orders//fulfillments.json"}, + {http_method: "post", operation: "post", ids: ["order_id"], path: "orders//fulfillments.json"}, + {http_method: "get", operation: "get", ids: ["fulfillment_order_id"], path: "fulfillment_orders//fulfillments.json"}, + {http_method: "get", operation: "count", ids: ["order_id"], path: "orders//fulfillments/count.json"}, + {http_method: "get", operation: "get", ids: ["order_id", "id"], path: "orders//fulfillments/.json"}, + {http_method: "put", operation: "put", ids: ["order_id", "id"], path: "orders//fulfillments/.json"}, + {http_method: "post", operation: "post", ids: [], path: "fulfillments.json"}, + {http_method: "post", operation: "update_tracking", ids: ["id"], path: "fulfillments//update_tracking.json"}, + {http_method: "post", operation: "complete", ids: ["order_id", "id"], path: "orders//fulfillments//complete.json"}, + {http_method: "post", operation: "open", ids: ["order_id", "id"], path: "orders//fulfillments//open.json"}, + {http_method: "post", operation: "cancel", ids: ["order_id", "id"], path: "orders//fulfillments//cancel.json"}, + {http_method: "post", operation: "cancel", ids: ["id"], path: "fulfillments//cancel.json"} + ]; + + public static async find( + { + session, + id, + order_id = null, + fields = null + }: FindArgs + ): Promise { + const result = await Fulfillment.baseFind({ + session: session, + urlIds: {id: id, order_id: order_id}, + params: {fields: fields}, + }); + return result ? result[0] as Fulfillment : null; + } + + public static async all( + { + session, + order_id = null, + fulfillment_order_id = null, + created_at_max = null, + created_at_min = null, + fields = null, + limit = null, + since_id = null, + updated_at_max = null, + updated_at_min = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Fulfillment.baseFind({ + session: session, + urlIds: {order_id: order_id, fulfillment_order_id: fulfillment_order_id}, + params: {created_at_max: created_at_max, created_at_min: created_at_min, fields: fields, limit: limit, since_id: since_id, updated_at_max: updated_at_max, updated_at_min: updated_at_min, ...otherArgs}, + }); + + return response as Fulfillment[]; + } + + public static async count( + { + session, + order_id = null, + created_at_min = null, + created_at_max = null, + updated_at_min = null, + updated_at_max = null, + ...otherArgs + }: CountArgs + ): Promise { + const response = await Fulfillment.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {order_id: order_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, ...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public async update_tracking( + { + body = null, + ...otherArgs + }: UpdateTrackingArgs + ): Promise { + const response = await Fulfillment.request({ + http_method: "post", + operation: "update_tracking", + session: this.session, + urlIds: {id: this.id}, + params: {...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public async complete( + { + body = null, + ...otherArgs + }: CompleteArgs + ): Promise { + const response = await Fulfillment.request({ + http_method: "post", + operation: "complete", + session: this.session, + urlIds: {id: this.id, order_id: this.order_id}, + params: {...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public async open( + { + body = null, + ...otherArgs + }: OpenArgs + ): Promise { + const response = await Fulfillment.request({ + http_method: "post", + operation: "open", + session: this.session, + urlIds: {id: this.id, order_id: this.order_id}, + params: {...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public async cancel( + { + body = null, + ...otherArgs + }: CancelArgs + ): Promise { + const response = await Fulfillment.request({ + http_method: "post", + operation: "cancel", + session: this.session, + urlIds: {id: this.id, order_id: this.order_id}, + params: {...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public created_at: string | null; + public id: number | null; + public line_items: {[key: string]: unknown}[] | null; + public location_id: number | null; + public name: string | null; + public notify_customer: boolean | null; + public order_id: number | null; + public receipt: {[key: string]: unknown} | null; + public service: string | null; + public shipment_status: string | null; + public status: string | null; + public tracking_company: string | null; + public tracking_numbers: string[] | null; + public tracking_urls: string[] | null; + public updated_at: string | null; + public variant_inventory_management: string | null; +} diff --git a/src/rest-resources/2021-04/fulfillment_event.ts b/src/rest-resources/2021-04/fulfillment_event.ts new file mode 100644 index 000000000..12d952fd5 --- /dev/null +++ b/src/rest-resources/2021-04/fulfillment_event.ts @@ -0,0 +1,120 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Country} from './country'; +import {Province} from './province'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + order_id?: number | string | null; + fulfillment_id?: number | string | null; + event_id?: unknown; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; + order_id?: number | string | null; + fulfillment_id?: number | string | null; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + order_id?: number | string | null; + fulfillment_id?: number | string | null; +} + +export class FulfillmentEvent extends Base { + public static API_VERSION = ApiVersion.April21; + + protected static NAME = 'fulfillment_event'; + protected static PLURAL_NAME = 'fulfillment_events'; + protected static HAS_ONE: {[key: string]: typeof Base} = { + country: Country, + province: Province + }; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: ["order_id", "fulfillment_id"], path: "orders//fulfillments//events.json"}, + {http_method: "post", operation: "post", ids: ["order_id", "fulfillment_id"], path: "orders//fulfillments//events.json"}, + {http_method: "get", operation: "get", ids: ["order_id", "fulfillment_id", "id"], path: "orders//fulfillments//events/.json"}, + {http_method: "delete", operation: "delete", ids: ["order_id", "fulfillment_id", "id"], path: "orders//fulfillments//events/.json"} + ]; + + protected static getJsonBodyName(): string + { + return "event"; + } + + public static async find( + { + session, + id, + order_id = null, + fulfillment_id = null, + event_id = null + }: FindArgs + ): Promise { + const result = await FulfillmentEvent.baseFind({ + session: session, + urlIds: {id: id, order_id: order_id, fulfillment_id: fulfillment_id}, + params: {event_id: event_id}, + }); + return result ? result[0] as FulfillmentEvent : null; + } + + public static async delete( + { + session, + id, + order_id = null, + fulfillment_id = null + }: DeleteArgs + ): Promise { + const response = await FulfillmentEvent.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id, order_id: order_id, fulfillment_id: fulfillment_id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + order_id = null, + fulfillment_id = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await FulfillmentEvent.baseFind({ + session: session, + urlIds: {order_id: order_id, fulfillment_id: fulfillment_id}, + params: {...otherArgs}, + }); + + return response as FulfillmentEvent[]; + } + + public address1: string | null; + public city: string | null; + public country: Country | null | {[key: string]: any}; + public created_at: string | null; + public estimated_delivery_at: string | null; + public fulfillment_id: number | null; + public happened_at: string | null; + public id: number | null; + public latitude: number | null; + public longitude: number | null; + public message: string | null; + public order_id: number | null; + public province: Province | null | {[key: string]: any}; + public shop_id: number | null; + public status: string | null; + public updated_at: string | null; + public zip: string | null; +} diff --git a/src/rest-resources/2021-04/fulfillment_order.ts b/src/rest-resources/2021-04/fulfillment_order.ts new file mode 100644 index 000000000..3eb035dfc --- /dev/null +++ b/src/rest-resources/2021-04/fulfillment_order.ts @@ -0,0 +1,194 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + order_id?: number | string | null; +} +interface CancelArgs { + [key: string]: unknown; + body?: {[key: string]: unknown} | null; +} +interface CloseArgs { + [key: string]: unknown; + message?: unknown; + body?: {[key: string]: unknown} | null; +} +interface MoveArgs { + [key: string]: unknown; + new_location_id?: unknown; + body?: {[key: string]: unknown} | null; +} +interface OpenArgs { + [key: string]: unknown; + body?: {[key: string]: unknown} | null; +} +interface RescheduleArgs { + [key: string]: unknown; + body?: {[key: string]: unknown} | null; +} + +export class FulfillmentOrder extends Base { + public static API_VERSION = ApiVersion.April21; + + protected static NAME = 'fulfillment_order'; + protected static PLURAL_NAME = 'fulfillment_orders'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: ["order_id"], path: "orders//fulfillment_orders.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "fulfillment_orders/.json"}, + {http_method: "post", operation: "cancel", ids: ["id"], path: "fulfillment_orders//cancel.json"}, + {http_method: "post", operation: "close", ids: ["id"], path: "fulfillment_orders//close.json"}, + {http_method: "post", operation: "move", ids: ["id"], path: "fulfillment_orders//move.json"}, + {http_method: "post", operation: "open", ids: ["id"], path: "fulfillment_orders//open.json"}, + {http_method: "post", operation: "reschedule", ids: ["id"], path: "fulfillment_orders//reschedule.json"} + ]; + + public static async find( + { + session, + id + }: FindArgs + ): Promise { + const result = await FulfillmentOrder.baseFind({ + session: session, + urlIds: {id: id}, + params: {}, + }); + return result ? result[0] as FulfillmentOrder : null; + } + + public static async all( + { + session, + order_id = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await FulfillmentOrder.baseFind({ + session: session, + urlIds: {order_id: order_id}, + params: {...otherArgs}, + }); + + return response as FulfillmentOrder[]; + } + + public async cancel( + { + body = null, + ...otherArgs + }: CancelArgs + ): Promise { + const response = await FulfillmentOrder.request({ + http_method: "post", + operation: "cancel", + session: this.session, + urlIds: {id: this.id}, + params: {...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public async close( + { + message = null, + body = null, + ...otherArgs + }: CloseArgs + ): Promise { + const response = await FulfillmentOrder.request({ + http_method: "post", + operation: "close", + session: this.session, + urlIds: {id: this.id}, + params: {message: message, ...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public async move( + { + new_location_id = null, + body = null, + ...otherArgs + }: MoveArgs + ): Promise { + const response = await FulfillmentOrder.request({ + http_method: "post", + operation: "move", + session: this.session, + urlIds: {id: this.id}, + params: {new_location_id: new_location_id, ...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public async open( + { + body = null, + ...otherArgs + }: OpenArgs + ): Promise { + const response = await FulfillmentOrder.request({ + http_method: "post", + operation: "open", + session: this.session, + urlIds: {id: this.id}, + params: {...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public async reschedule( + { + body = null, + ...otherArgs + }: RescheduleArgs + ): Promise { + const response = await FulfillmentOrder.request({ + http_method: "post", + operation: "reschedule", + session: this.session, + urlIds: {id: this.id}, + params: {...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public assigned_location: {[key: string]: unknown} | null; + public assigned_location_id: number | null; + public delivery_method: {[key: string]: unknown} | null; + public destination: {[key: string]: unknown} | null; + public fulfill_at: string | null; + public id: number | null; + public line_items: {[key: string]: unknown}[] | null; + public merchant_requests: {[key: string]: unknown}[] | null; + public order_id: number | null; + public request_status: string | null; + public shop_id: number | null; + public status: string | null; + public supported_actions: string[] | null; +} diff --git a/src/rest-resources/2021-04/fulfillment_request.ts b/src/rest-resources/2021-04/fulfillment_request.ts new file mode 100644 index 000000000..993719fad --- /dev/null +++ b/src/rest-resources/2021-04/fulfillment_request.ts @@ -0,0 +1,69 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {ApiVersion} from '../../base-types'; + +interface AcceptArgs { + [key: string]: unknown; + message?: unknown; + body?: {[key: string]: unknown} | null; +} +interface RejectArgs { + [key: string]: unknown; + message?: unknown; + body?: {[key: string]: unknown} | null; +} + +export class FulfillmentRequest extends Base { + public static API_VERSION = ApiVersion.April21; + + protected static NAME = 'fulfillment_request'; + protected static PLURAL_NAME = 'fulfillment_requests'; + 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_request.json"}, + {http_method: "post", operation: "accept", ids: ["fulfillment_order_id"], path: "fulfillment_orders//fulfillment_request/accept.json"}, + {http_method: "post", operation: "reject", ids: ["fulfillment_order_id"], path: "fulfillment_orders//fulfillment_request/reject.json"} + ]; + + public async accept( + { + message = null, + body = null, + ...otherArgs + }: AcceptArgs + ): Promise { + const response = await FulfillmentRequest.request({ + http_method: "post", + operation: "accept", + session: this.session, + urlIds: {fulfillment_order_id: this.fulfillment_order_id}, + params: {message: message, ...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public async reject( + { + message = null, + body = null, + ...otherArgs + }: RejectArgs + ): Promise { + const response = await FulfillmentRequest.request({ + http_method: "post", + operation: "reject", + session: this.session, + urlIds: {fulfillment_order_id: this.fulfillment_order_id}, + params: {message: message, ...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public fulfillment_order_id: number | null; +} diff --git a/src/rest-resources/2021-04/fulfillment_service.ts b/src/rest-resources/2021-04/fulfillment_service.ts new file mode 100644 index 000000000..bac300595 --- /dev/null +++ b/src/rest-resources/2021-04/fulfillment_service.ts @@ -0,0 +1,93 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + scope?: unknown; +} + +export class FulfillmentService extends Base { + public static API_VERSION = ApiVersion.April21; + + protected static NAME = 'fulfillment_service'; + protected static PLURAL_NAME = 'fulfillment_services'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "fulfillment_services.json"}, + {http_method: "post", operation: "post", ids: [], path: "fulfillment_services.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "fulfillment_services/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "fulfillment_services/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "fulfillment_services/.json"} + ]; + + public static async find( + { + session, + id + }: FindArgs + ): Promise { + const result = await FulfillmentService.baseFind({ + session: session, + urlIds: {id: id}, + params: {}, + }); + return result ? result[0] as FulfillmentService : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await FulfillmentService.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + scope = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await FulfillmentService.baseFind({ + session: session, + urlIds: {}, + params: {scope: scope, ...otherArgs}, + }); + + return response as FulfillmentService[]; + } + + public admin_graphql_api_id: string | null; + public callback_url: string | null; + public format: string | null; + public fulfillment_orders_opt_in: boolean | null; + public handle: string | null; + public id: number | null; + public inventory_management: boolean | null; + public location_id: number | null; + public name: string | null; + public provider_id: string | null; + public requires_shipping_method: boolean | null; + public tracking_support: boolean | null; +} diff --git a/src/rest-resources/2021-04/gift_card.ts b/src/rest-resources/2021-04/gift_card.ts new file mode 100644 index 000000000..38f818bbf --- /dev/null +++ b/src/rest-resources/2021-04/gift_card.ts @@ -0,0 +1,170 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Balance} from './balance'; +import {Currency} from './currency'; + +interface FindArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + status?: unknown; + limit?: unknown; + since_id?: unknown; + fields?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; + status?: unknown; +} +interface SearchArgs { + [key: string]: unknown; + session: SessionInterface; + order?: unknown; + query?: unknown; + limit?: unknown; + fields?: unknown; +} +interface DisableArgs { + [key: string]: unknown; + body?: {[key: string]: unknown} | null; +} + +export class GiftCard extends Base { + public static API_VERSION = ApiVersion.April21; + + protected static NAME = 'gift_card'; + protected static PLURAL_NAME = 'gift_cards'; + protected static HAS_ONE: {[key: string]: typeof Base} = { + balance: Balance, + currency: Currency + }; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "gift_cards.json"}, + {http_method: "post", operation: "post", ids: [], path: "gift_cards.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "gift_cards/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "gift_cards/.json"}, + {http_method: "get", operation: "count", ids: [], path: "gift_cards/count.json"}, + {http_method: "post", operation: "disable", ids: ["id"], path: "gift_cards//disable.json"}, + {http_method: "get", operation: "search", ids: [], path: "gift_cards/search.json"} + ]; + + public static async find( + { + session, + id + }: FindArgs + ): Promise { + const result = await GiftCard.baseFind({ + session: session, + urlIds: {id: id}, + params: {}, + }); + return result ? result[0] as GiftCard : null; + } + + public static async all( + { + session, + status = null, + limit = null, + since_id = null, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await GiftCard.baseFind({ + session: session, + urlIds: {}, + params: {status: status, limit: limit, since_id: since_id, fields: fields, ...otherArgs}, + }); + + return response as GiftCard[]; + } + + public static async count( + { + session, + status = null, + ...otherArgs + }: CountArgs + ): Promise { + const response = await GiftCard.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {}, + params: {status: status, ...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public static async search( + { + session, + order = null, + query = null, + limit = null, + fields = null, + ...otherArgs + }: SearchArgs + ): Promise { + const response = await GiftCard.request({ + http_method: "get", + operation: "search", + session: session, + urlIds: {}, + params: {order: order, query: query, limit: limit, fields: fields, ...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public async disable( + { + body = null, + ...otherArgs + }: DisableArgs + ): Promise { + const response = await GiftCard.request({ + http_method: "post", + operation: "disable", + session: this.session, + urlIds: {id: this.id}, + params: {...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public api_client_id: number | null; + public balance: Balance | null | {[key: string]: any}; + public code: string | null; + public created_at: string | null; + public currency: Currency | null | {[key: string]: any}; + public customer_id: number | null; + public disabled_at: string | null; + public expires_on: string | null; + public id: number | null; + public initial_value: number | null; + public last_characters: string | null; + public line_item_id: number | null; + public note: string | null; + public order_id: number | null; + public template_suffix: string | null; + public updated_at: string | null; + public user_id: number | null; +} diff --git a/src/rest-resources/2021-04/gift_card_adjustment.ts b/src/rest-resources/2021-04/gift_card_adjustment.ts new file mode 100644 index 000000000..06cb747ca --- /dev/null +++ b/src/rest-resources/2021-04/gift_card_adjustment.ts @@ -0,0 +1,77 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + gift_card_id?: number | string | null; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + gift_card_id?: number | string | null; +} + +export class GiftCardAdjustment extends Base { + public static API_VERSION = ApiVersion.April21; + + protected static NAME = 'gift_card_adjustment'; + protected static PLURAL_NAME = 'gift_card_adjustments'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: ["gift_card_id"], path: "gift_cards//adjustments.json"}, + {http_method: "post", operation: "post", ids: ["gift_card_id"], path: "gift_cards//adjustments.json"}, + {http_method: "get", operation: "get", ids: ["gift_card_id", "id"], path: "gift_cards//adjustments/9.json"} + ]; + + protected static getJsonBodyName(): string + { + return "adjustment"; + } + + public static async find( + { + session, + id, + gift_card_id = null + }: FindArgs + ): Promise { + const result = await GiftCardAdjustment.baseFind({ + session: session, + urlIds: {id: id, gift_card_id: gift_card_id}, + params: {}, + }); + return result ? result[0] as GiftCardAdjustment : null; + } + + public static async all( + { + session, + gift_card_id = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await GiftCardAdjustment.baseFind({ + session: session, + urlIds: {gift_card_id: gift_card_id}, + params: {...otherArgs}, + }); + + return response as GiftCardAdjustment[]; + } + + public amount: number | null; + public api_client_id: number | null; + public created_at: string | null; + public gift_card_id: number | null; + public id: number | null; + public note: string | null; + public number: number | null; + public order_transaction_id: number | null; + public processed_at: string | null; + public remote_transaction_ref: string | null; + public remote_transaction_url: string | null; + public user_id: number | null; +} diff --git a/src/rest-resources/2021-04/image.ts b/src/rest-resources/2021-04/image.ts new file mode 100644 index 000000000..0177edc4f --- /dev/null +++ b/src/rest-resources/2021-04/image.ts @@ -0,0 +1,128 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + product_id?: number | string | null; + fields?: unknown; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; + product_id?: number | string | null; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + product_id?: number | string | null; + since_id?: unknown; + fields?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; + product_id?: number | string | null; + since_id?: unknown; +} + +export class Image extends Base { + public static API_VERSION = ApiVersion.April21; + + protected static NAME = 'image'; + protected static PLURAL_NAME = 'images'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: ["product_id"], path: "products//images.json"}, + {http_method: "post", operation: "post", ids: ["product_id"], path: "products//images.json"}, + {http_method: "get", operation: "count", ids: ["product_id"], path: "products//images/count.json"}, + {http_method: "get", operation: "get", ids: ["product_id", "id"], path: "products//images/.json"}, + {http_method: "put", operation: "put", ids: ["product_id", "id"], path: "products//images/.json"}, + {http_method: "delete", operation: "delete", ids: ["product_id", "id"], path: "products//images/.json"} + ]; + + public static async find( + { + session, + id, + product_id = null, + fields = null + }: FindArgs + ): Promise { + const result = await Image.baseFind({ + session: session, + urlIds: {id: id, product_id: product_id}, + params: {fields: fields}, + }); + return result ? result[0] as Image : null; + } + + public static async delete( + { + session, + id, + product_id = null + }: DeleteArgs + ): Promise { + const response = await Image.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id, product_id: product_id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + product_id = null, + since_id = null, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Image.baseFind({ + session: session, + urlIds: {product_id: product_id}, + params: {since_id: since_id, fields: fields, ...otherArgs}, + }); + + return response as Image[]; + } + + public static async count( + { + session, + product_id = null, + since_id = null, + ...otherArgs + }: CountArgs + ): Promise { + const response = await Image.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {product_id: product_id}, + params: {since_id: since_id, ...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public created_at: string | null; + public height: number | null; + public id: number | null; + public position: number | null; + public product_id: number | null; + public src: string | null; + public updated_at: string | null; + public variant_ids: number[] | null; + public width: number | null; +} diff --git a/src/rest-resources/2021-04/index.ts b/src/rest-resources/2021-04/index.ts new file mode 100644 index 000000000..ed825721a --- /dev/null +++ b/src/rest-resources/2021-04/index.ts @@ -0,0 +1,74 @@ +export {AbandonedCheckout} from './abandoned_checkout'; +export {AccessScope} from './access_scope'; +export {AndroidPayKey} from './android_pay_key'; +export {ApplePayCertificate} from './apple_pay_certificate'; +export {ApplicationCharge} from './application_charge'; +export {ApplicationCredit} from './application_credit'; +export {Article} from './article'; +export {Asset} from './asset'; +export {AssignedFulfillmentOrder} from './assigned_fulfillment_order'; +export {Balance} from './balance'; +export {Blog} from './blog'; +export {CancellationRequest} from './cancellation_request'; +export {CarrierService} from './carrier_service'; +export {Checkout} from './checkout'; +export {Collect} from './collect'; +export {Collection} from './collection'; +export {CollectionListing} from './collection_listing'; +export {Comment} from './comment'; +export {Country} from './country'; +export {Currency} from './currency'; +export {CustomCollection} from './custom_collection'; +export {Customer} from './customer'; +export {CustomerAddress} from './customer_address'; +export {CustomerSavedSearch} from './customer_saved_search'; +export {DeprecatedApiCall} from './deprecated_api_call'; +export {DiscountCode} from './discount_code'; +export {Dispute} from './dispute'; +export {DraftOrder} from './draft_order'; +export {Event} from './event'; +export {Fulfillment} from './fulfillment'; +export {FulfillmentEvent} from './fulfillment_event'; +export {FulfillmentOrder} from './fulfillment_order'; +export {FulfillmentRequest} from './fulfillment_request'; +export {FulfillmentService} from './fulfillment_service'; +export {GiftCard} from './gift_card'; +export {GiftCardAdjustment} from './gift_card_adjustment'; +export {Image} from './image'; +export {InventoryItem} from './inventory_item'; +export {InventoryLevel} from './inventory_level'; +export {Location} from './location'; +export {LocationsForMove} from './locations_for_move'; +export {MarketingEvent} from './marketing_event'; +export {Metafield} from './metafield'; +export {MobilePlatformApplication} from './mobile_platform_application'; +export {Order} from './order'; +export {OrderRisk} from './order_risk'; +export {Page} from './page'; +export {Payment} from './payment'; +export {PaymentGateway} from './payment_gateway'; +export {PaymentTransaction} from './payment_transaction'; +export {Payout} from './payout'; +export {Policy} from './policy'; +export {PriceRule} from './price_rule'; +export {Product} from './product'; +export {ProductListing} from './product_listing'; +export {ProductResourceFeedback} from './product_resource_feedback'; +export {Province} from './province'; +export {RecurringApplicationCharge} from './recurring_application_charge'; +export {Redirect} from './redirect'; +export {Refund} from './refund'; +export {Report} from './report'; +export {ResourceFeedback} from './resource_feedback'; +export {ScriptTag} from './script_tag'; +export {ShippingZone} from './shipping_zone'; +export {Shop} from './shop'; +export {SmartCollection} from './smart_collection'; +export {StorefrontAccessToken} from './storefront_access_token'; +export {TenderTransaction} from './tender_transaction'; +export {Theme} from './theme'; +export {Transaction} from './transaction'; +export {UsageCharge} from './usage_charge'; +export {User} from './user'; +export {Variant} from './variant'; +export {Webhook} from './webhook'; \ No newline at end of file diff --git a/src/rest-resources/2021-04/inventory_item.ts b/src/rest-resources/2021-04/inventory_item.ts new file mode 100644 index 000000000..a9268b732 --- /dev/null +++ b/src/rest-resources/2021-04/inventory_item.ts @@ -0,0 +1,71 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + ids?: unknown; + limit?: unknown; +} + +export class InventoryItem extends Base { + public static API_VERSION = ApiVersion.April21; + + protected static NAME = 'inventory_item'; + protected static PLURAL_NAME = 'inventory_items'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "inventory_items.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "inventory_items/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "inventory_items/.json"} + ]; + + public static async find( + { + session, + id + }: FindArgs + ): Promise { + const result = await InventoryItem.baseFind({ + session: session, + urlIds: {id: id}, + params: {}, + }); + return result ? result[0] as InventoryItem : null; + } + + public static async all( + { + session, + ids = null, + limit = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await InventoryItem.baseFind({ + session: session, + urlIds: {}, + params: {ids: ids, limit: limit, ...otherArgs}, + }); + + return response as InventoryItem[]; + } + + public cost: string | null; + public country_code_of_origin: string | null; + public country_harmonized_system_codes: {[key: string]: unknown}[] | null; + public created_at: string | null; + public harmonized_system_code: number | null; + public id: number | null; + public province_code_of_origin: string | null; + public requires_shipping: boolean | null; + public sku: string | null; + public tracked: boolean | null; + public updated_at: string | null; +} diff --git a/src/rest-resources/2021-04/inventory_level.ts b/src/rest-resources/2021-04/inventory_level.ts new file mode 100644 index 000000000..ffb244d34 --- /dev/null +++ b/src/rest-resources/2021-04/inventory_level.ts @@ -0,0 +1,164 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface DeleteArgs { + session: SessionInterface; + inventory_item_id?: unknown; + location_id?: unknown; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + inventory_item_ids?: unknown; + location_ids?: unknown; + limit?: unknown; + updated_at_min?: unknown; +} +interface AdjustArgs { + [key: string]: unknown; + inventory_item_id?: unknown; + location_id?: unknown; + available_adjustment?: unknown; + body?: {[key: string]: unknown} | null; +} +interface ConnectArgs { + [key: string]: unknown; + inventory_item_id?: unknown; + location_id?: unknown; + relocate_if_necessary?: unknown; + body?: {[key: string]: unknown} | null; +} +interface SetArgs { + [key: string]: unknown; + inventory_item_id?: unknown; + location_id?: unknown; + available?: unknown; + disconnect_if_necessary?: unknown; + body?: {[key: string]: unknown} | null; +} + +export class InventoryLevel extends Base { + public static API_VERSION = ApiVersion.April21; + + protected static NAME = 'inventory_level'; + protected static PLURAL_NAME = 'inventory_levels'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "inventory_levels.json"}, + {http_method: "post", operation: "adjust", ids: [], path: "inventory_levels/adjust.json"}, + {http_method: "delete", operation: "delete", ids: [], path: "inventory_levels.json"}, + {http_method: "post", operation: "connect", ids: [], path: "inventory_levels/connect.json"}, + {http_method: "post", operation: "set", ids: [], path: "inventory_levels/set.json"} + ]; + + public static async delete( + { + session, + inventory_item_id = null, + location_id = null + }: DeleteArgs + ): Promise { + const response = await InventoryLevel.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {}, + params: {inventory_item_id: inventory_item_id, location_id: location_id}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + inventory_item_ids = null, + location_ids = null, + limit = null, + updated_at_min = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await InventoryLevel.baseFind({ + session: session, + urlIds: {}, + params: {inventory_item_ids: inventory_item_ids, location_ids: location_ids, limit: limit, updated_at_min: updated_at_min, ...otherArgs}, + }); + + return response as InventoryLevel[]; + } + + public async adjust( + { + inventory_item_id = null, + location_id = null, + available_adjustment = null, + body = null, + ...otherArgs + }: AdjustArgs + ): Promise { + const response = await InventoryLevel.request({ + http_method: "post", + operation: "adjust", + session: this.session, + urlIds: {}, + params: {inventory_item_id: inventory_item_id, location_id: location_id, available_adjustment: available_adjustment, ...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public async connect( + { + inventory_item_id = null, + location_id = null, + relocate_if_necessary = null, + body = null, + ...otherArgs + }: ConnectArgs + ): Promise { + const response = await InventoryLevel.request({ + http_method: "post", + operation: "connect", + session: this.session, + urlIds: {}, + params: {inventory_item_id: inventory_item_id, location_id: location_id, relocate_if_necessary: relocate_if_necessary, ...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public async set( + { + inventory_item_id = null, + location_id = null, + available = null, + disconnect_if_necessary = null, + body = null, + ...otherArgs + }: SetArgs + ): Promise { + const response = await InventoryLevel.request({ + http_method: "post", + operation: "set", + session: this.session, + urlIds: {}, + params: {inventory_item_id: inventory_item_id, location_id: location_id, available: available, disconnect_if_necessary: disconnect_if_necessary, ...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public available: number | null; + public inventory_item_id: number | null; + public location_id: number | null; + public updated_at: string | null; +} diff --git a/src/rest-resources/2021-04/location.ts b/src/rest-resources/2021-04/location.ts new file mode 100644 index 000000000..1e28ba95b --- /dev/null +++ b/src/rest-resources/2021-04/location.ts @@ -0,0 +1,128 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Country} from './country'; +import {Province} from './province'; + +interface FindArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; +} +interface InventoryLevelsArgs { + [key: string]: unknown; + session: SessionInterface; + id: number | string; +} + +export class Location extends Base { + public static API_VERSION = ApiVersion.April21; + + protected static NAME = 'location'; + protected static PLURAL_NAME = 'locations'; + protected static HAS_ONE: {[key: string]: typeof Base} = { + country: Country, + province: Province + }; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "locations.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "locations/.json"}, + {http_method: "get", operation: "count", ids: [], path: "locations/count.json"}, + {http_method: "get", operation: "inventory_levels", ids: ["id"], path: "locations//inventory_levels.json"} + ]; + + public static async find( + { + session, + id + }: FindArgs + ): Promise { + const result = await Location.baseFind({ + session: session, + urlIds: {id: id}, + params: {}, + }); + return result ? result[0] as Location : null; + } + + public static async all( + { + session, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Location.baseFind({ + session: session, + urlIds: {}, + params: {...otherArgs}, + }); + + return response as Location[]; + } + + public static async count( + { + session, + ...otherArgs + }: CountArgs + ): Promise { + const response = await Location.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {}, + params: {...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public static async inventory_levels( + { + session, + id, + ...otherArgs + }: InventoryLevelsArgs + ): Promise { + const response = await Location.request({ + http_method: "get", + operation: "inventory_levels", + session: session, + urlIds: {id: id}, + params: {...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public active: boolean | null; + public address1: string | null; + public address2: string | null; + public city: string | null; + public country: Country | null | {[key: string]: any}; + public country_code: string | null; + public created_at: string | null; + public id: number | null; + public legacy: boolean | null; + public localized_country_name: string | null; + public localized_province_name: string | null; + public name: string | null; + public phone: string | null; + public province: Province | null | {[key: string]: any}; + public province_code: string | null; + public updated_at: string | null; + public zip: string | null; +} diff --git a/src/rest-resources/2021-04/locations_for_move.ts b/src/rest-resources/2021-04/locations_for_move.ts new file mode 100644 index 000000000..b78e821d7 --- /dev/null +++ b/src/rest-resources/2021-04/locations_for_move.ts @@ -0,0 +1,39 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + fulfillment_order_id?: number | string | null; +} + +export class LocationsForMove extends Base { + public static API_VERSION = ApiVersion.April21; + + protected static NAME = 'locations_for_move'; + protected static PLURAL_NAME = 'locations_for_moves'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: ["fulfillment_order_id"], path: "fulfillment_orders//locations_for_move.json"} + ]; + + public static async all( + { + session, + fulfillment_order_id = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await LocationsForMove.baseFind({ + session: session, + urlIds: {fulfillment_order_id: fulfillment_order_id}, + params: {...otherArgs}, + }); + + return response as LocationsForMove[]; + } + + public locations_for_move: {[key: string]: unknown}[] | null; +} diff --git a/src/rest-resources/2021-04/marketing_event.ts b/src/rest-resources/2021-04/marketing_event.ts new file mode 100644 index 000000000..370ef3e9a --- /dev/null +++ b/src/rest-resources/2021-04/marketing_event.ts @@ -0,0 +1,166 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + limit?: unknown; + offset?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; +} +interface EngagementsArgs { + [key: string]: unknown; + occurred_on?: unknown; + impressions_count?: unknown; + views_count?: unknown; + clicks_count?: unknown; + shares_count?: unknown; + favorites_count?: unknown; + comments_count?: unknown; + ad_spend?: unknown; + is_cumulative?: unknown; + body?: {[key: string]: unknown} | null; +} + +export class MarketingEvent extends Base { + public static API_VERSION = ApiVersion.April21; + + protected static NAME = 'marketing_event'; + protected static PLURAL_NAME = 'marketing_events'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "marketing_events.json"}, + {http_method: "post", operation: "post", ids: [], path: "marketing_events.json"}, + {http_method: "get", operation: "count", ids: [], path: "marketing_events/count.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "marketing_events/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "marketing_events/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "marketing_events/.json"}, + {http_method: "post", operation: "engagements", ids: ["id"], path: "marketing_events//engagements.json"} + ]; + + public static async find( + { + session, + id + }: FindArgs + ): Promise { + const result = await MarketingEvent.baseFind({ + session: session, + urlIds: {id: id}, + params: {}, + }); + return result ? result[0] as MarketingEvent : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await MarketingEvent.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + limit = null, + offset = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await MarketingEvent.baseFind({ + session: session, + urlIds: {}, + params: {limit: limit, offset: offset, ...otherArgs}, + }); + + return response as MarketingEvent[]; + } + + public static async count( + { + session, + ...otherArgs + }: CountArgs + ): Promise { + const response = await MarketingEvent.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {}, + params: {...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public async engagements( + { + occurred_on = null, + impressions_count = null, + views_count = null, + clicks_count = null, + shares_count = null, + favorites_count = null, + comments_count = null, + ad_spend = null, + is_cumulative = null, + body = null, + ...otherArgs + }: EngagementsArgs + ): Promise { + const response = await MarketingEvent.request({ + http_method: "post", + operation: "engagements", + session: this.session, + urlIds: {id: this.id}, + params: {occurred_on: occurred_on, impressions_count: impressions_count, views_count: views_count, clicks_count: clicks_count, shares_count: shares_count, favorites_count: favorites_count, comments_count: comments_count, ad_spend: ad_spend, is_cumulative: is_cumulative, ...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public event_type: string | null; + public marketing_channel: string | null; + public paid: boolean | null; + public started_at: string | null; + public UTM_parameters: {[key: string]: unknown} | null; + public budget: string | null; + public budget_type: string | null; + public currency: string | null; + public description: string | null; + public ended_at: string | null; + public id: number | null; + public manage_url: string | null; + public marketed_resources: {[key: string]: unknown}[] | null; + public preview_url: string | null; + public referring_domain: string | null; + public remote_id: string | null; + public scheduled_to_end_at: string | null; +} diff --git a/src/rest-resources/2021-04/metafield.ts b/src/rest-resources/2021-04/metafield.ts new file mode 100644 index 000000000..42f5825d5 --- /dev/null +++ b/src/rest-resources/2021-04/metafield.ts @@ -0,0 +1,138 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + limit?: unknown; + since_id?: unknown; + created_at_min?: unknown; + created_at_max?: unknown; + updated_at_min?: unknown; + updated_at_max?: unknown; + namespace?: unknown; + key?: unknown; + value_type?: unknown; + fields?: unknown; + metafield?: {[key: string]: unknown} | null; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; +} + +export class Metafield extends Base { + public static API_VERSION = ApiVersion.April21; + + protected static NAME = 'metafield'; + protected static PLURAL_NAME = 'metafields'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "metafields.json"}, + {http_method: "post", operation: "post", ids: [], path: "metafields.json"}, + {http_method: "get", operation: "get", ids: [], path: "metafields.json"}, + {http_method: "get", operation: "count", ids: [], path: "metafields/count.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "metafields/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "metafields/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "metafields/.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await Metafield.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as Metafield : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await Metafield.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + limit = null, + since_id = null, + created_at_min = null, + created_at_max = null, + updated_at_min = null, + updated_at_max = null, + namespace = null, + key = null, + value_type = null, + fields = null, + metafield = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Metafield.baseFind({ + session: session, + urlIds: {}, + params: {limit: limit, since_id: since_id, created_at_min: created_at_min, created_at_max: created_at_max, updated_at_min: updated_at_min, updated_at_max: updated_at_max, namespace: namespace, key: key, value_type: value_type, fields: fields, metafield: metafield, ...otherArgs}, + }); + + return response as Metafield[]; + } + + public static async count( + { + session, + ...otherArgs + }: CountArgs + ): Promise { + const response = await Metafield.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {}, + params: {...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public key: string | null; + public namespace: string | null; + public value: string | number | number | null; + public created_at: string | null; + public description: string | null; + public id: number | null; + public owner_id: number | null; + public owner_resource: string | null; + public updated_at: string | null; + public value_type: string | null; +} diff --git a/src/rest-resources/2021-04/mobile_platform_application.ts b/src/rest-resources/2021-04/mobile_platform_application.ts new file mode 100644 index 000000000..006d6308d --- /dev/null +++ b/src/rest-resources/2021-04/mobile_platform_application.ts @@ -0,0 +1,85 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; +} + +export class MobilePlatformApplication extends Base { + public static API_VERSION = ApiVersion.April21; + + protected static NAME = 'mobile_platform_application'; + protected static PLURAL_NAME = 'mobile_platform_applications'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "mobile_platform_applications.json"}, + {http_method: "post", operation: "post", ids: [], path: "mobile_platform_applications.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "mobile_platform_applications/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "mobile_platform_applications/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "mobile_platform_applications/.json"} + ]; + + public static async find( + { + session, + id + }: FindArgs + ): Promise { + const result = await MobilePlatformApplication.baseFind({ + session: session, + urlIds: {id: id}, + params: {}, + }); + return result ? result[0] as MobilePlatformApplication : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await MobilePlatformApplication.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + ...otherArgs + }: AllArgs + ): Promise { + const response = await MobilePlatformApplication.baseFind({ + session: session, + urlIds: {}, + params: {...otherArgs}, + }); + + return response as MobilePlatformApplication[]; + } + + public application_id: string | null; + public enabled_shared_webcredentials: boolean | null; + public enabled_universal_or_app_links: boolean | null; + public id: number | null; + public platform: string | null; + public sha256_cert_fingerprints: string[] | null; +} diff --git a/src/rest-resources/2021-04/order.ts b/src/rest-resources/2021-04/order.ts new file mode 100644 index 000000000..ce4e370b6 --- /dev/null +++ b/src/rest-resources/2021-04/order.ts @@ -0,0 +1,315 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Customer} from './customer'; +import {DiscountCode} from './discount_code'; +import {Fulfillment} from './fulfillment'; +import {Refund} from './refund'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + ids?: unknown; + limit?: unknown; + since_id?: unknown; + created_at_min?: unknown; + created_at_max?: unknown; + updated_at_min?: unknown; + updated_at_max?: unknown; + processed_at_min?: unknown; + processed_at_max?: unknown; + attribution_app_id?: unknown; + status?: unknown; + financial_status?: unknown; + fulfillment_status?: unknown; + fields?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; + created_at_min?: unknown; + created_at_max?: unknown; + updated_at_min?: unknown; + updated_at_max?: unknown; + status?: unknown; + financial_status?: unknown; + fulfillment_status?: unknown; +} +interface CloseArgs { + [key: string]: unknown; + body?: {[key: string]: unknown} | null; +} +interface OpenArgs { + [key: string]: unknown; + body?: {[key: string]: unknown} | null; +} +interface CancelArgs { + [key: string]: unknown; + amount?: unknown; + currency?: unknown; + restock?: unknown; + reason?: unknown; + email?: unknown; + refund?: unknown; + body?: {[key: string]: unknown} | null; +} + +export class Order extends Base { + public static API_VERSION = ApiVersion.April21; + + protected static NAME = 'order'; + protected static PLURAL_NAME = 'orders'; + protected static HAS_ONE: {[key: string]: typeof Base} = { + customer: Customer + }; + protected static HAS_MANY: {[key: string]: typeof Base} = { + discount_codes: DiscountCode, + fulfillments: Fulfillment, + refunds: Refund + }; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "orders.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "orders/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "orders/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "orders/.json"}, + {http_method: "get", operation: "count", ids: [], path: "orders/count.json"}, + {http_method: "post", operation: "close", ids: ["id"], path: "orders//close.json"}, + {http_method: "post", operation: "open", ids: ["id"], path: "orders//open.json"}, + {http_method: "post", operation: "cancel", ids: ["id"], path: "orders//cancel.json"}, + {http_method: "post", operation: "post", ids: [], path: "orders.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await Order.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as Order : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await Order.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + ids = null, + limit = null, + since_id = null, + created_at_min = null, + created_at_max = null, + updated_at_min = null, + updated_at_max = null, + processed_at_min = null, + processed_at_max = null, + attribution_app_id = null, + status = null, + financial_status = null, + fulfillment_status = null, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Order.baseFind({ + session: session, + urlIds: {}, + params: {ids: ids, limit: limit, since_id: since_id, created_at_min: created_at_min, created_at_max: created_at_max, updated_at_min: updated_at_min, updated_at_max: updated_at_max, processed_at_min: processed_at_min, processed_at_max: processed_at_max, attribution_app_id: attribution_app_id, status: status, financial_status: financial_status, fulfillment_status: fulfillment_status, fields: fields, ...otherArgs}, + }); + + return response as Order[]; + } + + public static async count( + { + session, + created_at_min = null, + created_at_max = null, + updated_at_min = null, + updated_at_max = null, + status = null, + financial_status = null, + fulfillment_status = null, + ...otherArgs + }: CountArgs + ): Promise { + const response = await Order.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {}, + 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, status: status, financial_status: financial_status, fulfillment_status: fulfillment_status, ...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public async close( + { + body = null, + ...otherArgs + }: CloseArgs + ): Promise { + const response = await Order.request({ + http_method: "post", + operation: "close", + session: this.session, + urlIds: {id: this.id}, + params: {...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public async open( + { + body = null, + ...otherArgs + }: OpenArgs + ): Promise { + const response = await Order.request({ + http_method: "post", + operation: "open", + session: this.session, + urlIds: {id: this.id}, + params: {...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public async cancel( + { + amount = null, + currency = null, + restock = null, + reason = null, + email = null, + refund = null, + body = null, + ...otherArgs + }: CancelArgs + ): Promise { + const response = await Order.request({ + http_method: "post", + operation: "cancel", + session: this.session, + urlIds: {id: this.id}, + params: {amount: amount, currency: currency, restock: restock, reason: reason, email: email, refund: refund, ...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public line_items: {[key: string]: unknown}[] | null; + public app_id: number | null; + public billing_address: {[key: string]: unknown} | null; + public browser_ip: string | null; + public buyer_accepts_marketing: boolean | null; + public cancel_reason: string | null; + public cancelled_at: string | null; + public cart_token: string | null; + public checkout_token: string | null; + public client_details: {[key: string]: unknown} | null; + public closed_at: string | null; + public created_at: string | null; + public currency: string | null; + public current_subtotal_price: string | null; + public current_subtotal_price_set: {[key: string]: unknown} | null; + public current_total_discounts: string | null; + public current_total_discounts_set: {[key: string]: unknown} | null; + public current_total_duties_set: {[key: string]: unknown} | null; + public current_total_price: string | null; + public current_total_price_set: {[key: string]: unknown} | null; + public current_total_tax: string | null; + public current_total_tax_set: {[key: string]: unknown} | null; + public customer: Customer | null | {[key: string]: any}; + public customer_locale: string | null; + public discount_applications: {[key: string]: unknown}[] | null; + public discount_codes: DiscountCode[] | null | {[key: string]: any}; + public email: string | null; + public financial_status: string | null; + public fulfillment_status: string | null; + public fulfillments: Fulfillment[] | null | {[key: string]: any}; + public gateway: string | null; + public id: number | null; + public landing_site: string | null; + public location_id: number | null; + public name: string | null; + public note: string | null; + public note_attributes: {[key: string]: unknown}[] | null; + public number: number | null; + public order_number: number | null; + public order_status_url: string | null; + public original_total_duties_set: {[key: string]: unknown} | null; + public payment_details: {[key: string]: unknown} | null; + public payment_gateway_names: string[] | null; + public phone: string | null; + public presentment_currency: string | null; + public processed_at: string | null; + public processing_method: string | null; + public referring_site: string | null; + public refunds: Refund[] | null | {[key: string]: any}; + public shipping_address: {[key: string]: unknown} | null; + public shipping_lines: {[key: string]: unknown}[] | null; + public source_name: string | null; + public subtotal_price: number | null; + public subtotal_price_set: {[key: string]: unknown} | null; + public tags: string | null; + public tax_lines: {[key: string]: unknown}[] | null; + public taxes_included: boolean | null; + public test: boolean | null; + public token: string | null; + public total_discounts: string | null; + public total_discounts_set: {[key: string]: unknown} | null; + public total_line_items_price: string | null; + public total_line_items_price_set: {[key: string]: unknown} | null; + public total_outstanding: string | null; + public total_price: string | null; + public total_price_set: {[key: string]: unknown} | null; + public total_shipping_price_set: {[key: string]: unknown} | null; + public total_tax: string | number | null; + public total_tax_set: {[key: string]: unknown} | null; + public total_tip_received: string | null; + public total_weight: number | null; + public updated_at: string | null; + public user_id: number | null; +} diff --git a/src/rest-resources/2021-04/order_risk.ts b/src/rest-resources/2021-04/order_risk.ts new file mode 100644 index 000000000..f7c20c893 --- /dev/null +++ b/src/rest-resources/2021-04/order_risk.ts @@ -0,0 +1,100 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + order_id?: number | string | null; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; + order_id?: number | string | null; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + order_id?: number | string | null; +} + +export class OrderRisk extends Base { + public static API_VERSION = ApiVersion.April21; + + protected static NAME = 'order_risk'; + protected static PLURAL_NAME = 'order_risks'; + 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: ["order_id"], path: "orders//risks.json"}, + {http_method: "get", operation: "get", ids: ["order_id"], path: "orders//risks.json"}, + {http_method: "get", operation: "get", ids: ["order_id", "id"], path: "orders//risks/.json"}, + {http_method: "put", operation: "put", ids: ["order_id", "id"], path: "orders//risks/.json"}, + {http_method: "delete", operation: "delete", ids: ["order_id", "id"], path: "orders//risks/.json"} + ]; + + protected static getJsonBodyName(): string + { + return "risk"; + } + + public static async find( + { + session, + id, + order_id = null + }: FindArgs + ): Promise { + const result = await OrderRisk.baseFind({ + session: session, + urlIds: {id: id, order_id: order_id}, + params: {}, + }); + return result ? result[0] as OrderRisk : null; + } + + public static async delete( + { + session, + id, + order_id = null + }: DeleteArgs + ): Promise { + const response = await OrderRisk.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id, order_id: order_id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + order_id = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await OrderRisk.baseFind({ + session: session, + urlIds: {order_id: order_id}, + params: {...otherArgs}, + }); + + return response as OrderRisk[]; + } + + public cause_cancel: boolean | null; + public checkout_id: number | null; + public display: boolean | null; + public id: number | null; + public merchant_message: string | null; + public message: string | null; + public order_id: number | null; + public recommendation: string | null; + public score: number | null; + public source: string | null; +} diff --git a/src/rest-resources/2021-04/page.ts b/src/rest-resources/2021-04/page.ts new file mode 100644 index 000000000..d6448b6c9 --- /dev/null +++ b/src/rest-resources/2021-04/page.ts @@ -0,0 +1,161 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Metafield} from './metafield'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + limit?: unknown; + since_id?: unknown; + title?: unknown; + handle?: unknown; + created_at_min?: unknown; + created_at_max?: unknown; + updated_at_min?: unknown; + updated_at_max?: unknown; + published_at_min?: unknown; + published_at_max?: unknown; + fields?: unknown; + published_status?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; + title?: unknown; + created_at_min?: unknown; + created_at_max?: unknown; + updated_at_min?: unknown; + updated_at_max?: unknown; + published_at_min?: unknown; + published_at_max?: unknown; + published_status?: unknown; +} + +export class Page extends Base { + public static API_VERSION = ApiVersion.April21; + + protected static NAME = 'page'; + protected static PLURAL_NAME = 'pages'; + protected static HAS_ONE: {[key: string]: typeof Base} = { + metafield: Metafield + }; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "pages.json"}, + {http_method: "post", operation: "post", ids: [], path: "pages.json"}, + {http_method: "get", operation: "count", ids: [], path: "pages/count.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "pages/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "pages/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "pages/.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await Page.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as Page : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await Page.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + limit = null, + since_id = null, + title = null, + handle = 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, + fields = null, + published_status = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Page.baseFind({ + session: session, + urlIds: {}, + params: {limit: limit, since_id: since_id, title: title, handle: handle, 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, fields: fields, published_status: published_status, ...otherArgs}, + }); + + return response as Page[]; + } + + public static async count( + { + session, + title = 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 + ): Promise { + const response = await Page.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {}, + params: {title: title, 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, + }); + + return response ? response.body : null; + } + + public admin_graphql_api_id: string | null; + public author: string | null; + public body_html: string | null; + public created_at: string | null; + public handle: string | null; + public id: number | null; + public metafield: Metafield | null | {[key: string]: any}; + public published_at: string | null; + public shop_id: number | null; + public template_suffix: string | null; + public title: string | null; + public updated_at: string | null; +} diff --git a/src/rest-resources/2021-04/payment.ts b/src/rest-resources/2021-04/payment.ts new file mode 100644 index 000000000..d3be17b6c --- /dev/null +++ b/src/rest-resources/2021-04/payment.ts @@ -0,0 +1,99 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Transaction} from './transaction'; +import {Checkout} from './checkout'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + checkout_id?: number | string | null; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + checkout_id?: number | string | null; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; + checkout_id?: number | string | null; +} + +export class Payment extends Base { + public static API_VERSION = ApiVersion.April21; + + protected static NAME = 'payment'; + protected static PLURAL_NAME = 'payments'; + protected static HAS_ONE: {[key: string]: typeof Base} = { + transaction: Transaction, + checkout: Checkout + }; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "post", operation: "post", ids: ["checkout_id"], path: "checkouts//payments.json"}, + {http_method: "get", operation: "get", ids: ["checkout_id"], path: "checkouts//payments.json"}, + {http_method: "get", operation: "get", ids: ["checkout_id", "id"], path: "checkouts//payments/.json"}, + {http_method: "get", operation: "count", ids: ["checkout_id"], path: "checkouts//payments/count.json"} + ]; + + public static async find( + { + session, + id, + checkout_id = null + }: FindArgs + ): Promise { + const result = await Payment.baseFind({ + session: session, + urlIds: {id: id, checkout_id: checkout_id}, + params: {}, + }); + return result ? result[0] as Payment : null; + } + + public static async all( + { + session, + checkout_id = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Payment.baseFind({ + session: session, + urlIds: {checkout_id: checkout_id}, + params: {...otherArgs}, + }); + + return response as Payment[]; + } + + public static async count( + { + session, + checkout_id = null, + ...otherArgs + }: CountArgs + ): Promise { + const response = await Payment.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {checkout_id: checkout_id}, + params: {...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public checkout: Checkout | null | {[key: string]: any}; + public credit_card: {[key: string]: unknown} | null; + public id: number | null; + public next_action: {[key: string]: unknown} | null; + public payment_processing_error_message: string | null; + public transaction: Transaction | null | {[key: string]: any}; + public unique_token: string | null; +} diff --git a/src/rest-resources/2021-04/payment_gateway.ts b/src/rest-resources/2021-04/payment_gateway.ts new file mode 100644 index 000000000..6220dcf67 --- /dev/null +++ b/src/rest-resources/2021-04/payment_gateway.ts @@ -0,0 +1,96 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; +} + +export class PaymentGateway extends Base { + public static API_VERSION = ApiVersion.April21; + + protected static NAME = 'payment_gateway'; + protected static PLURAL_NAME = 'payment_gateways'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "payment_gateways.json"}, + {http_method: "post", operation: "post", ids: [], path: "payment_gateways.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "payment_gateways/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "payment_gateways/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "payment_gateways/.json"} + ]; + + public static async find( + { + session, + id + }: FindArgs + ): Promise { + const result = await PaymentGateway.baseFind({ + session: session, + urlIds: {id: id}, + params: {}, + }); + return result ? result[0] as PaymentGateway : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await PaymentGateway.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + ...otherArgs + }: AllArgs + ): Promise { + const response = await PaymentGateway.baseFind({ + session: session, + urlIds: {}, + params: {...otherArgs}, + }); + + return response as PaymentGateway[]; + } + + public attachment: string | null; + public created_at: string | null; + public credential1: string | null; + public credential2: string | null; + public credential3: string | null; + public credential4: string | null; + public disabled: boolean | null; + public enabled_card_brands: string[] | null; + public id: number | null; + public name: string | null; + public processing_method: string | null; + public provider_id: number | null; + public sandbox: boolean | null; + public service_name: string | null; + public supports_network_tokenization: boolean | null; + public type: string | null; + public updated_at: string | null; +} diff --git a/src/rest-resources/2021-04/payment_transaction.ts b/src/rest-resources/2021-04/payment_transaction.ts new file mode 100644 index 000000000..739401806 --- /dev/null +++ b/src/rest-resources/2021-04/payment_transaction.ts @@ -0,0 +1,68 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Currency} from './currency'; + +interface TransactionsArgs { + [key: string]: unknown; + session: SessionInterface; + since_id?: unknown; + last_id?: unknown; + test?: unknown; + payout_id?: unknown; + payout_status?: unknown; +} + +export class PaymentTransaction extends Base { + public static API_VERSION = ApiVersion.April21; + + protected static NAME = 'payment_transaction'; + protected static PLURAL_NAME = 'payment_transactions'; + protected static HAS_ONE: {[key: string]: typeof Base} = { + currency: Currency + }; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "transactions", ids: [], path: "shopify_payments/balance/transactions.json"} + ]; + + public static async transactions( + { + session, + since_id = null, + last_id = null, + test = null, + payout_id = null, + payout_status = null, + ...otherArgs + }: TransactionsArgs + ): Promise { + const response = await PaymentTransaction.request({ + http_method: "get", + operation: "transactions", + session: session, + urlIds: {}, + params: {since_id: since_id, last_id: last_id, test: test, payout_id: payout_id, payout_status: payout_status, ...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public amount: string | null; + public currency: Currency | null | {[key: string]: any}; + public fee: string | null; + public id: number | null; + public net: string | null; + public payout_id: number | null; + public payout_status: string | null; + public processed_at: string | null; + public source_id: number | null; + public source_order_id: number | null; + public source_order_transaction_id: number | null; + public source_type: string | null; + public test: boolean | null; + public type: string | null; +} diff --git a/src/rest-resources/2021-04/payout.ts b/src/rest-resources/2021-04/payout.ts new file mode 100644 index 000000000..81240d41c --- /dev/null +++ b/src/rest-resources/2021-04/payout.ts @@ -0,0 +1,76 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Currency} from './currency'; + +interface FindArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + since_id?: unknown; + last_id?: unknown; + date_min?: unknown; + date_max?: unknown; + date?: unknown; + status?: unknown; +} + +export class Payout extends Base { + public static API_VERSION = ApiVersion.April21; + + protected static NAME = 'payout'; + protected static PLURAL_NAME = 'payouts'; + protected static HAS_ONE: {[key: string]: typeof Base} = { + currency: Currency + }; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "shopify_payments/payouts.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "shopify_payments/payouts/.json"} + ]; + + public static async find( + { + session, + id + }: FindArgs + ): Promise { + const result = await Payout.baseFind({ + session: session, + urlIds: {id: id}, + params: {}, + }); + return result ? result[0] as Payout : null; + } + + public static async all( + { + session, + since_id = null, + last_id = null, + date_min = null, + date_max = null, + date = null, + status = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Payout.baseFind({ + session: session, + urlIds: {}, + params: {since_id: since_id, last_id: last_id, date_min: date_min, date_max: date_max, date: date, status: status, ...otherArgs}, + }); + + return response as Payout[]; + } + + public amount: string | null; + public currency: Currency | null | {[key: string]: any}; + public date: string | null; + public id: number | null; + public status: string | null; +} diff --git a/src/rest-resources/2021-04/policy.ts b/src/rest-resources/2021-04/policy.ts new file mode 100644 index 000000000..ae6ce5f08 --- /dev/null +++ b/src/rest-resources/2021-04/policy.ts @@ -0,0 +1,42 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; +} + +export class Policy extends Base { + public static API_VERSION = ApiVersion.April21; + + protected static NAME = 'policy'; + protected static PLURAL_NAME = 'policies'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "policies.json"} + ]; + + public static async all( + { + session, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Policy.baseFind({ + session: session, + urlIds: {}, + params: {...otherArgs}, + }); + + return response as Policy[]; + } + + public body: string | null; + public created_at: string | null; + public handle: string | null; + public title: string | null; + public updated_at: string | null; + public url: string | null; +} diff --git a/src/rest-resources/2021-04/price_rule.ts b/src/rest-resources/2021-04/price_rule.ts new file mode 100644 index 000000000..64bfd17f6 --- /dev/null +++ b/src/rest-resources/2021-04/price_rule.ts @@ -0,0 +1,154 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + limit?: unknown; + since_id?: unknown; + created_at_min?: unknown; + created_at_max?: unknown; + updated_at_min?: unknown; + updated_at_max?: unknown; + starts_at_min?: unknown; + starts_at_max?: unknown; + ends_at_min?: unknown; + ends_at_max?: unknown; + times_used?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; +} + +export class PriceRule extends Base { + public static API_VERSION = ApiVersion.April21; + + protected static NAME = 'price_rule'; + protected static PLURAL_NAME = 'price_rules'; + 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: "price_rules.json"}, + {http_method: "get", operation: "get", ids: [], path: "price_rules.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "price_rules/.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "price_rules/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "price_rules/.json"}, + {http_method: "get", operation: "count", ids: [], path: "price_rules/count.json"} + ]; + + public static async find( + { + session, + id + }: FindArgs + ): Promise { + const result = await PriceRule.baseFind({ + session: session, + urlIds: {id: id}, + params: {}, + }); + return result ? result[0] as PriceRule : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await PriceRule.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + limit = null, + since_id = null, + created_at_min = null, + created_at_max = null, + updated_at_min = null, + updated_at_max = null, + starts_at_min = null, + starts_at_max = null, + ends_at_min = null, + ends_at_max = null, + times_used = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await PriceRule.baseFind({ + session: session, + urlIds: {}, + params: {limit: limit, since_id: since_id, created_at_min: created_at_min, created_at_max: created_at_max, updated_at_min: updated_at_min, updated_at_max: updated_at_max, starts_at_min: starts_at_min, starts_at_max: starts_at_max, ends_at_min: ends_at_min, ends_at_max: ends_at_max, times_used: times_used, ...otherArgs}, + }); + + return response as PriceRule[]; + } + + public static async count( + { + session, + ...otherArgs + }: CountArgs + ): Promise { + const response = await PriceRule.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {}, + params: {...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public allocation_limit: number | null; + public allocation_method: string | null; + public created_at: string | null; + public customer_selection: string | null; + public ends_at: string | null; + public entitled_collection_ids: number[] | null; + public entitled_country_ids: number[] | null; + public entitled_product_ids: number[] | null; + public entitled_variant_ids: number[] | null; + public id: number | null; + public once_per_customer: boolean | null; + public prerequisite_collection_ids: number[] | null; + public prerequisite_customer_ids: number[] | null; + public prerequisite_product_ids: number[] | null; + public prerequisite_quantity_range: {[key: string]: unknown} | null; + public prerequisite_saved_search_ids: number[] | null; + public prerequisite_shipping_price_range: {[key: string]: unknown} | null; + public prerequisite_subtotal_range: {[key: string]: unknown} | null; + public prerequisite_to_entitlement_purchase: {[key: string]: unknown} | null; + public prerequisite_to_entitlement_quantity_ratio: {[key: string]: unknown} | null; + public prerequisite_variant_ids: number[] | null; + public starts_at: string | null; + public target_selection: string | null; + public target_type: string | null; + public title: string | null; + public updated_at: string | null; + public usage_limit: number | null; + public value: string | null; + public value_type: string | null; +} diff --git a/src/rest-resources/2021-04/product.ts b/src/rest-resources/2021-04/product.ts new file mode 100644 index 000000000..1831770d4 --- /dev/null +++ b/src/rest-resources/2021-04/product.ts @@ -0,0 +1,183 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Image} from './image'; +import {Variant} from './variant'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + ids?: unknown; + limit?: unknown; + since_id?: unknown; + title?: unknown; + vendor?: unknown; + handle?: unknown; + product_type?: unknown; + status?: unknown; + collection_id?: unknown; + created_at_min?: unknown; + created_at_max?: unknown; + updated_at_min?: unknown; + updated_at_max?: unknown; + published_at_min?: unknown; + published_at_max?: unknown; + published_status?: unknown; + fields?: unknown; + presentment_currencies?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; + vendor?: unknown; + product_type?: unknown; + collection_id?: unknown; + created_at_min?: unknown; + created_at_max?: unknown; + updated_at_min?: unknown; + updated_at_max?: unknown; + published_at_min?: unknown; + published_at_max?: unknown; + published_status?: unknown; +} + +export class Product extends Base { + public static API_VERSION = ApiVersion.April21; + + protected static NAME = 'product'; + protected static PLURAL_NAME = 'products'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = { + images: Image, + variants: Variant + }; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "products.json"}, + {http_method: "post", operation: "post", ids: [], path: "products.json"}, + {http_method: "get", operation: "count", ids: [], path: "products/count.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "products/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "products/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "products/.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await Product.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as Product : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await Product.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + ids = null, + limit = null, + since_id = null, + title = null, + vendor = null, + handle = null, + product_type = null, + status = null, + collection_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, + fields = null, + presentment_currencies = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Product.baseFind({ + session: session, + urlIds: {}, + params: {ids: ids, limit: limit, since_id: since_id, title: title, vendor: vendor, handle: handle, product_type: product_type, status: status, collection_id: collection_id, 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, fields: fields, presentment_currencies: presentment_currencies, ...otherArgs}, + }); + + return response as Product[]; + } + + public static async count( + { + session, + vendor = null, + product_type = null, + collection_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 + ): Promise { + const response = await Product.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {}, + params: {vendor: vendor, product_type: product_type, collection_id: collection_id, 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, + }); + + return response ? response.body : null; + } + + public title: string | null; + public body_html: string | null; + public created_at: string | null; + public handle: string | null; + public id: number | null; + public images: Image[] | null | {[key: string]: any}; + public options: {[key: string]: unknown} | {[key: string]: unknown}[] | null; + public product_type: string | null; + public published_at: string | null; + public published_scope: string | null; + public status: string | null; + public tags: string | string[] | null; + public template_suffix: string | null; + public updated_at: string | null; + public variants: Variant[] | null | {[key: string]: any}; + public vendor: string | null; +} diff --git a/src/rest-resources/2021-04/product_listing.ts b/src/rest-resources/2021-04/product_listing.ts new file mode 100644 index 000000000..669f52f30 --- /dev/null +++ b/src/rest-resources/2021-04/product_listing.ts @@ -0,0 +1,158 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Image} from './image'; +import {Variant} from './variant'; + +interface FindArgs { + session: SessionInterface; + product_id: number | string; +} +interface DeleteArgs { + session: SessionInterface; + product_id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + product_ids?: unknown; + limit?: unknown; + collection_id?: unknown; + updated_at_min?: unknown; + handle?: unknown; +} +interface ProductIdsArgs { + [key: string]: unknown; + session: SessionInterface; + limit?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; +} + +export class ProductListing extends Base { + public static API_VERSION = ApiVersion.April21; + + protected static NAME = 'product_listing'; + protected static PLURAL_NAME = 'product_listings'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = { + images: Image, + variants: Variant + }; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "product_listings.json"}, + {http_method: "get", operation: "product_ids", ids: [], path: "product_listings/product_ids.json"}, + {http_method: "get", operation: "count", ids: [], path: "product_listings/count.json"}, + {http_method: "get", operation: "get", ids: ["product_id"], path: "product_listings/.json"}, + {http_method: "put", operation: "put", ids: ["product_id"], path: "product_listings/.json"}, + {http_method: "delete", operation: "delete", ids: ["product_id"], path: "product_listings/.json"} + ]; + protected static PRIMARY_KEY: string = "product_id"; + + public static async find( + { + session, + product_id + }: FindArgs + ): Promise { + const result = await ProductListing.baseFind({ + session: session, + urlIds: {product_id: product_id}, + params: {}, + }); + return result ? result[0] as ProductListing : null; + } + + public static async delete( + { + session, + product_id + }: DeleteArgs + ): Promise { + const response = await ProductListing.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {product_id: product_id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + product_ids = null, + limit = null, + collection_id = null, + updated_at_min = null, + handle = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await ProductListing.baseFind({ + session: session, + urlIds: {}, + params: {product_ids: product_ids, limit: limit, collection_id: collection_id, updated_at_min: updated_at_min, handle: handle, ...otherArgs}, + }); + + return response as ProductListing[]; + } + + public static async product_ids( + { + session, + limit = null, + ...otherArgs + }: ProductIdsArgs + ): Promise { + const response = await ProductListing.request({ + http_method: "get", + operation: "product_ids", + session: session, + urlIds: {}, + params: {limit: limit, ...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public static async count( + { + session, + ...otherArgs + }: CountArgs + ): Promise { + const response = await ProductListing.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {}, + params: {...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public body_html: string | null; + public created_at: string | null; + public handle: string | null; + public images: Image[] | null | {[key: string]: any}; + public options: {[key: string]: unknown}[] | null; + public product_id: number | null; + public product_type: string | null; + public published_at: string | null; + public tags: string | null; + public title: string | null; + public updated_at: string | null; + public variants: Variant[] | null | {[key: string]: any}; + public vendor: string | null; +} diff --git a/src/rest-resources/2021-04/product_resource_feedback.ts b/src/rest-resources/2021-04/product_resource_feedback.ts new file mode 100644 index 000000000..3cef79a2c --- /dev/null +++ b/src/rest-resources/2021-04/product_resource_feedback.ts @@ -0,0 +1,53 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + product_id?: number | string | null; +} + +export class ProductResourceFeedback extends Base { + public static API_VERSION = ApiVersion.April21; + + protected static NAME = 'product_resource_feedback'; + protected static PLURAL_NAME = 'product_resource_feedbacks'; + 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: ["product_id"], path: "products//resource_feedback.json"}, + {http_method: "get", operation: "get", ids: ["product_id"], path: "products//resource_feedback.json"} + ]; + + protected static getJsonBodyName(): string + { + return "resource_feedback"; + } + + public static async all( + { + session, + product_id = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await ProductResourceFeedback.baseFind({ + session: session, + urlIds: {product_id: product_id}, + params: {...otherArgs}, + }); + + return response as ProductResourceFeedback[]; + } + + public created_at: string | null; + public feedback_generated_at: string | null; + public messages: string[] | null; + public product_id: number | null; + public resource_id: number | null; + public resource_type: string | null; + public resource_updated_at: string | null; + public state: string | null; + public updated_at: string | null; +} diff --git a/src/rest-resources/2021-04/province.ts b/src/rest-resources/2021-04/province.ts new file mode 100644 index 000000000..ba52740d0 --- /dev/null +++ b/src/rest-resources/2021-04/province.ts @@ -0,0 +1,101 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + country_id?: number | string | null; + fields?: unknown; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + country_id?: number | string | null; + since_id?: unknown; + fields?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; + country_id?: number | string | null; +} + +export class Province extends Base { + public static API_VERSION = ApiVersion.April21; + + protected static NAME = 'province'; + protected static PLURAL_NAME = 'provinces'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: ["country_id"], path: "countries//provinces.json"}, + {http_method: "get", operation: "count", ids: ["country_id"], path: "countries//provinces/count.json"}, + {http_method: "get", operation: "get", ids: ["country_id", "id"], path: "countries//provinces/.json"}, + {http_method: "put", operation: "put", ids: ["country_id", "id"], path: "countries//provinces/.json"} + ]; + + public static async find( + { + session, + id, + country_id = null, + fields = null + }: FindArgs + ): Promise { + const result = await Province.baseFind({ + session: session, + urlIds: {id: id, country_id: country_id}, + params: {fields: fields}, + }); + return result ? result[0] as Province : null; + } + + public static async all( + { + session, + country_id = null, + since_id = null, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Province.baseFind({ + session: session, + urlIds: {country_id: country_id}, + params: {since_id: since_id, fields: fields, ...otherArgs}, + }); + + return response as Province[]; + } + + public static async count( + { + session, + country_id = null, + ...otherArgs + }: CountArgs + ): Promise { + const response = await Province.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {country_id: country_id}, + params: {...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public code: string | null; + public country_id: number | null; + public id: number | null; + public name: string | null; + public shipping_zone_id: number | null; + public tax: number | null; + public tax_name: string | null; + public tax_percentage: number | null; + public tax_type: string | null; +} diff --git a/src/rest-resources/2021-04/recurring_application_charge.ts b/src/rest-resources/2021-04/recurring_application_charge.ts new file mode 100644 index 000000000..cec5ff714 --- /dev/null +++ b/src/rest-resources/2021-04/recurring_application_charge.ts @@ -0,0 +1,124 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + since_id?: unknown; + fields?: unknown; +} +interface CustomizeArgs { + [key: string]: unknown; + body?: {[key: string]: unknown} | null; +} + +export class RecurringApplicationCharge extends Base { + public static API_VERSION = ApiVersion.April21; + + protected static NAME = 'recurring_application_charge'; + protected static PLURAL_NAME = 'recurring_application_charges'; + 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: "recurring_application_charges.json"}, + {http_method: "get", operation: "get", ids: [], path: "recurring_application_charges.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "recurring_application_charges/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "recurring_application_charges/.json"}, + {http_method: "put", operation: "customize", ids: ["id"], path: "recurring_application_charges//customize.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await RecurringApplicationCharge.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as RecurringApplicationCharge : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await RecurringApplicationCharge.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + since_id = null, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await RecurringApplicationCharge.baseFind({ + session: session, + urlIds: {}, + params: {since_id: since_id, fields: fields, ...otherArgs}, + }); + + return response as RecurringApplicationCharge[]; + } + + public async customize( + { + body = null, + ...otherArgs + }: CustomizeArgs + ): Promise { + const response = await RecurringApplicationCharge.request({ + http_method: "put", + operation: "customize", + session: this.session, + urlIds: {id: this.id}, + params: {...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public activated_on: string | null; + public billing_on: string | null; + public cancelled_on: string | null; + public capped_amount: string | number | null; + public confirmation_url: string | null; + public created_at: string | null; + public id: number | null; + public name: string | null; + public price: string | number | null; + public return_url: string | null; + public status: string | null; + public terms: string | null; + public test: boolean | null; + public trial_days: number | null; + public trial_ends_on: string | null; + public updated_at: string | null; +} diff --git a/src/rest-resources/2021-04/redirect.ts b/src/rest-resources/2021-04/redirect.ts new file mode 100644 index 000000000..4e96c51f4 --- /dev/null +++ b/src/rest-resources/2021-04/redirect.ts @@ -0,0 +1,122 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + limit?: unknown; + since_id?: unknown; + path?: unknown; + target?: unknown; + fields?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; + path?: unknown; + target?: unknown; +} + +export class Redirect extends Base { + public static API_VERSION = ApiVersion.April21; + + protected static NAME = 'redirect'; + protected static PLURAL_NAME = 'redirects'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "redirects.json"}, + {http_method: "post", operation: "post", ids: [], path: "redirects.json"}, + {http_method: "get", operation: "count", ids: [], path: "redirects/count.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "redirects/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "redirects/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "redirects/.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await Redirect.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as Redirect : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await Redirect.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + limit = null, + since_id = null, + path = null, + target = null, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Redirect.baseFind({ + session: session, + urlIds: {}, + params: {limit: limit, since_id: since_id, path: path, target: target, fields: fields, ...otherArgs}, + }); + + return response as Redirect[]; + } + + public static async count( + { + session, + path = null, + target = null, + ...otherArgs + }: CountArgs + ): Promise { + const response = await Redirect.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {}, + params: {path: path, target: target, ...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public id: number | null; + public path: string | null; + public target: string | null; +} diff --git a/src/rest-resources/2021-04/refund.ts b/src/rest-resources/2021-04/refund.ts new file mode 100644 index 000000000..8faa7c87a --- /dev/null +++ b/src/rest-resources/2021-04/refund.ts @@ -0,0 +1,116 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Transaction} from './transaction'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + order_id?: number | string | null; + fields?: unknown; + in_shop_currency?: unknown; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + order_id?: number | string | null; + limit?: unknown; + fields?: unknown; + in_shop_currency?: unknown; +} +interface CalculateArgs { + [key: string]: unknown; + shipping?: unknown; + refund_line_items?: unknown; + currency?: unknown; + body?: {[key: string]: unknown} | null; +} + +export class Refund extends Base { + public static API_VERSION = ApiVersion.April21; + + protected static NAME = 'refund'; + protected static PLURAL_NAME = 'refunds'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = { + transactions: Transaction + }; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: ["order_id"], path: "orders//refunds.json"}, + {http_method: "post", operation: "post", ids: ["order_id"], path: "orders//refunds.json"}, + {http_method: "get", operation: "get", ids: ["order_id", "id"], path: "orders//refunds/.json"}, + {http_method: "post", operation: "calculate", ids: ["order_id"], path: "orders//refunds/calculate.json"} + ]; + + public static async find( + { + session, + id, + order_id = null, + fields = null, + in_shop_currency = null + }: FindArgs + ): Promise { + const result = await Refund.baseFind({ + session: session, + urlIds: {id: id, order_id: order_id}, + params: {fields: fields, in_shop_currency: in_shop_currency}, + }); + return result ? result[0] as Refund : null; + } + + public static async all( + { + session, + order_id = null, + limit = null, + fields = null, + in_shop_currency = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Refund.baseFind({ + session: session, + urlIds: {order_id: order_id}, + params: {limit: limit, fields: fields, in_shop_currency: in_shop_currency, ...otherArgs}, + }); + + return response as Refund[]; + } + + public async calculate( + { + shipping = null, + refund_line_items = null, + currency = null, + body = null, + ...otherArgs + }: CalculateArgs + ): Promise { + const response = await Refund.request({ + http_method: "post", + operation: "calculate", + session: this.session, + urlIds: {order_id: this.order_id}, + params: {shipping: shipping, refund_line_items: refund_line_items, currency: currency, ...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public created_at: string | null; + public duties: {[key: string]: unknown}[] | null; + public id: number | null; + public note: string | null; + public order_adjustments: {[key: string]: unknown}[] | null; + public order_id: number | null; + public processed_at: string | null; + public refund_duties: {[key: string]: unknown}[] | null; + public refund_line_items: {[key: string]: unknown}[] | null; + public restock: boolean | null; + public transactions: Transaction[] | null | {[key: string]: any}; + public user_id: number | null; +} diff --git a/src/rest-resources/2021-04/report.ts b/src/rest-resources/2021-04/report.ts new file mode 100644 index 000000000..090820554 --- /dev/null +++ b/src/rest-resources/2021-04/report.ts @@ -0,0 +1,98 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + ids?: unknown; + limit?: unknown; + since_id?: unknown; + updated_at_min?: unknown; + updated_at_max?: unknown; + fields?: unknown; +} + +export class Report extends Base { + public static API_VERSION = ApiVersion.April21; + + protected static NAME = 'report'; + protected static PLURAL_NAME = 'reports'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "reports.json"}, + {http_method: "post", operation: "post", ids: [], path: "reports.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "reports/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "reports/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "reports/.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await Report.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as Report : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await Report.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + ids = null, + limit = null, + since_id = null, + updated_at_min = null, + updated_at_max = null, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Report.baseFind({ + session: session, + urlIds: {}, + params: {ids: ids, limit: limit, since_id: since_id, updated_at_min: updated_at_min, updated_at_max: updated_at_max, fields: fields, ...otherArgs}, + }); + + return response as Report[]; + } + + public category: string | null; + public id: number | null; + public name: string | null; + public shopify_ql: string | null; + public updated_at: string | null; +} diff --git a/src/rest-resources/2021-04/resource_feedback.ts b/src/rest-resources/2021-04/resource_feedback.ts new file mode 100644 index 000000000..ec24f70e1 --- /dev/null +++ b/src/rest-resources/2021-04/resource_feedback.ts @@ -0,0 +1,44 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; +} + +export class ResourceFeedback extends Base { + public static API_VERSION = ApiVersion.April21; + + protected static NAME = 'resource_feedback'; + protected static PLURAL_NAME = 'resource_feedbacks'; + 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: "resource_feedback.json"}, + {http_method: "get", operation: "get", ids: [], path: "resource_feedback.json"} + ]; + + public static async all( + { + session, + ...otherArgs + }: AllArgs + ): Promise { + const response = await ResourceFeedback.baseFind({ + session: session, + urlIds: {}, + params: {...otherArgs}, + }); + + return response as ResourceFeedback[]; + } + + public created_at: string | null; + public feedback_generated_at: string | null; + public messages: string[] | null; + public resource_id: number | null; + public resource_type: string | null; + public state: string | null; + public updated_at: string | null; +} diff --git a/src/rest-resources/2021-04/script_tag.ts b/src/rest-resources/2021-04/script_tag.ts new file mode 100644 index 000000000..d881000db --- /dev/null +++ b/src/rest-resources/2021-04/script_tag.ts @@ -0,0 +1,130 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + limit?: unknown; + since_id?: unknown; + created_at_min?: unknown; + created_at_max?: unknown; + updated_at_min?: unknown; + updated_at_max?: unknown; + src?: unknown; + fields?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; + src?: unknown; +} + +export class ScriptTag extends Base { + public static API_VERSION = ApiVersion.April21; + + protected static NAME = 'script_tag'; + protected static PLURAL_NAME = 'script_tags'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "script_tags.json"}, + {http_method: "post", operation: "post", ids: [], path: "script_tags.json"}, + {http_method: "get", operation: "count", ids: [], path: "script_tags/count.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "script_tags/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "script_tags/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "script_tags/.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await ScriptTag.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as ScriptTag : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await ScriptTag.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + limit = null, + since_id = null, + created_at_min = null, + created_at_max = null, + updated_at_min = null, + updated_at_max = null, + src = null, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await ScriptTag.baseFind({ + session: session, + urlIds: {}, + params: {limit: limit, since_id: since_id, created_at_min: created_at_min, created_at_max: created_at_max, updated_at_min: updated_at_min, updated_at_max: updated_at_max, src: src, fields: fields, ...otherArgs}, + }); + + return response as ScriptTag[]; + } + + public static async count( + { + session, + src = null, + ...otherArgs + }: CountArgs + ): Promise { + const response = await ScriptTag.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {}, + params: {src: src, ...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public event: string | null; + public src: string | null; + public cache: boolean | null; + public created_at: string | null; + public display_scope: string | null; + public id: number | null; + public updated_at: string | null; +} diff --git a/src/rest-resources/2021-04/shipping_zone.ts b/src/rest-resources/2021-04/shipping_zone.ts new file mode 100644 index 000000000..0b13ffb4d --- /dev/null +++ b/src/rest-resources/2021-04/shipping_zone.ts @@ -0,0 +1,53 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Country} from './country'; +import {Province} from './province'; + +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + fields?: unknown; +} + +export class ShippingZone extends Base { + public static API_VERSION = ApiVersion.April21; + + protected static NAME = 'shipping_zone'; + protected static PLURAL_NAME = 'shipping_zones'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = { + countries: Country, + provinces: Province + }; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "shipping_zones.json"} + ]; + + public static async all( + { + session, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await ShippingZone.baseFind({ + session: session, + urlIds: {}, + params: {fields: fields, ...otherArgs}, + }); + + return response as ShippingZone[]; + } + + public carrier_shipping_rate_providers: unknown | null; + public countries: Country[] | null | {[key: string]: any}; + public id: number | null; + public location_group_id: number | null; + public name: string | null; + public price_based_shipping_rates: {[key: string]: unknown} | null; + public profile_id: number | null; + public provinces: Province[] | null | {[key: string]: any}; + public weight_based_shipping_rates: {[key: string]: unknown} | null; +} diff --git a/src/rest-resources/2021-04/shop.ts b/src/rest-resources/2021-04/shop.ts new file mode 100644 index 000000000..53dd13d66 --- /dev/null +++ b/src/rest-resources/2021-04/shop.ts @@ -0,0 +1,100 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Country} from './country'; +import {Currency} from './currency'; +import {Province} from './province'; + +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + fields?: unknown; +} + +export class Shop extends Base { + public static API_VERSION = ApiVersion.April21; + + protected static NAME = 'shop'; + protected static PLURAL_NAME = 'shops'; + protected static HAS_ONE: {[key: string]: typeof Base} = { + country: Country, + currency: Currency, + province: Province + }; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "shop.json"} + ]; + + public static async all( + { + session, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Shop.baseFind({ + session: session, + urlIds: {}, + params: {fields: fields, ...otherArgs}, + }); + + return response as Shop[]; + } + + public address1: string | null; + public address2: string | null; + public checkout_api_supported: boolean | null; + public city: string | null; + public cookie_consent_level: string | null; + public country: Country | null | {[key: string]: any}; + public country_code: string | null; + public country_name: string | null; + public county_taxes: string | null; + public created_at: string | null; + public currency: Currency | null | {[key: string]: any}; + public customer_email: string | null; + public domain: string | null; + public eligible_for_card_reader_giveaway: boolean | null; + public eligible_for_payments: boolean | null; + public email: string | null; + public enabled_presentment_currencies: string[] | null; + public finances: boolean | null; + public force_ssl: boolean | null; + public google_apps_domain: string | null; + public google_apps_login_enabled: string | null; + public has_discounts: boolean | null; + public has_gift_cards: boolean | null; + public has_storefront: boolean | null; + public iana_timezone: string | null; + public id: number | null; + public latitude: number | null; + public longitude: number | null; + public money_format: string | null; + public money_in_emails_format: string | null; + public money_with_currency_format: string | null; + public money_with_currency_in_emails_format: string | null; + public multi_location_enabled: boolean | null; + public myshopify_domain: string | null; + public name: string | null; + public password_enabled: boolean | null; + public phone: string | null; + public plan_display_name: string | null; + public plan_name: string | null; + public pre_launch_enabled: boolean | null; + public primary_locale: string | null; + public primary_location_id: number | null; + public province: Province | null | {[key: string]: any}; + public province_code: string | null; + public requires_extra_payments_agreement: boolean | null; + public setup_required: boolean | null; + public shop_owner: string | null; + public source: string | null; + public tax_shipping: string | null; + public taxes_included: string | null; + public timezone: string | null; + public updated_at: string | null; + public weight_unit: string | null; + public zip: string | null; +} diff --git a/src/rest-resources/2021-04/smart_collection.ts b/src/rest-resources/2021-04/smart_collection.ts new file mode 100644 index 000000000..b5975323c --- /dev/null +++ b/src/rest-resources/2021-04/smart_collection.ts @@ -0,0 +1,183 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + limit?: unknown; + ids?: unknown; + since_id?: unknown; + title?: unknown; + product_id?: unknown; + handle?: unknown; + updated_at_min?: unknown; + updated_at_max?: unknown; + published_at_min?: unknown; + published_at_max?: unknown; + published_status?: unknown; + fields?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; + title?: unknown; + product_id?: unknown; + updated_at_min?: unknown; + updated_at_max?: unknown; + published_at_min?: unknown; + published_at_max?: unknown; + published_status?: unknown; +} +interface OrderArgs { + [key: string]: unknown; + products?: unknown; + sort_order?: unknown; + body?: {[key: string]: unknown} | null; +} + +export class SmartCollection extends Base { + public static API_VERSION = ApiVersion.April21; + + protected static NAME = 'smart_collection'; + protected static PLURAL_NAME = 'smart_collections'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "smart_collections.json"}, + {http_method: "post", operation: "post", ids: [], path: "smart_collections.json"}, + {http_method: "get", operation: "count", ids: [], path: "smart_collections/count.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "smart_collections/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "smart_collections/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "smart_collections/.json"}, + {http_method: "put", operation: "order", ids: ["id"], path: "smart_collections//order.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await SmartCollection.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as SmartCollection : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await SmartCollection.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + limit = null, + ids = null, + since_id = null, + title = null, + product_id = null, + handle = null, + updated_at_min = null, + updated_at_max = null, + published_at_min = null, + published_at_max = null, + published_status = null, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await SmartCollection.baseFind({ + session: session, + urlIds: {}, + params: {limit: limit, ids: ids, since_id: since_id, title: title, product_id: product_id, handle: handle, 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, fields: fields, ...otherArgs}, + }); + + return response as SmartCollection[]; + } + + public static async count( + { + session, + title = null, + product_id = null, + updated_at_min = null, + updated_at_max = null, + published_at_min = null, + published_at_max = null, + published_status = null, + ...otherArgs + }: CountArgs + ): Promise { + const response = await SmartCollection.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {}, + params: {title: title, product_id: product_id, 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, + }); + + return response ? response.body : null; + } + + public async order( + { + products = null, + sort_order = null, + body = null, + ...otherArgs + }: OrderArgs + ): Promise { + const response = await SmartCollection.request({ + http_method: "put", + operation: "order", + session: this.session, + urlIds: {id: this.id}, + params: {products: products, sort_order: sort_order, ...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public rules: {[key: string]: unknown} | {[key: string]: unknown}[] | null; + public title: string | null; + public body_html: string | null; + public disjunctive: boolean | null; + public handle: string | null; + public id: number | null; + public image: string | {[key: string]: unknown} | null; + public published_at: string | null; + public published_scope: string | null; + public sort_order: string | null; + public template_suffix: string | null; + public updated_at: string | null; +} diff --git a/src/rest-resources/2021-04/storefront_access_token.ts b/src/rest-resources/2021-04/storefront_access_token.ts new file mode 100644 index 000000000..6360f3e74 --- /dev/null +++ b/src/rest-resources/2021-04/storefront_access_token.ts @@ -0,0 +1,68 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {AccessScope} from './access_scope'; + +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; +} + +export class StorefrontAccessToken extends Base { + public static API_VERSION = ApiVersion.April21; + + protected static NAME = 'storefront_access_token'; + protected static PLURAL_NAME = 'storefront_access_tokens'; + protected static HAS_ONE: {[key: string]: typeof Base} = { + access_scope: AccessScope + }; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "post", operation: "post", ids: [], path: "storefront_access_tokens.json"}, + {http_method: "get", operation: "get", ids: [], path: "storefront_access_tokens.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "storefront_access_tokens/.json"} + ]; + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await StorefrontAccessToken.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + ...otherArgs + }: AllArgs + ): Promise { + const response = await StorefrontAccessToken.baseFind({ + session: session, + urlIds: {}, + params: {...otherArgs}, + }); + + return response as StorefrontAccessToken[]; + } + + public title: string | null; + public access_scope: AccessScope | null | {[key: string]: any}; + public access_token: string | null; + public created_at: string | null; + public id: number | null; +} diff --git a/src/rest-resources/2021-04/tender_transaction.ts b/src/rest-resources/2021-04/tender_transaction.ts new file mode 100644 index 000000000..24b5bbaca --- /dev/null +++ b/src/rest-resources/2021-04/tender_transaction.ts @@ -0,0 +1,62 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Currency} from './currency'; + +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + limit?: unknown; + since_id?: unknown; + processed_at_min?: unknown; + processed_at_max?: unknown; + processed_at?: unknown; + order?: unknown; +} + +export class TenderTransaction extends Base { + public static API_VERSION = ApiVersion.April21; + + protected static NAME = 'tender_transaction'; + protected static PLURAL_NAME = 'tender_transactions'; + protected static HAS_ONE: {[key: string]: typeof Base} = { + currency: Currency + }; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "tender_transactions.json"} + ]; + + public static async all( + { + session, + limit = null, + since_id = null, + processed_at_min = null, + processed_at_max = null, + processed_at = null, + order = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await TenderTransaction.baseFind({ + session: session, + urlIds: {}, + params: {limit: limit, since_id: since_id, processed_at_min: processed_at_min, processed_at_max: processed_at_max, processed_at: processed_at, order: order, ...otherArgs}, + }); + + return response as TenderTransaction[]; + } + + public amount: string | null; + public currency: Currency | null | {[key: string]: any}; + public id: number | null; + public order_id: number | null; + public payment_details: {[key: string]: unknown} | null; + public payment_method: string | null; + public processed_at: string | null; + public remote_reference: string | null; + public test: boolean | null; + public user_id: number | null; +} diff --git a/src/rest-resources/2021-04/theme.ts b/src/rest-resources/2021-04/theme.ts new file mode 100644 index 000000000..6aa687d32 --- /dev/null +++ b/src/rest-resources/2021-04/theme.ts @@ -0,0 +1,91 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + fields?: unknown; +} + +export class Theme extends Base { + public static API_VERSION = ApiVersion.April21; + + protected static NAME = 'theme'; + protected static PLURAL_NAME = 'themes'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "themes.json"}, + {http_method: "post", operation: "post", ids: [], path: "themes.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "themes/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "themes/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "themes/.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await Theme.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as Theme : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await Theme.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Theme.baseFind({ + session: session, + urlIds: {}, + params: {fields: fields, ...otherArgs}, + }); + + return response as Theme[]; + } + + public created_at: string | null; + public id: number | null; + public name: string | null; + public previewable: boolean | null; + public processing: boolean | null; + public role: string | null; + public theme_store_id: number | null; + public updated_at: string | null; +} diff --git a/src/rest-resources/2021-04/transaction.ts b/src/rest-resources/2021-04/transaction.ts new file mode 100644 index 000000000..9528df387 --- /dev/null +++ b/src/rest-resources/2021-04/transaction.ts @@ -0,0 +1,119 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + order_id?: number | string | null; + fields?: unknown; + in_shop_currency?: unknown; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + order_id?: number | string | null; + since_id?: unknown; + fields?: unknown; + in_shop_currency?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; + order_id?: number | string | null; +} + +export class Transaction extends Base { + public static API_VERSION = ApiVersion.April21; + + protected static NAME = 'transaction'; + protected static PLURAL_NAME = 'transactions'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: ["order_id"], path: "orders//transactions.json"}, + {http_method: "post", operation: "post", ids: ["order_id"], path: "orders//transactions.json"}, + {http_method: "get", operation: "count", ids: ["order_id"], path: "orders//transactions/count.json"}, + {http_method: "get", operation: "get", ids: ["order_id", "id"], path: "orders//transactions/.json"} + ]; + + public static async find( + { + session, + id, + order_id = null, + fields = null, + in_shop_currency = null + }: FindArgs + ): Promise { + const result = await Transaction.baseFind({ + session: session, + urlIds: {id: id, order_id: order_id}, + params: {fields: fields, in_shop_currency: in_shop_currency}, + }); + return result ? result[0] as Transaction : null; + } + + public static async all( + { + session, + order_id = null, + since_id = null, + fields = null, + in_shop_currency = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Transaction.baseFind({ + session: session, + urlIds: {order_id: order_id}, + params: {since_id: since_id, fields: fields, in_shop_currency: in_shop_currency, ...otherArgs}, + }); + + return response as Transaction[]; + } + + public static async count( + { + session, + order_id = null, + ...otherArgs + }: CountArgs + ): Promise { + const response = await Transaction.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {order_id: order_id}, + params: {...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public kind: string | null; + public amount: string | null; + public authorization: string | null; + public authorization_expires_at: string | null; + public created_at: string | null; + public currency: string | null; + public currency_exchange_adjustment: {[key: string]: unknown} | null; + public device_id: number | null; + public error_code: string | null; + public extended_authorization_attributes: {[key: string]: unknown} | null; + public gateway: string | null; + public id: number | null; + public location_id: number | null; + public message: string | null; + public order_id: number | null; + public parent_id: number | null; + public payment_details: {[key: string]: unknown} | null; + public processed_at: string | null; + public receipt: {[key: string]: unknown} | null; + public source_name: string | null; + public status: string | null; + public test: boolean | null; + public user_id: number | null; +} diff --git a/src/rest-resources/2021-04/usage_charge.ts b/src/rest-resources/2021-04/usage_charge.ts new file mode 100644 index 000000000..acec010e7 --- /dev/null +++ b/src/rest-resources/2021-04/usage_charge.ts @@ -0,0 +1,70 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + recurring_application_charge_id?: number | string | null; + fields?: unknown; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + recurring_application_charge_id?: number | string | null; + fields?: unknown; +} + +export class UsageCharge extends Base { + public static API_VERSION = ApiVersion.April21; + + protected static NAME = 'usage_charge'; + protected static PLURAL_NAME = 'usage_charges'; + 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: ["recurring_application_charge_id"], path: "recurring_application_charges//usage_charges.json"}, + {http_method: "get", operation: "get", ids: ["recurring_application_charge_id"], path: "recurring_application_charges//usage_charges.json"}, + {http_method: "get", operation: "get", ids: ["recurring_application_charge_id", "id"], path: "recurring_application_charges//usage_charges/.json"} + ]; + + public static async find( + { + session, + id, + recurring_application_charge_id = null, + fields = null + }: FindArgs + ): Promise { + const result = await UsageCharge.baseFind({ + session: session, + urlIds: {id: id, recurring_application_charge_id: recurring_application_charge_id}, + params: {fields: fields}, + }); + return result ? result[0] as UsageCharge : null; + } + + public static async all( + { + session, + recurring_application_charge_id = null, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await UsageCharge.baseFind({ + session: session, + urlIds: {recurring_application_charge_id: recurring_application_charge_id}, + params: {fields: fields, ...otherArgs}, + }); + + return response as UsageCharge[]; + } + + public created_at: string | null; + public description: string | null; + public id: number | null; + public price: number | null; + public recurring_application_charge_id: number | null; + public updated_at: string | null; +} diff --git a/src/rest-resources/2021-04/user.ts b/src/rest-resources/2021-04/user.ts new file mode 100644 index 000000000..300c3014e --- /dev/null +++ b/src/rest-resources/2021-04/user.ts @@ -0,0 +1,97 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + limit?: unknown; + page_info?: unknown; +} +interface CurrentArgs { + [key: string]: unknown; + session: SessionInterface; +} + +export class User extends Base { + public static API_VERSION = ApiVersion.April21; + + protected static NAME = 'user'; + protected static PLURAL_NAME = 'users'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "users.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "users/.json"}, + {http_method: "get", operation: "current", ids: [], path: "users/current.json"} + ]; + + public static async find( + { + session, + id + }: FindArgs + ): Promise { + const result = await User.baseFind({ + session: session, + urlIds: {id: id}, + params: {}, + }); + return result ? result[0] as User : null; + } + + public static async all( + { + session, + limit = null, + page_info = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await User.baseFind({ + session: session, + urlIds: {}, + params: {limit: limit, page_info: page_info, ...otherArgs}, + }); + + return response as User[]; + } + + public static async current( + { + session, + ...otherArgs + }: CurrentArgs + ): Promise { + const response = await User.request({ + http_method: "get", + operation: "current", + session: session, + urlIds: {}, + params: {...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public account_owner: boolean | null; + public bio: string | null; + public email: string | null; + public first_name: string | null; + public id: number | null; + public im: string | null; + public last_name: string | null; + public locale: string | null; + public permissions: string[] | null; + public phone: string | null; + public receive_announcements: number | null; + public screen_name: string | null; + public url: string | null; + public user_type: string | null; +} diff --git a/src/rest-resources/2021-04/variant.ts b/src/rest-resources/2021-04/variant.ts new file mode 100644 index 000000000..fb1b624c1 --- /dev/null +++ b/src/rest-resources/2021-04/variant.ts @@ -0,0 +1,145 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; + product_id?: number | string | null; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + product_id?: number | string | null; + limit?: unknown; + presentment_currencies?: unknown; + since_id?: unknown; + fields?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; + product_id?: number | string | null; +} + +export class Variant extends Base { + public static API_VERSION = ApiVersion.April21; + + protected static NAME = 'variant'; + protected static PLURAL_NAME = 'variants'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: ["product_id"], path: "products//variants.json"}, + {http_method: "get", operation: "count", ids: ["product_id"], path: "products//variants/count.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "variants/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "variants/.json"}, + {http_method: "post", operation: "post", ids: ["product_id"], path: "products//variants.json"}, + {http_method: "delete", operation: "delete", ids: ["product_id", "id"], path: "products//variants/.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await Variant.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as Variant : null; + } + + public static async delete( + { + session, + id, + product_id = null + }: DeleteArgs + ): Promise { + const response = await Variant.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id, product_id: product_id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + product_id = null, + limit = null, + presentment_currencies = null, + since_id = null, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Variant.baseFind({ + session: session, + urlIds: {product_id: product_id}, + params: {limit: limit, presentment_currencies: presentment_currencies, since_id: since_id, fields: fields, ...otherArgs}, + }); + + return response as Variant[]; + } + + public static async count( + { + session, + product_id = null, + ...otherArgs + }: CountArgs + ): Promise { + const response = await Variant.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {product_id: product_id}, + params: {...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public barcode: string | null; + public compare_at_price: string | null; + public created_at: string | null; + public fulfillment_service: string | null; + public grams: number | null; + public id: number | null; + public image_id: number | null; + public inventory_item_id: number | null; + public inventory_management: string | null; + public inventory_policy: string | null; + public inventory_quantity: number | null; + public inventory_quantity_adjustment: number | null; + public old_inventory_quantity: number | null; + public option: {[key: string]: unknown} | null; + public position: number | null; + public presentment_prices: {[key: string]: unknown}[] | null; + public price: string | null; + public product_id: number | null; + public requires_shipping: boolean | null; + public sku: string | null; + public tax_code: string | null; + public taxable: boolean | null; + public title: string | null; + public updated_at: string | null; + public weight: number | null; + public weight_unit: string | null; +} diff --git a/src/rest-resources/2021-04/webhook.ts b/src/rest-resources/2021-04/webhook.ts new file mode 100644 index 000000000..fb32fb7ea --- /dev/null +++ b/src/rest-resources/2021-04/webhook.ts @@ -0,0 +1,137 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + address?: unknown; + created_at_max?: unknown; + created_at_min?: unknown; + fields?: unknown; + limit?: unknown; + since_id?: unknown; + topic?: unknown; + updated_at_min?: unknown; + updated_at_max?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; + address?: unknown; + topic?: unknown; +} + +export class Webhook extends Base { + public static API_VERSION = ApiVersion.April21; + + protected static NAME = 'webhook'; + protected static PLURAL_NAME = 'webhooks'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "webhooks.json"}, + {http_method: "post", operation: "post", ids: [], path: "webhooks.json"}, + {http_method: "get", operation: "count", ids: [], path: "webhooks/count.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "webhooks/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "webhooks/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "webhooks/.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await Webhook.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as Webhook : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await Webhook.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + address = null, + created_at_max = null, + created_at_min = null, + fields = null, + limit = null, + since_id = null, + topic = null, + updated_at_min = null, + updated_at_max = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Webhook.baseFind({ + session: session, + urlIds: {}, + params: {address: address, created_at_max: created_at_max, created_at_min: created_at_min, fields: fields, limit: limit, since_id: since_id, topic: topic, updated_at_min: updated_at_min, updated_at_max: updated_at_max, ...otherArgs}, + }); + + return response as Webhook[]; + } + + public static async count( + { + session, + address = null, + topic = null, + ...otherArgs + }: CountArgs + ): Promise { + const response = await Webhook.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {}, + params: {address: address, topic: topic, ...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public address: string | null; + public topic: string | null; + public api_version: string | null; + public created_at: string | null; + public fields: string[] | null; + public format: string | null; + public id: number | null; + public metafield_namespaces: string[] | null; + public private_metafield_namespaces: string[] | null; + public updated_at: string | null; +} diff --git a/src/rest-resources/2021-07/abandoned_checkout.ts b/src/rest-resources/2021-07/abandoned_checkout.ts new file mode 100644 index 000000000..03093d36c --- /dev/null +++ b/src/rest-resources/2021-07/abandoned_checkout.ts @@ -0,0 +1,103 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Currency} from './currency'; +import {Customer} from './customer'; +import {DiscountCode} from './discount_code'; + +interface CheckoutsArgs { + [key: string]: unknown; + session: SessionInterface; + since_id?: unknown; + created_at_min?: unknown; + created_at_max?: unknown; + updated_at_min?: unknown; + updated_at_max?: unknown; + status?: unknown; + limit?: unknown; +} + +export class AbandonedCheckout extends Base { + public static API_VERSION = ApiVersion.July21; + + protected static NAME = 'abandoned_checkout'; + protected static PLURAL_NAME = 'abandoned_checkouts'; + protected static HAS_ONE: {[key: string]: typeof Base} = { + currency: Currency, + customer: Customer + }; + protected static HAS_MANY: {[key: string]: typeof Base} = { + discount_codes: DiscountCode + }; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "checkouts", ids: [], path: "checkouts.json"}, + {http_method: "get", operation: "checkouts", ids: [], path: "checkouts.json"} + ]; + + public static async checkouts( + { + session, + since_id = null, + created_at_min = null, + created_at_max = null, + updated_at_min = null, + updated_at_max = null, + status = null, + limit = null, + ...otherArgs + }: CheckoutsArgs + ): Promise { + const response = await AbandonedCheckout.request({ + http_method: "get", + operation: "checkouts", + session: session, + urlIds: {}, + params: {since_id: since_id, created_at_min: created_at_min, created_at_max: created_at_max, updated_at_min: updated_at_min, updated_at_max: updated_at_max, status: status, limit: limit, ...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public abandoned_checkout_url: string | null; + public billing_address: {[key: string]: unknown} | null; + public buyer_accepts_marketing: boolean | null; + public buyer_accepts_sms_marketing: boolean | null; + public cart_token: string | null; + public closed_at: string | null; + public completed_at: string | null; + public created_at: string | null; + public currency: Currency | null | {[key: string]: any}; + public customer: Customer | null | {[key: string]: any}; + public customer_locale: string | null; + public device_id: number | null; + public discount_codes: DiscountCode[] | null | {[key: string]: any}; + public email: string | null; + public gateway: string | null; + public id: number | null; + public landing_site: string | null; + public line_items: {[key: string]: unknown} | null; + public location_id: number | null; + public note: string | null; + public phone: string | null; + public presentment_currency: string | null; + public referring_site: string | null; + public shipping_address: {[key: string]: unknown} | null; + public shipping_lines: {[key: string]: unknown} | null; + public sms_marketing_phone: string | null; + public source_name: string | null; + public subtotal_price: string | null; + public tax_lines: {[key: string]: unknown} | null; + public taxes_included: boolean | null; + public token: string | null; + public total_discounts: string | null; + public total_duties: string | null; + public total_line_items_price: string | null; + public total_price: string | null; + public total_tax: string | null; + public total_weight: number | null; + public updated_at: string | null; + public user_id: number | null; +} diff --git a/src/rest-resources/2021-07/access_scope.ts b/src/rest-resources/2021-07/access_scope.ts new file mode 100644 index 000000000..20ea85ac3 --- /dev/null +++ b/src/rest-resources/2021-07/access_scope.ts @@ -0,0 +1,39 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; +} + +export class AccessScope extends Base { + public static API_VERSION = ApiVersion.July21; + + protected static NAME = 'access_scope'; + protected static PLURAL_NAME = 'access_scopes'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static CUSTOM_PREFIX: string | null = "/admin/oauth"; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "access_scopes.json"} + ]; + + public static async all( + { + session, + ...otherArgs + }: AllArgs + ): Promise { + const response = await AccessScope.baseFind({ + session: session, + urlIds: {}, + params: {...otherArgs}, + }); + + return response as AccessScope[]; + } + + public handle: string | null; + public access_scopes: {[key: string]: unknown}[] | null; +} diff --git a/src/rest-resources/2021-07/android_pay_key.ts b/src/rest-resources/2021-07/android_pay_key.ts new file mode 100644 index 000000000..9ccd9e810 --- /dev/null +++ b/src/rest-resources/2021-07/android_pay_key.ts @@ -0,0 +1,60 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} + +export class AndroidPayKey extends Base { + public static API_VERSION = ApiVersion.July21; + + protected static NAME = 'android_pay_key'; + protected static PLURAL_NAME = 'android_pay_keys'; + 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: "get", operation: "get", ids: ["id"], path: "android_pay_keys/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "android_pay_keys/.json"} + ]; + + public static async find( + { + session, + id + }: FindArgs + ): Promise { + const result = await AndroidPayKey.baseFind({ + session: session, + urlIds: {id: id}, + params: {}, + }); + return result ? result[0] as AndroidPayKey : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await AndroidPayKey.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public id: number | null; + public public_key: string | null; +} diff --git a/src/rest-resources/2021-07/apple_pay_certificate.ts b/src/rest-resources/2021-07/apple_pay_certificate.ts new file mode 100644 index 000000000..59a08c0eb --- /dev/null +++ b/src/rest-resources/2021-07/apple_pay_certificate.ts @@ -0,0 +1,88 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface CsrArgs { + [key: string]: unknown; + session: SessionInterface; + id: number | string; +} + +export class ApplePayCertificate extends Base { + public static API_VERSION = ApiVersion.July21; + + protected static NAME = 'apple_pay_certificate'; + protected static PLURAL_NAME = 'apple_pay_certificates'; + 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/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "apple_pay_certificates/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "apple_pay_certificates/.json"}, + {http_method: "get", operation: "csr", ids: ["id"], path: "apple_pay_certificates//csr.json"} + ]; + + public static async find( + { + session, + id + }: FindArgs + ): Promise { + const result = await ApplePayCertificate.baseFind({ + session: session, + urlIds: {id: id}, + params: {}, + }); + return result ? result[0] as ApplePayCertificate : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await ApplePayCertificate.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async csr( + { + session, + id, + ...otherArgs + }: CsrArgs + ): Promise { + const response = await ApplePayCertificate.request({ + http_method: "get", + operation: "csr", + session: session, + urlIds: {id: id}, + params: {...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public id: number | null; + public merchant_id: string | null; + public status: string | null; +} diff --git a/src/rest-resources/2021-07/application_charge.ts b/src/rest-resources/2021-07/application_charge.ts new file mode 100644 index 000000000..7cd5896e8 --- /dev/null +++ b/src/rest-resources/2021-07/application_charge.ts @@ -0,0 +1,71 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + since_id?: unknown; + fields?: unknown; +} + +export class ApplicationCharge extends Base { + public static API_VERSION = ApiVersion.July21; + + protected static NAME = 'application_charge'; + protected static PLURAL_NAME = 'application_charges'; + 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: ["id"], path: "application_charges/.json"}, + {http_method: "get", operation: "get", ids: [], path: "application_charges.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await ApplicationCharge.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as ApplicationCharge : null; + } + + public static async all( + { + session, + since_id = null, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await ApplicationCharge.baseFind({ + session: session, + urlIds: {}, + params: {since_id: since_id, fields: fields, ...otherArgs}, + }); + + return response as ApplicationCharge[]; + } + + public confirmation_url: string | null; + public created_at: string | null; + public id: number | null; + public name: string | null; + public price: string | number | null; + public return_url: string | null; + public status: string | null; + public test: boolean | null; + public updated_at: string | null; +} diff --git a/src/rest-resources/2021-07/application_credit.ts b/src/rest-resources/2021-07/application_credit.ts new file mode 100644 index 000000000..9527a82c5 --- /dev/null +++ b/src/rest-resources/2021-07/application_credit.ts @@ -0,0 +1,64 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + fields?: unknown; +} + +export class ApplicationCredit extends Base { + public static API_VERSION = ApiVersion.July21; + + protected static NAME = 'application_credit'; + protected static PLURAL_NAME = 'application_credits'; + 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/.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await ApplicationCredit.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as ApplicationCredit : null; + } + + public static async all( + { + session, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await ApplicationCredit.baseFind({ + session: session, + urlIds: {}, + params: {fields: fields, ...otherArgs}, + }); + + return response as ApplicationCredit[]; + } + + public amount: number | null; + public description: string | null; + public id: number | null; + public test: boolean | null; +} diff --git a/src/rest-resources/2021-07/article.ts b/src/rest-resources/2021-07/article.ts new file mode 100644 index 000000000..20b4febe7 --- /dev/null +++ b/src/rest-resources/2021-07/article.ts @@ -0,0 +1,228 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Metafield} from './metafield'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + blog_id?: number | string | null; + fields?: unknown; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; + blog_id?: number | string | null; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + blog_id?: number | string | null; + limit?: unknown; + since_id?: unknown; + created_at_min?: unknown; + created_at_max?: unknown; + updated_at_min?: unknown; + updated_at_max?: unknown; + published_at_min?: unknown; + published_at_max?: unknown; + published_status?: unknown; + handle?: unknown; + tag?: unknown; + author?: unknown; + fields?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; + blog_id?: number | string | null; + created_at_min?: unknown; + created_at_max?: unknown; + updated_at_min?: unknown; + updated_at_max?: unknown; + published_at_min?: unknown; + 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 { + public static API_VERSION = ApiVersion.July21; + + protected static NAME = 'article'; + protected static PLURAL_NAME = 'articles'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = { + metafields: Metafield + }; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: ["blog_id"], path: "blogs//articles.json"}, + {http_method: "post", operation: "post", ids: ["blog_id"], path: "blogs//articles.json"}, + {http_method: "get", operation: "count", ids: ["blog_id"], path: "blogs//articles/count.json"}, + {http_method: "get", operation: "get", ids: ["blog_id", "id"], path: "blogs//articles/.json"}, + {http_method: "put", operation: "put", ids: ["blog_id", "id"], path: "blogs//articles/.json"}, + {http_method: "delete", operation: "delete", ids: ["blog_id", "id"], path: "blogs//articles/.json"}, + {http_method: "get", operation: "authors", ids: [], path: "articles/authors.json"}, + {http_method: "get", operation: "tags", ids: ["blog_id"], path: "blogs//articles/tags.json"}, + {http_method: "get", operation: "tags", ids: [], path: "articles/tags.json"} + ]; + + public static async find( + { + session, + id, + blog_id = null, + fields = null + }: FindArgs + ): Promise
{ + const result = await Article.baseFind({ + session: session, + urlIds: {id: id, blog_id: blog_id}, + params: {fields: fields}, + }); + return result ? result[0] as Article : null; + } + + public static async delete( + { + session, + id, + blog_id = null + }: DeleteArgs + ): Promise { + const response = await Article.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id, blog_id: blog_id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + blog_id = null, + limit = null, + since_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, + handle = null, + tag = null, + author = null, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Article.baseFind({ + session: session, + urlIds: {blog_id: blog_id}, + params: {limit: limit, since_id: since_id, 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, handle: handle, tag: tag, author: author, fields: fields, ...otherArgs}, + }); + + return response as Article[]; + } + + 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 + }: CountArgs + ): Promise { + const response = await Article.request({ + http_method: "get", + operation: "count", + 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}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public static async authors( + { + session, + ...otherArgs + }: AuthorsArgs + ): Promise { + const response = await Article.request({ + http_method: "get", + operation: "authors", + session: session, + urlIds: {}, + params: {...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public static async tags( + { + session, + blog_id = null, + limit = null, + popular = null, + ...otherArgs + }: TagsArgs + ): Promise { + const response = await Article.request({ + http_method: "get", + operation: "tags", + session: session, + urlIds: {blog_id: blog_id}, + params: {limit: limit, popular: popular, ...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public author: string | null; + public blog_id: number | null; + public body_html: string | null; + public created_at: string | null; + public handle: string | null; + public id: number | null; + public image: string | {[key: string]: unknown} | null; + public metafields: Metafield[] | null | {[key: string]: any}; + public published: boolean | null; + public published_at: string | null; + public summary_html: string | null; + public tags: string | null; + public template_suffix: string | null; + public title: string | null; + public updated_at: string | null; + public user_id: number | null; +} diff --git a/src/rest-resources/2021-07/asset.ts b/src/rest-resources/2021-07/asset.ts new file mode 100644 index 000000000..ebb8534b7 --- /dev/null +++ b/src/rest-resources/2021-07/asset.ts @@ -0,0 +1,79 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface DeleteArgs { + session: SessionInterface; + theme_id?: number | string | null; + asset?: {[key: string]: unknown} | null; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + theme_id?: number | string | null; + fields?: unknown; + asset?: {[key: string]: unknown} | null; +} + +export class Asset extends Base { + public static API_VERSION = ApiVersion.July21; + + protected static NAME = 'asset'; + protected static PLURAL_NAME = 'assets'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: ["theme_id"], path: "themes//assets.json"}, + {http_method: "put", operation: "put", ids: ["theme_id"], path: "themes//assets.json"}, + {http_method: "get", operation: "get", ids: ["theme_id"], path: "themes//assets.json"}, + {http_method: "delete", operation: "delete", ids: ["theme_id"], path: "themes//assets.json"} + ]; + protected static PRIMARY_KEY: string = "key"; + + public static async delete( + { + session, + theme_id = null, + asset = null + }: DeleteArgs + ): Promise { + const response = await Asset.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {theme_id: theme_id}, + params: {asset: asset}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + theme_id = null, + fields = null, + asset = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Asset.baseFind({ + session: session, + urlIds: {theme_id: theme_id}, + params: {fields: fields, asset: asset, ...otherArgs}, + }); + + return response as Asset[]; + } + + public attachment: string | null; + public checksum: string | null; + public content_type: string | null; + public created_at: string | null; + public key: string | null; + public public_url: string | null; + public size: number | null; + public theme_id: number | null; + public updated_at: string | null; + public value: string | null; +} diff --git a/src/rest-resources/2021-07/assigned_fulfillment_order.ts b/src/rest-resources/2021-07/assigned_fulfillment_order.ts new file mode 100644 index 000000000..6815af902 --- /dev/null +++ b/src/rest-resources/2021-07/assigned_fulfillment_order.ts @@ -0,0 +1,48 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + assignment_status?: unknown; + location_ids?: unknown[] | number | string | null; +} + +export class AssignedFulfillmentOrder extends Base { + public static API_VERSION = ApiVersion.July21; + + protected static NAME = 'assigned_fulfillment_order'; + protected static PLURAL_NAME = 'assigned_fulfillment_orders'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "assigned_fulfillment_orders.json"} + ]; + + public static async all( + { + session, + assignment_status = null, + location_ids = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await AssignedFulfillmentOrder.baseFind({ + session: session, + urlIds: {}, + params: {assignment_status: assignment_status, location_ids: location_ids, ...otherArgs}, + }); + + return response as AssignedFulfillmentOrder[]; + } + + public assigned_location_id: number | null; + public destination: {[key: string]: unknown} | null; + public id: number | null; + public line_items: {[key: string]: unknown}[] | null; + public order_id: number | null; + public request_status: string | null; + public shop_id: number | null; + public status: string | null; +} diff --git a/src/rest-resources/2021-07/balance.ts b/src/rest-resources/2021-07/balance.ts new file mode 100644 index 000000000..362a28d8e --- /dev/null +++ b/src/rest-resources/2021-07/balance.ts @@ -0,0 +1,36 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; +} + +export class Balance extends Base { + public static API_VERSION = ApiVersion.July21; + + protected static NAME = 'balance'; + protected static PLURAL_NAME = 'balances'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "shopify_payments/balance.json"} + ]; + + public static async all( + { + session, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Balance.baseFind({ + session: session, + urlIds: {}, + params: {...otherArgs}, + }); + + return response as Balance[]; + } + +} diff --git a/src/rest-resources/2021-07/blog.ts b/src/rest-resources/2021-07/blog.ts new file mode 100644 index 000000000..44353d2eb --- /dev/null +++ b/src/rest-resources/2021-07/blog.ts @@ -0,0 +1,129 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Metafield} from './metafield'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + limit?: unknown; + since_id?: unknown; + handle?: unknown; + fields?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; +} + +export class Blog extends Base { + public static API_VERSION = ApiVersion.July21; + + protected static NAME = 'blog'; + protected static PLURAL_NAME = 'blogs'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof 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: "get", operation: "count", ids: [], path: "blogs/count.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "blogs/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "blogs/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "blogs/.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await Blog.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as Blog : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await Blog.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + limit = null, + since_id = null, + handle = null, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Blog.baseFind({ + session: session, + urlIds: {}, + params: {limit: limit, since_id: since_id, handle: handle, fields: fields, ...otherArgs}, + }); + + return response as Blog[]; + } + + public static async count( + { + session, + ...otherArgs + }: CountArgs + ): Promise { + const response = await Blog.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {}, + params: {...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public admin_graphql_api_id: string | null; + public commentable: string | null; + public created_at: string | null; + public feedburner: string | null; + public feedburner_location: string | null; + public handle: string | null; + public id: number | null; + public metafields: Metafield[] | null | {[key: string]: any}; + public tags: string | null; + public template_suffix: string | null; + public title: string | null; + public updated_at: string | null; +} diff --git a/src/rest-resources/2021-07/cancellation_request.ts b/src/rest-resources/2021-07/cancellation_request.ts new file mode 100644 index 000000000..b88b8862b --- /dev/null +++ b/src/rest-resources/2021-07/cancellation_request.ts @@ -0,0 +1,69 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {ApiVersion} from '../../base-types'; + +interface AcceptArgs { + [key: string]: unknown; + message?: unknown; + body?: {[key: string]: unknown} | null; +} +interface RejectArgs { + [key: string]: unknown; + message?: unknown; + body?: {[key: string]: unknown} | null; +} + +export class CancellationRequest extends Base { + public static API_VERSION = ApiVersion.July21; + + protected static NAME = 'cancellation_request'; + protected static PLURAL_NAME = 'cancellation_requests'; + 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//cancellation_request.json"}, + {http_method: "post", operation: "accept", ids: ["fulfillment_order_id"], path: "fulfillment_orders//cancellation_request/accept.json"}, + {http_method: "post", operation: "reject", ids: ["fulfillment_order_id"], path: "fulfillment_orders//cancellation_request/reject.json"} + ]; + + public async accept( + { + message = null, + body = null, + ...otherArgs + }: AcceptArgs + ): Promise { + const response = await CancellationRequest.request({ + http_method: "post", + operation: "accept", + session: this.session, + urlIds: {fulfillment_order_id: this.fulfillment_order_id}, + params: {message: message, ...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public async reject( + { + message = null, + body = null, + ...otherArgs + }: RejectArgs + ): Promise { + const response = await CancellationRequest.request({ + http_method: "post", + operation: "reject", + session: this.session, + urlIds: {fulfillment_order_id: this.fulfillment_order_id}, + params: {message: message, ...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public fulfillment_order_id: number | null; +} diff --git a/src/rest-resources/2021-07/carrier_service.ts b/src/rest-resources/2021-07/carrier_service.ts new file mode 100644 index 000000000..14a57d9c4 --- /dev/null +++ b/src/rest-resources/2021-07/carrier_service.ts @@ -0,0 +1,87 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; +} + +export class CarrierService extends Base { + public static API_VERSION = ApiVersion.July21; + + protected static NAME = 'carrier_service'; + protected static PLURAL_NAME = 'carrier_services'; + 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: "get", operation: "get", ids: [], path: "carrier_services.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "carrier_services/.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "carrier_services/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "carrier_services/.json"} + ]; + + public static async find( + { + session, + id + }: FindArgs + ): Promise { + const result = await CarrierService.baseFind({ + session: session, + urlIds: {id: id}, + params: {}, + }); + return result ? result[0] as CarrierService : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await CarrierService.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + ...otherArgs + }: AllArgs + ): Promise { + const response = await CarrierService.baseFind({ + session: session, + urlIds: {}, + params: {...otherArgs}, + }); + + return response as CarrierService[]; + } + + public active: boolean | null; + public admin_graphql_api_id: string | null; + public callback_url: string | null; + public carrier_service_type: string | null; + public format: string | null; + public id: number | null; + public name: string | null; + public service_discovery: boolean | null; +} diff --git a/src/rest-resources/2021-07/checkout.ts b/src/rest-resources/2021-07/checkout.ts new file mode 100644 index 000000000..9be711e9d --- /dev/null +++ b/src/rest-resources/2021-07/checkout.ts @@ -0,0 +1,130 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Currency} from './currency'; +import {DiscountCode} from './discount_code'; +import {Order} from './order'; +import {GiftCard} from './gift_card'; + +interface FindArgs { + session: SessionInterface; + token: number | string; +} +interface ShippingRatesArgs { + [key: string]: unknown; + session: SessionInterface; + token: number | string; +} +interface CompleteArgs { + [key: string]: unknown; + body?: {[key: string]: unknown} | null; +} + +export class Checkout extends Base { + public static API_VERSION = ApiVersion.July21; + + protected static NAME = 'checkout'; + protected static PLURAL_NAME = 'checkouts'; + protected static HAS_ONE: {[key: string]: typeof Base} = { + currency: Currency, + discount_code: DiscountCode, + order: Order + }; + protected static HAS_MANY: {[key: string]: typeof 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//complete.json"}, + {http_method: "get", operation: "get", ids: ["token"], path: "checkouts/.json"}, + {http_method: "put", operation: "put", ids: ["token"], path: "checkouts/.json"}, + {http_method: "get", operation: "shipping_rates", ids: ["token"], path: "checkouts//shipping_rates.json"} + ]; + protected static PRIMARY_KEY: string = "token"; + + public static async find( + { + session, + token + }: FindArgs + ): Promise { + const result = await Checkout.baseFind({ + session: session, + urlIds: {token: token}, + params: {}, + }); + return result ? result[0] as Checkout : null; + } + + public static async shipping_rates( + { + session, + token, + ...otherArgs + }: ShippingRatesArgs + ): Promise { + const response = await Checkout.request({ + http_method: "get", + operation: "shipping_rates", + session: session, + urlIds: {token: token}, + params: {...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public async complete( + { + body = null, + ...otherArgs + }: CompleteArgs + ): Promise { + const response = await Checkout.request({ + http_method: "post", + operation: "complete", + session: this.session, + urlIds: {token: this.token}, + params: {...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public billing_address: {[key: string]: unknown} | null; + public line_items: {[key: string]: unknown}[] | null; + public applied_discount: {[key: string]: unknown} | null; + public buyer_accepts_marketing: boolean | null; + public created_at: string | null; + public currency: Currency | null | {[key: string]: any}; + public customer_id: number | null; + public discount_code: DiscountCode | null | {[key: string]: any}; + public email: string | null; + public gift_cards: GiftCard[] | null | {[key: string]: any}; + public order: Order | null | {[key: string]: any}; + public payment_due: string | null; + public payment_url: string | null; + public phone: string | null; + public presentment_currency: string | null; + public requires_shipping: boolean | null; + public reservation_time: string | null; + public reservation_time_left: number | null; + public shipping_address: {[key: string]: unknown} | null; + public shipping_line: {[key: string]: unknown} | null; + public shipping_rate: {[key: string]: unknown} | null; + public source_name: string | null; + public subtotal_price: string | null; + public tax_lines: {[key: string]: unknown}[] | null; + public taxes_included: boolean | null; + public token: string | null; + public total_price: string | null; + public total_tax: string | null; + public updated_at: string | null; + public user_id: number | null; + public web_url: string | null; +} diff --git a/src/rest-resources/2021-07/collect.ts b/src/rest-resources/2021-07/collect.ts new file mode 100644 index 000000000..061916e27 --- /dev/null +++ b/src/rest-resources/2021-07/collect.ts @@ -0,0 +1,117 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + limit?: unknown; + since_id?: unknown; + fields?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; +} + +export class Collect extends Base { + public static API_VERSION = ApiVersion.July21; + + protected static NAME = 'collect'; + protected static PLURAL_NAME = 'collects'; + 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/.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "collects/.json"}, + {http_method: "get", operation: "count", ids: [], path: "collects/count.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await Collect.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as Collect : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await Collect.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + limit = null, + since_id = null, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Collect.baseFind({ + session: session, + urlIds: {}, + params: {limit: limit, since_id: since_id, fields: fields, ...otherArgs}, + }); + + return response as Collect[]; + } + + public static async count( + { + session, + ...otherArgs + }: CountArgs + ): Promise { + const response = await Collect.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {}, + params: {...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public collection_id: number | null; + public created_at: string | null; + public id: number | null; + public position: number | null; + public product_id: number | null; + public sort_value: string | null; + public updated_at: string | null; +} diff --git a/src/rest-resources/2021-07/collection.ts b/src/rest-resources/2021-07/collection.ts new file mode 100644 index 000000000..0d3bef0c8 --- /dev/null +++ b/src/rest-resources/2021-07/collection.ts @@ -0,0 +1,79 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Image} from './image'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface ProductsArgs { + [key: string]: unknown; + session: SessionInterface; + id: number | string; + limit?: unknown; +} + +export class Collection extends Base { + public static API_VERSION = ApiVersion.July21; + + protected static NAME = 'collection'; + protected static PLURAL_NAME = 'collections'; + protected static HAS_ONE: {[key: string]: typeof Base} = { + image: Image + }; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: ["id"], path: "collections/.json"}, + {http_method: "get", operation: "products", ids: ["id"], path: "collections//products.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await Collection.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as Collection : null; + } + + public static async products( + { + session, + id, + limit = null, + ...otherArgs + }: ProductsArgs + ): Promise { + const response = await Collection.request({ + http_method: "get", + operation: "products", + session: session, + urlIds: {id: id}, + params: {limit: limit, ...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public title: string | null; + public body_html: string | null; + public handle: string | null; + public id: number | null; + public image: Image | null | {[key: string]: any}; + public published_at: string | null; + public published_scope: string | null; + public sort_order: string | null; + public template_suffix: string | null; + public updated_at: string | null; +} diff --git a/src/rest-resources/2021-07/collection_listing.ts b/src/rest-resources/2021-07/collection_listing.ts new file mode 100644 index 000000000..74b22c270 --- /dev/null +++ b/src/rest-resources/2021-07/collection_listing.ts @@ -0,0 +1,122 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Image} from './image'; + +interface FindArgs { + session: SessionInterface; + collection_id: number | string; +} +interface DeleteArgs { + session: SessionInterface; + collection_id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + limit?: unknown; +} +interface ProductIdsArgs { + [key: string]: unknown; + session: SessionInterface; + collection_id: number | string; + limit?: unknown; +} + +export class CollectionListing extends Base { + public static API_VERSION = ApiVersion.July21; + + protected static NAME = 'collection_listing'; + protected static PLURAL_NAME = 'collection_listings'; + protected static HAS_ONE: {[key: string]: typeof Base} = { + image: Image + }; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "collection_listings.json"}, + {http_method: "get", operation: "product_ids", ids: ["collection_id"], path: "collection_listings//product_ids.json"}, + {http_method: "get", operation: "get", ids: ["collection_id"], path: "collection_listings/.json"}, + {http_method: "put", operation: "put", ids: ["collection_id"], path: "collection_listings/.json"}, + {http_method: "delete", operation: "delete", ids: ["collection_id"], path: "collection_listings/.json"} + ]; + protected static PRIMARY_KEY: string = "collection_id"; + + public static async find( + { + session, + collection_id + }: FindArgs + ): Promise { + const result = await CollectionListing.baseFind({ + session: session, + urlIds: {collection_id: collection_id}, + params: {}, + }); + return result ? result[0] as CollectionListing : null; + } + + public static async delete( + { + session, + collection_id + }: DeleteArgs + ): Promise { + const response = await CollectionListing.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {collection_id: collection_id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + limit = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await CollectionListing.baseFind({ + session: session, + urlIds: {}, + params: {limit: limit, ...otherArgs}, + }); + + return response as CollectionListing[]; + } + + public static async product_ids( + { + session, + collection_id, + limit = null, + ...otherArgs + }: ProductIdsArgs + ): Promise { + const response = await CollectionListing.request({ + http_method: "get", + operation: "product_ids", + session: session, + urlIds: {collection_id: collection_id}, + params: {limit: limit, ...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public body_html: string | null; + public collection_id: number | null; + public default_product_image: {[key: string]: unknown}[] | null; + public handle: string | null; + public image: Image | null | {[key: string]: any}; + public published_at: string | null; + public sort_order: string | null; + public title: string | null; + public updated_at: string | null; +} diff --git a/src/rest-resources/2021-07/comment.ts b/src/rest-resources/2021-07/comment.ts new file mode 100644 index 000000000..953091f7d --- /dev/null +++ b/src/rest-resources/2021-07/comment.ts @@ -0,0 +1,254 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + limit?: unknown; + since_id?: unknown; + created_at_min?: unknown; + created_at_max?: unknown; + updated_at_min?: unknown; + updated_at_max?: unknown; + published_at_min?: unknown; + published_at_max?: unknown; + fields?: unknown; + published_status?: unknown; + status?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; + created_at_min?: unknown; + created_at_max?: unknown; + updated_at_min?: unknown; + updated_at_max?: unknown; + published_at_min?: unknown; + published_at_max?: unknown; + published_status?: unknown; + status?: unknown; +} +interface SpamArgs { + [key: string]: unknown; + body?: {[key: string]: unknown} | null; +} +interface NotSpamArgs { + [key: string]: unknown; + body?: {[key: string]: unknown} | null; +} +interface ApproveArgs { + [key: string]: unknown; + body?: {[key: string]: unknown} | null; +} +interface RemoveArgs { + [key: string]: unknown; + body?: {[key: string]: unknown} | null; +} +interface RestoreArgs { + [key: string]: unknown; + body?: {[key: string]: unknown} | null; +} + +export class Comment extends Base { + public static API_VERSION = ApiVersion.July21; + + protected static NAME = 'comment'; + protected static PLURAL_NAME = 'comments'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "comments.json"}, + {http_method: "get", operation: "count", ids: [], path: "comments/count.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "comments/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "comments/.json"}, + {http_method: "post", operation: "post", ids: [], path: "comments.json"}, + {http_method: "post", operation: "spam", ids: ["id"], path: "comments//spam.json"}, + {http_method: "post", operation: "not_spam", ids: ["id"], path: "comments//not_spam.json"}, + {http_method: "post", operation: "approve", ids: ["id"], path: "comments//approve.json"}, + {http_method: "post", operation: "remove", ids: ["id"], path: "comments//remove.json"}, + {http_method: "post", operation: "restore", ids: ["id"], path: "comments//restore.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await Comment.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as Comment : null; + } + + public static async all( + { + session, + limit = null, + since_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, + fields = null, + published_status = null, + status = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Comment.baseFind({ + session: session, + urlIds: {}, + params: {limit: limit, since_id: since_id, 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, fields: fields, published_status: published_status, status: status, ...otherArgs}, + }); + + return response as Comment[]; + } + + public static async count( + { + session, + 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, + status = null, + ...otherArgs + }: CountArgs + ): Promise { + const response = await Comment.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {}, + 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, status: status, ...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public async spam( + { + body = null, + ...otherArgs + }: SpamArgs + ): Promise { + const response = await Comment.request({ + http_method: "post", + operation: "spam", + session: this.session, + urlIds: {id: this.id}, + params: {...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public async not_spam( + { + body = null, + ...otherArgs + }: NotSpamArgs + ): Promise { + const response = await Comment.request({ + http_method: "post", + operation: "not_spam", + session: this.session, + urlIds: {id: this.id}, + params: {...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public async approve( + { + body = null, + ...otherArgs + }: ApproveArgs + ): Promise { + const response = await Comment.request({ + http_method: "post", + operation: "approve", + session: this.session, + urlIds: {id: this.id}, + params: {...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public async remove( + { + body = null, + ...otherArgs + }: RemoveArgs + ): Promise { + const response = await Comment.request({ + http_method: "post", + operation: "remove", + session: this.session, + urlIds: {id: this.id}, + params: {...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public async restore( + { + body = null, + ...otherArgs + }: RestoreArgs + ): Promise { + const response = await Comment.request({ + http_method: "post", + operation: "restore", + session: this.session, + urlIds: {id: this.id}, + params: {...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public article_id: number | null; + public author: string | null; + public blog_id: number | null; + public body: string | null; + public body_html: string | null; + public created_at: string | null; + public email: string | null; + public id: number | null; + public ip: string | null; + public published_at: string | null; + public status: string | null; + public updated_at: string | null; + public user_agent: string | null; +} diff --git a/src/rest-resources/2021-07/country.ts b/src/rest-resources/2021-07/country.ts new file mode 100644 index 000000000..c7f03a0c0 --- /dev/null +++ b/src/rest-resources/2021-07/country.ts @@ -0,0 +1,118 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Province} from './province'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + since_id?: unknown; + fields?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; +} + +export class Country extends Base { + public static API_VERSION = ApiVersion.July21; + + protected static NAME = 'country'; + protected static PLURAL_NAME = 'countries'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = { + provinces: Province + }; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "countries.json"}, + {http_method: "post", operation: "post", ids: [], path: "countries.json"}, + {http_method: "get", operation: "count", ids: [], path: "countries/count.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "countries/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "countries/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "countries/.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await Country.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as Country : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await Country.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + since_id = null, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Country.baseFind({ + session: session, + urlIds: {}, + params: {since_id: since_id, fields: fields, ...otherArgs}, + }); + + return response as Country[]; + } + + public static async count( + { + session, + ...otherArgs + }: CountArgs + ): Promise { + const response = await Country.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {}, + params: {...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public code: string | null; + public id: number | null; + public name: string | null; + public provinces: Province[] | null | {[key: string]: any}; + public tax: number | null; +} diff --git a/src/rest-resources/2021-07/currency.ts b/src/rest-resources/2021-07/currency.ts new file mode 100644 index 000000000..886ec2d6d --- /dev/null +++ b/src/rest-resources/2021-07/currency.ts @@ -0,0 +1,38 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; +} + +export class Currency extends Base { + public static API_VERSION = ApiVersion.July21; + + protected static NAME = 'currency'; + protected static PLURAL_NAME = 'currencies'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "currencies.json"} + ]; + + public static async all( + { + session, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Currency.baseFind({ + session: session, + urlIds: {}, + params: {...otherArgs}, + }); + + return response as Currency[]; + } + + public currency: string | null; + public rate_updated_at: string | null; +} diff --git a/src/rest-resources/2021-07/custom_collection.ts b/src/rest-resources/2021-07/custom_collection.ts new file mode 100644 index 000000000..e187530ff --- /dev/null +++ b/src/rest-resources/2021-07/custom_collection.ts @@ -0,0 +1,154 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + limit?: unknown; + ids?: unknown; + since_id?: unknown; + title?: unknown; + product_id?: unknown; + handle?: unknown; + updated_at_min?: unknown; + updated_at_max?: unknown; + published_at_min?: unknown; + published_at_max?: unknown; + published_status?: unknown; + fields?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; + title?: unknown; + product_id?: unknown; + updated_at_min?: unknown; + updated_at_max?: unknown; + published_at_min?: unknown; + published_at_max?: unknown; + published_status?: unknown; +} + +export class CustomCollection extends Base { + public static API_VERSION = ApiVersion.July21; + + protected static NAME = 'custom_collection'; + protected static PLURAL_NAME = 'custom_collections'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "custom_collections.json"}, + {http_method: "post", operation: "post", ids: [], path: "custom_collections.json"}, + {http_method: "get", operation: "count", ids: [], path: "custom_collections/count.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "custom_collections/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "custom_collections/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "custom_collections/.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await CustomCollection.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as CustomCollection : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await CustomCollection.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + limit = null, + ids = null, + since_id = null, + title = null, + product_id = null, + handle = null, + updated_at_min = null, + updated_at_max = null, + published_at_min = null, + published_at_max = null, + published_status = null, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await CustomCollection.baseFind({ + session: session, + urlIds: {}, + params: {limit: limit, ids: ids, since_id: since_id, title: title, product_id: product_id, handle: handle, 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, fields: fields, ...otherArgs}, + }); + + return response as CustomCollection[]; + } + + public static async count( + { + session, + title = null, + product_id = null, + updated_at_min = null, + updated_at_max = null, + published_at_min = null, + published_at_max = null, + published_status = null, + ...otherArgs + }: CountArgs + ): Promise { + const response = await CustomCollection.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {}, + params: {title: title, product_id: product_id, 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, + }); + + return response ? response.body : null; + } + + public title: string | null; + public body_html: string | null; + public handle: string | null; + public id: number | null; + public image: string | {[key: string]: unknown} | null; + public published: boolean | null; + public published_at: string | null; + public published_scope: string | null; + public sort_order: string | null; + public template_suffix: string | null; + public updated_at: string | null; +} diff --git a/src/rest-resources/2021-07/customer.ts b/src/rest-resources/2021-07/customer.ts new file mode 100644 index 000000000..8c58b8d9b --- /dev/null +++ b/src/rest-resources/2021-07/customer.ts @@ -0,0 +1,258 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Currency} from './currency'; +import {Metafield} from './metafield'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + ids?: unknown; + since_id?: unknown; + created_at_min?: unknown; + created_at_max?: unknown; + updated_at_min?: unknown; + updated_at_max?: unknown; + limit?: unknown; + fields?: unknown; +} +interface SearchArgs { + [key: string]: unknown; + session: SessionInterface; + order?: unknown; + query?: unknown; + limit?: unknown; + fields?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; +} +interface OrdersArgs { + [key: string]: unknown; + session: SessionInterface; + id: number | string; +} +interface AccountActivationUrlArgs { + [key: string]: unknown; + body?: {[key: string]: unknown} | null; +} +interface SendInviteArgs { + [key: string]: unknown; + body?: {[key: string]: unknown} | null; +} + +export class Customer extends Base { + public static API_VERSION = ApiVersion.July21; + + protected static NAME = 'customer'; + protected static PLURAL_NAME = 'customers'; + protected static HAS_ONE: {[key: string]: typeof Base} = { + currency: Currency, + metafield: Metafield + }; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "customers.json"}, + {http_method: "post", operation: "post", ids: [], path: "customers.json"}, + {http_method: "get", operation: "search", ids: [], path: "customers/search.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "customers/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "customers/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "customers/.json"}, + {http_method: "post", operation: "account_activation_url", ids: ["id"], path: "customers//account_activation_url.json"}, + {http_method: "post", operation: "send_invite", ids: ["id"], path: "customers//send_invite.json"}, + {http_method: "get", operation: "count", ids: [], path: "customers/count.json"}, + {http_method: "get", operation: "orders", ids: ["id"], path: "customers//orders.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await Customer.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as Customer : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await Customer.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + ids = null, + since_id = null, + created_at_min = null, + created_at_max = null, + updated_at_min = null, + updated_at_max = null, + limit = null, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Customer.baseFind({ + session: session, + urlIds: {}, + params: {ids: ids, since_id: since_id, created_at_min: created_at_min, created_at_max: created_at_max, updated_at_min: updated_at_min, updated_at_max: updated_at_max, limit: limit, fields: fields, ...otherArgs}, + }); + + return response as Customer[]; + } + + public static async search( + { + session, + order = null, + query = null, + limit = null, + fields = null, + ...otherArgs + }: SearchArgs + ): Promise { + const response = await Customer.request({ + http_method: "get", + operation: "search", + session: session, + urlIds: {}, + params: {order: order, query: query, limit: limit, fields: fields, ...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public static async count( + { + session, + ...otherArgs + }: CountArgs + ): Promise { + const response = await Customer.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {}, + params: {...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public static async orders( + { + session, + id, + ...otherArgs + }: OrdersArgs + ): Promise { + const response = await Customer.request({ + http_method: "get", + operation: "orders", + session: session, + urlIds: {id: id}, + params: {...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public async account_activation_url( + { + body = null, + ...otherArgs + }: AccountActivationUrlArgs + ): Promise { + const response = await Customer.request({ + http_method: "post", + operation: "account_activation_url", + session: this.session, + urlIds: {id: this.id}, + params: {...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public async send_invite( + { + body = null, + ...otherArgs + }: SendInviteArgs + ): Promise { + const response = await Customer.request({ + http_method: "post", + operation: "send_invite", + session: this.session, + urlIds: {id: this.id}, + params: {...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public accepts_marketing: boolean | null; + public accepts_marketing_updated_at: string | null; + public addresses: {[key: string]: unknown}[] | null; + public created_at: string | null; + public currency: Currency | null | {[key: string]: any}; + public default_address: {[key: string]: unknown} | null; + public email: string | null; + public first_name: string | null; + public id: number | null; + public last_name: string | null; + public last_order_id: number | null; + public last_order_name: string | null; + public marketing_opt_in_level: string | null; + public metafield: Metafield | null | {[key: string]: any}; + public multipass_identifier: string | null; + public note: string | null; + public orders_count: number | null; + public phone: string | null; + public state: string | null; + public tags: string | null; + public tax_exempt: boolean | null; + public tax_exemptions: string[] | null; + public total_spent: string | null; + public updated_at: string | null; + public verified_email: boolean | null; +} diff --git a/src/rest-resources/2021-07/customer_address.ts b/src/rest-resources/2021-07/customer_address.ts new file mode 100644 index 000000000..5072ce2e5 --- /dev/null +++ b/src/rest-resources/2021-07/customer_address.ts @@ -0,0 +1,158 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + customer_id?: number | string | null; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; + customer_id?: number | string | null; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + customer_id?: number | string | null; +} +interface SetArgs { + [key: string]: unknown; + address_ids?: unknown[] | number | string | null; + operation?: unknown; + body?: {[key: string]: unknown} | null; +} +interface DefaultArgs { + [key: string]: unknown; + body?: {[key: string]: unknown} | null; +} + +export class CustomerAddress extends Base { + public static API_VERSION = ApiVersion.July21; + + protected static NAME = 'customer_address'; + protected static PLURAL_NAME = 'customer_addresses'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: ["customer_id"], path: "customers//addresses.json"}, + {http_method: "post", operation: "post", ids: ["customer_id"], path: "customers//addresses.json"}, + {http_method: "get", operation: "get", ids: ["customer_id", "id"], path: "customers//addresses/.json"}, + {http_method: "put", operation: "put", ids: ["customer_id", "id"], path: "customers//addresses/.json"}, + {http_method: "delete", operation: "delete", ids: ["customer_id", "id"], path: "customers//addresses/.json"}, + {http_method: "put", operation: "set", ids: ["customer_id"], path: "customers//addresses/set.json"}, + {http_method: "put", operation: "default", ids: ["customer_id", "id"], path: "customers//addresses//default.json"} + ]; + + protected static getJsonBodyName(): string + { + return "address"; + } + + public static async find( + { + session, + id, + customer_id = null + }: FindArgs + ): Promise { + const result = await CustomerAddress.baseFind({ + session: session, + urlIds: {id: id, customer_id: customer_id}, + params: {}, + }); + return result ? result[0] as CustomerAddress : null; + } + + public static async delete( + { + session, + id, + customer_id = null + }: DeleteArgs + ): Promise { + const response = await CustomerAddress.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id, customer_id: customer_id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + customer_id = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await CustomerAddress.baseFind({ + session: session, + urlIds: {customer_id: customer_id}, + params: {...otherArgs}, + }); + + return response as CustomerAddress[]; + } + + public async set( + { + address_ids = null, + operation = null, + body = null, + ...otherArgs + }: SetArgs + ): Promise { + const response = await CustomerAddress.request({ + http_method: "put", + operation: "set", + session: this.session, + urlIds: {customer_id: this.customer_id}, + params: {address_ids: address_ids, operation: operation, ...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public async default( + { + body = null, + ...otherArgs + }: DefaultArgs + ): Promise { + const response = await CustomerAddress.request({ + http_method: "put", + operation: "default", + session: this.session, + urlIds: {id: this.id, customer_id: this.customer_id}, + params: {...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public address1: string | null; + public address2: string | null; + public city: string | null; + public company: string | null; + public country: string | null; + public country_code: string | null; + public country_name: string | null; + public customer_id: number | null; + public first_name: string | null; + public id: number | null; + public last_name: string | null; + public name: string | null; + public phone: string | null; + public province: string | null; + public province_code: string | null; + public zip: string | null; +} diff --git a/src/rest-resources/2021-07/customer_saved_search.ts b/src/rest-resources/2021-07/customer_saved_search.ts new file mode 100644 index 000000000..5ecba45c0 --- /dev/null +++ b/src/rest-resources/2021-07/customer_saved_search.ts @@ -0,0 +1,150 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + limit?: unknown; + since_id?: unknown; + fields?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; + since_id?: unknown; +} +interface CustomersArgs { + [key: string]: unknown; + session: SessionInterface; + id: number | string; + order?: unknown; + limit?: unknown; + fields?: unknown; +} + +export class CustomerSavedSearch extends Base { + public static API_VERSION = ApiVersion.July21; + + protected static NAME = 'customer_saved_search'; + protected static PLURAL_NAME = 'customer_saved_searches'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "customer_saved_searches.json"}, + {http_method: "post", operation: "post", ids: [], path: "customer_saved_searches.json"}, + {http_method: "get", operation: "count", ids: [], path: "customer_saved_searches/count.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "customer_saved_searches/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "customer_saved_searches/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "customer_saved_searches/.json"}, + {http_method: "get", operation: "customers", ids: ["id"], path: "customer_saved_searches//customers.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await CustomerSavedSearch.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as CustomerSavedSearch : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await CustomerSavedSearch.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + limit = null, + since_id = null, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await CustomerSavedSearch.baseFind({ + session: session, + urlIds: {}, + params: {limit: limit, since_id: since_id, fields: fields, ...otherArgs}, + }); + + return response as CustomerSavedSearch[]; + } + + public static async count( + { + session, + since_id = null, + ...otherArgs + }: CountArgs + ): Promise { + const response = await CustomerSavedSearch.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {}, + params: {since_id: since_id, ...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public static async customers( + { + session, + id, + order = null, + limit = null, + fields = null, + ...otherArgs + }: CustomersArgs + ): Promise { + const response = await CustomerSavedSearch.request({ + http_method: "get", + operation: "customers", + session: session, + urlIds: {id: id}, + params: {order: order, limit: limit, fields: fields, ...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public created_at: string | null; + public id: number | null; + public name: string | null; + public query: string | null; + public updated_at: string | null; +} diff --git a/src/rest-resources/2021-07/deprecated_api_call.ts b/src/rest-resources/2021-07/deprecated_api_call.ts new file mode 100644 index 000000000..9514113c6 --- /dev/null +++ b/src/rest-resources/2021-07/deprecated_api_call.ts @@ -0,0 +1,38 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; +} + +export class DeprecatedApiCall extends Base { + public static API_VERSION = ApiVersion.July21; + + protected static NAME = 'deprecated_api_call'; + protected static PLURAL_NAME = 'deprecated_api_calls'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "deprecated_api_calls.json"} + ]; + + public static async all( + { + session, + ...otherArgs + }: AllArgs + ): Promise { + const response = await DeprecatedApiCall.baseFind({ + session: session, + urlIds: {}, + params: {...otherArgs}, + }); + + return response as DeprecatedApiCall[]; + } + + public data_updated_at: string | null; + public deprecated_api_calls: {[key: string]: unknown}[] | null; +} diff --git a/src/rest-resources/2021-07/discount_code.ts b/src/rest-resources/2021-07/discount_code.ts new file mode 100644 index 000000000..ef80d541a --- /dev/null +++ b/src/rest-resources/2021-07/discount_code.ts @@ -0,0 +1,202 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + price_rule_id?: number | string | null; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; + price_rule_id?: number | string | null; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + price_rule_id?: number | string | null; + batch_id?: number | string | null; +} +interface LookupArgs { + [key: string]: unknown; + session: SessionInterface; + code?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; + times_used?: unknown; + times_used_min?: unknown; + times_used_max?: unknown; +} +interface GetAllArgs { + [key: string]: unknown; + session: SessionInterface; + price_rule_id?: number | string | null; + batch_id?: number | string | null; +} +interface BatchArgs { + [key: string]: unknown; + body?: {[key: string]: unknown} | null; +} + +export class DiscountCode extends Base { + public static API_VERSION = ApiVersion.July21; + + protected static NAME = 'discount_code'; + protected static PLURAL_NAME = 'discount_codes'; + 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: ["price_rule_id"], path: "price_rules//discount_codes.json"}, + {http_method: "get", operation: "get", ids: ["price_rule_id"], path: "price_rules//discount_codes.json"}, + {http_method: "put", operation: "put", ids: ["price_rule_id", "id"], path: "price_rules//discount_codes/.json"}, + {http_method: "get", operation: "get", ids: ["price_rule_id", "id"], path: "price_rules//discount_codes/.json"}, + {http_method: "delete", operation: "delete", ids: ["price_rule_id", "id"], path: "price_rules//discount_codes/.json"}, + {http_method: "get", operation: "lookup", ids: [], path: "discount_codes/lookup.json"}, + {http_method: "get", operation: "count", ids: [], path: "discount_codes/count.json"}, + {http_method: "post", operation: "batch", ids: ["price_rule_id"], path: "price_rules//batch.json"}, + {http_method: "get", operation: "get_all", ids: ["price_rule_id", "batch_id"], path: "price_rules//batch/.json"}, + {http_method: "get", operation: "get", ids: ["price_rule_id", "batch_id"], path: "price_rules//batch//discount_codes.json"} + ]; + + public static async find( + { + session, + id, + price_rule_id = null + }: FindArgs + ): Promise { + const result = await DiscountCode.baseFind({ + session: session, + urlIds: {id: id, price_rule_id: price_rule_id}, + params: {}, + }); + return result ? result[0] as DiscountCode : null; + } + + public static async delete( + { + session, + id, + price_rule_id = null + }: DeleteArgs + ): Promise { + const response = await DiscountCode.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id, price_rule_id: price_rule_id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + price_rule_id = null, + batch_id = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await DiscountCode.baseFind({ + session: session, + urlIds: {price_rule_id: price_rule_id, batch_id: batch_id}, + params: {...otherArgs}, + }); + + return response as DiscountCode[]; + } + + public static async lookup( + { + session, + code = null, + ...otherArgs + }: LookupArgs + ): Promise { + const response = await DiscountCode.request({ + http_method: "get", + operation: "lookup", + session: session, + urlIds: {}, + params: {code: code, ...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public static async count( + { + session, + times_used = null, + times_used_min = null, + times_used_max = null, + ...otherArgs + }: CountArgs + ): Promise { + const response = await DiscountCode.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {}, + params: {times_used: times_used, times_used_min: times_used_min, times_used_max: times_used_max, ...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public static async get_all( + { + session, + price_rule_id = null, + batch_id = null, + ...otherArgs + }: GetAllArgs + ): Promise { + const response = await DiscountCode.request({ + http_method: "get", + operation: "get_all", + session: session, + urlIds: {price_rule_id: price_rule_id, batch_id: batch_id}, + params: {...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public async batch( + { + body = null, + ...otherArgs + }: BatchArgs + ): Promise { + const response = await DiscountCode.request({ + http_method: "post", + operation: "batch", + session: this.session, + urlIds: {price_rule_id: this.price_rule_id}, + params: {...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public code: string | null; + public created_at: string | null; + public id: number | null; + public price_rule_id: number | null; + public updated_at: string | null; + public usage_count: number | null; +} diff --git a/src/rest-resources/2021-07/dispute.ts b/src/rest-resources/2021-07/dispute.ts new file mode 100644 index 000000000..8cb5606dc --- /dev/null +++ b/src/rest-resources/2021-07/dispute.ts @@ -0,0 +1,78 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Currency} from './currency'; + +interface FindArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + since_id?: unknown; + last_id?: unknown; + status?: unknown; + initiated_at?: unknown; +} + +export class Dispute extends Base { + public static API_VERSION = ApiVersion.July21; + + protected static NAME = 'dispute'; + protected static PLURAL_NAME = 'disputes'; + protected static HAS_ONE: {[key: string]: typeof Base} = { + currency: Currency + }; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "shopify_payments/disputes.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "shopify_payments/disputes/.json"} + ]; + + public static async find( + { + session, + id + }: FindArgs + ): Promise { + const result = await Dispute.baseFind({ + session: session, + urlIds: {id: id}, + params: {}, + }); + return result ? result[0] as Dispute : null; + } + + public static async all( + { + session, + since_id = null, + last_id = null, + status = null, + initiated_at = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Dispute.baseFind({ + session: session, + urlIds: {}, + params: {since_id: since_id, last_id: last_id, status: status, initiated_at: initiated_at, ...otherArgs}, + }); + + return response as Dispute[]; + } + + public amount: string | null; + public currency: Currency | null | {[key: string]: any}; + public evidence_due_by: string | null; + public evidence_sent_on: string | null; + public finalized_on: string | null; + public id: number | null; + public network_reason_code: number | null; + public order_id: number | null; + public reason: string | null; + public status: string | null; + public type: string | null; +} diff --git a/src/rest-resources/2021-07/draft_order.ts b/src/rest-resources/2021-07/draft_order.ts new file mode 100644 index 000000000..f75024822 --- /dev/null +++ b/src/rest-resources/2021-07/draft_order.ts @@ -0,0 +1,210 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Customer} from './customer'; +import {Currency} from './currency'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + fields?: unknown; + limit?: unknown; + since_id?: unknown; + updated_at_min?: unknown; + updated_at_max?: unknown; + ids?: unknown; + status?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; + since_id?: unknown; + status?: unknown; + updated_at_max?: unknown; + updated_at_min?: unknown; +} +interface SendInvoiceArgs { + [key: string]: unknown; + body?: {[key: string]: unknown} | null; +} +interface CompleteArgs { + [key: string]: unknown; + payment_pending?: unknown; + body?: {[key: string]: unknown} | null; +} + +export class DraftOrder extends Base { + public static API_VERSION = ApiVersion.July21; + + protected static NAME = 'draft_order'; + protected static PLURAL_NAME = 'draft_orders'; + protected static HAS_ONE: {[key: string]: typeof Base} = { + customer: Customer, + currency: Currency + }; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "post", operation: "post", ids: [], path: "draft_orders.json"}, + {http_method: "get", operation: "get", ids: [], path: "draft_orders.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "draft_orders/.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "draft_orders/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "draft_orders/.json"}, + {http_method: "get", operation: "count", ids: [], path: "draft_orders/count.json"}, + {http_method: "post", operation: "send_invoice", ids: ["id"], path: "draft_orders//send_invoice.json"}, + {http_method: "put", operation: "complete", ids: ["id"], path: "draft_orders//complete.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await DraftOrder.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as DraftOrder : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await DraftOrder.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + fields = null, + limit = null, + since_id = null, + updated_at_min = null, + updated_at_max = null, + ids = null, + status = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await DraftOrder.baseFind({ + session: session, + urlIds: {}, + params: {fields: fields, limit: limit, since_id: since_id, updated_at_min: updated_at_min, updated_at_max: updated_at_max, ids: ids, status: status, ...otherArgs}, + }); + + return response as DraftOrder[]; + } + + public static async count( + { + session, + since_id = null, + status = null, + updated_at_max = null, + updated_at_min = null, + ...otherArgs + }: CountArgs + ): Promise { + const response = await DraftOrder.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {}, + params: {since_id: since_id, status: status, updated_at_max: updated_at_max, updated_at_min: updated_at_min, ...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public async send_invoice( + { + body = null, + ...otherArgs + }: SendInvoiceArgs + ): Promise { + const response = await DraftOrder.request({ + http_method: "post", + operation: "send_invoice", + session: this.session, + urlIds: {id: this.id}, + params: {...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public async complete( + { + payment_pending = null, + body = null, + ...otherArgs + }: CompleteArgs + ): Promise { + const response = await DraftOrder.request({ + http_method: "put", + operation: "complete", + session: this.session, + urlIds: {id: this.id}, + params: {payment_pending: payment_pending, ...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public applied_discount: {[key: string]: unknown} | null; + public billing_address: {[key: string]: unknown} | null; + public completed_at: string | null; + public created_at: string | null; + public currency: Currency | null | {[key: string]: any}; + public customer: Customer | null | {[key: string]: any}; + public email: string | null; + public id: number | null; + public invoice_sent_at: string | null; + public invoice_url: string | null; + public line_items: {[key: string]: unknown}[] | null; + public name: string | null; + public note: string | null; + public note_attributes: {[key: string]: unknown}[] | null; + public order_id: number | null; + public shipping_address: {[key: string]: unknown} | null; + public shipping_line: {[key: string]: unknown} | null; + public status: string | null; + public subtotal_price: number | null; + public tags: string | null; + public tax_exempt: boolean | null; + public tax_exemptions: string[] | null; + public tax_lines: {[key: string]: unknown}[] | null; + public taxes_included: boolean | null; + public total_price: string | null; + public total_tax: string | null; + public updated_at: string | null; +} diff --git a/src/rest-resources/2021-07/event.ts b/src/rest-resources/2021-07/event.ts new file mode 100644 index 000000000..7b7ae1329 --- /dev/null +++ b/src/rest-resources/2021-07/event.ts @@ -0,0 +1,115 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + order_id?: number | string | null; + product_id?: number | string | null; + limit?: unknown; + since_id?: unknown; + created_at_min?: unknown; + created_at_max?: unknown; + filter?: unknown; + verb?: unknown; + fields?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; + created_at_min?: unknown; + created_at_max?: unknown; +} + +export class Event extends Base { + public static API_VERSION = ApiVersion.July21; + + protected static NAME = 'event'; + protected static PLURAL_NAME = 'events'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "events.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "events/.json"}, + {http_method: "get", operation: "count", ids: [], path: "events/count.json"}, + {http_method: "get", operation: "get", ids: ["order_id"], path: "orders//events.json"}, + {http_method: "get", operation: "get", ids: ["product_id"], path: "products//events.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await Event.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as Event : null; + } + + public static async all( + { + session, + order_id = null, + product_id = null, + limit = null, + since_id = null, + created_at_min = null, + created_at_max = null, + filter = null, + verb = null, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Event.baseFind({ + session: session, + urlIds: {order_id: order_id, product_id: product_id}, + params: {limit: limit, since_id: since_id, created_at_min: created_at_min, created_at_max: created_at_max, filter: filter, verb: verb, fields: fields, ...otherArgs}, + }); + + return response as Event[]; + } + + public static async count( + { + session, + created_at_min = null, + created_at_max = null, + ...otherArgs + }: CountArgs + ): Promise { + const response = await Event.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {}, + params: {created_at_min: created_at_min, created_at_max: created_at_max, ...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public arguments: string | null; + public body: string | null; + public created_at: string | null; + public description: string | null; + public id: number | null; + public message: string | null; + public path: string | null; + public subject_id: number | null; + public subject_type: string | null; + public verb: string | null; +} diff --git a/src/rest-resources/2021-07/fulfillment.ts b/src/rest-resources/2021-07/fulfillment.ts new file mode 100644 index 000000000..eeec6ac4e --- /dev/null +++ b/src/rest-resources/2021-07/fulfillment.ts @@ -0,0 +1,228 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + order_id?: number | string | null; + fields?: unknown; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + order_id?: number | string | null; + fulfillment_order_id?: number | string | null; + created_at_max?: unknown; + created_at_min?: unknown; + fields?: unknown; + limit?: unknown; + since_id?: unknown; + updated_at_max?: unknown; + updated_at_min?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; + order_id?: number | string | null; + created_at_min?: unknown; + created_at_max?: unknown; + updated_at_min?: unknown; + updated_at_max?: unknown; +} +interface UpdateTrackingArgs { + [key: string]: unknown; + body?: {[key: string]: unknown} | null; +} +interface CompleteArgs { + [key: string]: unknown; + body?: {[key: string]: unknown} | null; +} +interface OpenArgs { + [key: string]: unknown; + body?: {[key: string]: unknown} | null; +} +interface CancelArgs { + [key: string]: unknown; + body?: {[key: string]: unknown} | null; +} + +export class Fulfillment extends Base { + public static API_VERSION = ApiVersion.July21; + + protected static NAME = 'fulfillment'; + protected static PLURAL_NAME = 'fulfillments'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: ["order_id"], path: "orders//fulfillments.json"}, + {http_method: "post", operation: "post", ids: ["order_id"], path: "orders//fulfillments.json"}, + {http_method: "get", operation: "get", ids: ["fulfillment_order_id"], path: "fulfillment_orders//fulfillments.json"}, + {http_method: "get", operation: "count", ids: ["order_id"], path: "orders//fulfillments/count.json"}, + {http_method: "get", operation: "get", ids: ["order_id", "id"], path: "orders//fulfillments/.json"}, + {http_method: "put", operation: "put", ids: ["order_id", "id"], path: "orders//fulfillments/.json"}, + {http_method: "post", operation: "post", ids: [], path: "fulfillments.json"}, + {http_method: "post", operation: "update_tracking", ids: ["id"], path: "fulfillments//update_tracking.json"}, + {http_method: "post", operation: "complete", ids: ["order_id", "id"], path: "orders//fulfillments//complete.json"}, + {http_method: "post", operation: "open", ids: ["order_id", "id"], path: "orders//fulfillments//open.json"}, + {http_method: "post", operation: "cancel", ids: ["order_id", "id"], path: "orders//fulfillments//cancel.json"}, + {http_method: "post", operation: "cancel", ids: ["id"], path: "fulfillments//cancel.json"} + ]; + + public static async find( + { + session, + id, + order_id = null, + fields = null + }: FindArgs + ): Promise { + const result = await Fulfillment.baseFind({ + session: session, + urlIds: {id: id, order_id: order_id}, + params: {fields: fields}, + }); + return result ? result[0] as Fulfillment : null; + } + + public static async all( + { + session, + order_id = null, + fulfillment_order_id = null, + created_at_max = null, + created_at_min = null, + fields = null, + limit = null, + since_id = null, + updated_at_max = null, + updated_at_min = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Fulfillment.baseFind({ + session: session, + urlIds: {order_id: order_id, fulfillment_order_id: fulfillment_order_id}, + params: {created_at_max: created_at_max, created_at_min: created_at_min, fields: fields, limit: limit, since_id: since_id, updated_at_max: updated_at_max, updated_at_min: updated_at_min, ...otherArgs}, + }); + + return response as Fulfillment[]; + } + + public static async count( + { + session, + order_id = null, + created_at_min = null, + created_at_max = null, + updated_at_min = null, + updated_at_max = null, + ...otherArgs + }: CountArgs + ): Promise { + const response = await Fulfillment.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {order_id: order_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, ...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public async update_tracking( + { + body = null, + ...otherArgs + }: UpdateTrackingArgs + ): Promise { + const response = await Fulfillment.request({ + http_method: "post", + operation: "update_tracking", + session: this.session, + urlIds: {id: this.id}, + params: {...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public async complete( + { + body = null, + ...otherArgs + }: CompleteArgs + ): Promise { + const response = await Fulfillment.request({ + http_method: "post", + operation: "complete", + session: this.session, + urlIds: {id: this.id, order_id: this.order_id}, + params: {...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public async open( + { + body = null, + ...otherArgs + }: OpenArgs + ): Promise { + const response = await Fulfillment.request({ + http_method: "post", + operation: "open", + session: this.session, + urlIds: {id: this.id, order_id: this.order_id}, + params: {...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public async cancel( + { + body = null, + ...otherArgs + }: CancelArgs + ): Promise { + const response = await Fulfillment.request({ + http_method: "post", + operation: "cancel", + session: this.session, + urlIds: {id: this.id, order_id: this.order_id}, + params: {...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public created_at: string | null; + public id: number | null; + public line_items: {[key: string]: unknown}[] | null; + public location_id: number | null; + public name: string | null; + public notify_customer: boolean | null; + public order_id: number | null; + public receipt: {[key: string]: unknown} | null; + public service: string | null; + public shipment_status: string | null; + public status: string | null; + public tracking_company: string | null; + public tracking_numbers: string[] | null; + public tracking_urls: string[] | null; + public updated_at: string | null; + public variant_inventory_management: string | null; +} diff --git a/src/rest-resources/2021-07/fulfillment_event.ts b/src/rest-resources/2021-07/fulfillment_event.ts new file mode 100644 index 000000000..56f68188a --- /dev/null +++ b/src/rest-resources/2021-07/fulfillment_event.ts @@ -0,0 +1,120 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Country} from './country'; +import {Province} from './province'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + order_id?: number | string | null; + fulfillment_id?: number | string | null; + event_id?: unknown; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; + order_id?: number | string | null; + fulfillment_id?: number | string | null; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + order_id?: number | string | null; + fulfillment_id?: number | string | null; +} + +export class FulfillmentEvent extends Base { + public static API_VERSION = ApiVersion.July21; + + protected static NAME = 'fulfillment_event'; + protected static PLURAL_NAME = 'fulfillment_events'; + protected static HAS_ONE: {[key: string]: typeof Base} = { + country: Country, + province: Province + }; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: ["order_id", "fulfillment_id"], path: "orders//fulfillments//events.json"}, + {http_method: "post", operation: "post", ids: ["order_id", "fulfillment_id"], path: "orders//fulfillments//events.json"}, + {http_method: "get", operation: "get", ids: ["order_id", "fulfillment_id", "id"], path: "orders//fulfillments//events/.json"}, + {http_method: "delete", operation: "delete", ids: ["order_id", "fulfillment_id", "id"], path: "orders//fulfillments//events/.json"} + ]; + + protected static getJsonBodyName(): string + { + return "event"; + } + + public static async find( + { + session, + id, + order_id = null, + fulfillment_id = null, + event_id = null + }: FindArgs + ): Promise { + const result = await FulfillmentEvent.baseFind({ + session: session, + urlIds: {id: id, order_id: order_id, fulfillment_id: fulfillment_id}, + params: {event_id: event_id}, + }); + return result ? result[0] as FulfillmentEvent : null; + } + + public static async delete( + { + session, + id, + order_id = null, + fulfillment_id = null + }: DeleteArgs + ): Promise { + const response = await FulfillmentEvent.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id, order_id: order_id, fulfillment_id: fulfillment_id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + order_id = null, + fulfillment_id = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await FulfillmentEvent.baseFind({ + session: session, + urlIds: {order_id: order_id, fulfillment_id: fulfillment_id}, + params: {...otherArgs}, + }); + + return response as FulfillmentEvent[]; + } + + public address1: string | null; + public city: string | null; + public country: Country | null | {[key: string]: any}; + public created_at: string | null; + public estimated_delivery_at: string | null; + public fulfillment_id: number | null; + public happened_at: string | null; + public id: number | null; + public latitude: number | null; + public longitude: number | null; + public message: string | null; + public order_id: number | null; + public province: Province | null | {[key: string]: any}; + public shop_id: number | null; + public status: string | null; + public updated_at: string | null; + public zip: string | null; +} diff --git a/src/rest-resources/2021-07/fulfillment_order.ts b/src/rest-resources/2021-07/fulfillment_order.ts new file mode 100644 index 000000000..67ce3806b --- /dev/null +++ b/src/rest-resources/2021-07/fulfillment_order.ts @@ -0,0 +1,195 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + order_id?: number | string | null; +} +interface CancelArgs { + [key: string]: unknown; + body?: {[key: string]: unknown} | null; +} +interface CloseArgs { + [key: string]: unknown; + message?: unknown; + body?: {[key: string]: unknown} | null; +} +interface MoveArgs { + [key: string]: unknown; + new_location_id?: unknown; + body?: {[key: string]: unknown} | null; +} +interface OpenArgs { + [key: string]: unknown; + body?: {[key: string]: unknown} | null; +} +interface RescheduleArgs { + [key: string]: unknown; + body?: {[key: string]: unknown} | null; +} + +export class FulfillmentOrder extends Base { + public static API_VERSION = ApiVersion.July21; + + protected static NAME = 'fulfillment_order'; + protected static PLURAL_NAME = 'fulfillment_orders'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: ["order_id"], path: "orders//fulfillment_orders.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "fulfillment_orders/.json"}, + {http_method: "post", operation: "cancel", ids: ["id"], path: "fulfillment_orders//cancel.json"}, + {http_method: "post", operation: "close", ids: ["id"], path: "fulfillment_orders//close.json"}, + {http_method: "post", operation: "move", ids: ["id"], path: "fulfillment_orders//move.json"}, + {http_method: "post", operation: "open", ids: ["id"], path: "fulfillment_orders//open.json"}, + {http_method: "post", operation: "reschedule", ids: ["id"], path: "fulfillment_orders//reschedule.json"} + ]; + + public static async find( + { + session, + id + }: FindArgs + ): Promise { + const result = await FulfillmentOrder.baseFind({ + session: session, + urlIds: {id: id}, + params: {}, + }); + return result ? result[0] as FulfillmentOrder : null; + } + + public static async all( + { + session, + order_id = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await FulfillmentOrder.baseFind({ + session: session, + urlIds: {order_id: order_id}, + params: {...otherArgs}, + }); + + return response as FulfillmentOrder[]; + } + + public async cancel( + { + body = null, + ...otherArgs + }: CancelArgs + ): Promise { + const response = await FulfillmentOrder.request({ + http_method: "post", + operation: "cancel", + session: this.session, + urlIds: {id: this.id}, + params: {...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public async close( + { + message = null, + body = null, + ...otherArgs + }: CloseArgs + ): Promise { + const response = await FulfillmentOrder.request({ + http_method: "post", + operation: "close", + session: this.session, + urlIds: {id: this.id}, + params: {message: message, ...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public async move( + { + new_location_id = null, + body = null, + ...otherArgs + }: MoveArgs + ): Promise { + const response = await FulfillmentOrder.request({ + http_method: "post", + operation: "move", + session: this.session, + urlIds: {id: this.id}, + params: {new_location_id: new_location_id, ...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public async open( + { + body = null, + ...otherArgs + }: OpenArgs + ): Promise { + const response = await FulfillmentOrder.request({ + http_method: "post", + operation: "open", + session: this.session, + urlIds: {id: this.id}, + params: {...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public async reschedule( + { + body = null, + ...otherArgs + }: RescheduleArgs + ): Promise { + const response = await FulfillmentOrder.request({ + http_method: "post", + operation: "reschedule", + session: this.session, + urlIds: {id: this.id}, + params: {...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public assigned_location: {[key: string]: unknown} | null; + public assigned_location_id: number | null; + public delivery_method: {[key: string]: unknown} | null; + public destination: {[key: string]: unknown} | null; + public fulfill_at: string | null; + public id: number | null; + public international_duties: {[key: string]: unknown} | null; + public line_items: {[key: string]: unknown}[] | null; + public merchant_requests: {[key: string]: unknown}[] | null; + public order_id: number | null; + public request_status: string | null; + public shop_id: number | null; + public status: string | null; + public supported_actions: string[] | null; +} diff --git a/src/rest-resources/2021-07/fulfillment_request.ts b/src/rest-resources/2021-07/fulfillment_request.ts new file mode 100644 index 000000000..5a6776284 --- /dev/null +++ b/src/rest-resources/2021-07/fulfillment_request.ts @@ -0,0 +1,69 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {ApiVersion} from '../../base-types'; + +interface AcceptArgs { + [key: string]: unknown; + message?: unknown; + body?: {[key: string]: unknown} | null; +} +interface RejectArgs { + [key: string]: unknown; + message?: unknown; + body?: {[key: string]: unknown} | null; +} + +export class FulfillmentRequest extends Base { + public static API_VERSION = ApiVersion.July21; + + protected static NAME = 'fulfillment_request'; + protected static PLURAL_NAME = 'fulfillment_requests'; + 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_request.json"}, + {http_method: "post", operation: "accept", ids: ["fulfillment_order_id"], path: "fulfillment_orders//fulfillment_request/accept.json"}, + {http_method: "post", operation: "reject", ids: ["fulfillment_order_id"], path: "fulfillment_orders//fulfillment_request/reject.json"} + ]; + + public async accept( + { + message = null, + body = null, + ...otherArgs + }: AcceptArgs + ): Promise { + const response = await FulfillmentRequest.request({ + http_method: "post", + operation: "accept", + session: this.session, + urlIds: {fulfillment_order_id: this.fulfillment_order_id}, + params: {message: message, ...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public async reject( + { + message = null, + body = null, + ...otherArgs + }: RejectArgs + ): Promise { + const response = await FulfillmentRequest.request({ + http_method: "post", + operation: "reject", + session: this.session, + urlIds: {fulfillment_order_id: this.fulfillment_order_id}, + params: {message: message, ...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public fulfillment_order_id: number | null; +} diff --git a/src/rest-resources/2021-07/fulfillment_service.ts b/src/rest-resources/2021-07/fulfillment_service.ts new file mode 100644 index 000000000..3fae518ee --- /dev/null +++ b/src/rest-resources/2021-07/fulfillment_service.ts @@ -0,0 +1,93 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + scope?: unknown; +} + +export class FulfillmentService extends Base { + public static API_VERSION = ApiVersion.July21; + + protected static NAME = 'fulfillment_service'; + protected static PLURAL_NAME = 'fulfillment_services'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "fulfillment_services.json"}, + {http_method: "post", operation: "post", ids: [], path: "fulfillment_services.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "fulfillment_services/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "fulfillment_services/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "fulfillment_services/.json"} + ]; + + public static async find( + { + session, + id + }: FindArgs + ): Promise { + const result = await FulfillmentService.baseFind({ + session: session, + urlIds: {id: id}, + params: {}, + }); + return result ? result[0] as FulfillmentService : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await FulfillmentService.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + scope = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await FulfillmentService.baseFind({ + session: session, + urlIds: {}, + params: {scope: scope, ...otherArgs}, + }); + + return response as FulfillmentService[]; + } + + public admin_graphql_api_id: string | null; + public callback_url: string | null; + public format: string | null; + public fulfillment_orders_opt_in: boolean | null; + public handle: string | null; + public id: number | null; + public inventory_management: boolean | null; + public location_id: number | null; + public name: string | null; + public provider_id: string | null; + public requires_shipping_method: boolean | null; + public tracking_support: boolean | null; +} diff --git a/src/rest-resources/2021-07/gift_card.ts b/src/rest-resources/2021-07/gift_card.ts new file mode 100644 index 000000000..2e6010156 --- /dev/null +++ b/src/rest-resources/2021-07/gift_card.ts @@ -0,0 +1,170 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Balance} from './balance'; +import {Currency} from './currency'; + +interface FindArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + status?: unknown; + limit?: unknown; + since_id?: unknown; + fields?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; + status?: unknown; +} +interface SearchArgs { + [key: string]: unknown; + session: SessionInterface; + order?: unknown; + query?: unknown; + limit?: unknown; + fields?: unknown; +} +interface DisableArgs { + [key: string]: unknown; + body?: {[key: string]: unknown} | null; +} + +export class GiftCard extends Base { + public static API_VERSION = ApiVersion.July21; + + protected static NAME = 'gift_card'; + protected static PLURAL_NAME = 'gift_cards'; + protected static HAS_ONE: {[key: string]: typeof Base} = { + balance: Balance, + currency: Currency + }; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "gift_cards.json"}, + {http_method: "post", operation: "post", ids: [], path: "gift_cards.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "gift_cards/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "gift_cards/.json"}, + {http_method: "get", operation: "count", ids: [], path: "gift_cards/count.json"}, + {http_method: "post", operation: "disable", ids: ["id"], path: "gift_cards//disable.json"}, + {http_method: "get", operation: "search", ids: [], path: "gift_cards/search.json"} + ]; + + public static async find( + { + session, + id + }: FindArgs + ): Promise { + const result = await GiftCard.baseFind({ + session: session, + urlIds: {id: id}, + params: {}, + }); + return result ? result[0] as GiftCard : null; + } + + public static async all( + { + session, + status = null, + limit = null, + since_id = null, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await GiftCard.baseFind({ + session: session, + urlIds: {}, + params: {status: status, limit: limit, since_id: since_id, fields: fields, ...otherArgs}, + }); + + return response as GiftCard[]; + } + + public static async count( + { + session, + status = null, + ...otherArgs + }: CountArgs + ): Promise { + const response = await GiftCard.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {}, + params: {status: status, ...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public static async search( + { + session, + order = null, + query = null, + limit = null, + fields = null, + ...otherArgs + }: SearchArgs + ): Promise { + const response = await GiftCard.request({ + http_method: "get", + operation: "search", + session: session, + urlIds: {}, + params: {order: order, query: query, limit: limit, fields: fields, ...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public async disable( + { + body = null, + ...otherArgs + }: DisableArgs + ): Promise { + const response = await GiftCard.request({ + http_method: "post", + operation: "disable", + session: this.session, + urlIds: {id: this.id}, + params: {...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public api_client_id: number | null; + public balance: Balance | null | {[key: string]: any}; + public code: string | null; + public created_at: string | null; + public currency: Currency | null | {[key: string]: any}; + public customer_id: number | null; + public disabled_at: string | null; + public expires_on: string | null; + public id: number | null; + public initial_value: number | null; + public last_characters: string | null; + public line_item_id: number | null; + public note: string | null; + public order_id: number | null; + public template_suffix: string | null; + public updated_at: string | null; + public user_id: number | null; +} diff --git a/src/rest-resources/2021-07/gift_card_adjustment.ts b/src/rest-resources/2021-07/gift_card_adjustment.ts new file mode 100644 index 000000000..42ab936cc --- /dev/null +++ b/src/rest-resources/2021-07/gift_card_adjustment.ts @@ -0,0 +1,77 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + gift_card_id?: number | string | null; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + gift_card_id?: number | string | null; +} + +export class GiftCardAdjustment extends Base { + public static API_VERSION = ApiVersion.July21; + + protected static NAME = 'gift_card_adjustment'; + protected static PLURAL_NAME = 'gift_card_adjustments'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: ["gift_card_id"], path: "gift_cards//adjustments.json"}, + {http_method: "post", operation: "post", ids: ["gift_card_id"], path: "gift_cards//adjustments.json"}, + {http_method: "get", operation: "get", ids: ["gift_card_id", "id"], path: "gift_cards//adjustments/9.json"} + ]; + + protected static getJsonBodyName(): string + { + return "adjustment"; + } + + public static async find( + { + session, + id, + gift_card_id = null + }: FindArgs + ): Promise { + const result = await GiftCardAdjustment.baseFind({ + session: session, + urlIds: {id: id, gift_card_id: gift_card_id}, + params: {}, + }); + return result ? result[0] as GiftCardAdjustment : null; + } + + public static async all( + { + session, + gift_card_id = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await GiftCardAdjustment.baseFind({ + session: session, + urlIds: {gift_card_id: gift_card_id}, + params: {...otherArgs}, + }); + + return response as GiftCardAdjustment[]; + } + + public amount: number | null; + public api_client_id: number | null; + public created_at: string | null; + public gift_card_id: number | null; + public id: number | null; + public note: string | null; + public number: number | null; + public order_transaction_id: number | null; + public processed_at: string | null; + public remote_transaction_ref: string | null; + public remote_transaction_url: string | null; + public user_id: number | null; +} diff --git a/src/rest-resources/2021-07/image.ts b/src/rest-resources/2021-07/image.ts new file mode 100644 index 000000000..edd715f4f --- /dev/null +++ b/src/rest-resources/2021-07/image.ts @@ -0,0 +1,128 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + product_id?: number | string | null; + fields?: unknown; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; + product_id?: number | string | null; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + product_id?: number | string | null; + since_id?: unknown; + fields?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; + product_id?: number | string | null; + since_id?: unknown; +} + +export class Image extends Base { + public static API_VERSION = ApiVersion.July21; + + protected static NAME = 'image'; + protected static PLURAL_NAME = 'images'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: ["product_id"], path: "products//images.json"}, + {http_method: "post", operation: "post", ids: ["product_id"], path: "products//images.json"}, + {http_method: "get", operation: "count", ids: ["product_id"], path: "products//images/count.json"}, + {http_method: "get", operation: "get", ids: ["product_id", "id"], path: "products//images/.json"}, + {http_method: "put", operation: "put", ids: ["product_id", "id"], path: "products//images/.json"}, + {http_method: "delete", operation: "delete", ids: ["product_id", "id"], path: "products//images/.json"} + ]; + + public static async find( + { + session, + id, + product_id = null, + fields = null + }: FindArgs + ): Promise { + const result = await Image.baseFind({ + session: session, + urlIds: {id: id, product_id: product_id}, + params: {fields: fields}, + }); + return result ? result[0] as Image : null; + } + + public static async delete( + { + session, + id, + product_id = null + }: DeleteArgs + ): Promise { + const response = await Image.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id, product_id: product_id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + product_id = null, + since_id = null, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Image.baseFind({ + session: session, + urlIds: {product_id: product_id}, + params: {since_id: since_id, fields: fields, ...otherArgs}, + }); + + return response as Image[]; + } + + public static async count( + { + session, + product_id = null, + since_id = null, + ...otherArgs + }: CountArgs + ): Promise { + const response = await Image.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {product_id: product_id}, + params: {since_id: since_id, ...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public created_at: string | null; + public height: number | null; + public id: number | null; + public position: number | null; + public product_id: number | null; + public src: string | null; + public updated_at: string | null; + public variant_ids: number[] | null; + public width: number | null; +} diff --git a/src/rest-resources/2021-07/index.ts b/src/rest-resources/2021-07/index.ts new file mode 100644 index 000000000..ed825721a --- /dev/null +++ b/src/rest-resources/2021-07/index.ts @@ -0,0 +1,74 @@ +export {AbandonedCheckout} from './abandoned_checkout'; +export {AccessScope} from './access_scope'; +export {AndroidPayKey} from './android_pay_key'; +export {ApplePayCertificate} from './apple_pay_certificate'; +export {ApplicationCharge} from './application_charge'; +export {ApplicationCredit} from './application_credit'; +export {Article} from './article'; +export {Asset} from './asset'; +export {AssignedFulfillmentOrder} from './assigned_fulfillment_order'; +export {Balance} from './balance'; +export {Blog} from './blog'; +export {CancellationRequest} from './cancellation_request'; +export {CarrierService} from './carrier_service'; +export {Checkout} from './checkout'; +export {Collect} from './collect'; +export {Collection} from './collection'; +export {CollectionListing} from './collection_listing'; +export {Comment} from './comment'; +export {Country} from './country'; +export {Currency} from './currency'; +export {CustomCollection} from './custom_collection'; +export {Customer} from './customer'; +export {CustomerAddress} from './customer_address'; +export {CustomerSavedSearch} from './customer_saved_search'; +export {DeprecatedApiCall} from './deprecated_api_call'; +export {DiscountCode} from './discount_code'; +export {Dispute} from './dispute'; +export {DraftOrder} from './draft_order'; +export {Event} from './event'; +export {Fulfillment} from './fulfillment'; +export {FulfillmentEvent} from './fulfillment_event'; +export {FulfillmentOrder} from './fulfillment_order'; +export {FulfillmentRequest} from './fulfillment_request'; +export {FulfillmentService} from './fulfillment_service'; +export {GiftCard} from './gift_card'; +export {GiftCardAdjustment} from './gift_card_adjustment'; +export {Image} from './image'; +export {InventoryItem} from './inventory_item'; +export {InventoryLevel} from './inventory_level'; +export {Location} from './location'; +export {LocationsForMove} from './locations_for_move'; +export {MarketingEvent} from './marketing_event'; +export {Metafield} from './metafield'; +export {MobilePlatformApplication} from './mobile_platform_application'; +export {Order} from './order'; +export {OrderRisk} from './order_risk'; +export {Page} from './page'; +export {Payment} from './payment'; +export {PaymentGateway} from './payment_gateway'; +export {PaymentTransaction} from './payment_transaction'; +export {Payout} from './payout'; +export {Policy} from './policy'; +export {PriceRule} from './price_rule'; +export {Product} from './product'; +export {ProductListing} from './product_listing'; +export {ProductResourceFeedback} from './product_resource_feedback'; +export {Province} from './province'; +export {RecurringApplicationCharge} from './recurring_application_charge'; +export {Redirect} from './redirect'; +export {Refund} from './refund'; +export {Report} from './report'; +export {ResourceFeedback} from './resource_feedback'; +export {ScriptTag} from './script_tag'; +export {ShippingZone} from './shipping_zone'; +export {Shop} from './shop'; +export {SmartCollection} from './smart_collection'; +export {StorefrontAccessToken} from './storefront_access_token'; +export {TenderTransaction} from './tender_transaction'; +export {Theme} from './theme'; +export {Transaction} from './transaction'; +export {UsageCharge} from './usage_charge'; +export {User} from './user'; +export {Variant} from './variant'; +export {Webhook} from './webhook'; \ No newline at end of file diff --git a/src/rest-resources/2021-07/inventory_item.ts b/src/rest-resources/2021-07/inventory_item.ts new file mode 100644 index 000000000..083b22eeb --- /dev/null +++ b/src/rest-resources/2021-07/inventory_item.ts @@ -0,0 +1,71 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + ids?: unknown; + limit?: unknown; +} + +export class InventoryItem extends Base { + public static API_VERSION = ApiVersion.July21; + + protected static NAME = 'inventory_item'; + protected static PLURAL_NAME = 'inventory_items'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "inventory_items.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "inventory_items/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "inventory_items/.json"} + ]; + + public static async find( + { + session, + id + }: FindArgs + ): Promise { + const result = await InventoryItem.baseFind({ + session: session, + urlIds: {id: id}, + params: {}, + }); + return result ? result[0] as InventoryItem : null; + } + + public static async all( + { + session, + ids = null, + limit = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await InventoryItem.baseFind({ + session: session, + urlIds: {}, + params: {ids: ids, limit: limit, ...otherArgs}, + }); + + return response as InventoryItem[]; + } + + public cost: string | null; + public country_code_of_origin: string | null; + public country_harmonized_system_codes: {[key: string]: unknown}[] | null; + public created_at: string | null; + public harmonized_system_code: number | null; + public id: number | null; + public province_code_of_origin: string | null; + public requires_shipping: boolean | null; + public sku: string | null; + public tracked: boolean | null; + public updated_at: string | null; +} diff --git a/src/rest-resources/2021-07/inventory_level.ts b/src/rest-resources/2021-07/inventory_level.ts new file mode 100644 index 000000000..4ed025600 --- /dev/null +++ b/src/rest-resources/2021-07/inventory_level.ts @@ -0,0 +1,164 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface DeleteArgs { + session: SessionInterface; + inventory_item_id?: unknown; + location_id?: unknown; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + inventory_item_ids?: unknown; + location_ids?: unknown; + limit?: unknown; + updated_at_min?: unknown; +} +interface AdjustArgs { + [key: string]: unknown; + inventory_item_id?: unknown; + location_id?: unknown; + available_adjustment?: unknown; + body?: {[key: string]: unknown} | null; +} +interface ConnectArgs { + [key: string]: unknown; + inventory_item_id?: unknown; + location_id?: unknown; + relocate_if_necessary?: unknown; + body?: {[key: string]: unknown} | null; +} +interface SetArgs { + [key: string]: unknown; + inventory_item_id?: unknown; + location_id?: unknown; + available?: unknown; + disconnect_if_necessary?: unknown; + body?: {[key: string]: unknown} | null; +} + +export class InventoryLevel extends Base { + public static API_VERSION = ApiVersion.July21; + + protected static NAME = 'inventory_level'; + protected static PLURAL_NAME = 'inventory_levels'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "inventory_levels.json"}, + {http_method: "post", operation: "adjust", ids: [], path: "inventory_levels/adjust.json"}, + {http_method: "delete", operation: "delete", ids: [], path: "inventory_levels.json"}, + {http_method: "post", operation: "connect", ids: [], path: "inventory_levels/connect.json"}, + {http_method: "post", operation: "set", ids: [], path: "inventory_levels/set.json"} + ]; + + public static async delete( + { + session, + inventory_item_id = null, + location_id = null + }: DeleteArgs + ): Promise { + const response = await InventoryLevel.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {}, + params: {inventory_item_id: inventory_item_id, location_id: location_id}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + inventory_item_ids = null, + location_ids = null, + limit = null, + updated_at_min = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await InventoryLevel.baseFind({ + session: session, + urlIds: {}, + params: {inventory_item_ids: inventory_item_ids, location_ids: location_ids, limit: limit, updated_at_min: updated_at_min, ...otherArgs}, + }); + + return response as InventoryLevel[]; + } + + public async adjust( + { + inventory_item_id = null, + location_id = null, + available_adjustment = null, + body = null, + ...otherArgs + }: AdjustArgs + ): Promise { + const response = await InventoryLevel.request({ + http_method: "post", + operation: "adjust", + session: this.session, + urlIds: {}, + params: {inventory_item_id: inventory_item_id, location_id: location_id, available_adjustment: available_adjustment, ...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public async connect( + { + inventory_item_id = null, + location_id = null, + relocate_if_necessary = null, + body = null, + ...otherArgs + }: ConnectArgs + ): Promise { + const response = await InventoryLevel.request({ + http_method: "post", + operation: "connect", + session: this.session, + urlIds: {}, + params: {inventory_item_id: inventory_item_id, location_id: location_id, relocate_if_necessary: relocate_if_necessary, ...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public async set( + { + inventory_item_id = null, + location_id = null, + available = null, + disconnect_if_necessary = null, + body = null, + ...otherArgs + }: SetArgs + ): Promise { + const response = await InventoryLevel.request({ + http_method: "post", + operation: "set", + session: this.session, + urlIds: {}, + params: {inventory_item_id: inventory_item_id, location_id: location_id, available: available, disconnect_if_necessary: disconnect_if_necessary, ...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public available: number | null; + public inventory_item_id: number | null; + public location_id: number | null; + public updated_at: string | null; +} diff --git a/src/rest-resources/2021-07/location.ts b/src/rest-resources/2021-07/location.ts new file mode 100644 index 000000000..ce78674ad --- /dev/null +++ b/src/rest-resources/2021-07/location.ts @@ -0,0 +1,128 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Country} from './country'; +import {Province} from './province'; + +interface FindArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; +} +interface InventoryLevelsArgs { + [key: string]: unknown; + session: SessionInterface; + id: number | string; +} + +export class Location extends Base { + public static API_VERSION = ApiVersion.July21; + + protected static NAME = 'location'; + protected static PLURAL_NAME = 'locations'; + protected static HAS_ONE: {[key: string]: typeof Base} = { + country: Country, + province: Province + }; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "locations.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "locations/.json"}, + {http_method: "get", operation: "count", ids: [], path: "locations/count.json"}, + {http_method: "get", operation: "inventory_levels", ids: ["id"], path: "locations//inventory_levels.json"} + ]; + + public static async find( + { + session, + id + }: FindArgs + ): Promise { + const result = await Location.baseFind({ + session: session, + urlIds: {id: id}, + params: {}, + }); + return result ? result[0] as Location : null; + } + + public static async all( + { + session, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Location.baseFind({ + session: session, + urlIds: {}, + params: {...otherArgs}, + }); + + return response as Location[]; + } + + public static async count( + { + session, + ...otherArgs + }: CountArgs + ): Promise { + const response = await Location.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {}, + params: {...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public static async inventory_levels( + { + session, + id, + ...otherArgs + }: InventoryLevelsArgs + ): Promise { + const response = await Location.request({ + http_method: "get", + operation: "inventory_levels", + session: session, + urlIds: {id: id}, + params: {...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public active: boolean | null; + public address1: string | null; + public address2: string | null; + public city: string | null; + public country: Country | null | {[key: string]: any}; + public country_code: string | null; + public created_at: string | null; + public id: number | null; + public legacy: boolean | null; + public localized_country_name: string | null; + public localized_province_name: string | null; + public name: string | null; + public phone: string | null; + public province: Province | null | {[key: string]: any}; + public province_code: string | null; + public updated_at: string | null; + public zip: string | null; +} diff --git a/src/rest-resources/2021-07/locations_for_move.ts b/src/rest-resources/2021-07/locations_for_move.ts new file mode 100644 index 000000000..645901784 --- /dev/null +++ b/src/rest-resources/2021-07/locations_for_move.ts @@ -0,0 +1,39 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + fulfillment_order_id?: number | string | null; +} + +export class LocationsForMove extends Base { + public static API_VERSION = ApiVersion.July21; + + protected static NAME = 'locations_for_move'; + protected static PLURAL_NAME = 'locations_for_moves'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: ["fulfillment_order_id"], path: "fulfillment_orders//locations_for_move.json"} + ]; + + public static async all( + { + session, + fulfillment_order_id = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await LocationsForMove.baseFind({ + session: session, + urlIds: {fulfillment_order_id: fulfillment_order_id}, + params: {...otherArgs}, + }); + + return response as LocationsForMove[]; + } + + public locations_for_move: {[key: string]: unknown}[] | null; +} diff --git a/src/rest-resources/2021-07/marketing_event.ts b/src/rest-resources/2021-07/marketing_event.ts new file mode 100644 index 000000000..0cf1ed770 --- /dev/null +++ b/src/rest-resources/2021-07/marketing_event.ts @@ -0,0 +1,166 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + limit?: unknown; + offset?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; +} +interface EngagementsArgs { + [key: string]: unknown; + occurred_on?: unknown; + impressions_count?: unknown; + views_count?: unknown; + clicks_count?: unknown; + shares_count?: unknown; + favorites_count?: unknown; + comments_count?: unknown; + ad_spend?: unknown; + is_cumulative?: unknown; + body?: {[key: string]: unknown} | null; +} + +export class MarketingEvent extends Base { + public static API_VERSION = ApiVersion.July21; + + protected static NAME = 'marketing_event'; + protected static PLURAL_NAME = 'marketing_events'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "marketing_events.json"}, + {http_method: "post", operation: "post", ids: [], path: "marketing_events.json"}, + {http_method: "get", operation: "count", ids: [], path: "marketing_events/count.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "marketing_events/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "marketing_events/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "marketing_events/.json"}, + {http_method: "post", operation: "engagements", ids: ["id"], path: "marketing_events//engagements.json"} + ]; + + public static async find( + { + session, + id + }: FindArgs + ): Promise { + const result = await MarketingEvent.baseFind({ + session: session, + urlIds: {id: id}, + params: {}, + }); + return result ? result[0] as MarketingEvent : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await MarketingEvent.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + limit = null, + offset = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await MarketingEvent.baseFind({ + session: session, + urlIds: {}, + params: {limit: limit, offset: offset, ...otherArgs}, + }); + + return response as MarketingEvent[]; + } + + public static async count( + { + session, + ...otherArgs + }: CountArgs + ): Promise { + const response = await MarketingEvent.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {}, + params: {...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public async engagements( + { + occurred_on = null, + impressions_count = null, + views_count = null, + clicks_count = null, + shares_count = null, + favorites_count = null, + comments_count = null, + ad_spend = null, + is_cumulative = null, + body = null, + ...otherArgs + }: EngagementsArgs + ): Promise { + const response = await MarketingEvent.request({ + http_method: "post", + operation: "engagements", + session: this.session, + urlIds: {id: this.id}, + params: {occurred_on: occurred_on, impressions_count: impressions_count, views_count: views_count, clicks_count: clicks_count, shares_count: shares_count, favorites_count: favorites_count, comments_count: comments_count, ad_spend: ad_spend, is_cumulative: is_cumulative, ...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public event_type: string | null; + public marketing_channel: string | null; + public paid: boolean | null; + public started_at: string | null; + public UTM_parameters: {[key: string]: unknown} | null; + public budget: string | null; + public budget_type: string | null; + public currency: string | null; + public description: string | null; + public ended_at: string | null; + public id: number | null; + public manage_url: string | null; + public marketed_resources: {[key: string]: unknown}[] | null; + public preview_url: string | null; + public referring_domain: string | null; + public remote_id: string | null; + public scheduled_to_end_at: string | null; +} diff --git a/src/rest-resources/2021-07/metafield.ts b/src/rest-resources/2021-07/metafield.ts new file mode 100644 index 000000000..7c4f33453 --- /dev/null +++ b/src/rest-resources/2021-07/metafield.ts @@ -0,0 +1,141 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + limit?: unknown; + since_id?: unknown; + created_at_min?: unknown; + created_at_max?: unknown; + updated_at_min?: unknown; + updated_at_max?: unknown; + namespace?: unknown; + key?: unknown; + type?: unknown; + value_type?: unknown; + fields?: unknown; + metafield?: {[key: string]: unknown} | null; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; +} + +export class Metafield extends Base { + public static API_VERSION = ApiVersion.July21; + + protected static NAME = 'metafield'; + protected static PLURAL_NAME = 'metafields'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "metafields.json"}, + {http_method: "post", operation: "post", ids: [], path: "metafields.json"}, + {http_method: "get", operation: "get", ids: [], path: "metafields.json"}, + {http_method: "get", operation: "count", ids: [], path: "metafields/count.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "metafields/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "metafields/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "metafields/.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await Metafield.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as Metafield : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await Metafield.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + limit = null, + since_id = null, + created_at_min = null, + created_at_max = null, + updated_at_min = null, + updated_at_max = null, + namespace = null, + key = null, + type = null, + value_type = null, + fields = null, + metafield = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Metafield.baseFind({ + session: session, + urlIds: {}, + params: {limit: limit, since_id: since_id, created_at_min: created_at_min, created_at_max: created_at_max, updated_at_min: updated_at_min, updated_at_max: updated_at_max, namespace: namespace, key: key, type: type, value_type: value_type, fields: fields, metafield: metafield, ...otherArgs}, + }); + + return response as Metafield[]; + } + + public static async count( + { + session, + ...otherArgs + }: CountArgs + ): Promise { + const response = await Metafield.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {}, + params: {...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public key: string | null; + public namespace: string | null; + public value: string | number | number | null; + public created_at: string | null; + public description: string | null; + public id: number | null; + public owner_id: number | null; + public owner_resource: string | null; + public type: string | null; + public updated_at: string | null; + public value_type: string | null; +} diff --git a/src/rest-resources/2021-07/mobile_platform_application.ts b/src/rest-resources/2021-07/mobile_platform_application.ts new file mode 100644 index 000000000..c644694cf --- /dev/null +++ b/src/rest-resources/2021-07/mobile_platform_application.ts @@ -0,0 +1,85 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; +} + +export class MobilePlatformApplication extends Base { + public static API_VERSION = ApiVersion.July21; + + protected static NAME = 'mobile_platform_application'; + protected static PLURAL_NAME = 'mobile_platform_applications'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "mobile_platform_applications.json"}, + {http_method: "post", operation: "post", ids: [], path: "mobile_platform_applications.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "mobile_platform_applications/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "mobile_platform_applications/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "mobile_platform_applications/.json"} + ]; + + public static async find( + { + session, + id + }: FindArgs + ): Promise { + const result = await MobilePlatformApplication.baseFind({ + session: session, + urlIds: {id: id}, + params: {}, + }); + return result ? result[0] as MobilePlatformApplication : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await MobilePlatformApplication.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + ...otherArgs + }: AllArgs + ): Promise { + const response = await MobilePlatformApplication.baseFind({ + session: session, + urlIds: {}, + params: {...otherArgs}, + }); + + return response as MobilePlatformApplication[]; + } + + public application_id: string | null; + public enabled_shared_webcredentials: boolean | null; + public enabled_universal_or_app_links: boolean | null; + public id: number | null; + public platform: string | null; + public sha256_cert_fingerprints: string[] | null; +} diff --git a/src/rest-resources/2021-07/order.ts b/src/rest-resources/2021-07/order.ts new file mode 100644 index 000000000..5f0b53068 --- /dev/null +++ b/src/rest-resources/2021-07/order.ts @@ -0,0 +1,316 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Customer} from './customer'; +import {DiscountCode} from './discount_code'; +import {Fulfillment} from './fulfillment'; +import {Refund} from './refund'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + ids?: unknown; + limit?: unknown; + since_id?: unknown; + created_at_min?: unknown; + created_at_max?: unknown; + updated_at_min?: unknown; + updated_at_max?: unknown; + processed_at_min?: unknown; + processed_at_max?: unknown; + attribution_app_id?: unknown; + status?: unknown; + financial_status?: unknown; + fulfillment_status?: unknown; + fields?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; + created_at_min?: unknown; + created_at_max?: unknown; + updated_at_min?: unknown; + updated_at_max?: unknown; + status?: unknown; + financial_status?: unknown; + fulfillment_status?: unknown; +} +interface CloseArgs { + [key: string]: unknown; + body?: {[key: string]: unknown} | null; +} +interface OpenArgs { + [key: string]: unknown; + body?: {[key: string]: unknown} | null; +} +interface CancelArgs { + [key: string]: unknown; + amount?: unknown; + currency?: unknown; + restock?: unknown; + reason?: unknown; + email?: unknown; + refund?: unknown; + body?: {[key: string]: unknown} | null; +} + +export class Order extends Base { + public static API_VERSION = ApiVersion.July21; + + protected static NAME = 'order'; + protected static PLURAL_NAME = 'orders'; + protected static HAS_ONE: {[key: string]: typeof Base} = { + customer: Customer + }; + protected static HAS_MANY: {[key: string]: typeof Base} = { + discount_codes: DiscountCode, + fulfillments: Fulfillment, + refunds: Refund + }; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "orders.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "orders/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "orders/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "orders/.json"}, + {http_method: "get", operation: "count", ids: [], path: "orders/count.json"}, + {http_method: "post", operation: "close", ids: ["id"], path: "orders//close.json"}, + {http_method: "post", operation: "open", ids: ["id"], path: "orders//open.json"}, + {http_method: "post", operation: "cancel", ids: ["id"], path: "orders//cancel.json"}, + {http_method: "post", operation: "post", ids: [], path: "orders.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await Order.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as Order : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await Order.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + ids = null, + limit = null, + since_id = null, + created_at_min = null, + created_at_max = null, + updated_at_min = null, + updated_at_max = null, + processed_at_min = null, + processed_at_max = null, + attribution_app_id = null, + status = null, + financial_status = null, + fulfillment_status = null, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Order.baseFind({ + session: session, + urlIds: {}, + params: {ids: ids, limit: limit, since_id: since_id, created_at_min: created_at_min, created_at_max: created_at_max, updated_at_min: updated_at_min, updated_at_max: updated_at_max, processed_at_min: processed_at_min, processed_at_max: processed_at_max, attribution_app_id: attribution_app_id, status: status, financial_status: financial_status, fulfillment_status: fulfillment_status, fields: fields, ...otherArgs}, + }); + + return response as Order[]; + } + + public static async count( + { + session, + created_at_min = null, + created_at_max = null, + updated_at_min = null, + updated_at_max = null, + status = null, + financial_status = null, + fulfillment_status = null, + ...otherArgs + }: CountArgs + ): Promise { + const response = await Order.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {}, + 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, status: status, financial_status: financial_status, fulfillment_status: fulfillment_status, ...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public async close( + { + body = null, + ...otherArgs + }: CloseArgs + ): Promise { + const response = await Order.request({ + http_method: "post", + operation: "close", + session: this.session, + urlIds: {id: this.id}, + params: {...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public async open( + { + body = null, + ...otherArgs + }: OpenArgs + ): Promise { + const response = await Order.request({ + http_method: "post", + operation: "open", + session: this.session, + urlIds: {id: this.id}, + params: {...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public async cancel( + { + amount = null, + currency = null, + restock = null, + reason = null, + email = null, + refund = null, + body = null, + ...otherArgs + }: CancelArgs + ): Promise { + const response = await Order.request({ + http_method: "post", + operation: "cancel", + session: this.session, + urlIds: {id: this.id}, + params: {amount: amount, currency: currency, restock: restock, reason: reason, email: email, refund: refund, ...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public line_items: {[key: string]: unknown}[] | null; + public app_id: number | null; + public billing_address: {[key: string]: unknown} | null; + public browser_ip: string | null; + public buyer_accepts_marketing: boolean | null; + public cancel_reason: string | null; + public cancelled_at: string | null; + public cart_token: string | null; + public checkout_token: string | null; + public client_details: {[key: string]: unknown} | null; + public closed_at: string | null; + public created_at: string | null; + public currency: string | null; + public current_subtotal_price: string | null; + public current_subtotal_price_set: {[key: string]: unknown} | null; + public current_total_discounts: string | null; + public current_total_discounts_set: {[key: string]: unknown} | null; + public current_total_duties_set: {[key: string]: unknown} | null; + public current_total_price: string | null; + public current_total_price_set: {[key: string]: unknown} | null; + public current_total_tax: string | null; + public current_total_tax_set: {[key: string]: unknown} | null; + public customer: Customer | null | {[key: string]: any}; + public customer_locale: string | null; + public discount_applications: {[key: string]: unknown}[] | null; + public discount_codes: DiscountCode[] | null | {[key: string]: any}; + public email: string | null; + public estimated_taxes: boolean | null; + public financial_status: string | null; + public fulfillment_status: string | null; + public fulfillments: Fulfillment[] | null | {[key: string]: any}; + public gateway: string | null; + public id: number | null; + public landing_site: string | null; + public location_id: number | null; + public name: string | null; + public note: string | null; + public note_attributes: {[key: string]: unknown}[] | null; + public number: number | null; + public order_number: number | null; + public order_status_url: string | null; + public original_total_duties_set: {[key: string]: unknown} | null; + public payment_details: {[key: string]: unknown} | null; + public payment_gateway_names: string[] | null; + public phone: string | null; + public presentment_currency: string | null; + public processed_at: string | null; + public processing_method: string | null; + public referring_site: string | null; + public refunds: Refund[] | null | {[key: string]: any}; + public shipping_address: {[key: string]: unknown} | null; + public shipping_lines: {[key: string]: unknown}[] | null; + public source_name: string | null; + public subtotal_price: number | null; + public subtotal_price_set: {[key: string]: unknown} | null; + public tags: string | null; + public tax_lines: {[key: string]: unknown}[] | null; + public taxes_included: boolean | null; + public test: boolean | null; + public token: string | null; + public total_discounts: string | null; + public total_discounts_set: {[key: string]: unknown} | null; + public total_line_items_price: string | null; + public total_line_items_price_set: {[key: string]: unknown} | null; + public total_outstanding: string | null; + public total_price: string | null; + public total_price_set: {[key: string]: unknown} | null; + public total_shipping_price_set: {[key: string]: unknown} | null; + public total_tax: string | number | null; + public total_tax_set: {[key: string]: unknown} | null; + public total_tip_received: string | null; + public total_weight: number | null; + public updated_at: string | null; + public user_id: number | null; +} diff --git a/src/rest-resources/2021-07/order_risk.ts b/src/rest-resources/2021-07/order_risk.ts new file mode 100644 index 000000000..b066fa7ba --- /dev/null +++ b/src/rest-resources/2021-07/order_risk.ts @@ -0,0 +1,100 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + order_id?: number | string | null; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; + order_id?: number | string | null; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + order_id?: number | string | null; +} + +export class OrderRisk extends Base { + public static API_VERSION = ApiVersion.July21; + + protected static NAME = 'order_risk'; + protected static PLURAL_NAME = 'order_risks'; + 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: ["order_id"], path: "orders//risks.json"}, + {http_method: "get", operation: "get", ids: ["order_id"], path: "orders//risks.json"}, + {http_method: "get", operation: "get", ids: ["order_id", "id"], path: "orders//risks/.json"}, + {http_method: "put", operation: "put", ids: ["order_id", "id"], path: "orders//risks/.json"}, + {http_method: "delete", operation: "delete", ids: ["order_id", "id"], path: "orders//risks/.json"} + ]; + + protected static getJsonBodyName(): string + { + return "risk"; + } + + public static async find( + { + session, + id, + order_id = null + }: FindArgs + ): Promise { + const result = await OrderRisk.baseFind({ + session: session, + urlIds: {id: id, order_id: order_id}, + params: {}, + }); + return result ? result[0] as OrderRisk : null; + } + + public static async delete( + { + session, + id, + order_id = null + }: DeleteArgs + ): Promise { + const response = await OrderRisk.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id, order_id: order_id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + order_id = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await OrderRisk.baseFind({ + session: session, + urlIds: {order_id: order_id}, + params: {...otherArgs}, + }); + + return response as OrderRisk[]; + } + + public cause_cancel: boolean | null; + public checkout_id: number | null; + public display: boolean | null; + public id: number | null; + public merchant_message: string | null; + public message: string | null; + public order_id: number | null; + public recommendation: string | null; + public score: number | null; + public source: string | null; +} diff --git a/src/rest-resources/2021-07/page.ts b/src/rest-resources/2021-07/page.ts new file mode 100644 index 000000000..c898d621d --- /dev/null +++ b/src/rest-resources/2021-07/page.ts @@ -0,0 +1,161 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Metafield} from './metafield'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + limit?: unknown; + since_id?: unknown; + title?: unknown; + handle?: unknown; + created_at_min?: unknown; + created_at_max?: unknown; + updated_at_min?: unknown; + updated_at_max?: unknown; + published_at_min?: unknown; + published_at_max?: unknown; + fields?: unknown; + published_status?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; + title?: unknown; + created_at_min?: unknown; + created_at_max?: unknown; + updated_at_min?: unknown; + updated_at_max?: unknown; + published_at_min?: unknown; + published_at_max?: unknown; + published_status?: unknown; +} + +export class Page extends Base { + public static API_VERSION = ApiVersion.July21; + + protected static NAME = 'page'; + protected static PLURAL_NAME = 'pages'; + protected static HAS_ONE: {[key: string]: typeof Base} = { + metafield: Metafield + }; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "pages.json"}, + {http_method: "post", operation: "post", ids: [], path: "pages.json"}, + {http_method: "get", operation: "count", ids: [], path: "pages/count.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "pages/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "pages/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "pages/.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await Page.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as Page : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await Page.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + limit = null, + since_id = null, + title = null, + handle = 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, + fields = null, + published_status = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Page.baseFind({ + session: session, + urlIds: {}, + params: {limit: limit, since_id: since_id, title: title, handle: handle, 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, fields: fields, published_status: published_status, ...otherArgs}, + }); + + return response as Page[]; + } + + public static async count( + { + session, + title = 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 + ): Promise { + const response = await Page.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {}, + params: {title: title, 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, + }); + + return response ? response.body : null; + } + + public admin_graphql_api_id: string | null; + public author: string | null; + public body_html: string | null; + public created_at: string | null; + public handle: string | null; + public id: number | null; + public metafield: Metafield | null | {[key: string]: any}; + public published_at: string | null; + public shop_id: number | null; + public template_suffix: string | null; + public title: string | null; + public updated_at: string | null; +} diff --git a/src/rest-resources/2021-07/payment.ts b/src/rest-resources/2021-07/payment.ts new file mode 100644 index 000000000..b44deacc4 --- /dev/null +++ b/src/rest-resources/2021-07/payment.ts @@ -0,0 +1,99 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Transaction} from './transaction'; +import {Checkout} from './checkout'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + checkout_id?: number | string | null; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + checkout_id?: number | string | null; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; + checkout_id?: number | string | null; +} + +export class Payment extends Base { + public static API_VERSION = ApiVersion.July21; + + protected static NAME = 'payment'; + protected static PLURAL_NAME = 'payments'; + protected static HAS_ONE: {[key: string]: typeof Base} = { + transaction: Transaction, + checkout: Checkout + }; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "post", operation: "post", ids: ["checkout_id"], path: "checkouts//payments.json"}, + {http_method: "get", operation: "get", ids: ["checkout_id"], path: "checkouts//payments.json"}, + {http_method: "get", operation: "get", ids: ["checkout_id", "id"], path: "checkouts//payments/.json"}, + {http_method: "get", operation: "count", ids: ["checkout_id"], path: "checkouts//payments/count.json"} + ]; + + public static async find( + { + session, + id, + checkout_id = null + }: FindArgs + ): Promise { + const result = await Payment.baseFind({ + session: session, + urlIds: {id: id, checkout_id: checkout_id}, + params: {}, + }); + return result ? result[0] as Payment : null; + } + + public static async all( + { + session, + checkout_id = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Payment.baseFind({ + session: session, + urlIds: {checkout_id: checkout_id}, + params: {...otherArgs}, + }); + + return response as Payment[]; + } + + public static async count( + { + session, + checkout_id = null, + ...otherArgs + }: CountArgs + ): Promise { + const response = await Payment.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {checkout_id: checkout_id}, + params: {...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public checkout: Checkout | null | {[key: string]: any}; + public credit_card: {[key: string]: unknown} | null; + public id: number | null; + public next_action: {[key: string]: unknown} | null; + public payment_processing_error_message: string | null; + public transaction: Transaction | null | {[key: string]: any}; + public unique_token: string | null; +} diff --git a/src/rest-resources/2021-07/payment_gateway.ts b/src/rest-resources/2021-07/payment_gateway.ts new file mode 100644 index 000000000..adcd0c0d7 --- /dev/null +++ b/src/rest-resources/2021-07/payment_gateway.ts @@ -0,0 +1,96 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; +} + +export class PaymentGateway extends Base { + public static API_VERSION = ApiVersion.July21; + + protected static NAME = 'payment_gateway'; + protected static PLURAL_NAME = 'payment_gateways'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "payment_gateways.json"}, + {http_method: "post", operation: "post", ids: [], path: "payment_gateways.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "payment_gateways/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "payment_gateways/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "payment_gateways/.json"} + ]; + + public static async find( + { + session, + id + }: FindArgs + ): Promise { + const result = await PaymentGateway.baseFind({ + session: session, + urlIds: {id: id}, + params: {}, + }); + return result ? result[0] as PaymentGateway : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await PaymentGateway.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + ...otherArgs + }: AllArgs + ): Promise { + const response = await PaymentGateway.baseFind({ + session: session, + urlIds: {}, + params: {...otherArgs}, + }); + + return response as PaymentGateway[]; + } + + public attachment: string | null; + public created_at: string | null; + public credential1: string | null; + public credential2: string | null; + public credential3: string | null; + public credential4: string | null; + public disabled: boolean | null; + public enabled_card_brands: string[] | null; + public id: number | null; + public name: string | null; + public processing_method: string | null; + public provider_id: number | null; + public sandbox: boolean | null; + public service_name: string | null; + public supports_network_tokenization: boolean | null; + public type: string | null; + public updated_at: string | null; +} diff --git a/src/rest-resources/2021-07/payment_transaction.ts b/src/rest-resources/2021-07/payment_transaction.ts new file mode 100644 index 000000000..f2b3c7c8b --- /dev/null +++ b/src/rest-resources/2021-07/payment_transaction.ts @@ -0,0 +1,68 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Currency} from './currency'; + +interface TransactionsArgs { + [key: string]: unknown; + session: SessionInterface; + since_id?: unknown; + last_id?: unknown; + test?: unknown; + payout_id?: unknown; + payout_status?: unknown; +} + +export class PaymentTransaction extends Base { + public static API_VERSION = ApiVersion.July21; + + protected static NAME = 'payment_transaction'; + protected static PLURAL_NAME = 'payment_transactions'; + protected static HAS_ONE: {[key: string]: typeof Base} = { + currency: Currency + }; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "transactions", ids: [], path: "shopify_payments/balance/transactions.json"} + ]; + + public static async transactions( + { + session, + since_id = null, + last_id = null, + test = null, + payout_id = null, + payout_status = null, + ...otherArgs + }: TransactionsArgs + ): Promise { + const response = await PaymentTransaction.request({ + http_method: "get", + operation: "transactions", + session: session, + urlIds: {}, + params: {since_id: since_id, last_id: last_id, test: test, payout_id: payout_id, payout_status: payout_status, ...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public amount: string | null; + public currency: Currency | null | {[key: string]: any}; + public fee: string | null; + public id: number | null; + public net: string | null; + public payout_id: number | null; + public payout_status: string | null; + public processed_at: string | null; + public source_id: number | null; + public source_order_id: number | null; + public source_order_transaction_id: number | null; + public source_type: string | null; + public test: boolean | null; + public type: string | null; +} diff --git a/src/rest-resources/2021-07/payout.ts b/src/rest-resources/2021-07/payout.ts new file mode 100644 index 000000000..0a74046cb --- /dev/null +++ b/src/rest-resources/2021-07/payout.ts @@ -0,0 +1,76 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Currency} from './currency'; + +interface FindArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + since_id?: unknown; + last_id?: unknown; + date_min?: unknown; + date_max?: unknown; + date?: unknown; + status?: unknown; +} + +export class Payout extends Base { + public static API_VERSION = ApiVersion.July21; + + protected static NAME = 'payout'; + protected static PLURAL_NAME = 'payouts'; + protected static HAS_ONE: {[key: string]: typeof Base} = { + currency: Currency + }; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "shopify_payments/payouts.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "shopify_payments/payouts/.json"} + ]; + + public static async find( + { + session, + id + }: FindArgs + ): Promise { + const result = await Payout.baseFind({ + session: session, + urlIds: {id: id}, + params: {}, + }); + return result ? result[0] as Payout : null; + } + + public static async all( + { + session, + since_id = null, + last_id = null, + date_min = null, + date_max = null, + date = null, + status = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Payout.baseFind({ + session: session, + urlIds: {}, + params: {since_id: since_id, last_id: last_id, date_min: date_min, date_max: date_max, date: date, status: status, ...otherArgs}, + }); + + return response as Payout[]; + } + + public amount: string | null; + public currency: Currency | null | {[key: string]: any}; + public date: string | null; + public id: number | null; + public status: string | null; +} diff --git a/src/rest-resources/2021-07/policy.ts b/src/rest-resources/2021-07/policy.ts new file mode 100644 index 000000000..28048dc20 --- /dev/null +++ b/src/rest-resources/2021-07/policy.ts @@ -0,0 +1,42 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; +} + +export class Policy extends Base { + public static API_VERSION = ApiVersion.July21; + + protected static NAME = 'policy'; + protected static PLURAL_NAME = 'policies'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "policies.json"} + ]; + + public static async all( + { + session, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Policy.baseFind({ + session: session, + urlIds: {}, + params: {...otherArgs}, + }); + + return response as Policy[]; + } + + public body: string | null; + public created_at: string | null; + public handle: string | null; + public title: string | null; + public updated_at: string | null; + public url: string | null; +} diff --git a/src/rest-resources/2021-07/price_rule.ts b/src/rest-resources/2021-07/price_rule.ts new file mode 100644 index 000000000..a3f1d82bf --- /dev/null +++ b/src/rest-resources/2021-07/price_rule.ts @@ -0,0 +1,154 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + limit?: unknown; + since_id?: unknown; + created_at_min?: unknown; + created_at_max?: unknown; + updated_at_min?: unknown; + updated_at_max?: unknown; + starts_at_min?: unknown; + starts_at_max?: unknown; + ends_at_min?: unknown; + ends_at_max?: unknown; + times_used?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; +} + +export class PriceRule extends Base { + public static API_VERSION = ApiVersion.July21; + + protected static NAME = 'price_rule'; + protected static PLURAL_NAME = 'price_rules'; + 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: "price_rules.json"}, + {http_method: "get", operation: "get", ids: [], path: "price_rules.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "price_rules/.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "price_rules/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "price_rules/.json"}, + {http_method: "get", operation: "count", ids: [], path: "price_rules/count.json"} + ]; + + public static async find( + { + session, + id + }: FindArgs + ): Promise { + const result = await PriceRule.baseFind({ + session: session, + urlIds: {id: id}, + params: {}, + }); + return result ? result[0] as PriceRule : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await PriceRule.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + limit = null, + since_id = null, + created_at_min = null, + created_at_max = null, + updated_at_min = null, + updated_at_max = null, + starts_at_min = null, + starts_at_max = null, + ends_at_min = null, + ends_at_max = null, + times_used = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await PriceRule.baseFind({ + session: session, + urlIds: {}, + params: {limit: limit, since_id: since_id, created_at_min: created_at_min, created_at_max: created_at_max, updated_at_min: updated_at_min, updated_at_max: updated_at_max, starts_at_min: starts_at_min, starts_at_max: starts_at_max, ends_at_min: ends_at_min, ends_at_max: ends_at_max, times_used: times_used, ...otherArgs}, + }); + + return response as PriceRule[]; + } + + public static async count( + { + session, + ...otherArgs + }: CountArgs + ): Promise { + const response = await PriceRule.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {}, + params: {...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public allocation_limit: number | null; + public allocation_method: string | null; + public created_at: string | null; + public customer_selection: string | null; + public ends_at: string | null; + public entitled_collection_ids: number[] | null; + public entitled_country_ids: number[] | null; + public entitled_product_ids: number[] | null; + public entitled_variant_ids: number[] | null; + public id: number | null; + public once_per_customer: boolean | null; + public prerequisite_collection_ids: number[] | null; + public prerequisite_customer_ids: number[] | null; + public prerequisite_product_ids: number[] | null; + public prerequisite_quantity_range: {[key: string]: unknown} | null; + public prerequisite_saved_search_ids: number[] | null; + public prerequisite_shipping_price_range: {[key: string]: unknown} | null; + public prerequisite_subtotal_range: {[key: string]: unknown} | null; + public prerequisite_to_entitlement_purchase: {[key: string]: unknown} | null; + public prerequisite_to_entitlement_quantity_ratio: {[key: string]: unknown} | null; + public prerequisite_variant_ids: number[] | null; + public starts_at: string | null; + public target_selection: string | null; + public target_type: string | null; + public title: string | null; + public updated_at: string | null; + public usage_limit: number | null; + public value: string | null; + public value_type: string | null; +} diff --git a/src/rest-resources/2021-07/product.ts b/src/rest-resources/2021-07/product.ts new file mode 100644 index 000000000..7718f3346 --- /dev/null +++ b/src/rest-resources/2021-07/product.ts @@ -0,0 +1,183 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Image} from './image'; +import {Variant} from './variant'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + ids?: unknown; + limit?: unknown; + since_id?: unknown; + title?: unknown; + vendor?: unknown; + handle?: unknown; + product_type?: unknown; + status?: unknown; + collection_id?: unknown; + created_at_min?: unknown; + created_at_max?: unknown; + updated_at_min?: unknown; + updated_at_max?: unknown; + published_at_min?: unknown; + published_at_max?: unknown; + published_status?: unknown; + fields?: unknown; + presentment_currencies?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; + vendor?: unknown; + product_type?: unknown; + collection_id?: unknown; + created_at_min?: unknown; + created_at_max?: unknown; + updated_at_min?: unknown; + updated_at_max?: unknown; + published_at_min?: unknown; + published_at_max?: unknown; + published_status?: unknown; +} + +export class Product extends Base { + public static API_VERSION = ApiVersion.July21; + + protected static NAME = 'product'; + protected static PLURAL_NAME = 'products'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = { + images: Image, + variants: Variant + }; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "products.json"}, + {http_method: "post", operation: "post", ids: [], path: "products.json"}, + {http_method: "get", operation: "count", ids: [], path: "products/count.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "products/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "products/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "products/.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await Product.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as Product : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await Product.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + ids = null, + limit = null, + since_id = null, + title = null, + vendor = null, + handle = null, + product_type = null, + status = null, + collection_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, + fields = null, + presentment_currencies = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Product.baseFind({ + session: session, + urlIds: {}, + params: {ids: ids, limit: limit, since_id: since_id, title: title, vendor: vendor, handle: handle, product_type: product_type, status: status, collection_id: collection_id, 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, fields: fields, presentment_currencies: presentment_currencies, ...otherArgs}, + }); + + return response as Product[]; + } + + public static async count( + { + session, + vendor = null, + product_type = null, + collection_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 + ): Promise { + const response = await Product.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {}, + params: {vendor: vendor, product_type: product_type, collection_id: collection_id, 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, + }); + + return response ? response.body : null; + } + + public title: string | null; + public body_html: string | null; + public created_at: string | null; + public handle: string | null; + public id: number | null; + public images: Image[] | null | {[key: string]: any}; + public options: {[key: string]: unknown} | {[key: string]: unknown}[] | null; + public product_type: string | null; + public published_at: string | null; + public published_scope: string | null; + public status: string | null; + public tags: string | string[] | null; + public template_suffix: string | null; + public updated_at: string | null; + public variants: Variant[] | null | {[key: string]: any}; + public vendor: string | null; +} diff --git a/src/rest-resources/2021-07/product_listing.ts b/src/rest-resources/2021-07/product_listing.ts new file mode 100644 index 000000000..caacf0d0f --- /dev/null +++ b/src/rest-resources/2021-07/product_listing.ts @@ -0,0 +1,158 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Image} from './image'; +import {Variant} from './variant'; + +interface FindArgs { + session: SessionInterface; + product_id: number | string; +} +interface DeleteArgs { + session: SessionInterface; + product_id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + product_ids?: unknown; + limit?: unknown; + collection_id?: unknown; + updated_at_min?: unknown; + handle?: unknown; +} +interface ProductIdsArgs { + [key: string]: unknown; + session: SessionInterface; + limit?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; +} + +export class ProductListing extends Base { + public static API_VERSION = ApiVersion.July21; + + protected static NAME = 'product_listing'; + protected static PLURAL_NAME = 'product_listings'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = { + images: Image, + variants: Variant + }; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "product_listings.json"}, + {http_method: "get", operation: "product_ids", ids: [], path: "product_listings/product_ids.json"}, + {http_method: "get", operation: "count", ids: [], path: "product_listings/count.json"}, + {http_method: "get", operation: "get", ids: ["product_id"], path: "product_listings/.json"}, + {http_method: "put", operation: "put", ids: ["product_id"], path: "product_listings/.json"}, + {http_method: "delete", operation: "delete", ids: ["product_id"], path: "product_listings/.json"} + ]; + protected static PRIMARY_KEY: string = "product_id"; + + public static async find( + { + session, + product_id + }: FindArgs + ): Promise { + const result = await ProductListing.baseFind({ + session: session, + urlIds: {product_id: product_id}, + params: {}, + }); + return result ? result[0] as ProductListing : null; + } + + public static async delete( + { + session, + product_id + }: DeleteArgs + ): Promise { + const response = await ProductListing.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {product_id: product_id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + product_ids = null, + limit = null, + collection_id = null, + updated_at_min = null, + handle = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await ProductListing.baseFind({ + session: session, + urlIds: {}, + params: {product_ids: product_ids, limit: limit, collection_id: collection_id, updated_at_min: updated_at_min, handle: handle, ...otherArgs}, + }); + + return response as ProductListing[]; + } + + public static async product_ids( + { + session, + limit = null, + ...otherArgs + }: ProductIdsArgs + ): Promise { + const response = await ProductListing.request({ + http_method: "get", + operation: "product_ids", + session: session, + urlIds: {}, + params: {limit: limit, ...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public static async count( + { + session, + ...otherArgs + }: CountArgs + ): Promise { + const response = await ProductListing.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {}, + params: {...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public body_html: string | null; + public created_at: string | null; + public handle: string | null; + public images: Image[] | null | {[key: string]: any}; + public options: {[key: string]: unknown}[] | null; + public product_id: number | null; + public product_type: string | null; + public published_at: string | null; + public tags: string | null; + public title: string | null; + public updated_at: string | null; + public variants: Variant[] | null | {[key: string]: any}; + public vendor: string | null; +} diff --git a/src/rest-resources/2021-07/product_resource_feedback.ts b/src/rest-resources/2021-07/product_resource_feedback.ts new file mode 100644 index 000000000..ce2f6e73e --- /dev/null +++ b/src/rest-resources/2021-07/product_resource_feedback.ts @@ -0,0 +1,53 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + product_id?: number | string | null; +} + +export class ProductResourceFeedback extends Base { + public static API_VERSION = ApiVersion.July21; + + protected static NAME = 'product_resource_feedback'; + protected static PLURAL_NAME = 'product_resource_feedbacks'; + 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: ["product_id"], path: "products//resource_feedback.json"}, + {http_method: "get", operation: "get", ids: ["product_id"], path: "products//resource_feedback.json"} + ]; + + protected static getJsonBodyName(): string + { + return "resource_feedback"; + } + + public static async all( + { + session, + product_id = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await ProductResourceFeedback.baseFind({ + session: session, + urlIds: {product_id: product_id}, + params: {...otherArgs}, + }); + + return response as ProductResourceFeedback[]; + } + + public created_at: string | null; + public feedback_generated_at: string | null; + public messages: string[] | null; + public product_id: number | null; + public resource_id: number | null; + public resource_type: string | null; + public resource_updated_at: string | null; + public state: string | null; + public updated_at: string | null; +} diff --git a/src/rest-resources/2021-07/province.ts b/src/rest-resources/2021-07/province.ts new file mode 100644 index 000000000..24dbe0e12 --- /dev/null +++ b/src/rest-resources/2021-07/province.ts @@ -0,0 +1,101 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + country_id?: number | string | null; + fields?: unknown; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + country_id?: number | string | null; + since_id?: unknown; + fields?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; + country_id?: number | string | null; +} + +export class Province extends Base { + public static API_VERSION = ApiVersion.July21; + + protected static NAME = 'province'; + protected static PLURAL_NAME = 'provinces'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: ["country_id"], path: "countries//provinces.json"}, + {http_method: "get", operation: "count", ids: ["country_id"], path: "countries//provinces/count.json"}, + {http_method: "get", operation: "get", ids: ["country_id", "id"], path: "countries//provinces/.json"}, + {http_method: "put", operation: "put", ids: ["country_id", "id"], path: "countries//provinces/.json"} + ]; + + public static async find( + { + session, + id, + country_id = null, + fields = null + }: FindArgs + ): Promise { + const result = await Province.baseFind({ + session: session, + urlIds: {id: id, country_id: country_id}, + params: {fields: fields}, + }); + return result ? result[0] as Province : null; + } + + public static async all( + { + session, + country_id = null, + since_id = null, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Province.baseFind({ + session: session, + urlIds: {country_id: country_id}, + params: {since_id: since_id, fields: fields, ...otherArgs}, + }); + + return response as Province[]; + } + + public static async count( + { + session, + country_id = null, + ...otherArgs + }: CountArgs + ): Promise { + const response = await Province.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {country_id: country_id}, + params: {...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public code: string | null; + public country_id: number | null; + public id: number | null; + public name: string | null; + public shipping_zone_id: number | null; + public tax: number | null; + public tax_name: string | null; + public tax_percentage: number | null; + public tax_type: string | null; +} diff --git a/src/rest-resources/2021-07/recurring_application_charge.ts b/src/rest-resources/2021-07/recurring_application_charge.ts new file mode 100644 index 000000000..354921a2f --- /dev/null +++ b/src/rest-resources/2021-07/recurring_application_charge.ts @@ -0,0 +1,124 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + since_id?: unknown; + fields?: unknown; +} +interface CustomizeArgs { + [key: string]: unknown; + body?: {[key: string]: unknown} | null; +} + +export class RecurringApplicationCharge extends Base { + public static API_VERSION = ApiVersion.July21; + + protected static NAME = 'recurring_application_charge'; + protected static PLURAL_NAME = 'recurring_application_charges'; + 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: "recurring_application_charges.json"}, + {http_method: "get", operation: "get", ids: [], path: "recurring_application_charges.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "recurring_application_charges/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "recurring_application_charges/.json"}, + {http_method: "put", operation: "customize", ids: ["id"], path: "recurring_application_charges//customize.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await RecurringApplicationCharge.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as RecurringApplicationCharge : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await RecurringApplicationCharge.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + since_id = null, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await RecurringApplicationCharge.baseFind({ + session: session, + urlIds: {}, + params: {since_id: since_id, fields: fields, ...otherArgs}, + }); + + return response as RecurringApplicationCharge[]; + } + + public async customize( + { + body = null, + ...otherArgs + }: CustomizeArgs + ): Promise { + const response = await RecurringApplicationCharge.request({ + http_method: "put", + operation: "customize", + session: this.session, + urlIds: {id: this.id}, + params: {...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public activated_on: string | null; + public billing_on: string | null; + public cancelled_on: string | null; + public capped_amount: string | number | null; + public confirmation_url: string | null; + public created_at: string | null; + public id: number | null; + public name: string | null; + public price: string | number | null; + public return_url: string | null; + public status: string | null; + public terms: string | null; + public test: boolean | null; + public trial_days: number | null; + public trial_ends_on: string | null; + public updated_at: string | null; +} diff --git a/src/rest-resources/2021-07/redirect.ts b/src/rest-resources/2021-07/redirect.ts new file mode 100644 index 000000000..5850fcc79 --- /dev/null +++ b/src/rest-resources/2021-07/redirect.ts @@ -0,0 +1,122 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + limit?: unknown; + since_id?: unknown; + path?: unknown; + target?: unknown; + fields?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; + path?: unknown; + target?: unknown; +} + +export class Redirect extends Base { + public static API_VERSION = ApiVersion.July21; + + protected static NAME = 'redirect'; + protected static PLURAL_NAME = 'redirects'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "redirects.json"}, + {http_method: "post", operation: "post", ids: [], path: "redirects.json"}, + {http_method: "get", operation: "count", ids: [], path: "redirects/count.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "redirects/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "redirects/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "redirects/.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await Redirect.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as Redirect : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await Redirect.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + limit = null, + since_id = null, + path = null, + target = null, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Redirect.baseFind({ + session: session, + urlIds: {}, + params: {limit: limit, since_id: since_id, path: path, target: target, fields: fields, ...otherArgs}, + }); + + return response as Redirect[]; + } + + public static async count( + { + session, + path = null, + target = null, + ...otherArgs + }: CountArgs + ): Promise { + const response = await Redirect.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {}, + params: {path: path, target: target, ...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public id: number | null; + public path: string | null; + public target: string | null; +} diff --git a/src/rest-resources/2021-07/refund.ts b/src/rest-resources/2021-07/refund.ts new file mode 100644 index 000000000..5047d4a89 --- /dev/null +++ b/src/rest-resources/2021-07/refund.ts @@ -0,0 +1,116 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Transaction} from './transaction'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + order_id?: number | string | null; + fields?: unknown; + in_shop_currency?: unknown; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + order_id?: number | string | null; + limit?: unknown; + fields?: unknown; + in_shop_currency?: unknown; +} +interface CalculateArgs { + [key: string]: unknown; + shipping?: unknown; + refund_line_items?: unknown; + currency?: unknown; + body?: {[key: string]: unknown} | null; +} + +export class Refund extends Base { + public static API_VERSION = ApiVersion.July21; + + protected static NAME = 'refund'; + protected static PLURAL_NAME = 'refunds'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = { + transactions: Transaction + }; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: ["order_id"], path: "orders//refunds.json"}, + {http_method: "post", operation: "post", ids: ["order_id"], path: "orders//refunds.json"}, + {http_method: "get", operation: "get", ids: ["order_id", "id"], path: "orders//refunds/.json"}, + {http_method: "post", operation: "calculate", ids: ["order_id"], path: "orders//refunds/calculate.json"} + ]; + + public static async find( + { + session, + id, + order_id = null, + fields = null, + in_shop_currency = null + }: FindArgs + ): Promise { + const result = await Refund.baseFind({ + session: session, + urlIds: {id: id, order_id: order_id}, + params: {fields: fields, in_shop_currency: in_shop_currency}, + }); + return result ? result[0] as Refund : null; + } + + public static async all( + { + session, + order_id = null, + limit = null, + fields = null, + in_shop_currency = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Refund.baseFind({ + session: session, + urlIds: {order_id: order_id}, + params: {limit: limit, fields: fields, in_shop_currency: in_shop_currency, ...otherArgs}, + }); + + return response as Refund[]; + } + + public async calculate( + { + shipping = null, + refund_line_items = null, + currency = null, + body = null, + ...otherArgs + }: CalculateArgs + ): Promise { + const response = await Refund.request({ + http_method: "post", + operation: "calculate", + session: this.session, + urlIds: {order_id: this.order_id}, + params: {shipping: shipping, refund_line_items: refund_line_items, currency: currency, ...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public created_at: string | null; + public duties: {[key: string]: unknown}[] | null; + public id: number | null; + public note: string | null; + public order_adjustments: {[key: string]: unknown}[] | null; + public order_id: number | null; + public processed_at: string | null; + public refund_duties: {[key: string]: unknown}[] | null; + public refund_line_items: {[key: string]: unknown}[] | null; + public restock: boolean | null; + public transactions: Transaction[] | null | {[key: string]: any}; + public user_id: number | null; +} diff --git a/src/rest-resources/2021-07/report.ts b/src/rest-resources/2021-07/report.ts new file mode 100644 index 000000000..9514d7466 --- /dev/null +++ b/src/rest-resources/2021-07/report.ts @@ -0,0 +1,98 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + ids?: unknown; + limit?: unknown; + since_id?: unknown; + updated_at_min?: unknown; + updated_at_max?: unknown; + fields?: unknown; +} + +export class Report extends Base { + public static API_VERSION = ApiVersion.July21; + + protected static NAME = 'report'; + protected static PLURAL_NAME = 'reports'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "reports.json"}, + {http_method: "post", operation: "post", ids: [], path: "reports.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "reports/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "reports/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "reports/.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await Report.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as Report : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await Report.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + ids = null, + limit = null, + since_id = null, + updated_at_min = null, + updated_at_max = null, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Report.baseFind({ + session: session, + urlIds: {}, + params: {ids: ids, limit: limit, since_id: since_id, updated_at_min: updated_at_min, updated_at_max: updated_at_max, fields: fields, ...otherArgs}, + }); + + return response as Report[]; + } + + public category: string | null; + public id: number | null; + public name: string | null; + public shopify_ql: string | null; + public updated_at: string | null; +} diff --git a/src/rest-resources/2021-07/resource_feedback.ts b/src/rest-resources/2021-07/resource_feedback.ts new file mode 100644 index 000000000..36f21d7e1 --- /dev/null +++ b/src/rest-resources/2021-07/resource_feedback.ts @@ -0,0 +1,44 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; +} + +export class ResourceFeedback extends Base { + public static API_VERSION = ApiVersion.July21; + + protected static NAME = 'resource_feedback'; + protected static PLURAL_NAME = 'resource_feedbacks'; + 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: "resource_feedback.json"}, + {http_method: "get", operation: "get", ids: [], path: "resource_feedback.json"} + ]; + + public static async all( + { + session, + ...otherArgs + }: AllArgs + ): Promise { + const response = await ResourceFeedback.baseFind({ + session: session, + urlIds: {}, + params: {...otherArgs}, + }); + + return response as ResourceFeedback[]; + } + + public created_at: string | null; + public feedback_generated_at: string | null; + public messages: string[] | null; + public resource_id: number | null; + public resource_type: string | null; + public state: string | null; + public updated_at: string | null; +} diff --git a/src/rest-resources/2021-07/script_tag.ts b/src/rest-resources/2021-07/script_tag.ts new file mode 100644 index 000000000..f805dec48 --- /dev/null +++ b/src/rest-resources/2021-07/script_tag.ts @@ -0,0 +1,130 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + limit?: unknown; + since_id?: unknown; + created_at_min?: unknown; + created_at_max?: unknown; + updated_at_min?: unknown; + updated_at_max?: unknown; + src?: unknown; + fields?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; + src?: unknown; +} + +export class ScriptTag extends Base { + public static API_VERSION = ApiVersion.July21; + + protected static NAME = 'script_tag'; + protected static PLURAL_NAME = 'script_tags'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "script_tags.json"}, + {http_method: "post", operation: "post", ids: [], path: "script_tags.json"}, + {http_method: "get", operation: "count", ids: [], path: "script_tags/count.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "script_tags/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "script_tags/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "script_tags/.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await ScriptTag.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as ScriptTag : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await ScriptTag.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + limit = null, + since_id = null, + created_at_min = null, + created_at_max = null, + updated_at_min = null, + updated_at_max = null, + src = null, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await ScriptTag.baseFind({ + session: session, + urlIds: {}, + params: {limit: limit, since_id: since_id, created_at_min: created_at_min, created_at_max: created_at_max, updated_at_min: updated_at_min, updated_at_max: updated_at_max, src: src, fields: fields, ...otherArgs}, + }); + + return response as ScriptTag[]; + } + + public static async count( + { + session, + src = null, + ...otherArgs + }: CountArgs + ): Promise { + const response = await ScriptTag.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {}, + params: {src: src, ...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public event: string | null; + public src: string | null; + public cache: boolean | null; + public created_at: string | null; + public display_scope: string | null; + public id: number | null; + public updated_at: string | null; +} diff --git a/src/rest-resources/2021-07/shipping_zone.ts b/src/rest-resources/2021-07/shipping_zone.ts new file mode 100644 index 000000000..b3d91d245 --- /dev/null +++ b/src/rest-resources/2021-07/shipping_zone.ts @@ -0,0 +1,53 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Country} from './country'; +import {Province} from './province'; + +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + fields?: unknown; +} + +export class ShippingZone extends Base { + public static API_VERSION = ApiVersion.July21; + + protected static NAME = 'shipping_zone'; + protected static PLURAL_NAME = 'shipping_zones'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = { + countries: Country, + provinces: Province + }; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "shipping_zones.json"} + ]; + + public static async all( + { + session, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await ShippingZone.baseFind({ + session: session, + urlIds: {}, + params: {fields: fields, ...otherArgs}, + }); + + return response as ShippingZone[]; + } + + public carrier_shipping_rate_providers: unknown | null; + public countries: Country[] | null | {[key: string]: any}; + public id: number | null; + public location_group_id: number | null; + public name: string | null; + public price_based_shipping_rates: {[key: string]: unknown} | null; + public profile_id: number | null; + public provinces: Province[] | null | {[key: string]: any}; + public weight_based_shipping_rates: {[key: string]: unknown} | null; +} diff --git a/src/rest-resources/2021-07/shop.ts b/src/rest-resources/2021-07/shop.ts new file mode 100644 index 000000000..f2848619f --- /dev/null +++ b/src/rest-resources/2021-07/shop.ts @@ -0,0 +1,100 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Country} from './country'; +import {Currency} from './currency'; +import {Province} from './province'; + +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + fields?: unknown; +} + +export class Shop extends Base { + public static API_VERSION = ApiVersion.July21; + + protected static NAME = 'shop'; + protected static PLURAL_NAME = 'shops'; + protected static HAS_ONE: {[key: string]: typeof Base} = { + country: Country, + currency: Currency, + province: Province + }; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "shop.json"} + ]; + + public static async all( + { + session, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Shop.baseFind({ + session: session, + urlIds: {}, + params: {fields: fields, ...otherArgs}, + }); + + return response as Shop[]; + } + + public address1: string | null; + public address2: string | null; + public checkout_api_supported: boolean | null; + public city: string | null; + public cookie_consent_level: string | null; + public country: Country | null | {[key: string]: any}; + public country_code: string | null; + public country_name: string | null; + public county_taxes: string | null; + public created_at: string | null; + public currency: Currency | null | {[key: string]: any}; + public customer_email: string | null; + public domain: string | null; + public eligible_for_card_reader_giveaway: boolean | null; + public eligible_for_payments: boolean | null; + public email: string | null; + public enabled_presentment_currencies: string[] | null; + public finances: boolean | null; + public force_ssl: boolean | null; + public google_apps_domain: string | null; + public google_apps_login_enabled: string | null; + public has_discounts: boolean | null; + public has_gift_cards: boolean | null; + public has_storefront: boolean | null; + public iana_timezone: string | null; + public id: number | null; + public latitude: number | null; + public longitude: number | null; + public money_format: string | null; + public money_in_emails_format: string | null; + public money_with_currency_format: string | null; + public money_with_currency_in_emails_format: string | null; + public multi_location_enabled: boolean | null; + public myshopify_domain: string | null; + public name: string | null; + public password_enabled: boolean | null; + public phone: string | null; + public plan_display_name: string | null; + public plan_name: string | null; + public pre_launch_enabled: boolean | null; + public primary_locale: string | null; + public primary_location_id: number | null; + public province: Province | null | {[key: string]: any}; + public province_code: string | null; + public requires_extra_payments_agreement: boolean | null; + public setup_required: boolean | null; + public shop_owner: string | null; + public source: string | null; + public tax_shipping: string | null; + public taxes_included: string | null; + public timezone: string | null; + public updated_at: string | null; + public weight_unit: string | null; + public zip: string | null; +} diff --git a/src/rest-resources/2021-07/smart_collection.ts b/src/rest-resources/2021-07/smart_collection.ts new file mode 100644 index 000000000..e479c0072 --- /dev/null +++ b/src/rest-resources/2021-07/smart_collection.ts @@ -0,0 +1,183 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + limit?: unknown; + ids?: unknown; + since_id?: unknown; + title?: unknown; + product_id?: unknown; + handle?: unknown; + updated_at_min?: unknown; + updated_at_max?: unknown; + published_at_min?: unknown; + published_at_max?: unknown; + published_status?: unknown; + fields?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; + title?: unknown; + product_id?: unknown; + updated_at_min?: unknown; + updated_at_max?: unknown; + published_at_min?: unknown; + published_at_max?: unknown; + published_status?: unknown; +} +interface OrderArgs { + [key: string]: unknown; + products?: unknown; + sort_order?: unknown; + body?: {[key: string]: unknown} | null; +} + +export class SmartCollection extends Base { + public static API_VERSION = ApiVersion.July21; + + protected static NAME = 'smart_collection'; + protected static PLURAL_NAME = 'smart_collections'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "smart_collections.json"}, + {http_method: "post", operation: "post", ids: [], path: "smart_collections.json"}, + {http_method: "get", operation: "count", ids: [], path: "smart_collections/count.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "smart_collections/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "smart_collections/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "smart_collections/.json"}, + {http_method: "put", operation: "order", ids: ["id"], path: "smart_collections//order.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await SmartCollection.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as SmartCollection : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await SmartCollection.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + limit = null, + ids = null, + since_id = null, + title = null, + product_id = null, + handle = null, + updated_at_min = null, + updated_at_max = null, + published_at_min = null, + published_at_max = null, + published_status = null, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await SmartCollection.baseFind({ + session: session, + urlIds: {}, + params: {limit: limit, ids: ids, since_id: since_id, title: title, product_id: product_id, handle: handle, 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, fields: fields, ...otherArgs}, + }); + + return response as SmartCollection[]; + } + + public static async count( + { + session, + title = null, + product_id = null, + updated_at_min = null, + updated_at_max = null, + published_at_min = null, + published_at_max = null, + published_status = null, + ...otherArgs + }: CountArgs + ): Promise { + const response = await SmartCollection.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {}, + params: {title: title, product_id: product_id, 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, + }); + + return response ? response.body : null; + } + + public async order( + { + products = null, + sort_order = null, + body = null, + ...otherArgs + }: OrderArgs + ): Promise { + const response = await SmartCollection.request({ + http_method: "put", + operation: "order", + session: this.session, + urlIds: {id: this.id}, + params: {products: products, sort_order: sort_order, ...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public rules: {[key: string]: unknown} | {[key: string]: unknown}[] | null; + public title: string | null; + public body_html: string | null; + public disjunctive: boolean | null; + public handle: string | null; + public id: number | null; + public image: string | {[key: string]: unknown} | null; + public published_at: string | null; + public published_scope: string | null; + public sort_order: string | null; + public template_suffix: string | null; + public updated_at: string | null; +} diff --git a/src/rest-resources/2021-07/storefront_access_token.ts b/src/rest-resources/2021-07/storefront_access_token.ts new file mode 100644 index 000000000..2661b7200 --- /dev/null +++ b/src/rest-resources/2021-07/storefront_access_token.ts @@ -0,0 +1,68 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {AccessScope} from './access_scope'; + +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; +} + +export class StorefrontAccessToken extends Base { + public static API_VERSION = ApiVersion.July21; + + protected static NAME = 'storefront_access_token'; + protected static PLURAL_NAME = 'storefront_access_tokens'; + protected static HAS_ONE: {[key: string]: typeof Base} = { + access_scope: AccessScope + }; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "post", operation: "post", ids: [], path: "storefront_access_tokens.json"}, + {http_method: "get", operation: "get", ids: [], path: "storefront_access_tokens.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "storefront_access_tokens/.json"} + ]; + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await StorefrontAccessToken.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + ...otherArgs + }: AllArgs + ): Promise { + const response = await StorefrontAccessToken.baseFind({ + session: session, + urlIds: {}, + params: {...otherArgs}, + }); + + return response as StorefrontAccessToken[]; + } + + public title: string | null; + public access_scope: AccessScope | null | {[key: string]: any}; + public access_token: string | null; + public created_at: string | null; + public id: number | null; +} diff --git a/src/rest-resources/2021-07/tender_transaction.ts b/src/rest-resources/2021-07/tender_transaction.ts new file mode 100644 index 000000000..66c38935f --- /dev/null +++ b/src/rest-resources/2021-07/tender_transaction.ts @@ -0,0 +1,62 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Currency} from './currency'; + +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + limit?: unknown; + since_id?: unknown; + processed_at_min?: unknown; + processed_at_max?: unknown; + processed_at?: unknown; + order?: unknown; +} + +export class TenderTransaction extends Base { + public static API_VERSION = ApiVersion.July21; + + protected static NAME = 'tender_transaction'; + protected static PLURAL_NAME = 'tender_transactions'; + protected static HAS_ONE: {[key: string]: typeof Base} = { + currency: Currency + }; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "tender_transactions.json"} + ]; + + public static async all( + { + session, + limit = null, + since_id = null, + processed_at_min = null, + processed_at_max = null, + processed_at = null, + order = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await TenderTransaction.baseFind({ + session: session, + urlIds: {}, + params: {limit: limit, since_id: since_id, processed_at_min: processed_at_min, processed_at_max: processed_at_max, processed_at: processed_at, order: order, ...otherArgs}, + }); + + return response as TenderTransaction[]; + } + + public amount: string | null; + public currency: Currency | null | {[key: string]: any}; + public id: number | null; + public order_id: number | null; + public payment_details: {[key: string]: unknown} | null; + public payment_method: string | null; + public processed_at: string | null; + public remote_reference: string | null; + public test: boolean | null; + public user_id: number | null; +} diff --git a/src/rest-resources/2021-07/theme.ts b/src/rest-resources/2021-07/theme.ts new file mode 100644 index 000000000..139be6013 --- /dev/null +++ b/src/rest-resources/2021-07/theme.ts @@ -0,0 +1,91 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + fields?: unknown; +} + +export class Theme extends Base { + public static API_VERSION = ApiVersion.July21; + + protected static NAME = 'theme'; + protected static PLURAL_NAME = 'themes'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "themes.json"}, + {http_method: "post", operation: "post", ids: [], path: "themes.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "themes/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "themes/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "themes/.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await Theme.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as Theme : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await Theme.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Theme.baseFind({ + session: session, + urlIds: {}, + params: {fields: fields, ...otherArgs}, + }); + + return response as Theme[]; + } + + public created_at: string | null; + public id: number | null; + public name: string | null; + public previewable: boolean | null; + public processing: boolean | null; + public role: string | null; + public theme_store_id: number | null; + public updated_at: string | null; +} diff --git a/src/rest-resources/2021-07/transaction.ts b/src/rest-resources/2021-07/transaction.ts new file mode 100644 index 000000000..fc1cc02dc --- /dev/null +++ b/src/rest-resources/2021-07/transaction.ts @@ -0,0 +1,119 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + order_id?: number | string | null; + fields?: unknown; + in_shop_currency?: unknown; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + order_id?: number | string | null; + since_id?: unknown; + fields?: unknown; + in_shop_currency?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; + order_id?: number | string | null; +} + +export class Transaction extends Base { + public static API_VERSION = ApiVersion.July21; + + protected static NAME = 'transaction'; + protected static PLURAL_NAME = 'transactions'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: ["order_id"], path: "orders//transactions.json"}, + {http_method: "post", operation: "post", ids: ["order_id"], path: "orders//transactions.json"}, + {http_method: "get", operation: "count", ids: ["order_id"], path: "orders//transactions/count.json"}, + {http_method: "get", operation: "get", ids: ["order_id", "id"], path: "orders//transactions/.json"} + ]; + + public static async find( + { + session, + id, + order_id = null, + fields = null, + in_shop_currency = null + }: FindArgs + ): Promise { + const result = await Transaction.baseFind({ + session: session, + urlIds: {id: id, order_id: order_id}, + params: {fields: fields, in_shop_currency: in_shop_currency}, + }); + return result ? result[0] as Transaction : null; + } + + public static async all( + { + session, + order_id = null, + since_id = null, + fields = null, + in_shop_currency = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Transaction.baseFind({ + session: session, + urlIds: {order_id: order_id}, + params: {since_id: since_id, fields: fields, in_shop_currency: in_shop_currency, ...otherArgs}, + }); + + return response as Transaction[]; + } + + public static async count( + { + session, + order_id = null, + ...otherArgs + }: CountArgs + ): Promise { + const response = await Transaction.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {order_id: order_id}, + params: {...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public kind: string | null; + public amount: string | null; + public authorization: string | null; + public authorization_expires_at: string | null; + public created_at: string | null; + public currency: string | null; + public currency_exchange_adjustment: {[key: string]: unknown} | null; + public device_id: number | null; + public error_code: string | null; + public extended_authorization_attributes: {[key: string]: unknown} | null; + public gateway: string | null; + public id: number | null; + public location_id: number | null; + public message: string | null; + public order_id: number | null; + public parent_id: number | null; + public payment_details: {[key: string]: unknown} | null; + public processed_at: string | null; + public receipt: {[key: string]: unknown} | null; + public source_name: string | null; + public status: string | null; + public test: boolean | null; + public user_id: number | null; +} diff --git a/src/rest-resources/2021-07/usage_charge.ts b/src/rest-resources/2021-07/usage_charge.ts new file mode 100644 index 000000000..eab61cfbf --- /dev/null +++ b/src/rest-resources/2021-07/usage_charge.ts @@ -0,0 +1,70 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + recurring_application_charge_id?: number | string | null; + fields?: unknown; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + recurring_application_charge_id?: number | string | null; + fields?: unknown; +} + +export class UsageCharge extends Base { + public static API_VERSION = ApiVersion.July21; + + protected static NAME = 'usage_charge'; + protected static PLURAL_NAME = 'usage_charges'; + 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: ["recurring_application_charge_id"], path: "recurring_application_charges//usage_charges.json"}, + {http_method: "get", operation: "get", ids: ["recurring_application_charge_id"], path: "recurring_application_charges//usage_charges.json"}, + {http_method: "get", operation: "get", ids: ["recurring_application_charge_id", "id"], path: "recurring_application_charges//usage_charges/.json"} + ]; + + public static async find( + { + session, + id, + recurring_application_charge_id = null, + fields = null + }: FindArgs + ): Promise { + const result = await UsageCharge.baseFind({ + session: session, + urlIds: {id: id, recurring_application_charge_id: recurring_application_charge_id}, + params: {fields: fields}, + }); + return result ? result[0] as UsageCharge : null; + } + + public static async all( + { + session, + recurring_application_charge_id = null, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await UsageCharge.baseFind({ + session: session, + urlIds: {recurring_application_charge_id: recurring_application_charge_id}, + params: {fields: fields, ...otherArgs}, + }); + + return response as UsageCharge[]; + } + + public created_at: string | null; + public description: string | null; + public id: number | null; + public price: number | null; + public recurring_application_charge_id: number | null; + public updated_at: string | null; +} diff --git a/src/rest-resources/2021-07/user.ts b/src/rest-resources/2021-07/user.ts new file mode 100644 index 000000000..918e43d51 --- /dev/null +++ b/src/rest-resources/2021-07/user.ts @@ -0,0 +1,97 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + limit?: unknown; + page_info?: unknown; +} +interface CurrentArgs { + [key: string]: unknown; + session: SessionInterface; +} + +export class User extends Base { + public static API_VERSION = ApiVersion.July21; + + protected static NAME = 'user'; + protected static PLURAL_NAME = 'users'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "users.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "users/.json"}, + {http_method: "get", operation: "current", ids: [], path: "users/current.json"} + ]; + + public static async find( + { + session, + id + }: FindArgs + ): Promise { + const result = await User.baseFind({ + session: session, + urlIds: {id: id}, + params: {}, + }); + return result ? result[0] as User : null; + } + + public static async all( + { + session, + limit = null, + page_info = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await User.baseFind({ + session: session, + urlIds: {}, + params: {limit: limit, page_info: page_info, ...otherArgs}, + }); + + return response as User[]; + } + + public static async current( + { + session, + ...otherArgs + }: CurrentArgs + ): Promise { + const response = await User.request({ + http_method: "get", + operation: "current", + session: session, + urlIds: {}, + params: {...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public account_owner: boolean | null; + public bio: string | null; + public email: string | null; + public first_name: string | null; + public id: number | null; + public im: string | null; + public last_name: string | null; + public locale: string | null; + public permissions: string[] | null; + public phone: string | null; + public receive_announcements: number | null; + public screen_name: string | null; + public url: string | null; + public user_type: string | null; +} diff --git a/src/rest-resources/2021-07/variant.ts b/src/rest-resources/2021-07/variant.ts new file mode 100644 index 000000000..02745a189 --- /dev/null +++ b/src/rest-resources/2021-07/variant.ts @@ -0,0 +1,145 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; + product_id?: number | string | null; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + product_id?: number | string | null; + limit?: unknown; + presentment_currencies?: unknown; + since_id?: unknown; + fields?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; + product_id?: number | string | null; +} + +export class Variant extends Base { + public static API_VERSION = ApiVersion.July21; + + protected static NAME = 'variant'; + protected static PLURAL_NAME = 'variants'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: ["product_id"], path: "products//variants.json"}, + {http_method: "get", operation: "count", ids: ["product_id"], path: "products//variants/count.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "variants/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "variants/.json"}, + {http_method: "post", operation: "post", ids: ["product_id"], path: "products//variants.json"}, + {http_method: "delete", operation: "delete", ids: ["product_id", "id"], path: "products//variants/.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await Variant.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as Variant : null; + } + + public static async delete( + { + session, + id, + product_id = null + }: DeleteArgs + ): Promise { + const response = await Variant.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id, product_id: product_id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + product_id = null, + limit = null, + presentment_currencies = null, + since_id = null, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Variant.baseFind({ + session: session, + urlIds: {product_id: product_id}, + params: {limit: limit, presentment_currencies: presentment_currencies, since_id: since_id, fields: fields, ...otherArgs}, + }); + + return response as Variant[]; + } + + public static async count( + { + session, + product_id = null, + ...otherArgs + }: CountArgs + ): Promise { + const response = await Variant.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {product_id: product_id}, + params: {...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public barcode: string | null; + public compare_at_price: string | null; + public created_at: string | null; + public fulfillment_service: string | null; + public grams: number | null; + public id: number | null; + public image_id: number | null; + public inventory_item_id: number | null; + public inventory_management: string | null; + public inventory_policy: string | null; + public inventory_quantity: number | null; + public inventory_quantity_adjustment: number | null; + public old_inventory_quantity: number | null; + public option: {[key: string]: unknown} | null; + public position: number | null; + public presentment_prices: {[key: string]: unknown}[] | null; + public price: string | null; + public product_id: number | null; + public requires_shipping: boolean | null; + public sku: string | null; + public tax_code: string | null; + public taxable: boolean | null; + public title: string | null; + public updated_at: string | null; + public weight: number | null; + public weight_unit: string | null; +} diff --git a/src/rest-resources/2021-07/webhook.ts b/src/rest-resources/2021-07/webhook.ts new file mode 100644 index 000000000..8e3e9f1bd --- /dev/null +++ b/src/rest-resources/2021-07/webhook.ts @@ -0,0 +1,137 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + address?: unknown; + created_at_max?: unknown; + created_at_min?: unknown; + fields?: unknown; + limit?: unknown; + since_id?: unknown; + topic?: unknown; + updated_at_min?: unknown; + updated_at_max?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; + address?: unknown; + topic?: unknown; +} + +export class Webhook extends Base { + public static API_VERSION = ApiVersion.July21; + + protected static NAME = 'webhook'; + protected static PLURAL_NAME = 'webhooks'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "webhooks.json"}, + {http_method: "post", operation: "post", ids: [], path: "webhooks.json"}, + {http_method: "get", operation: "count", ids: [], path: "webhooks/count.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "webhooks/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "webhooks/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "webhooks/.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await Webhook.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as Webhook : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await Webhook.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + address = null, + created_at_max = null, + created_at_min = null, + fields = null, + limit = null, + since_id = null, + topic = null, + updated_at_min = null, + updated_at_max = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Webhook.baseFind({ + session: session, + urlIds: {}, + params: {address: address, created_at_max: created_at_max, created_at_min: created_at_min, fields: fields, limit: limit, since_id: since_id, topic: topic, updated_at_min: updated_at_min, updated_at_max: updated_at_max, ...otherArgs}, + }); + + return response as Webhook[]; + } + + public static async count( + { + session, + address = null, + topic = null, + ...otherArgs + }: CountArgs + ): Promise { + const response = await Webhook.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {}, + params: {address: address, topic: topic, ...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public address: string | null; + public topic: string | null; + public api_version: string | null; + public created_at: string | null; + public fields: string[] | null; + public format: string | null; + public id: number | null; + public metafield_namespaces: string[] | null; + public private_metafield_namespaces: string[] | null; + public updated_at: string | null; +} diff --git a/src/rest-resources/2021-10/abandoned_checkout.ts b/src/rest-resources/2021-10/abandoned_checkout.ts new file mode 100644 index 000000000..5e2042e8d --- /dev/null +++ b/src/rest-resources/2021-10/abandoned_checkout.ts @@ -0,0 +1,103 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Currency} from './currency'; +import {Customer} from './customer'; +import {DiscountCode} from './discount_code'; + +interface CheckoutsArgs { + [key: string]: unknown; + session: SessionInterface; + since_id?: unknown; + created_at_min?: unknown; + created_at_max?: unknown; + updated_at_min?: unknown; + updated_at_max?: unknown; + status?: unknown; + limit?: unknown; +} + +export class AbandonedCheckout extends Base { + public static API_VERSION = ApiVersion.October21; + + protected static NAME = 'abandoned_checkout'; + protected static PLURAL_NAME = 'abandoned_checkouts'; + protected static HAS_ONE: {[key: string]: typeof Base} = { + currency: Currency, + customer: Customer + }; + protected static HAS_MANY: {[key: string]: typeof Base} = { + discount_codes: DiscountCode + }; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "checkouts", ids: [], path: "checkouts.json"}, + {http_method: "get", operation: "checkouts", ids: [], path: "checkouts.json"} + ]; + + public static async checkouts( + { + session, + since_id = null, + created_at_min = null, + created_at_max = null, + updated_at_min = null, + updated_at_max = null, + status = null, + limit = null, + ...otherArgs + }: CheckoutsArgs + ): Promise { + const response = await AbandonedCheckout.request({ + http_method: "get", + operation: "checkouts", + session: session, + urlIds: {}, + params: {since_id: since_id, created_at_min: created_at_min, created_at_max: created_at_max, updated_at_min: updated_at_min, updated_at_max: updated_at_max, status: status, limit: limit, ...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public abandoned_checkout_url: string | null; + public billing_address: {[key: string]: unknown} | null; + public buyer_accepts_marketing: boolean | null; + public buyer_accepts_sms_marketing: boolean | null; + public cart_token: string | null; + public closed_at: string | null; + public completed_at: string | null; + public created_at: string | null; + public currency: Currency | null | {[key: string]: any}; + public customer: Customer | null | {[key: string]: any}; + public customer_locale: string | null; + public device_id: number | null; + public discount_codes: DiscountCode[] | null | {[key: string]: any}; + public email: string | null; + public gateway: string | null; + public id: number | null; + public landing_site: string | null; + public line_items: {[key: string]: unknown} | null; + public location_id: number | null; + public note: string | null; + public phone: string | null; + public presentment_currency: string | null; + public referring_site: string | null; + public shipping_address: {[key: string]: unknown} | null; + public shipping_lines: {[key: string]: unknown} | null; + public sms_marketing_phone: string | null; + public source_name: string | null; + public subtotal_price: string | null; + public tax_lines: {[key: string]: unknown} | null; + public taxes_included: boolean | null; + public token: string | null; + public total_discounts: string | null; + public total_duties: string | null; + public total_line_items_price: string | null; + public total_price: string | null; + public total_tax: string | null; + public total_weight: number | null; + public updated_at: string | null; + public user_id: number | null; +} diff --git a/src/rest-resources/2021-10/access_scope.ts b/src/rest-resources/2021-10/access_scope.ts new file mode 100644 index 000000000..9f182c7c2 --- /dev/null +++ b/src/rest-resources/2021-10/access_scope.ts @@ -0,0 +1,39 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; +} + +export class AccessScope extends Base { + public static API_VERSION = ApiVersion.October21; + + protected static NAME = 'access_scope'; + protected static PLURAL_NAME = 'access_scopes'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static CUSTOM_PREFIX: string | null = "/admin/oauth"; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "access_scopes.json"} + ]; + + public static async all( + { + session, + ...otherArgs + }: AllArgs + ): Promise { + const response = await AccessScope.baseFind({ + session: session, + urlIds: {}, + params: {...otherArgs}, + }); + + return response as AccessScope[]; + } + + public handle: string | null; + public access_scopes: {[key: string]: unknown}[] | null; +} diff --git a/src/rest-resources/2021-10/android_pay_key.ts b/src/rest-resources/2021-10/android_pay_key.ts new file mode 100644 index 000000000..43b67e581 --- /dev/null +++ b/src/rest-resources/2021-10/android_pay_key.ts @@ -0,0 +1,60 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} + +export class AndroidPayKey extends Base { + public static API_VERSION = ApiVersion.October21; + + protected static NAME = 'android_pay_key'; + protected static PLURAL_NAME = 'android_pay_keys'; + 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: "get", operation: "get", ids: ["id"], path: "android_pay_keys/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "android_pay_keys/.json"} + ]; + + public static async find( + { + session, + id + }: FindArgs + ): Promise { + const result = await AndroidPayKey.baseFind({ + session: session, + urlIds: {id: id}, + params: {}, + }); + return result ? result[0] as AndroidPayKey : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await AndroidPayKey.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public id: number | null; + public public_key: string | null; +} diff --git a/src/rest-resources/2021-10/apple_pay_certificate.ts b/src/rest-resources/2021-10/apple_pay_certificate.ts new file mode 100644 index 000000000..f776398d7 --- /dev/null +++ b/src/rest-resources/2021-10/apple_pay_certificate.ts @@ -0,0 +1,88 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface CsrArgs { + [key: string]: unknown; + session: SessionInterface; + id: number | string; +} + +export class ApplePayCertificate extends Base { + public static API_VERSION = ApiVersion.October21; + + protected static NAME = 'apple_pay_certificate'; + protected static PLURAL_NAME = 'apple_pay_certificates'; + 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/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "apple_pay_certificates/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "apple_pay_certificates/.json"}, + {http_method: "get", operation: "csr", ids: ["id"], path: "apple_pay_certificates//csr.json"} + ]; + + public static async find( + { + session, + id + }: FindArgs + ): Promise { + const result = await ApplePayCertificate.baseFind({ + session: session, + urlIds: {id: id}, + params: {}, + }); + return result ? result[0] as ApplePayCertificate : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await ApplePayCertificate.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async csr( + { + session, + id, + ...otherArgs + }: CsrArgs + ): Promise { + const response = await ApplePayCertificate.request({ + http_method: "get", + operation: "csr", + session: session, + urlIds: {id: id}, + params: {...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public id: number | null; + public merchant_id: string | null; + public status: string | null; +} diff --git a/src/rest-resources/2021-10/application_charge.ts b/src/rest-resources/2021-10/application_charge.ts new file mode 100644 index 000000000..e79484189 --- /dev/null +++ b/src/rest-resources/2021-10/application_charge.ts @@ -0,0 +1,71 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + since_id?: unknown; + fields?: unknown; +} + +export class ApplicationCharge extends Base { + public static API_VERSION = ApiVersion.October21; + + protected static NAME = 'application_charge'; + protected static PLURAL_NAME = 'application_charges'; + 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: ["id"], path: "application_charges/.json"}, + {http_method: "get", operation: "get", ids: [], path: "application_charges.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await ApplicationCharge.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as ApplicationCharge : null; + } + + public static async all( + { + session, + since_id = null, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await ApplicationCharge.baseFind({ + session: session, + urlIds: {}, + params: {since_id: since_id, fields: fields, ...otherArgs}, + }); + + return response as ApplicationCharge[]; + } + + public confirmation_url: string | null; + public created_at: string | null; + public id: number | null; + public name: string | null; + public price: string | number | null; + public return_url: string | null; + public status: string | null; + public test: boolean | null; + public updated_at: string | null; +} diff --git a/src/rest-resources/2021-10/application_credit.ts b/src/rest-resources/2021-10/application_credit.ts new file mode 100644 index 000000000..b6ae21697 --- /dev/null +++ b/src/rest-resources/2021-10/application_credit.ts @@ -0,0 +1,64 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + fields?: unknown; +} + +export class ApplicationCredit extends Base { + public static API_VERSION = ApiVersion.October21; + + protected static NAME = 'application_credit'; + protected static PLURAL_NAME = 'application_credits'; + 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/.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await ApplicationCredit.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as ApplicationCredit : null; + } + + public static async all( + { + session, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await ApplicationCredit.baseFind({ + session: session, + urlIds: {}, + params: {fields: fields, ...otherArgs}, + }); + + return response as ApplicationCredit[]; + } + + public amount: number | null; + public description: string | null; + public id: number | null; + public test: boolean | null; +} diff --git a/src/rest-resources/2021-10/article.ts b/src/rest-resources/2021-10/article.ts new file mode 100644 index 000000000..69f4f3ae0 --- /dev/null +++ b/src/rest-resources/2021-10/article.ts @@ -0,0 +1,228 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Metafield} from './metafield'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + blog_id?: number | string | null; + fields?: unknown; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; + blog_id?: number | string | null; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + blog_id?: number | string | null; + limit?: unknown; + since_id?: unknown; + created_at_min?: unknown; + created_at_max?: unknown; + updated_at_min?: unknown; + updated_at_max?: unknown; + published_at_min?: unknown; + published_at_max?: unknown; + published_status?: unknown; + handle?: unknown; + tag?: unknown; + author?: unknown; + fields?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; + blog_id?: number | string | null; + created_at_min?: unknown; + created_at_max?: unknown; + updated_at_min?: unknown; + updated_at_max?: unknown; + published_at_min?: unknown; + 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 { + public static API_VERSION = ApiVersion.October21; + + protected static NAME = 'article'; + protected static PLURAL_NAME = 'articles'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = { + metafields: Metafield + }; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: ["blog_id"], path: "blogs//articles.json"}, + {http_method: "post", operation: "post", ids: ["blog_id"], path: "blogs//articles.json"}, + {http_method: "get", operation: "count", ids: ["blog_id"], path: "blogs//articles/count.json"}, + {http_method: "get", operation: "get", ids: ["blog_id", "id"], path: "blogs//articles/.json"}, + {http_method: "put", operation: "put", ids: ["blog_id", "id"], path: "blogs//articles/.json"}, + {http_method: "delete", operation: "delete", ids: ["blog_id", "id"], path: "blogs//articles/.json"}, + {http_method: "get", operation: "authors", ids: [], path: "articles/authors.json"}, + {http_method: "get", operation: "tags", ids: ["blog_id"], path: "blogs//articles/tags.json"}, + {http_method: "get", operation: "tags", ids: [], path: "articles/tags.json"} + ]; + + public static async find( + { + session, + id, + blog_id = null, + fields = null + }: FindArgs + ): Promise
{ + const result = await Article.baseFind({ + session: session, + urlIds: {id: id, blog_id: blog_id}, + params: {fields: fields}, + }); + return result ? result[0] as Article : null; + } + + public static async delete( + { + session, + id, + blog_id = null + }: DeleteArgs + ): Promise { + const response = await Article.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id, blog_id: blog_id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + blog_id = null, + limit = null, + since_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, + handle = null, + tag = null, + author = null, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Article.baseFind({ + session: session, + urlIds: {blog_id: blog_id}, + params: {limit: limit, since_id: since_id, 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, handle: handle, tag: tag, author: author, fields: fields, ...otherArgs}, + }); + + return response as Article[]; + } + + 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 + }: CountArgs + ): Promise { + const response = await Article.request({ + http_method: "get", + operation: "count", + 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}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public static async authors( + { + session, + ...otherArgs + }: AuthorsArgs + ): Promise { + const response = await Article.request({ + http_method: "get", + operation: "authors", + session: session, + urlIds: {}, + params: {...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public static async tags( + { + session, + blog_id = null, + limit = null, + popular = null, + ...otherArgs + }: TagsArgs + ): Promise { + const response = await Article.request({ + http_method: "get", + operation: "tags", + session: session, + urlIds: {blog_id: blog_id}, + params: {limit: limit, popular: popular, ...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public author: string | null; + public blog_id: number | null; + public body_html: string | null; + public created_at: string | null; + public handle: string | null; + public id: number | null; + public image: string | {[key: string]: unknown} | null; + public metafields: Metafield[] | null | {[key: string]: any}; + public published: boolean | null; + public published_at: string | null; + public summary_html: string | null; + public tags: string | null; + public template_suffix: string | null; + public title: string | null; + public updated_at: string | null; + public user_id: number | null; +} diff --git a/src/rest-resources/2021-10/asset.ts b/src/rest-resources/2021-10/asset.ts new file mode 100644 index 000000000..77f56b756 --- /dev/null +++ b/src/rest-resources/2021-10/asset.ts @@ -0,0 +1,79 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface DeleteArgs { + session: SessionInterface; + theme_id?: number | string | null; + asset?: {[key: string]: unknown} | null; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + theme_id?: number | string | null; + fields?: unknown; + asset?: {[key: string]: unknown} | null; +} + +export class Asset extends Base { + public static API_VERSION = ApiVersion.October21; + + protected static NAME = 'asset'; + protected static PLURAL_NAME = 'assets'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: ["theme_id"], path: "themes//assets.json"}, + {http_method: "put", operation: "put", ids: ["theme_id"], path: "themes//assets.json"}, + {http_method: "get", operation: "get", ids: ["theme_id"], path: "themes//assets.json"}, + {http_method: "delete", operation: "delete", ids: ["theme_id"], path: "themes//assets.json"} + ]; + protected static PRIMARY_KEY: string = "key"; + + public static async delete( + { + session, + theme_id = null, + asset = null + }: DeleteArgs + ): Promise { + const response = await Asset.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {theme_id: theme_id}, + params: {asset: asset}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + theme_id = null, + fields = null, + asset = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Asset.baseFind({ + session: session, + urlIds: {theme_id: theme_id}, + params: {fields: fields, asset: asset, ...otherArgs}, + }); + + return response as Asset[]; + } + + public attachment: string | null; + public checksum: string | null; + public content_type: string | null; + public created_at: string | null; + public key: string | null; + public public_url: string | null; + public size: number | null; + public theme_id: number | null; + public updated_at: string | null; + public value: string | null; +} diff --git a/src/rest-resources/2021-10/assigned_fulfillment_order.ts b/src/rest-resources/2021-10/assigned_fulfillment_order.ts new file mode 100644 index 000000000..4364ba903 --- /dev/null +++ b/src/rest-resources/2021-10/assigned_fulfillment_order.ts @@ -0,0 +1,48 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + assignment_status?: unknown; + location_ids?: unknown[] | number | string | null; +} + +export class AssignedFulfillmentOrder extends Base { + public static API_VERSION = ApiVersion.October21; + + protected static NAME = 'assigned_fulfillment_order'; + protected static PLURAL_NAME = 'assigned_fulfillment_orders'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "assigned_fulfillment_orders.json"} + ]; + + public static async all( + { + session, + assignment_status = null, + location_ids = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await AssignedFulfillmentOrder.baseFind({ + session: session, + urlIds: {}, + params: {assignment_status: assignment_status, location_ids: location_ids, ...otherArgs}, + }); + + return response as AssignedFulfillmentOrder[]; + } + + public assigned_location_id: number | null; + public destination: {[key: string]: unknown} | null; + public id: number | null; + public line_items: {[key: string]: unknown}[] | null; + public order_id: number | null; + public request_status: string | null; + public shop_id: number | null; + public status: string | null; +} diff --git a/src/rest-resources/2021-10/balance.ts b/src/rest-resources/2021-10/balance.ts new file mode 100644 index 000000000..11dbcf595 --- /dev/null +++ b/src/rest-resources/2021-10/balance.ts @@ -0,0 +1,36 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; +} + +export class Balance extends Base { + public static API_VERSION = ApiVersion.October21; + + protected static NAME = 'balance'; + protected static PLURAL_NAME = 'balances'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "shopify_payments/balance.json"} + ]; + + public static async all( + { + session, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Balance.baseFind({ + session: session, + urlIds: {}, + params: {...otherArgs}, + }); + + return response as Balance[]; + } + +} diff --git a/src/rest-resources/2021-10/blog.ts b/src/rest-resources/2021-10/blog.ts new file mode 100644 index 000000000..797fe78ed --- /dev/null +++ b/src/rest-resources/2021-10/blog.ts @@ -0,0 +1,129 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Metafield} from './metafield'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + limit?: unknown; + since_id?: unknown; + handle?: unknown; + fields?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; +} + +export class Blog extends Base { + public static API_VERSION = ApiVersion.October21; + + protected static NAME = 'blog'; + protected static PLURAL_NAME = 'blogs'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof 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: "get", operation: "count", ids: [], path: "blogs/count.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "blogs/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "blogs/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "blogs/.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await Blog.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as Blog : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await Blog.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + limit = null, + since_id = null, + handle = null, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Blog.baseFind({ + session: session, + urlIds: {}, + params: {limit: limit, since_id: since_id, handle: handle, fields: fields, ...otherArgs}, + }); + + return response as Blog[]; + } + + public static async count( + { + session, + ...otherArgs + }: CountArgs + ): Promise { + const response = await Blog.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {}, + params: {...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public admin_graphql_api_id: string | null; + public commentable: string | null; + public created_at: string | null; + public feedburner: string | null; + public feedburner_location: string | null; + public handle: string | null; + public id: number | null; + public metafields: Metafield[] | null | {[key: string]: any}; + public tags: string | null; + public template_suffix: string | null; + public title: string | null; + public updated_at: string | null; +} diff --git a/src/rest-resources/2021-10/cancellation_request.ts b/src/rest-resources/2021-10/cancellation_request.ts new file mode 100644 index 000000000..c7eb7eafd --- /dev/null +++ b/src/rest-resources/2021-10/cancellation_request.ts @@ -0,0 +1,69 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {ApiVersion} from '../../base-types'; + +interface AcceptArgs { + [key: string]: unknown; + message?: unknown; + body?: {[key: string]: unknown} | null; +} +interface RejectArgs { + [key: string]: unknown; + message?: unknown; + body?: {[key: string]: unknown} | null; +} + +export class CancellationRequest extends Base { + public static API_VERSION = ApiVersion.October21; + + protected static NAME = 'cancellation_request'; + protected static PLURAL_NAME = 'cancellation_requests'; + 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//cancellation_request.json"}, + {http_method: "post", operation: "accept", ids: ["fulfillment_order_id"], path: "fulfillment_orders//cancellation_request/accept.json"}, + {http_method: "post", operation: "reject", ids: ["fulfillment_order_id"], path: "fulfillment_orders//cancellation_request/reject.json"} + ]; + + public async accept( + { + message = null, + body = null, + ...otherArgs + }: AcceptArgs + ): Promise { + const response = await CancellationRequest.request({ + http_method: "post", + operation: "accept", + session: this.session, + urlIds: {fulfillment_order_id: this.fulfillment_order_id}, + params: {message: message, ...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public async reject( + { + message = null, + body = null, + ...otherArgs + }: RejectArgs + ): Promise { + const response = await CancellationRequest.request({ + http_method: "post", + operation: "reject", + session: this.session, + urlIds: {fulfillment_order_id: this.fulfillment_order_id}, + params: {message: message, ...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public fulfillment_order_id: number | null; +} diff --git a/src/rest-resources/2021-10/carrier_service.ts b/src/rest-resources/2021-10/carrier_service.ts new file mode 100644 index 000000000..76d2b4b59 --- /dev/null +++ b/src/rest-resources/2021-10/carrier_service.ts @@ -0,0 +1,87 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; +} + +export class CarrierService extends Base { + public static API_VERSION = ApiVersion.October21; + + protected static NAME = 'carrier_service'; + protected static PLURAL_NAME = 'carrier_services'; + 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: "get", operation: "get", ids: [], path: "carrier_services.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "carrier_services/.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "carrier_services/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "carrier_services/.json"} + ]; + + public static async find( + { + session, + id + }: FindArgs + ): Promise { + const result = await CarrierService.baseFind({ + session: session, + urlIds: {id: id}, + params: {}, + }); + return result ? result[0] as CarrierService : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await CarrierService.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + ...otherArgs + }: AllArgs + ): Promise { + const response = await CarrierService.baseFind({ + session: session, + urlIds: {}, + params: {...otherArgs}, + }); + + return response as CarrierService[]; + } + + public active: boolean | null; + public admin_graphql_api_id: string | null; + public callback_url: string | null; + public carrier_service_type: string | null; + public format: string | null; + public id: number | null; + public name: string | null; + public service_discovery: boolean | null; +} diff --git a/src/rest-resources/2021-10/checkout.ts b/src/rest-resources/2021-10/checkout.ts new file mode 100644 index 000000000..5ee6f6088 --- /dev/null +++ b/src/rest-resources/2021-10/checkout.ts @@ -0,0 +1,130 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Currency} from './currency'; +import {DiscountCode} from './discount_code'; +import {Order} from './order'; +import {GiftCard} from './gift_card'; + +interface FindArgs { + session: SessionInterface; + token: number | string; +} +interface ShippingRatesArgs { + [key: string]: unknown; + session: SessionInterface; + token: number | string; +} +interface CompleteArgs { + [key: string]: unknown; + body?: {[key: string]: unknown} | null; +} + +export class Checkout extends Base { + public static API_VERSION = ApiVersion.October21; + + protected static NAME = 'checkout'; + protected static PLURAL_NAME = 'checkouts'; + protected static HAS_ONE: {[key: string]: typeof Base} = { + currency: Currency, + discount_code: DiscountCode, + order: Order + }; + protected static HAS_MANY: {[key: string]: typeof 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//complete.json"}, + {http_method: "get", operation: "get", ids: ["token"], path: "checkouts/.json"}, + {http_method: "put", operation: "put", ids: ["token"], path: "checkouts/.json"}, + {http_method: "get", operation: "shipping_rates", ids: ["token"], path: "checkouts//shipping_rates.json"} + ]; + protected static PRIMARY_KEY: string = "token"; + + public static async find( + { + session, + token + }: FindArgs + ): Promise { + const result = await Checkout.baseFind({ + session: session, + urlIds: {token: token}, + params: {}, + }); + return result ? result[0] as Checkout : null; + } + + public static async shipping_rates( + { + session, + token, + ...otherArgs + }: ShippingRatesArgs + ): Promise { + const response = await Checkout.request({ + http_method: "get", + operation: "shipping_rates", + session: session, + urlIds: {token: token}, + params: {...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public async complete( + { + body = null, + ...otherArgs + }: CompleteArgs + ): Promise { + const response = await Checkout.request({ + http_method: "post", + operation: "complete", + session: this.session, + urlIds: {token: this.token}, + params: {...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public billing_address: {[key: string]: unknown} | null; + public line_items: {[key: string]: unknown}[] | null; + public applied_discount: {[key: string]: unknown} | null; + public buyer_accepts_marketing: boolean | null; + public created_at: string | null; + public currency: Currency | null | {[key: string]: any}; + public customer_id: number | null; + public discount_code: DiscountCode | null | {[key: string]: any}; + public email: string | null; + public gift_cards: GiftCard[] | null | {[key: string]: any}; + public order: Order | null | {[key: string]: any}; + public payment_due: string | null; + public payment_url: string | null; + public phone: string | null; + public presentment_currency: string | null; + public requires_shipping: boolean | null; + public reservation_time: string | null; + public reservation_time_left: number | null; + public shipping_address: {[key: string]: unknown} | null; + public shipping_line: {[key: string]: unknown} | null; + public shipping_rate: {[key: string]: unknown} | null; + public source_name: string | null; + public subtotal_price: string | null; + public tax_lines: {[key: string]: unknown}[] | null; + public taxes_included: boolean | null; + public token: string | null; + public total_price: string | null; + public total_tax: string | null; + public updated_at: string | null; + public user_id: number | null; + public web_url: string | null; +} diff --git a/src/rest-resources/2021-10/collect.ts b/src/rest-resources/2021-10/collect.ts new file mode 100644 index 000000000..a4a62d705 --- /dev/null +++ b/src/rest-resources/2021-10/collect.ts @@ -0,0 +1,117 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + limit?: unknown; + since_id?: unknown; + fields?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; +} + +export class Collect extends Base { + public static API_VERSION = ApiVersion.October21; + + protected static NAME = 'collect'; + protected static PLURAL_NAME = 'collects'; + 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/.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "collects/.json"}, + {http_method: "get", operation: "count", ids: [], path: "collects/count.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await Collect.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as Collect : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await Collect.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + limit = null, + since_id = null, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Collect.baseFind({ + session: session, + urlIds: {}, + params: {limit: limit, since_id: since_id, fields: fields, ...otherArgs}, + }); + + return response as Collect[]; + } + + public static async count( + { + session, + ...otherArgs + }: CountArgs + ): Promise { + const response = await Collect.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {}, + params: {...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public collection_id: number | null; + public created_at: string | null; + public id: number | null; + public position: number | null; + public product_id: number | null; + public sort_value: string | null; + public updated_at: string | null; +} diff --git a/src/rest-resources/2021-10/collection.ts b/src/rest-resources/2021-10/collection.ts new file mode 100644 index 000000000..d7e46062c --- /dev/null +++ b/src/rest-resources/2021-10/collection.ts @@ -0,0 +1,79 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Image} from './image'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface ProductsArgs { + [key: string]: unknown; + session: SessionInterface; + id: number | string; + limit?: unknown; +} + +export class Collection extends Base { + public static API_VERSION = ApiVersion.October21; + + protected static NAME = 'collection'; + protected static PLURAL_NAME = 'collections'; + protected static HAS_ONE: {[key: string]: typeof Base} = { + image: Image + }; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: ["id"], path: "collections/.json"}, + {http_method: "get", operation: "products", ids: ["id"], path: "collections//products.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await Collection.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as Collection : null; + } + + public static async products( + { + session, + id, + limit = null, + ...otherArgs + }: ProductsArgs + ): Promise { + const response = await Collection.request({ + http_method: "get", + operation: "products", + session: session, + urlIds: {id: id}, + params: {limit: limit, ...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public title: string | null; + public body_html: string | null; + public handle: string | null; + public id: number | null; + public image: Image | null | {[key: string]: any}; + public published_at: string | null; + public published_scope: string | null; + public sort_order: string | null; + public template_suffix: string | null; + public updated_at: string | null; +} diff --git a/src/rest-resources/2021-10/collection_listing.ts b/src/rest-resources/2021-10/collection_listing.ts new file mode 100644 index 000000000..c549ccf98 --- /dev/null +++ b/src/rest-resources/2021-10/collection_listing.ts @@ -0,0 +1,122 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Image} from './image'; + +interface FindArgs { + session: SessionInterface; + collection_id: number | string; +} +interface DeleteArgs { + session: SessionInterface; + collection_id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + limit?: unknown; +} +interface ProductIdsArgs { + [key: string]: unknown; + session: SessionInterface; + collection_id: number | string; + limit?: unknown; +} + +export class CollectionListing extends Base { + public static API_VERSION = ApiVersion.October21; + + protected static NAME = 'collection_listing'; + protected static PLURAL_NAME = 'collection_listings'; + protected static HAS_ONE: {[key: string]: typeof Base} = { + image: Image + }; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "collection_listings.json"}, + {http_method: "get", operation: "product_ids", ids: ["collection_id"], path: "collection_listings//product_ids.json"}, + {http_method: "get", operation: "get", ids: ["collection_id"], path: "collection_listings/.json"}, + {http_method: "put", operation: "put", ids: ["collection_id"], path: "collection_listings/.json"}, + {http_method: "delete", operation: "delete", ids: ["collection_id"], path: "collection_listings/.json"} + ]; + protected static PRIMARY_KEY: string = "collection_id"; + + public static async find( + { + session, + collection_id + }: FindArgs + ): Promise { + const result = await CollectionListing.baseFind({ + session: session, + urlIds: {collection_id: collection_id}, + params: {}, + }); + return result ? result[0] as CollectionListing : null; + } + + public static async delete( + { + session, + collection_id + }: DeleteArgs + ): Promise { + const response = await CollectionListing.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {collection_id: collection_id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + limit = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await CollectionListing.baseFind({ + session: session, + urlIds: {}, + params: {limit: limit, ...otherArgs}, + }); + + return response as CollectionListing[]; + } + + public static async product_ids( + { + session, + collection_id, + limit = null, + ...otherArgs + }: ProductIdsArgs + ): Promise { + const response = await CollectionListing.request({ + http_method: "get", + operation: "product_ids", + session: session, + urlIds: {collection_id: collection_id}, + params: {limit: limit, ...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public body_html: string | null; + public collection_id: number | null; + public default_product_image: {[key: string]: unknown}[] | null; + public handle: string | null; + public image: Image | null | {[key: string]: any}; + public published_at: string | null; + public sort_order: string | null; + public title: string | null; + public updated_at: string | null; +} diff --git a/src/rest-resources/2021-10/comment.ts b/src/rest-resources/2021-10/comment.ts new file mode 100644 index 000000000..8f4356659 --- /dev/null +++ b/src/rest-resources/2021-10/comment.ts @@ -0,0 +1,254 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + limit?: unknown; + since_id?: unknown; + created_at_min?: unknown; + created_at_max?: unknown; + updated_at_min?: unknown; + updated_at_max?: unknown; + published_at_min?: unknown; + published_at_max?: unknown; + fields?: unknown; + published_status?: unknown; + status?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; + created_at_min?: unknown; + created_at_max?: unknown; + updated_at_min?: unknown; + updated_at_max?: unknown; + published_at_min?: unknown; + published_at_max?: unknown; + published_status?: unknown; + status?: unknown; +} +interface SpamArgs { + [key: string]: unknown; + body?: {[key: string]: unknown} | null; +} +interface NotSpamArgs { + [key: string]: unknown; + body?: {[key: string]: unknown} | null; +} +interface ApproveArgs { + [key: string]: unknown; + body?: {[key: string]: unknown} | null; +} +interface RemoveArgs { + [key: string]: unknown; + body?: {[key: string]: unknown} | null; +} +interface RestoreArgs { + [key: string]: unknown; + body?: {[key: string]: unknown} | null; +} + +export class Comment extends Base { + public static API_VERSION = ApiVersion.October21; + + protected static NAME = 'comment'; + protected static PLURAL_NAME = 'comments'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "comments.json"}, + {http_method: "get", operation: "count", ids: [], path: "comments/count.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "comments/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "comments/.json"}, + {http_method: "post", operation: "post", ids: [], path: "comments.json"}, + {http_method: "post", operation: "spam", ids: ["id"], path: "comments//spam.json"}, + {http_method: "post", operation: "not_spam", ids: ["id"], path: "comments//not_spam.json"}, + {http_method: "post", operation: "approve", ids: ["id"], path: "comments//approve.json"}, + {http_method: "post", operation: "remove", ids: ["id"], path: "comments//remove.json"}, + {http_method: "post", operation: "restore", ids: ["id"], path: "comments//restore.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await Comment.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as Comment : null; + } + + public static async all( + { + session, + limit = null, + since_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, + fields = null, + published_status = null, + status = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Comment.baseFind({ + session: session, + urlIds: {}, + params: {limit: limit, since_id: since_id, 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, fields: fields, published_status: published_status, status: status, ...otherArgs}, + }); + + return response as Comment[]; + } + + public static async count( + { + session, + 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, + status = null, + ...otherArgs + }: CountArgs + ): Promise { + const response = await Comment.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {}, + 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, status: status, ...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public async spam( + { + body = null, + ...otherArgs + }: SpamArgs + ): Promise { + const response = await Comment.request({ + http_method: "post", + operation: "spam", + session: this.session, + urlIds: {id: this.id}, + params: {...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public async not_spam( + { + body = null, + ...otherArgs + }: NotSpamArgs + ): Promise { + const response = await Comment.request({ + http_method: "post", + operation: "not_spam", + session: this.session, + urlIds: {id: this.id}, + params: {...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public async approve( + { + body = null, + ...otherArgs + }: ApproveArgs + ): Promise { + const response = await Comment.request({ + http_method: "post", + operation: "approve", + session: this.session, + urlIds: {id: this.id}, + params: {...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public async remove( + { + body = null, + ...otherArgs + }: RemoveArgs + ): Promise { + const response = await Comment.request({ + http_method: "post", + operation: "remove", + session: this.session, + urlIds: {id: this.id}, + params: {...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public async restore( + { + body = null, + ...otherArgs + }: RestoreArgs + ): Promise { + const response = await Comment.request({ + http_method: "post", + operation: "restore", + session: this.session, + urlIds: {id: this.id}, + params: {...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public article_id: number | null; + public author: string | null; + public blog_id: number | null; + public body: string | null; + public body_html: string | null; + public created_at: string | null; + public email: string | null; + public id: number | null; + public ip: string | null; + public published_at: string | null; + public status: string | null; + public updated_at: string | null; + public user_agent: string | null; +} diff --git a/src/rest-resources/2021-10/country.ts b/src/rest-resources/2021-10/country.ts new file mode 100644 index 000000000..528342c0a --- /dev/null +++ b/src/rest-resources/2021-10/country.ts @@ -0,0 +1,118 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Province} from './province'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + since_id?: unknown; + fields?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; +} + +export class Country extends Base { + public static API_VERSION = ApiVersion.October21; + + protected static NAME = 'country'; + protected static PLURAL_NAME = 'countries'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = { + provinces: Province + }; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "countries.json"}, + {http_method: "post", operation: "post", ids: [], path: "countries.json"}, + {http_method: "get", operation: "count", ids: [], path: "countries/count.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "countries/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "countries/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "countries/.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await Country.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as Country : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await Country.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + since_id = null, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Country.baseFind({ + session: session, + urlIds: {}, + params: {since_id: since_id, fields: fields, ...otherArgs}, + }); + + return response as Country[]; + } + + public static async count( + { + session, + ...otherArgs + }: CountArgs + ): Promise { + const response = await Country.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {}, + params: {...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public code: string | null; + public id: number | null; + public name: string | null; + public provinces: Province[] | null | {[key: string]: any}; + public tax: number | null; +} diff --git a/src/rest-resources/2021-10/currency.ts b/src/rest-resources/2021-10/currency.ts new file mode 100644 index 000000000..8f1c48dd1 --- /dev/null +++ b/src/rest-resources/2021-10/currency.ts @@ -0,0 +1,38 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; +} + +export class Currency extends Base { + public static API_VERSION = ApiVersion.October21; + + protected static NAME = 'currency'; + protected static PLURAL_NAME = 'currencies'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "currencies.json"} + ]; + + public static async all( + { + session, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Currency.baseFind({ + session: session, + urlIds: {}, + params: {...otherArgs}, + }); + + return response as Currency[]; + } + + public currency: string | null; + public rate_updated_at: string | null; +} diff --git a/src/rest-resources/2021-10/custom_collection.ts b/src/rest-resources/2021-10/custom_collection.ts new file mode 100644 index 000000000..7c022054b --- /dev/null +++ b/src/rest-resources/2021-10/custom_collection.ts @@ -0,0 +1,154 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + limit?: unknown; + ids?: unknown; + since_id?: unknown; + title?: unknown; + product_id?: unknown; + handle?: unknown; + updated_at_min?: unknown; + updated_at_max?: unknown; + published_at_min?: unknown; + published_at_max?: unknown; + published_status?: unknown; + fields?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; + title?: unknown; + product_id?: unknown; + updated_at_min?: unknown; + updated_at_max?: unknown; + published_at_min?: unknown; + published_at_max?: unknown; + published_status?: unknown; +} + +export class CustomCollection extends Base { + public static API_VERSION = ApiVersion.October21; + + protected static NAME = 'custom_collection'; + protected static PLURAL_NAME = 'custom_collections'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "custom_collections.json"}, + {http_method: "post", operation: "post", ids: [], path: "custom_collections.json"}, + {http_method: "get", operation: "count", ids: [], path: "custom_collections/count.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "custom_collections/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "custom_collections/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "custom_collections/.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await CustomCollection.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as CustomCollection : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await CustomCollection.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + limit = null, + ids = null, + since_id = null, + title = null, + product_id = null, + handle = null, + updated_at_min = null, + updated_at_max = null, + published_at_min = null, + published_at_max = null, + published_status = null, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await CustomCollection.baseFind({ + session: session, + urlIds: {}, + params: {limit: limit, ids: ids, since_id: since_id, title: title, product_id: product_id, handle: handle, 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, fields: fields, ...otherArgs}, + }); + + return response as CustomCollection[]; + } + + public static async count( + { + session, + title = null, + product_id = null, + updated_at_min = null, + updated_at_max = null, + published_at_min = null, + published_at_max = null, + published_status = null, + ...otherArgs + }: CountArgs + ): Promise { + const response = await CustomCollection.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {}, + params: {title: title, product_id: product_id, 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, + }); + + return response ? response.body : null; + } + + public title: string | null; + public body_html: string | null; + public handle: string | null; + public id: number | null; + public image: string | {[key: string]: unknown} | null; + public published: boolean | null; + public published_at: string | null; + public published_scope: string | null; + public sort_order: string | null; + public template_suffix: string | null; + public updated_at: string | null; +} diff --git a/src/rest-resources/2021-10/customer.ts b/src/rest-resources/2021-10/customer.ts new file mode 100644 index 000000000..6bdb8e80f --- /dev/null +++ b/src/rest-resources/2021-10/customer.ts @@ -0,0 +1,259 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Currency} from './currency'; +import {Metafield} from './metafield'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + ids?: unknown; + since_id?: unknown; + created_at_min?: unknown; + created_at_max?: unknown; + updated_at_min?: unknown; + updated_at_max?: unknown; + limit?: unknown; + fields?: unknown; +} +interface SearchArgs { + [key: string]: unknown; + session: SessionInterface; + order?: unknown; + query?: unknown; + limit?: unknown; + fields?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; +} +interface OrdersArgs { + [key: string]: unknown; + session: SessionInterface; + id: number | string; +} +interface AccountActivationUrlArgs { + [key: string]: unknown; + body?: {[key: string]: unknown} | null; +} +interface SendInviteArgs { + [key: string]: unknown; + body?: {[key: string]: unknown} | null; +} + +export class Customer extends Base { + public static API_VERSION = ApiVersion.October21; + + protected static NAME = 'customer'; + protected static PLURAL_NAME = 'customers'; + protected static HAS_ONE: {[key: string]: typeof Base} = { + currency: Currency, + metafield: Metafield + }; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "customers.json"}, + {http_method: "post", operation: "post", ids: [], path: "customers.json"}, + {http_method: "get", operation: "search", ids: [], path: "customers/search.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "customers/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "customers/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "customers/.json"}, + {http_method: "post", operation: "account_activation_url", ids: ["id"], path: "customers//account_activation_url.json"}, + {http_method: "post", operation: "send_invite", ids: ["id"], path: "customers//send_invite.json"}, + {http_method: "get", operation: "count", ids: [], path: "customers/count.json"}, + {http_method: "get", operation: "orders", ids: ["id"], path: "customers//orders.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await Customer.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as Customer : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await Customer.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + ids = null, + since_id = null, + created_at_min = null, + created_at_max = null, + updated_at_min = null, + updated_at_max = null, + limit = null, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Customer.baseFind({ + session: session, + urlIds: {}, + params: {ids: ids, since_id: since_id, created_at_min: created_at_min, created_at_max: created_at_max, updated_at_min: updated_at_min, updated_at_max: updated_at_max, limit: limit, fields: fields, ...otherArgs}, + }); + + return response as Customer[]; + } + + public static async search( + { + session, + order = null, + query = null, + limit = null, + fields = null, + ...otherArgs + }: SearchArgs + ): Promise { + const response = await Customer.request({ + http_method: "get", + operation: "search", + session: session, + urlIds: {}, + params: {order: order, query: query, limit: limit, fields: fields, ...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public static async count( + { + session, + ...otherArgs + }: CountArgs + ): Promise { + const response = await Customer.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {}, + params: {...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public static async orders( + { + session, + id, + ...otherArgs + }: OrdersArgs + ): Promise { + const response = await Customer.request({ + http_method: "get", + operation: "orders", + session: session, + urlIds: {id: id}, + params: {...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public async account_activation_url( + { + body = null, + ...otherArgs + }: AccountActivationUrlArgs + ): Promise { + const response = await Customer.request({ + http_method: "post", + operation: "account_activation_url", + session: this.session, + urlIds: {id: this.id}, + params: {...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public async send_invite( + { + body = null, + ...otherArgs + }: SendInviteArgs + ): Promise { + const response = await Customer.request({ + http_method: "post", + operation: "send_invite", + session: this.session, + urlIds: {id: this.id}, + params: {...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public accepts_marketing: boolean | null; + public accepts_marketing_updated_at: string | null; + public addresses: {[key: string]: unknown}[] | null; + public created_at: string | null; + public currency: Currency | null | {[key: string]: any}; + public default_address: {[key: string]: unknown} | null; + public email: string | null; + public first_name: string | null; + public id: number | null; + public last_name: string | null; + public last_order_id: number | null; + public last_order_name: string | null; + public marketing_opt_in_level: string | null; + public metafield: Metafield | null | {[key: string]: any}; + public multipass_identifier: string | null; + public note: string | null; + public orders_count: number | null; + public phone: string | null; + public sms_marketing_consent: {[key: string]: unknown} | null; + public state: string | null; + public tags: string | null; + public tax_exempt: boolean | null; + public tax_exemptions: string[] | null; + public total_spent: string | null; + public updated_at: string | null; + public verified_email: boolean | null; +} diff --git a/src/rest-resources/2021-10/customer_address.ts b/src/rest-resources/2021-10/customer_address.ts new file mode 100644 index 000000000..961bca8dd --- /dev/null +++ b/src/rest-resources/2021-10/customer_address.ts @@ -0,0 +1,158 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + customer_id?: number | string | null; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; + customer_id?: number | string | null; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + customer_id?: number | string | null; +} +interface SetArgs { + [key: string]: unknown; + address_ids?: unknown[] | number | string | null; + operation?: unknown; + body?: {[key: string]: unknown} | null; +} +interface DefaultArgs { + [key: string]: unknown; + body?: {[key: string]: unknown} | null; +} + +export class CustomerAddress extends Base { + public static API_VERSION = ApiVersion.October21; + + protected static NAME = 'customer_address'; + protected static PLURAL_NAME = 'customer_addresses'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: ["customer_id"], path: "customers//addresses.json"}, + {http_method: "post", operation: "post", ids: ["customer_id"], path: "customers//addresses.json"}, + {http_method: "get", operation: "get", ids: ["customer_id", "id"], path: "customers//addresses/.json"}, + {http_method: "put", operation: "put", ids: ["customer_id", "id"], path: "customers//addresses/.json"}, + {http_method: "delete", operation: "delete", ids: ["customer_id", "id"], path: "customers//addresses/.json"}, + {http_method: "put", operation: "set", ids: ["customer_id"], path: "customers//addresses/set.json"}, + {http_method: "put", operation: "default", ids: ["customer_id", "id"], path: "customers//addresses//default.json"} + ]; + + protected static getJsonBodyName(): string + { + return "address"; + } + + public static async find( + { + session, + id, + customer_id = null + }: FindArgs + ): Promise { + const result = await CustomerAddress.baseFind({ + session: session, + urlIds: {id: id, customer_id: customer_id}, + params: {}, + }); + return result ? result[0] as CustomerAddress : null; + } + + public static async delete( + { + session, + id, + customer_id = null + }: DeleteArgs + ): Promise { + const response = await CustomerAddress.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id, customer_id: customer_id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + customer_id = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await CustomerAddress.baseFind({ + session: session, + urlIds: {customer_id: customer_id}, + params: {...otherArgs}, + }); + + return response as CustomerAddress[]; + } + + public async set( + { + address_ids = null, + operation = null, + body = null, + ...otherArgs + }: SetArgs + ): Promise { + const response = await CustomerAddress.request({ + http_method: "put", + operation: "set", + session: this.session, + urlIds: {customer_id: this.customer_id}, + params: {address_ids: address_ids, operation: operation, ...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public async default( + { + body = null, + ...otherArgs + }: DefaultArgs + ): Promise { + const response = await CustomerAddress.request({ + http_method: "put", + operation: "default", + session: this.session, + urlIds: {id: this.id, customer_id: this.customer_id}, + params: {...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public address1: string | null; + public address2: string | null; + public city: string | null; + public company: string | null; + public country: string | null; + public country_code: string | null; + public country_name: string | null; + public customer_id: number | null; + public first_name: string | null; + public id: number | null; + public last_name: string | null; + public name: string | null; + public phone: string | null; + public province: string | null; + public province_code: string | null; + public zip: string | null; +} diff --git a/src/rest-resources/2021-10/customer_saved_search.ts b/src/rest-resources/2021-10/customer_saved_search.ts new file mode 100644 index 000000000..e01e665cc --- /dev/null +++ b/src/rest-resources/2021-10/customer_saved_search.ts @@ -0,0 +1,150 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + limit?: unknown; + since_id?: unknown; + fields?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; + since_id?: unknown; +} +interface CustomersArgs { + [key: string]: unknown; + session: SessionInterface; + id: number | string; + order?: unknown; + limit?: unknown; + fields?: unknown; +} + +export class CustomerSavedSearch extends Base { + public static API_VERSION = ApiVersion.October21; + + protected static NAME = 'customer_saved_search'; + protected static PLURAL_NAME = 'customer_saved_searches'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "customer_saved_searches.json"}, + {http_method: "post", operation: "post", ids: [], path: "customer_saved_searches.json"}, + {http_method: "get", operation: "count", ids: [], path: "customer_saved_searches/count.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "customer_saved_searches/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "customer_saved_searches/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "customer_saved_searches/.json"}, + {http_method: "get", operation: "customers", ids: ["id"], path: "customer_saved_searches//customers.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await CustomerSavedSearch.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as CustomerSavedSearch : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await CustomerSavedSearch.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + limit = null, + since_id = null, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await CustomerSavedSearch.baseFind({ + session: session, + urlIds: {}, + params: {limit: limit, since_id: since_id, fields: fields, ...otherArgs}, + }); + + return response as CustomerSavedSearch[]; + } + + public static async count( + { + session, + since_id = null, + ...otherArgs + }: CountArgs + ): Promise { + const response = await CustomerSavedSearch.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {}, + params: {since_id: since_id, ...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public static async customers( + { + session, + id, + order = null, + limit = null, + fields = null, + ...otherArgs + }: CustomersArgs + ): Promise { + const response = await CustomerSavedSearch.request({ + http_method: "get", + operation: "customers", + session: session, + urlIds: {id: id}, + params: {order: order, limit: limit, fields: fields, ...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public created_at: string | null; + public id: number | null; + public name: string | null; + public query: string | null; + public updated_at: string | null; +} diff --git a/src/rest-resources/2021-10/deprecated_api_call.ts b/src/rest-resources/2021-10/deprecated_api_call.ts new file mode 100644 index 000000000..3f649d4ca --- /dev/null +++ b/src/rest-resources/2021-10/deprecated_api_call.ts @@ -0,0 +1,38 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; +} + +export class DeprecatedApiCall extends Base { + public static API_VERSION = ApiVersion.October21; + + protected static NAME = 'deprecated_api_call'; + protected static PLURAL_NAME = 'deprecated_api_calls'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "deprecated_api_calls.json"} + ]; + + public static async all( + { + session, + ...otherArgs + }: AllArgs + ): Promise { + const response = await DeprecatedApiCall.baseFind({ + session: session, + urlIds: {}, + params: {...otherArgs}, + }); + + return response as DeprecatedApiCall[]; + } + + public data_updated_at: string | null; + public deprecated_api_calls: {[key: string]: unknown}[] | null; +} diff --git a/src/rest-resources/2021-10/discount_code.ts b/src/rest-resources/2021-10/discount_code.ts new file mode 100644 index 000000000..24b8472cf --- /dev/null +++ b/src/rest-resources/2021-10/discount_code.ts @@ -0,0 +1,202 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + price_rule_id?: number | string | null; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; + price_rule_id?: number | string | null; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + price_rule_id?: number | string | null; + batch_id?: number | string | null; +} +interface LookupArgs { + [key: string]: unknown; + session: SessionInterface; + code?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; + times_used?: unknown; + times_used_min?: unknown; + times_used_max?: unknown; +} +interface GetAllArgs { + [key: string]: unknown; + session: SessionInterface; + price_rule_id?: number | string | null; + batch_id?: number | string | null; +} +interface BatchArgs { + [key: string]: unknown; + body?: {[key: string]: unknown} | null; +} + +export class DiscountCode extends Base { + public static API_VERSION = ApiVersion.October21; + + protected static NAME = 'discount_code'; + protected static PLURAL_NAME = 'discount_codes'; + 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: ["price_rule_id"], path: "price_rules//discount_codes.json"}, + {http_method: "get", operation: "get", ids: ["price_rule_id"], path: "price_rules//discount_codes.json"}, + {http_method: "put", operation: "put", ids: ["price_rule_id", "id"], path: "price_rules//discount_codes/.json"}, + {http_method: "get", operation: "get", ids: ["price_rule_id", "id"], path: "price_rules//discount_codes/.json"}, + {http_method: "delete", operation: "delete", ids: ["price_rule_id", "id"], path: "price_rules//discount_codes/.json"}, + {http_method: "get", operation: "lookup", ids: [], path: "discount_codes/lookup.json"}, + {http_method: "get", operation: "count", ids: [], path: "discount_codes/count.json"}, + {http_method: "post", operation: "batch", ids: ["price_rule_id"], path: "price_rules//batch.json"}, + {http_method: "get", operation: "get_all", ids: ["price_rule_id", "batch_id"], path: "price_rules//batch/.json"}, + {http_method: "get", operation: "get", ids: ["price_rule_id", "batch_id"], path: "price_rules//batch//discount_codes.json"} + ]; + + public static async find( + { + session, + id, + price_rule_id = null + }: FindArgs + ): Promise { + const result = await DiscountCode.baseFind({ + session: session, + urlIds: {id: id, price_rule_id: price_rule_id}, + params: {}, + }); + return result ? result[0] as DiscountCode : null; + } + + public static async delete( + { + session, + id, + price_rule_id = null + }: DeleteArgs + ): Promise { + const response = await DiscountCode.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id, price_rule_id: price_rule_id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + price_rule_id = null, + batch_id = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await DiscountCode.baseFind({ + session: session, + urlIds: {price_rule_id: price_rule_id, batch_id: batch_id}, + params: {...otherArgs}, + }); + + return response as DiscountCode[]; + } + + public static async lookup( + { + session, + code = null, + ...otherArgs + }: LookupArgs + ): Promise { + const response = await DiscountCode.request({ + http_method: "get", + operation: "lookup", + session: session, + urlIds: {}, + params: {code: code, ...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public static async count( + { + session, + times_used = null, + times_used_min = null, + times_used_max = null, + ...otherArgs + }: CountArgs + ): Promise { + const response = await DiscountCode.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {}, + params: {times_used: times_used, times_used_min: times_used_min, times_used_max: times_used_max, ...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public static async get_all( + { + session, + price_rule_id = null, + batch_id = null, + ...otherArgs + }: GetAllArgs + ): Promise { + const response = await DiscountCode.request({ + http_method: "get", + operation: "get_all", + session: session, + urlIds: {price_rule_id: price_rule_id, batch_id: batch_id}, + params: {...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public async batch( + { + body = null, + ...otherArgs + }: BatchArgs + ): Promise { + const response = await DiscountCode.request({ + http_method: "post", + operation: "batch", + session: this.session, + urlIds: {price_rule_id: this.price_rule_id}, + params: {...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public code: string | null; + public created_at: string | null; + public id: number | null; + public price_rule_id: number | null; + public updated_at: string | null; + public usage_count: number | null; +} diff --git a/src/rest-resources/2021-10/dispute.ts b/src/rest-resources/2021-10/dispute.ts new file mode 100644 index 000000000..728932087 --- /dev/null +++ b/src/rest-resources/2021-10/dispute.ts @@ -0,0 +1,78 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Currency} from './currency'; + +interface FindArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + since_id?: unknown; + last_id?: unknown; + status?: unknown; + initiated_at?: unknown; +} + +export class Dispute extends Base { + public static API_VERSION = ApiVersion.October21; + + protected static NAME = 'dispute'; + protected static PLURAL_NAME = 'disputes'; + protected static HAS_ONE: {[key: string]: typeof Base} = { + currency: Currency + }; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "shopify_payments/disputes.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "shopify_payments/disputes/.json"} + ]; + + public static async find( + { + session, + id + }: FindArgs + ): Promise { + const result = await Dispute.baseFind({ + session: session, + urlIds: {id: id}, + params: {}, + }); + return result ? result[0] as Dispute : null; + } + + public static async all( + { + session, + since_id = null, + last_id = null, + status = null, + initiated_at = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Dispute.baseFind({ + session: session, + urlIds: {}, + params: {since_id: since_id, last_id: last_id, status: status, initiated_at: initiated_at, ...otherArgs}, + }); + + return response as Dispute[]; + } + + public amount: string | null; + public currency: Currency | null | {[key: string]: any}; + public evidence_due_by: string | null; + public evidence_sent_on: string | null; + public finalized_on: string | null; + public id: number | null; + public network_reason_code: number | null; + public order_id: number | null; + public reason: string | null; + public status: string | null; + public type: string | null; +} diff --git a/src/rest-resources/2021-10/draft_order.ts b/src/rest-resources/2021-10/draft_order.ts new file mode 100644 index 000000000..93c295a29 --- /dev/null +++ b/src/rest-resources/2021-10/draft_order.ts @@ -0,0 +1,211 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Customer} from './customer'; +import {Currency} from './currency'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + fields?: unknown; + limit?: unknown; + since_id?: unknown; + updated_at_min?: unknown; + updated_at_max?: unknown; + ids?: unknown; + status?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; + since_id?: unknown; + status?: unknown; + updated_at_max?: unknown; + updated_at_min?: unknown; +} +interface SendInvoiceArgs { + [key: string]: unknown; + body?: {[key: string]: unknown} | null; +} +interface CompleteArgs { + [key: string]: unknown; + payment_pending?: unknown; + body?: {[key: string]: unknown} | null; +} + +export class DraftOrder extends Base { + public static API_VERSION = ApiVersion.October21; + + protected static NAME = 'draft_order'; + protected static PLURAL_NAME = 'draft_orders'; + protected static HAS_ONE: {[key: string]: typeof Base} = { + customer: Customer, + currency: Currency + }; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "post", operation: "post", ids: [], path: "draft_orders.json"}, + {http_method: "get", operation: "get", ids: [], path: "draft_orders.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "draft_orders/.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "draft_orders/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "draft_orders/.json"}, + {http_method: "get", operation: "count", ids: [], path: "draft_orders/count.json"}, + {http_method: "post", operation: "send_invoice", ids: ["id"], path: "draft_orders//send_invoice.json"}, + {http_method: "put", operation: "complete", ids: ["id"], path: "draft_orders//complete.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await DraftOrder.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as DraftOrder : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await DraftOrder.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + fields = null, + limit = null, + since_id = null, + updated_at_min = null, + updated_at_max = null, + ids = null, + status = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await DraftOrder.baseFind({ + session: session, + urlIds: {}, + params: {fields: fields, limit: limit, since_id: since_id, updated_at_min: updated_at_min, updated_at_max: updated_at_max, ids: ids, status: status, ...otherArgs}, + }); + + return response as DraftOrder[]; + } + + public static async count( + { + session, + since_id = null, + status = null, + updated_at_max = null, + updated_at_min = null, + ...otherArgs + }: CountArgs + ): Promise { + const response = await DraftOrder.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {}, + params: {since_id: since_id, status: status, updated_at_max: updated_at_max, updated_at_min: updated_at_min, ...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public async send_invoice( + { + body = null, + ...otherArgs + }: SendInvoiceArgs + ): Promise { + const response = await DraftOrder.request({ + http_method: "post", + operation: "send_invoice", + session: this.session, + urlIds: {id: this.id}, + params: {...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public async complete( + { + payment_pending = null, + body = null, + ...otherArgs + }: CompleteArgs + ): Promise { + const response = await DraftOrder.request({ + http_method: "put", + operation: "complete", + session: this.session, + urlIds: {id: this.id}, + params: {payment_pending: payment_pending, ...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public applied_discount: {[key: string]: unknown} | null; + public billing_address: {[key: string]: unknown} | null; + public completed_at: string | null; + public created_at: string | null; + public currency: Currency | null | {[key: string]: any}; + public customer: Customer | null | {[key: string]: any}; + public email: string | null; + public id: number | null; + public invoice_sent_at: string | null; + public invoice_url: string | null; + public line_items: {[key: string]: unknown}[] | null; + public name: string | null; + public note: string | null; + public note_attributes: {[key: string]: unknown}[] | null; + public order_id: number | null; + public payment_terms: {[key: string]: unknown} | null; + public shipping_address: {[key: string]: unknown} | null; + public shipping_line: {[key: string]: unknown} | null; + public status: string | null; + public subtotal_price: number | null; + public tags: string | null; + public tax_exempt: boolean | null; + public tax_exemptions: string[] | null; + public tax_lines: {[key: string]: unknown}[] | null; + public taxes_included: boolean | null; + public total_price: string | null; + public total_tax: string | null; + public updated_at: string | null; +} diff --git a/src/rest-resources/2021-10/event.ts b/src/rest-resources/2021-10/event.ts new file mode 100644 index 000000000..8d0a5454c --- /dev/null +++ b/src/rest-resources/2021-10/event.ts @@ -0,0 +1,115 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + order_id?: number | string | null; + product_id?: number | string | null; + limit?: unknown; + since_id?: unknown; + created_at_min?: unknown; + created_at_max?: unknown; + filter?: unknown; + verb?: unknown; + fields?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; + created_at_min?: unknown; + created_at_max?: unknown; +} + +export class Event extends Base { + public static API_VERSION = ApiVersion.October21; + + protected static NAME = 'event'; + protected static PLURAL_NAME = 'events'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "events.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "events/.json"}, + {http_method: "get", operation: "count", ids: [], path: "events/count.json"}, + {http_method: "get", operation: "get", ids: ["order_id"], path: "orders//events.json"}, + {http_method: "get", operation: "get", ids: ["product_id"], path: "products//events.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await Event.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as Event : null; + } + + public static async all( + { + session, + order_id = null, + product_id = null, + limit = null, + since_id = null, + created_at_min = null, + created_at_max = null, + filter = null, + verb = null, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Event.baseFind({ + session: session, + urlIds: {order_id: order_id, product_id: product_id}, + params: {limit: limit, since_id: since_id, created_at_min: created_at_min, created_at_max: created_at_max, filter: filter, verb: verb, fields: fields, ...otherArgs}, + }); + + return response as Event[]; + } + + public static async count( + { + session, + created_at_min = null, + created_at_max = null, + ...otherArgs + }: CountArgs + ): Promise { + const response = await Event.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {}, + params: {created_at_min: created_at_min, created_at_max: created_at_max, ...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public arguments: string | null; + public body: string | null; + public created_at: string | null; + public description: string | null; + public id: number | null; + public message: string | null; + public path: string | null; + public subject_id: number | null; + public subject_type: string | null; + public verb: string | null; +} diff --git a/src/rest-resources/2021-10/fulfillment.ts b/src/rest-resources/2021-10/fulfillment.ts new file mode 100644 index 000000000..057f96142 --- /dev/null +++ b/src/rest-resources/2021-10/fulfillment.ts @@ -0,0 +1,229 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + order_id?: number | string | null; + fields?: unknown; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + order_id?: number | string | null; + fulfillment_order_id?: number | string | null; + created_at_max?: unknown; + created_at_min?: unknown; + fields?: unknown; + limit?: unknown; + since_id?: unknown; + updated_at_max?: unknown; + updated_at_min?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; + order_id?: number | string | null; + created_at_min?: unknown; + created_at_max?: unknown; + updated_at_min?: unknown; + updated_at_max?: unknown; +} +interface UpdateTrackingArgs { + [key: string]: unknown; + body?: {[key: string]: unknown} | null; +} +interface CompleteArgs { + [key: string]: unknown; + body?: {[key: string]: unknown} | null; +} +interface OpenArgs { + [key: string]: unknown; + body?: {[key: string]: unknown} | null; +} +interface CancelArgs { + [key: string]: unknown; + body?: {[key: string]: unknown} | null; +} + +export class Fulfillment extends Base { + public static API_VERSION = ApiVersion.October21; + + protected static NAME = 'fulfillment'; + protected static PLURAL_NAME = 'fulfillments'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: ["order_id"], path: "orders//fulfillments.json"}, + {http_method: "post", operation: "post", ids: ["order_id"], path: "orders//fulfillments.json"}, + {http_method: "get", operation: "get", ids: ["fulfillment_order_id"], path: "fulfillment_orders//fulfillments.json"}, + {http_method: "get", operation: "count", ids: ["order_id"], path: "orders//fulfillments/count.json"}, + {http_method: "get", operation: "get", ids: ["order_id", "id"], path: "orders//fulfillments/.json"}, + {http_method: "put", operation: "put", ids: ["order_id", "id"], path: "orders//fulfillments/.json"}, + {http_method: "post", operation: "post", ids: [], path: "fulfillments.json"}, + {http_method: "post", operation: "update_tracking", ids: ["id"], path: "fulfillments//update_tracking.json"}, + {http_method: "post", operation: "complete", ids: ["order_id", "id"], path: "orders//fulfillments//complete.json"}, + {http_method: "post", operation: "open", ids: ["order_id", "id"], path: "orders//fulfillments//open.json"}, + {http_method: "post", operation: "cancel", ids: ["order_id", "id"], path: "orders//fulfillments//cancel.json"}, + {http_method: "post", operation: "cancel", ids: ["id"], path: "fulfillments//cancel.json"} + ]; + + public static async find( + { + session, + id, + order_id = null, + fields = null + }: FindArgs + ): Promise { + const result = await Fulfillment.baseFind({ + session: session, + urlIds: {id: id, order_id: order_id}, + params: {fields: fields}, + }); + return result ? result[0] as Fulfillment : null; + } + + public static async all( + { + session, + order_id = null, + fulfillment_order_id = null, + created_at_max = null, + created_at_min = null, + fields = null, + limit = null, + since_id = null, + updated_at_max = null, + updated_at_min = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Fulfillment.baseFind({ + session: session, + urlIds: {order_id: order_id, fulfillment_order_id: fulfillment_order_id}, + params: {created_at_max: created_at_max, created_at_min: created_at_min, fields: fields, limit: limit, since_id: since_id, updated_at_max: updated_at_max, updated_at_min: updated_at_min, ...otherArgs}, + }); + + return response as Fulfillment[]; + } + + public static async count( + { + session, + order_id = null, + created_at_min = null, + created_at_max = null, + updated_at_min = null, + updated_at_max = null, + ...otherArgs + }: CountArgs + ): Promise { + const response = await Fulfillment.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {order_id: order_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, ...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public async update_tracking( + { + body = null, + ...otherArgs + }: UpdateTrackingArgs + ): Promise { + const response = await Fulfillment.request({ + http_method: "post", + operation: "update_tracking", + session: this.session, + urlIds: {id: this.id}, + params: {...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public async complete( + { + body = null, + ...otherArgs + }: CompleteArgs + ): Promise { + const response = await Fulfillment.request({ + http_method: "post", + operation: "complete", + session: this.session, + urlIds: {id: this.id, order_id: this.order_id}, + params: {...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public async open( + { + body = null, + ...otherArgs + }: OpenArgs + ): Promise { + const response = await Fulfillment.request({ + http_method: "post", + operation: "open", + session: this.session, + urlIds: {id: this.id, order_id: this.order_id}, + params: {...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public async cancel( + { + body = null, + ...otherArgs + }: CancelArgs + ): Promise { + const response = await Fulfillment.request({ + http_method: "post", + operation: "cancel", + session: this.session, + urlIds: {id: this.id, order_id: this.order_id}, + params: {...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public created_at: string | null; + public id: number | null; + public line_items: {[key: string]: unknown}[] | null; + public location_id: number | null; + public name: string | null; + public notify_customer: boolean | null; + public order_id: number | null; + public origin_address: {[key: string]: unknown}[] | null; + public receipt: {[key: string]: unknown} | null; + public service: string | null; + public shipment_status: string | null; + public status: string | null; + public tracking_company: string | null; + public tracking_numbers: string[] | null; + public tracking_urls: string[] | null; + public updated_at: string | null; + public variant_inventory_management: string | null; +} diff --git a/src/rest-resources/2021-10/fulfillment_event.ts b/src/rest-resources/2021-10/fulfillment_event.ts new file mode 100644 index 000000000..45aa3a717 --- /dev/null +++ b/src/rest-resources/2021-10/fulfillment_event.ts @@ -0,0 +1,120 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Country} from './country'; +import {Province} from './province'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + order_id?: number | string | null; + fulfillment_id?: number | string | null; + event_id?: unknown; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; + order_id?: number | string | null; + fulfillment_id?: number | string | null; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + order_id?: number | string | null; + fulfillment_id?: number | string | null; +} + +export class FulfillmentEvent extends Base { + public static API_VERSION = ApiVersion.October21; + + protected static NAME = 'fulfillment_event'; + protected static PLURAL_NAME = 'fulfillment_events'; + protected static HAS_ONE: {[key: string]: typeof Base} = { + country: Country, + province: Province + }; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: ["order_id", "fulfillment_id"], path: "orders//fulfillments//events.json"}, + {http_method: "post", operation: "post", ids: ["order_id", "fulfillment_id"], path: "orders//fulfillments//events.json"}, + {http_method: "get", operation: "get", ids: ["order_id", "fulfillment_id", "id"], path: "orders//fulfillments//events/.json"}, + {http_method: "delete", operation: "delete", ids: ["order_id", "fulfillment_id", "id"], path: "orders//fulfillments//events/.json"} + ]; + + protected static getJsonBodyName(): string + { + return "event"; + } + + public static async find( + { + session, + id, + order_id = null, + fulfillment_id = null, + event_id = null + }: FindArgs + ): Promise { + const result = await FulfillmentEvent.baseFind({ + session: session, + urlIds: {id: id, order_id: order_id, fulfillment_id: fulfillment_id}, + params: {event_id: event_id}, + }); + return result ? result[0] as FulfillmentEvent : null; + } + + public static async delete( + { + session, + id, + order_id = null, + fulfillment_id = null + }: DeleteArgs + ): Promise { + const response = await FulfillmentEvent.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id, order_id: order_id, fulfillment_id: fulfillment_id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + order_id = null, + fulfillment_id = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await FulfillmentEvent.baseFind({ + session: session, + urlIds: {order_id: order_id, fulfillment_id: fulfillment_id}, + params: {...otherArgs}, + }); + + return response as FulfillmentEvent[]; + } + + public address1: string | null; + public city: string | null; + public country: Country | null | {[key: string]: any}; + public created_at: string | null; + public estimated_delivery_at: string | null; + public fulfillment_id: number | null; + public happened_at: string | null; + public id: number | null; + public latitude: number | null; + public longitude: number | null; + public message: string | null; + public order_id: number | null; + public province: Province | null | {[key: string]: any}; + public shop_id: number | null; + public status: string | null; + public updated_at: string | null; + public zip: string | null; +} diff --git a/src/rest-resources/2021-10/fulfillment_order.ts b/src/rest-resources/2021-10/fulfillment_order.ts new file mode 100644 index 000000000..ca341b5ed --- /dev/null +++ b/src/rest-resources/2021-10/fulfillment_order.ts @@ -0,0 +1,250 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + order_id?: number | string | null; +} +interface CancelArgs { + [key: string]: unknown; + body?: {[key: string]: unknown} | null; +} +interface CloseArgs { + [key: string]: unknown; + message?: unknown; + body?: {[key: string]: unknown} | null; +} +interface MoveArgs { + [key: string]: unknown; + new_location_id?: unknown; + body?: {[key: string]: unknown} | null; +} +interface OpenArgs { + [key: string]: unknown; + body?: {[key: string]: unknown} | null; +} +interface RescheduleArgs { + [key: string]: unknown; + body?: {[key: string]: unknown} | null; +} +interface HoldArgs { + [key: string]: unknown; + reason?: unknown; + reason_notes?: unknown; + notify_merchant?: unknown; + body?: {[key: string]: unknown} | null; +} +interface ReleaseHoldArgs { + [key: string]: unknown; + body?: {[key: string]: unknown} | null; +} + +export class FulfillmentOrder extends Base { + public static API_VERSION = ApiVersion.October21; + + protected static NAME = 'fulfillment_order'; + protected static PLURAL_NAME = 'fulfillment_orders'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: ["order_id"], path: "orders//fulfillment_orders.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "fulfillment_orders/.json"}, + {http_method: "post", operation: "cancel", ids: ["id"], path: "fulfillment_orders//cancel.json"}, + {http_method: "post", operation: "close", ids: ["id"], path: "fulfillment_orders//close.json"}, + {http_method: "post", operation: "move", ids: ["id"], path: "fulfillment_orders//move.json"}, + {http_method: "post", operation: "open", ids: ["id"], path: "fulfillment_orders//open.json"}, + {http_method: "post", operation: "reschedule", ids: ["id"], path: "fulfillment_orders//reschedule.json"}, + {http_method: "post", operation: "hold", ids: ["id"], path: "fulfillment_orders//hold.json"}, + {http_method: "post", operation: "release_hold", ids: ["id"], path: "fulfillment_orders//release_hold.json"} + ]; + + public static async find( + { + session, + id + }: FindArgs + ): Promise { + const result = await FulfillmentOrder.baseFind({ + session: session, + urlIds: {id: id}, + params: {}, + }); + return result ? result[0] as FulfillmentOrder : null; + } + + public static async all( + { + session, + order_id = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await FulfillmentOrder.baseFind({ + session: session, + urlIds: {order_id: order_id}, + params: {...otherArgs}, + }); + + return response as FulfillmentOrder[]; + } + + public async cancel( + { + body = null, + ...otherArgs + }: CancelArgs + ): Promise { + const response = await FulfillmentOrder.request({ + http_method: "post", + operation: "cancel", + session: this.session, + urlIds: {id: this.id}, + params: {...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public async close( + { + message = null, + body = null, + ...otherArgs + }: CloseArgs + ): Promise { + const response = await FulfillmentOrder.request({ + http_method: "post", + operation: "close", + session: this.session, + urlIds: {id: this.id}, + params: {message: message, ...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public async move( + { + new_location_id = null, + body = null, + ...otherArgs + }: MoveArgs + ): Promise { + const response = await FulfillmentOrder.request({ + http_method: "post", + operation: "move", + session: this.session, + urlIds: {id: this.id}, + params: {new_location_id: new_location_id, ...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public async open( + { + body = null, + ...otherArgs + }: OpenArgs + ): Promise { + const response = await FulfillmentOrder.request({ + http_method: "post", + operation: "open", + session: this.session, + urlIds: {id: this.id}, + params: {...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public async reschedule( + { + body = null, + ...otherArgs + }: RescheduleArgs + ): Promise { + const response = await FulfillmentOrder.request({ + http_method: "post", + operation: "reschedule", + session: this.session, + urlIds: {id: this.id}, + params: {...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public async hold( + { + reason = null, + reason_notes = null, + notify_merchant = null, + body = null, + ...otherArgs + }: HoldArgs + ): Promise { + const response = await FulfillmentOrder.request({ + http_method: "post", + operation: "hold", + session: this.session, + urlIds: {id: this.id}, + params: {reason: reason, reason_notes: reason_notes, notify_merchant: notify_merchant, ...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public async release_hold( + { + body = null, + ...otherArgs + }: ReleaseHoldArgs + ): Promise { + const response = await FulfillmentOrder.request({ + http_method: "post", + operation: "release_hold", + session: this.session, + urlIds: {id: this.id}, + params: {...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public assigned_location: {[key: string]: unknown} | null; + public assigned_location_id: number | null; + public delivery_method: {[key: string]: unknown} | null; + public destination: {[key: string]: unknown} | null; + public fulfill_at: string | null; + public fulfillment_holds: {[key: string]: unknown}[] | null; + public id: number | null; + public international_duties: {[key: string]: unknown} | null; + public line_items: {[key: string]: unknown}[] | null; + public merchant_requests: {[key: string]: unknown}[] | null; + public order_id: number | null; + public request_status: string | null; + public shop_id: number | null; + public status: string | null; + public supported_actions: string[] | null; +} diff --git a/src/rest-resources/2021-10/fulfillment_request.ts b/src/rest-resources/2021-10/fulfillment_request.ts new file mode 100644 index 000000000..e80b00a7a --- /dev/null +++ b/src/rest-resources/2021-10/fulfillment_request.ts @@ -0,0 +1,69 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {ApiVersion} from '../../base-types'; + +interface AcceptArgs { + [key: string]: unknown; + message?: unknown; + body?: {[key: string]: unknown} | null; +} +interface RejectArgs { + [key: string]: unknown; + message?: unknown; + body?: {[key: string]: unknown} | null; +} + +export class FulfillmentRequest extends Base { + public static API_VERSION = ApiVersion.October21; + + protected static NAME = 'fulfillment_request'; + protected static PLURAL_NAME = 'fulfillment_requests'; + 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_request.json"}, + {http_method: "post", operation: "accept", ids: ["fulfillment_order_id"], path: "fulfillment_orders//fulfillment_request/accept.json"}, + {http_method: "post", operation: "reject", ids: ["fulfillment_order_id"], path: "fulfillment_orders//fulfillment_request/reject.json"} + ]; + + public async accept( + { + message = null, + body = null, + ...otherArgs + }: AcceptArgs + ): Promise { + const response = await FulfillmentRequest.request({ + http_method: "post", + operation: "accept", + session: this.session, + urlIds: {fulfillment_order_id: this.fulfillment_order_id}, + params: {message: message, ...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public async reject( + { + message = null, + body = null, + ...otherArgs + }: RejectArgs + ): Promise { + const response = await FulfillmentRequest.request({ + http_method: "post", + operation: "reject", + session: this.session, + urlIds: {fulfillment_order_id: this.fulfillment_order_id}, + params: {message: message, ...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public fulfillment_order_id: number | null; +} diff --git a/src/rest-resources/2021-10/fulfillment_service.ts b/src/rest-resources/2021-10/fulfillment_service.ts new file mode 100644 index 000000000..9d3e13af0 --- /dev/null +++ b/src/rest-resources/2021-10/fulfillment_service.ts @@ -0,0 +1,93 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + scope?: unknown; +} + +export class FulfillmentService extends Base { + public static API_VERSION = ApiVersion.October21; + + protected static NAME = 'fulfillment_service'; + protected static PLURAL_NAME = 'fulfillment_services'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "fulfillment_services.json"}, + {http_method: "post", operation: "post", ids: [], path: "fulfillment_services.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "fulfillment_services/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "fulfillment_services/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "fulfillment_services/.json"} + ]; + + public static async find( + { + session, + id + }: FindArgs + ): Promise { + const result = await FulfillmentService.baseFind({ + session: session, + urlIds: {id: id}, + params: {}, + }); + return result ? result[0] as FulfillmentService : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await FulfillmentService.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + scope = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await FulfillmentService.baseFind({ + session: session, + urlIds: {}, + params: {scope: scope, ...otherArgs}, + }); + + return response as FulfillmentService[]; + } + + public admin_graphql_api_id: string | null; + public callback_url: string | null; + public format: string | null; + public fulfillment_orders_opt_in: boolean | null; + public handle: string | null; + public id: number | null; + public inventory_management: boolean | null; + public location_id: number | null; + public name: string | null; + public provider_id: string | null; + public requires_shipping_method: boolean | null; + public tracking_support: boolean | null; +} diff --git a/src/rest-resources/2021-10/gift_card.ts b/src/rest-resources/2021-10/gift_card.ts new file mode 100644 index 000000000..379031010 --- /dev/null +++ b/src/rest-resources/2021-10/gift_card.ts @@ -0,0 +1,170 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Balance} from './balance'; +import {Currency} from './currency'; + +interface FindArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + status?: unknown; + limit?: unknown; + since_id?: unknown; + fields?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; + status?: unknown; +} +interface SearchArgs { + [key: string]: unknown; + session: SessionInterface; + order?: unknown; + query?: unknown; + limit?: unknown; + fields?: unknown; +} +interface DisableArgs { + [key: string]: unknown; + body?: {[key: string]: unknown} | null; +} + +export class GiftCard extends Base { + public static API_VERSION = ApiVersion.October21; + + protected static NAME = 'gift_card'; + protected static PLURAL_NAME = 'gift_cards'; + protected static HAS_ONE: {[key: string]: typeof Base} = { + balance: Balance, + currency: Currency + }; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "gift_cards.json"}, + {http_method: "post", operation: "post", ids: [], path: "gift_cards.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "gift_cards/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "gift_cards/.json"}, + {http_method: "get", operation: "count", ids: [], path: "gift_cards/count.json"}, + {http_method: "post", operation: "disable", ids: ["id"], path: "gift_cards//disable.json"}, + {http_method: "get", operation: "search", ids: [], path: "gift_cards/search.json"} + ]; + + public static async find( + { + session, + id + }: FindArgs + ): Promise { + const result = await GiftCard.baseFind({ + session: session, + urlIds: {id: id}, + params: {}, + }); + return result ? result[0] as GiftCard : null; + } + + public static async all( + { + session, + status = null, + limit = null, + since_id = null, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await GiftCard.baseFind({ + session: session, + urlIds: {}, + params: {status: status, limit: limit, since_id: since_id, fields: fields, ...otherArgs}, + }); + + return response as GiftCard[]; + } + + public static async count( + { + session, + status = null, + ...otherArgs + }: CountArgs + ): Promise { + const response = await GiftCard.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {}, + params: {status: status, ...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public static async search( + { + session, + order = null, + query = null, + limit = null, + fields = null, + ...otherArgs + }: SearchArgs + ): Promise { + const response = await GiftCard.request({ + http_method: "get", + operation: "search", + session: session, + urlIds: {}, + params: {order: order, query: query, limit: limit, fields: fields, ...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public async disable( + { + body = null, + ...otherArgs + }: DisableArgs + ): Promise { + const response = await GiftCard.request({ + http_method: "post", + operation: "disable", + session: this.session, + urlIds: {id: this.id}, + params: {...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public api_client_id: number | null; + public balance: Balance | null | {[key: string]: any}; + public code: string | null; + public created_at: string | null; + public currency: Currency | null | {[key: string]: any}; + public customer_id: number | null; + public disabled_at: string | null; + public expires_on: string | null; + public id: number | null; + public initial_value: number | null; + public last_characters: string | null; + public line_item_id: number | null; + public note: string | null; + public order_id: number | null; + public template_suffix: string | null; + public updated_at: string | null; + public user_id: number | null; +} diff --git a/src/rest-resources/2021-10/gift_card_adjustment.ts b/src/rest-resources/2021-10/gift_card_adjustment.ts new file mode 100644 index 000000000..fa9a46ea5 --- /dev/null +++ b/src/rest-resources/2021-10/gift_card_adjustment.ts @@ -0,0 +1,77 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + gift_card_id?: number | string | null; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + gift_card_id?: number | string | null; +} + +export class GiftCardAdjustment extends Base { + public static API_VERSION = ApiVersion.October21; + + protected static NAME = 'gift_card_adjustment'; + protected static PLURAL_NAME = 'gift_card_adjustments'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: ["gift_card_id"], path: "gift_cards//adjustments.json"}, + {http_method: "post", operation: "post", ids: ["gift_card_id"], path: "gift_cards//adjustments.json"}, + {http_method: "get", operation: "get", ids: ["gift_card_id", "id"], path: "gift_cards//adjustments/9.json"} + ]; + + protected static getJsonBodyName(): string + { + return "adjustment"; + } + + public static async find( + { + session, + id, + gift_card_id = null + }: FindArgs + ): Promise { + const result = await GiftCardAdjustment.baseFind({ + session: session, + urlIds: {id: id, gift_card_id: gift_card_id}, + params: {}, + }); + return result ? result[0] as GiftCardAdjustment : null; + } + + public static async all( + { + session, + gift_card_id = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await GiftCardAdjustment.baseFind({ + session: session, + urlIds: {gift_card_id: gift_card_id}, + params: {...otherArgs}, + }); + + return response as GiftCardAdjustment[]; + } + + public amount: number | null; + public api_client_id: number | null; + public created_at: string | null; + public gift_card_id: number | null; + public id: number | null; + public note: string | null; + public number: number | null; + public order_transaction_id: number | null; + public processed_at: string | null; + public remote_transaction_ref: string | null; + public remote_transaction_url: string | null; + public user_id: number | null; +} diff --git a/src/rest-resources/2021-10/image.ts b/src/rest-resources/2021-10/image.ts new file mode 100644 index 000000000..45b11d0fe --- /dev/null +++ b/src/rest-resources/2021-10/image.ts @@ -0,0 +1,128 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + product_id?: number | string | null; + fields?: unknown; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; + product_id?: number | string | null; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + product_id?: number | string | null; + since_id?: unknown; + fields?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; + product_id?: number | string | null; + since_id?: unknown; +} + +export class Image extends Base { + public static API_VERSION = ApiVersion.October21; + + protected static NAME = 'image'; + protected static PLURAL_NAME = 'images'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: ["product_id"], path: "products//images.json"}, + {http_method: "post", operation: "post", ids: ["product_id"], path: "products//images.json"}, + {http_method: "get", operation: "count", ids: ["product_id"], path: "products//images/count.json"}, + {http_method: "get", operation: "get", ids: ["product_id", "id"], path: "products//images/.json"}, + {http_method: "put", operation: "put", ids: ["product_id", "id"], path: "products//images/.json"}, + {http_method: "delete", operation: "delete", ids: ["product_id", "id"], path: "products//images/.json"} + ]; + + public static async find( + { + session, + id, + product_id = null, + fields = null + }: FindArgs + ): Promise { + const result = await Image.baseFind({ + session: session, + urlIds: {id: id, product_id: product_id}, + params: {fields: fields}, + }); + return result ? result[0] as Image : null; + } + + public static async delete( + { + session, + id, + product_id = null + }: DeleteArgs + ): Promise { + const response = await Image.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id, product_id: product_id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + product_id = null, + since_id = null, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Image.baseFind({ + session: session, + urlIds: {product_id: product_id}, + params: {since_id: since_id, fields: fields, ...otherArgs}, + }); + + return response as Image[]; + } + + public static async count( + { + session, + product_id = null, + since_id = null, + ...otherArgs + }: CountArgs + ): Promise { + const response = await Image.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {product_id: product_id}, + params: {since_id: since_id, ...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public created_at: string | null; + public height: number | null; + public id: number | null; + public position: number | null; + public product_id: number | null; + public src: string | null; + public updated_at: string | null; + public variant_ids: number[] | null; + public width: number | null; +} diff --git a/src/rest-resources/2021-10/index.ts b/src/rest-resources/2021-10/index.ts new file mode 100644 index 000000000..ed825721a --- /dev/null +++ b/src/rest-resources/2021-10/index.ts @@ -0,0 +1,74 @@ +export {AbandonedCheckout} from './abandoned_checkout'; +export {AccessScope} from './access_scope'; +export {AndroidPayKey} from './android_pay_key'; +export {ApplePayCertificate} from './apple_pay_certificate'; +export {ApplicationCharge} from './application_charge'; +export {ApplicationCredit} from './application_credit'; +export {Article} from './article'; +export {Asset} from './asset'; +export {AssignedFulfillmentOrder} from './assigned_fulfillment_order'; +export {Balance} from './balance'; +export {Blog} from './blog'; +export {CancellationRequest} from './cancellation_request'; +export {CarrierService} from './carrier_service'; +export {Checkout} from './checkout'; +export {Collect} from './collect'; +export {Collection} from './collection'; +export {CollectionListing} from './collection_listing'; +export {Comment} from './comment'; +export {Country} from './country'; +export {Currency} from './currency'; +export {CustomCollection} from './custom_collection'; +export {Customer} from './customer'; +export {CustomerAddress} from './customer_address'; +export {CustomerSavedSearch} from './customer_saved_search'; +export {DeprecatedApiCall} from './deprecated_api_call'; +export {DiscountCode} from './discount_code'; +export {Dispute} from './dispute'; +export {DraftOrder} from './draft_order'; +export {Event} from './event'; +export {Fulfillment} from './fulfillment'; +export {FulfillmentEvent} from './fulfillment_event'; +export {FulfillmentOrder} from './fulfillment_order'; +export {FulfillmentRequest} from './fulfillment_request'; +export {FulfillmentService} from './fulfillment_service'; +export {GiftCard} from './gift_card'; +export {GiftCardAdjustment} from './gift_card_adjustment'; +export {Image} from './image'; +export {InventoryItem} from './inventory_item'; +export {InventoryLevel} from './inventory_level'; +export {Location} from './location'; +export {LocationsForMove} from './locations_for_move'; +export {MarketingEvent} from './marketing_event'; +export {Metafield} from './metafield'; +export {MobilePlatformApplication} from './mobile_platform_application'; +export {Order} from './order'; +export {OrderRisk} from './order_risk'; +export {Page} from './page'; +export {Payment} from './payment'; +export {PaymentGateway} from './payment_gateway'; +export {PaymentTransaction} from './payment_transaction'; +export {Payout} from './payout'; +export {Policy} from './policy'; +export {PriceRule} from './price_rule'; +export {Product} from './product'; +export {ProductListing} from './product_listing'; +export {ProductResourceFeedback} from './product_resource_feedback'; +export {Province} from './province'; +export {RecurringApplicationCharge} from './recurring_application_charge'; +export {Redirect} from './redirect'; +export {Refund} from './refund'; +export {Report} from './report'; +export {ResourceFeedback} from './resource_feedback'; +export {ScriptTag} from './script_tag'; +export {ShippingZone} from './shipping_zone'; +export {Shop} from './shop'; +export {SmartCollection} from './smart_collection'; +export {StorefrontAccessToken} from './storefront_access_token'; +export {TenderTransaction} from './tender_transaction'; +export {Theme} from './theme'; +export {Transaction} from './transaction'; +export {UsageCharge} from './usage_charge'; +export {User} from './user'; +export {Variant} from './variant'; +export {Webhook} from './webhook'; \ No newline at end of file diff --git a/src/rest-resources/2021-10/inventory_item.ts b/src/rest-resources/2021-10/inventory_item.ts new file mode 100644 index 000000000..fa9ace6bd --- /dev/null +++ b/src/rest-resources/2021-10/inventory_item.ts @@ -0,0 +1,71 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + ids?: unknown; + limit?: unknown; +} + +export class InventoryItem extends Base { + public static API_VERSION = ApiVersion.October21; + + protected static NAME = 'inventory_item'; + protected static PLURAL_NAME = 'inventory_items'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "inventory_items.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "inventory_items/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "inventory_items/.json"} + ]; + + public static async find( + { + session, + id + }: FindArgs + ): Promise { + const result = await InventoryItem.baseFind({ + session: session, + urlIds: {id: id}, + params: {}, + }); + return result ? result[0] as InventoryItem : null; + } + + public static async all( + { + session, + ids = null, + limit = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await InventoryItem.baseFind({ + session: session, + urlIds: {}, + params: {ids: ids, limit: limit, ...otherArgs}, + }); + + return response as InventoryItem[]; + } + + public cost: string | null; + public country_code_of_origin: string | null; + public country_harmonized_system_codes: {[key: string]: unknown}[] | null; + public created_at: string | null; + public harmonized_system_code: number | null; + public id: number | null; + public province_code_of_origin: string | null; + public requires_shipping: boolean | null; + public sku: string | null; + public tracked: boolean | null; + public updated_at: string | null; +} diff --git a/src/rest-resources/2021-10/inventory_level.ts b/src/rest-resources/2021-10/inventory_level.ts new file mode 100644 index 000000000..66da93804 --- /dev/null +++ b/src/rest-resources/2021-10/inventory_level.ts @@ -0,0 +1,164 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface DeleteArgs { + session: SessionInterface; + inventory_item_id?: unknown; + location_id?: unknown; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + inventory_item_ids?: unknown; + location_ids?: unknown; + limit?: unknown; + updated_at_min?: unknown; +} +interface AdjustArgs { + [key: string]: unknown; + inventory_item_id?: unknown; + location_id?: unknown; + available_adjustment?: unknown; + body?: {[key: string]: unknown} | null; +} +interface ConnectArgs { + [key: string]: unknown; + inventory_item_id?: unknown; + location_id?: unknown; + relocate_if_necessary?: unknown; + body?: {[key: string]: unknown} | null; +} +interface SetArgs { + [key: string]: unknown; + inventory_item_id?: unknown; + location_id?: unknown; + available?: unknown; + disconnect_if_necessary?: unknown; + body?: {[key: string]: unknown} | null; +} + +export class InventoryLevel extends Base { + public static API_VERSION = ApiVersion.October21; + + protected static NAME = 'inventory_level'; + protected static PLURAL_NAME = 'inventory_levels'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "inventory_levels.json"}, + {http_method: "post", operation: "adjust", ids: [], path: "inventory_levels/adjust.json"}, + {http_method: "delete", operation: "delete", ids: [], path: "inventory_levels.json"}, + {http_method: "post", operation: "connect", ids: [], path: "inventory_levels/connect.json"}, + {http_method: "post", operation: "set", ids: [], path: "inventory_levels/set.json"} + ]; + + public static async delete( + { + session, + inventory_item_id = null, + location_id = null + }: DeleteArgs + ): Promise { + const response = await InventoryLevel.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {}, + params: {inventory_item_id: inventory_item_id, location_id: location_id}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + inventory_item_ids = null, + location_ids = null, + limit = null, + updated_at_min = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await InventoryLevel.baseFind({ + session: session, + urlIds: {}, + params: {inventory_item_ids: inventory_item_ids, location_ids: location_ids, limit: limit, updated_at_min: updated_at_min, ...otherArgs}, + }); + + return response as InventoryLevel[]; + } + + public async adjust( + { + inventory_item_id = null, + location_id = null, + available_adjustment = null, + body = null, + ...otherArgs + }: AdjustArgs + ): Promise { + const response = await InventoryLevel.request({ + http_method: "post", + operation: "adjust", + session: this.session, + urlIds: {}, + params: {inventory_item_id: inventory_item_id, location_id: location_id, available_adjustment: available_adjustment, ...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public async connect( + { + inventory_item_id = null, + location_id = null, + relocate_if_necessary = null, + body = null, + ...otherArgs + }: ConnectArgs + ): Promise { + const response = await InventoryLevel.request({ + http_method: "post", + operation: "connect", + session: this.session, + urlIds: {}, + params: {inventory_item_id: inventory_item_id, location_id: location_id, relocate_if_necessary: relocate_if_necessary, ...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public async set( + { + inventory_item_id = null, + location_id = null, + available = null, + disconnect_if_necessary = null, + body = null, + ...otherArgs + }: SetArgs + ): Promise { + const response = await InventoryLevel.request({ + http_method: "post", + operation: "set", + session: this.session, + urlIds: {}, + params: {inventory_item_id: inventory_item_id, location_id: location_id, available: available, disconnect_if_necessary: disconnect_if_necessary, ...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public available: number | null; + public inventory_item_id: number | null; + public location_id: number | null; + public updated_at: string | null; +} diff --git a/src/rest-resources/2021-10/location.ts b/src/rest-resources/2021-10/location.ts new file mode 100644 index 000000000..fd58eb68a --- /dev/null +++ b/src/rest-resources/2021-10/location.ts @@ -0,0 +1,128 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Country} from './country'; +import {Province} from './province'; + +interface FindArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; +} +interface InventoryLevelsArgs { + [key: string]: unknown; + session: SessionInterface; + id: number | string; +} + +export class Location extends Base { + public static API_VERSION = ApiVersion.October21; + + protected static NAME = 'location'; + protected static PLURAL_NAME = 'locations'; + protected static HAS_ONE: {[key: string]: typeof Base} = { + country: Country, + province: Province + }; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "locations.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "locations/.json"}, + {http_method: "get", operation: "count", ids: [], path: "locations/count.json"}, + {http_method: "get", operation: "inventory_levels", ids: ["id"], path: "locations//inventory_levels.json"} + ]; + + public static async find( + { + session, + id + }: FindArgs + ): Promise { + const result = await Location.baseFind({ + session: session, + urlIds: {id: id}, + params: {}, + }); + return result ? result[0] as Location : null; + } + + public static async all( + { + session, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Location.baseFind({ + session: session, + urlIds: {}, + params: {...otherArgs}, + }); + + return response as Location[]; + } + + public static async count( + { + session, + ...otherArgs + }: CountArgs + ): Promise { + const response = await Location.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {}, + params: {...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public static async inventory_levels( + { + session, + id, + ...otherArgs + }: InventoryLevelsArgs + ): Promise { + const response = await Location.request({ + http_method: "get", + operation: "inventory_levels", + session: session, + urlIds: {id: id}, + params: {...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public active: boolean | null; + public address1: string | null; + public address2: string | null; + public city: string | null; + public country: Country | null | {[key: string]: any}; + public country_code: string | null; + public created_at: string | null; + public id: number | null; + public legacy: boolean | null; + public localized_country_name: string | null; + public localized_province_name: string | null; + public name: string | null; + public phone: string | null; + public province: Province | null | {[key: string]: any}; + public province_code: string | null; + public updated_at: string | null; + public zip: string | null; +} diff --git a/src/rest-resources/2021-10/locations_for_move.ts b/src/rest-resources/2021-10/locations_for_move.ts new file mode 100644 index 000000000..6bed0ceb8 --- /dev/null +++ b/src/rest-resources/2021-10/locations_for_move.ts @@ -0,0 +1,39 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + fulfillment_order_id?: number | string | null; +} + +export class LocationsForMove extends Base { + public static API_VERSION = ApiVersion.October21; + + protected static NAME = 'locations_for_move'; + protected static PLURAL_NAME = 'locations_for_moves'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: ["fulfillment_order_id"], path: "fulfillment_orders//locations_for_move.json"} + ]; + + public static async all( + { + session, + fulfillment_order_id = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await LocationsForMove.baseFind({ + session: session, + urlIds: {fulfillment_order_id: fulfillment_order_id}, + params: {...otherArgs}, + }); + + return response as LocationsForMove[]; + } + + public locations_for_move: {[key: string]: unknown}[] | null; +} diff --git a/src/rest-resources/2021-10/marketing_event.ts b/src/rest-resources/2021-10/marketing_event.ts new file mode 100644 index 000000000..f2dfa3cfd --- /dev/null +++ b/src/rest-resources/2021-10/marketing_event.ts @@ -0,0 +1,166 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + limit?: unknown; + offset?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; +} +interface EngagementsArgs { + [key: string]: unknown; + occurred_on?: unknown; + impressions_count?: unknown; + views_count?: unknown; + clicks_count?: unknown; + shares_count?: unknown; + favorites_count?: unknown; + comments_count?: unknown; + ad_spend?: unknown; + is_cumulative?: unknown; + body?: {[key: string]: unknown} | null; +} + +export class MarketingEvent extends Base { + public static API_VERSION = ApiVersion.October21; + + protected static NAME = 'marketing_event'; + protected static PLURAL_NAME = 'marketing_events'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "marketing_events.json"}, + {http_method: "post", operation: "post", ids: [], path: "marketing_events.json"}, + {http_method: "get", operation: "count", ids: [], path: "marketing_events/count.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "marketing_events/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "marketing_events/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "marketing_events/.json"}, + {http_method: "post", operation: "engagements", ids: ["id"], path: "marketing_events//engagements.json"} + ]; + + public static async find( + { + session, + id + }: FindArgs + ): Promise { + const result = await MarketingEvent.baseFind({ + session: session, + urlIds: {id: id}, + params: {}, + }); + return result ? result[0] as MarketingEvent : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await MarketingEvent.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + limit = null, + offset = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await MarketingEvent.baseFind({ + session: session, + urlIds: {}, + params: {limit: limit, offset: offset, ...otherArgs}, + }); + + return response as MarketingEvent[]; + } + + public static async count( + { + session, + ...otherArgs + }: CountArgs + ): Promise { + const response = await MarketingEvent.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {}, + params: {...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public async engagements( + { + occurred_on = null, + impressions_count = null, + views_count = null, + clicks_count = null, + shares_count = null, + favorites_count = null, + comments_count = null, + ad_spend = null, + is_cumulative = null, + body = null, + ...otherArgs + }: EngagementsArgs + ): Promise { + const response = await MarketingEvent.request({ + http_method: "post", + operation: "engagements", + session: this.session, + urlIds: {id: this.id}, + params: {occurred_on: occurred_on, impressions_count: impressions_count, views_count: views_count, clicks_count: clicks_count, shares_count: shares_count, favorites_count: favorites_count, comments_count: comments_count, ad_spend: ad_spend, is_cumulative: is_cumulative, ...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public event_type: string | null; + public marketing_channel: string | null; + public paid: boolean | null; + public started_at: string | null; + public UTM_parameters: {[key: string]: unknown} | null; + public budget: string | null; + public budget_type: string | null; + public currency: string | null; + public description: string | null; + public ended_at: string | null; + public id: number | null; + public manage_url: string | null; + public marketed_resources: {[key: string]: unknown}[] | null; + public preview_url: string | null; + public referring_domain: string | null; + public remote_id: string | null; + public scheduled_to_end_at: string | null; +} diff --git a/src/rest-resources/2021-10/metafield.ts b/src/rest-resources/2021-10/metafield.ts new file mode 100644 index 000000000..cda6b42d3 --- /dev/null +++ b/src/rest-resources/2021-10/metafield.ts @@ -0,0 +1,141 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + limit?: unknown; + since_id?: unknown; + created_at_min?: unknown; + created_at_max?: unknown; + updated_at_min?: unknown; + updated_at_max?: unknown; + namespace?: unknown; + key?: unknown; + type?: unknown; + value_type?: unknown; + fields?: unknown; + metafield?: {[key: string]: unknown} | null; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; +} + +export class Metafield extends Base { + public static API_VERSION = ApiVersion.October21; + + protected static NAME = 'metafield'; + protected static PLURAL_NAME = 'metafields'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "metafields.json"}, + {http_method: "post", operation: "post", ids: [], path: "metafields.json"}, + {http_method: "get", operation: "get", ids: [], path: "metafields.json"}, + {http_method: "get", operation: "count", ids: [], path: "metafields/count.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "metafields/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "metafields/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "metafields/.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await Metafield.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as Metafield : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await Metafield.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + limit = null, + since_id = null, + created_at_min = null, + created_at_max = null, + updated_at_min = null, + updated_at_max = null, + namespace = null, + key = null, + type = null, + value_type = null, + fields = null, + metafield = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Metafield.baseFind({ + session: session, + urlIds: {}, + params: {limit: limit, since_id: since_id, created_at_min: created_at_min, created_at_max: created_at_max, updated_at_min: updated_at_min, updated_at_max: updated_at_max, namespace: namespace, key: key, type: type, value_type: value_type, fields: fields, metafield: metafield, ...otherArgs}, + }); + + return response as Metafield[]; + } + + public static async count( + { + session, + ...otherArgs + }: CountArgs + ): Promise { + const response = await Metafield.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {}, + params: {...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public key: string | null; + public namespace: string | null; + public value: string | number | number | null; + public created_at: string | null; + public description: string | null; + public id: number | null; + public owner_id: number | null; + public owner_resource: string | null; + public type: string | null; + public updated_at: string | null; + public value_type: string | null; +} diff --git a/src/rest-resources/2021-10/mobile_platform_application.ts b/src/rest-resources/2021-10/mobile_platform_application.ts new file mode 100644 index 000000000..27b1c7c15 --- /dev/null +++ b/src/rest-resources/2021-10/mobile_platform_application.ts @@ -0,0 +1,85 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; +} + +export class MobilePlatformApplication extends Base { + public static API_VERSION = ApiVersion.October21; + + protected static NAME = 'mobile_platform_application'; + protected static PLURAL_NAME = 'mobile_platform_applications'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "mobile_platform_applications.json"}, + {http_method: "post", operation: "post", ids: [], path: "mobile_platform_applications.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "mobile_platform_applications/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "mobile_platform_applications/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "mobile_platform_applications/.json"} + ]; + + public static async find( + { + session, + id + }: FindArgs + ): Promise { + const result = await MobilePlatformApplication.baseFind({ + session: session, + urlIds: {id: id}, + params: {}, + }); + return result ? result[0] as MobilePlatformApplication : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await MobilePlatformApplication.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + ...otherArgs + }: AllArgs + ): Promise { + const response = await MobilePlatformApplication.baseFind({ + session: session, + urlIds: {}, + params: {...otherArgs}, + }); + + return response as MobilePlatformApplication[]; + } + + public application_id: string | null; + public enabled_shared_webcredentials: boolean | null; + public enabled_universal_or_app_links: boolean | null; + public id: number | null; + public platform: string | null; + public sha256_cert_fingerprints: string[] | null; +} diff --git a/src/rest-resources/2021-10/order.ts b/src/rest-resources/2021-10/order.ts new file mode 100644 index 000000000..f08b5013d --- /dev/null +++ b/src/rest-resources/2021-10/order.ts @@ -0,0 +1,317 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Customer} from './customer'; +import {DiscountCode} from './discount_code'; +import {Fulfillment} from './fulfillment'; +import {Refund} from './refund'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + ids?: unknown; + limit?: unknown; + since_id?: unknown; + created_at_min?: unknown; + created_at_max?: unknown; + updated_at_min?: unknown; + updated_at_max?: unknown; + processed_at_min?: unknown; + processed_at_max?: unknown; + attribution_app_id?: unknown; + status?: unknown; + financial_status?: unknown; + fulfillment_status?: unknown; + fields?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; + created_at_min?: unknown; + created_at_max?: unknown; + updated_at_min?: unknown; + updated_at_max?: unknown; + status?: unknown; + financial_status?: unknown; + fulfillment_status?: unknown; +} +interface CloseArgs { + [key: string]: unknown; + body?: {[key: string]: unknown} | null; +} +interface OpenArgs { + [key: string]: unknown; + body?: {[key: string]: unknown} | null; +} +interface CancelArgs { + [key: string]: unknown; + amount?: unknown; + currency?: unknown; + restock?: unknown; + reason?: unknown; + email?: unknown; + refund?: unknown; + body?: {[key: string]: unknown} | null; +} + +export class Order extends Base { + public static API_VERSION = ApiVersion.October21; + + protected static NAME = 'order'; + protected static PLURAL_NAME = 'orders'; + protected static HAS_ONE: {[key: string]: typeof Base} = { + customer: Customer + }; + protected static HAS_MANY: {[key: string]: typeof Base} = { + discount_codes: DiscountCode, + fulfillments: Fulfillment, + refunds: Refund + }; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "orders.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "orders/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "orders/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "orders/.json"}, + {http_method: "get", operation: "count", ids: [], path: "orders/count.json"}, + {http_method: "post", operation: "close", ids: ["id"], path: "orders//close.json"}, + {http_method: "post", operation: "open", ids: ["id"], path: "orders//open.json"}, + {http_method: "post", operation: "cancel", ids: ["id"], path: "orders//cancel.json"}, + {http_method: "post", operation: "post", ids: [], path: "orders.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await Order.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as Order : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await Order.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + ids = null, + limit = null, + since_id = null, + created_at_min = null, + created_at_max = null, + updated_at_min = null, + updated_at_max = null, + processed_at_min = null, + processed_at_max = null, + attribution_app_id = null, + status = null, + financial_status = null, + fulfillment_status = null, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Order.baseFind({ + session: session, + urlIds: {}, + params: {ids: ids, limit: limit, since_id: since_id, created_at_min: created_at_min, created_at_max: created_at_max, updated_at_min: updated_at_min, updated_at_max: updated_at_max, processed_at_min: processed_at_min, processed_at_max: processed_at_max, attribution_app_id: attribution_app_id, status: status, financial_status: financial_status, fulfillment_status: fulfillment_status, fields: fields, ...otherArgs}, + }); + + return response as Order[]; + } + + public static async count( + { + session, + created_at_min = null, + created_at_max = null, + updated_at_min = null, + updated_at_max = null, + status = null, + financial_status = null, + fulfillment_status = null, + ...otherArgs + }: CountArgs + ): Promise { + const response = await Order.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {}, + 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, status: status, financial_status: financial_status, fulfillment_status: fulfillment_status, ...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public async close( + { + body = null, + ...otherArgs + }: CloseArgs + ): Promise { + const response = await Order.request({ + http_method: "post", + operation: "close", + session: this.session, + urlIds: {id: this.id}, + params: {...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public async open( + { + body = null, + ...otherArgs + }: OpenArgs + ): Promise { + const response = await Order.request({ + http_method: "post", + operation: "open", + session: this.session, + urlIds: {id: this.id}, + params: {...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public async cancel( + { + amount = null, + currency = null, + restock = null, + reason = null, + email = null, + refund = null, + body = null, + ...otherArgs + }: CancelArgs + ): Promise { + const response = await Order.request({ + http_method: "post", + operation: "cancel", + session: this.session, + urlIds: {id: this.id}, + params: {amount: amount, currency: currency, restock: restock, reason: reason, email: email, refund: refund, ...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public line_items: {[key: string]: unknown}[] | null; + public app_id: number | null; + public billing_address: {[key: string]: unknown} | null; + public browser_ip: string | null; + public buyer_accepts_marketing: boolean | null; + public cancel_reason: string | null; + public cancelled_at: string | null; + public cart_token: string | null; + public checkout_token: string | null; + public client_details: {[key: string]: unknown} | null; + public closed_at: string | null; + public created_at: string | null; + public currency: string | null; + public current_subtotal_price: string | null; + public current_subtotal_price_set: {[key: string]: unknown} | null; + public current_total_discounts: string | null; + public current_total_discounts_set: {[key: string]: unknown} | null; + public current_total_duties_set: {[key: string]: unknown} | null; + public current_total_price: string | null; + public current_total_price_set: {[key: string]: unknown} | null; + public current_total_tax: string | null; + public current_total_tax_set: {[key: string]: unknown} | null; + public customer: Customer | null | {[key: string]: any}; + public customer_locale: string | null; + public discount_applications: {[key: string]: unknown}[] | null; + public discount_codes: DiscountCode[] | null | {[key: string]: any}; + public email: string | null; + public estimated_taxes: boolean | null; + public financial_status: string | null; + public fulfillment_status: string | null; + public fulfillments: Fulfillment[] | null | {[key: string]: any}; + public gateway: string | null; + public id: number | null; + public landing_site: string | null; + public location_id: number | null; + public name: string | null; + public note: string | null; + public note_attributes: {[key: string]: unknown}[] | null; + public number: number | null; + public order_number: number | null; + public order_status_url: string | null; + public original_total_duties_set: {[key: string]: unknown} | null; + public payment_details: {[key: string]: unknown} | null; + public payment_gateway_names: string[] | null; + public payment_terms: {[key: string]: unknown} | null; + public phone: string | null; + public presentment_currency: string | null; + public processed_at: string | null; + public processing_method: string | null; + public referring_site: string | null; + public refunds: Refund[] | null | {[key: string]: any}; + public shipping_address: {[key: string]: unknown} | null; + public shipping_lines: {[key: string]: unknown}[] | null; + public source_name: string | null; + public subtotal_price: number | null; + public subtotal_price_set: {[key: string]: unknown} | null; + public tags: string | null; + public tax_lines: {[key: string]: unknown}[] | null; + public taxes_included: boolean | null; + public test: boolean | null; + public token: string | null; + public total_discounts: string | null; + public total_discounts_set: {[key: string]: unknown} | null; + public total_line_items_price: string | null; + public total_line_items_price_set: {[key: string]: unknown} | null; + public total_outstanding: string | null; + public total_price: string | null; + public total_price_set: {[key: string]: unknown} | null; + public total_shipping_price_set: {[key: string]: unknown} | null; + public total_tax: string | number | null; + public total_tax_set: {[key: string]: unknown} | null; + public total_tip_received: string | null; + public total_weight: number | null; + public updated_at: string | null; + public user_id: number | null; +} diff --git a/src/rest-resources/2021-10/order_risk.ts b/src/rest-resources/2021-10/order_risk.ts new file mode 100644 index 000000000..0a681e267 --- /dev/null +++ b/src/rest-resources/2021-10/order_risk.ts @@ -0,0 +1,100 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + order_id?: number | string | null; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; + order_id?: number | string | null; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + order_id?: number | string | null; +} + +export class OrderRisk extends Base { + public static API_VERSION = ApiVersion.October21; + + protected static NAME = 'order_risk'; + protected static PLURAL_NAME = 'order_risks'; + 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: ["order_id"], path: "orders//risks.json"}, + {http_method: "get", operation: "get", ids: ["order_id"], path: "orders//risks.json"}, + {http_method: "get", operation: "get", ids: ["order_id", "id"], path: "orders//risks/.json"}, + {http_method: "put", operation: "put", ids: ["order_id", "id"], path: "orders//risks/.json"}, + {http_method: "delete", operation: "delete", ids: ["order_id", "id"], path: "orders//risks/.json"} + ]; + + protected static getJsonBodyName(): string + { + return "risk"; + } + + public static async find( + { + session, + id, + order_id = null + }: FindArgs + ): Promise { + const result = await OrderRisk.baseFind({ + session: session, + urlIds: {id: id, order_id: order_id}, + params: {}, + }); + return result ? result[0] as OrderRisk : null; + } + + public static async delete( + { + session, + id, + order_id = null + }: DeleteArgs + ): Promise { + const response = await OrderRisk.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id, order_id: order_id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + order_id = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await OrderRisk.baseFind({ + session: session, + urlIds: {order_id: order_id}, + params: {...otherArgs}, + }); + + return response as OrderRisk[]; + } + + public cause_cancel: boolean | null; + public checkout_id: number | null; + public display: boolean | null; + public id: number | null; + public merchant_message: string | null; + public message: string | null; + public order_id: number | null; + public recommendation: string | null; + public score: number | null; + public source: string | null; +} diff --git a/src/rest-resources/2021-10/page.ts b/src/rest-resources/2021-10/page.ts new file mode 100644 index 000000000..6f52c41d5 --- /dev/null +++ b/src/rest-resources/2021-10/page.ts @@ -0,0 +1,161 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Metafield} from './metafield'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + limit?: unknown; + since_id?: unknown; + title?: unknown; + handle?: unknown; + created_at_min?: unknown; + created_at_max?: unknown; + updated_at_min?: unknown; + updated_at_max?: unknown; + published_at_min?: unknown; + published_at_max?: unknown; + fields?: unknown; + published_status?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; + title?: unknown; + created_at_min?: unknown; + created_at_max?: unknown; + updated_at_min?: unknown; + updated_at_max?: unknown; + published_at_min?: unknown; + published_at_max?: unknown; + published_status?: unknown; +} + +export class Page extends Base { + public static API_VERSION = ApiVersion.October21; + + protected static NAME = 'page'; + protected static PLURAL_NAME = 'pages'; + protected static HAS_ONE: {[key: string]: typeof Base} = { + metafield: Metafield + }; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "pages.json"}, + {http_method: "post", operation: "post", ids: [], path: "pages.json"}, + {http_method: "get", operation: "count", ids: [], path: "pages/count.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "pages/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "pages/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "pages/.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await Page.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as Page : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await Page.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + limit = null, + since_id = null, + title = null, + handle = 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, + fields = null, + published_status = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Page.baseFind({ + session: session, + urlIds: {}, + params: {limit: limit, since_id: since_id, title: title, handle: handle, 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, fields: fields, published_status: published_status, ...otherArgs}, + }); + + return response as Page[]; + } + + public static async count( + { + session, + title = 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 + ): Promise { + const response = await Page.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {}, + params: {title: title, 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, + }); + + return response ? response.body : null; + } + + public admin_graphql_api_id: string | null; + public author: string | null; + public body_html: string | null; + public created_at: string | null; + public handle: string | null; + public id: number | null; + public metafield: Metafield | null | {[key: string]: any}; + public published_at: string | null; + public shop_id: number | null; + public template_suffix: string | null; + public title: string | null; + public updated_at: string | null; +} diff --git a/src/rest-resources/2021-10/payment.ts b/src/rest-resources/2021-10/payment.ts new file mode 100644 index 000000000..f6d7ed423 --- /dev/null +++ b/src/rest-resources/2021-10/payment.ts @@ -0,0 +1,99 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Transaction} from './transaction'; +import {Checkout} from './checkout'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + checkout_id?: number | string | null; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + checkout_id?: number | string | null; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; + checkout_id?: number | string | null; +} + +export class Payment extends Base { + public static API_VERSION = ApiVersion.October21; + + protected static NAME = 'payment'; + protected static PLURAL_NAME = 'payments'; + protected static HAS_ONE: {[key: string]: typeof Base} = { + transaction: Transaction, + checkout: Checkout + }; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "post", operation: "post", ids: ["checkout_id"], path: "checkouts//payments.json"}, + {http_method: "get", operation: "get", ids: ["checkout_id"], path: "checkouts//payments.json"}, + {http_method: "get", operation: "get", ids: ["checkout_id", "id"], path: "checkouts//payments/.json"}, + {http_method: "get", operation: "count", ids: ["checkout_id"], path: "checkouts//payments/count.json"} + ]; + + public static async find( + { + session, + id, + checkout_id = null + }: FindArgs + ): Promise { + const result = await Payment.baseFind({ + session: session, + urlIds: {id: id, checkout_id: checkout_id}, + params: {}, + }); + return result ? result[0] as Payment : null; + } + + public static async all( + { + session, + checkout_id = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Payment.baseFind({ + session: session, + urlIds: {checkout_id: checkout_id}, + params: {...otherArgs}, + }); + + return response as Payment[]; + } + + public static async count( + { + session, + checkout_id = null, + ...otherArgs + }: CountArgs + ): Promise { + const response = await Payment.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {checkout_id: checkout_id}, + params: {...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public checkout: Checkout | null | {[key: string]: any}; + public credit_card: {[key: string]: unknown} | null; + public id: number | null; + public next_action: {[key: string]: unknown} | null; + public payment_processing_error_message: string | null; + public transaction: Transaction | null | {[key: string]: any}; + public unique_token: string | null; +} diff --git a/src/rest-resources/2021-10/payment_gateway.ts b/src/rest-resources/2021-10/payment_gateway.ts new file mode 100644 index 000000000..1f9bc205d --- /dev/null +++ b/src/rest-resources/2021-10/payment_gateway.ts @@ -0,0 +1,96 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; +} + +export class PaymentGateway extends Base { + public static API_VERSION = ApiVersion.October21; + + protected static NAME = 'payment_gateway'; + protected static PLURAL_NAME = 'payment_gateways'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "payment_gateways.json"}, + {http_method: "post", operation: "post", ids: [], path: "payment_gateways.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "payment_gateways/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "payment_gateways/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "payment_gateways/.json"} + ]; + + public static async find( + { + session, + id + }: FindArgs + ): Promise { + const result = await PaymentGateway.baseFind({ + session: session, + urlIds: {id: id}, + params: {}, + }); + return result ? result[0] as PaymentGateway : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await PaymentGateway.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + ...otherArgs + }: AllArgs + ): Promise { + const response = await PaymentGateway.baseFind({ + session: session, + urlIds: {}, + params: {...otherArgs}, + }); + + return response as PaymentGateway[]; + } + + public attachment: string | null; + public created_at: string | null; + public credential1: string | null; + public credential2: string | null; + public credential3: string | null; + public credential4: string | null; + public disabled: boolean | null; + public enabled_card_brands: string[] | null; + public id: number | null; + public name: string | null; + public processing_method: string | null; + public provider_id: number | null; + public sandbox: boolean | null; + public service_name: string | null; + public supports_network_tokenization: boolean | null; + public type: string | null; + public updated_at: string | null; +} diff --git a/src/rest-resources/2021-10/payment_transaction.ts b/src/rest-resources/2021-10/payment_transaction.ts new file mode 100644 index 000000000..76e5506f9 --- /dev/null +++ b/src/rest-resources/2021-10/payment_transaction.ts @@ -0,0 +1,68 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Currency} from './currency'; + +interface TransactionsArgs { + [key: string]: unknown; + session: SessionInterface; + since_id?: unknown; + last_id?: unknown; + test?: unknown; + payout_id?: unknown; + payout_status?: unknown; +} + +export class PaymentTransaction extends Base { + public static API_VERSION = ApiVersion.October21; + + protected static NAME = 'payment_transaction'; + protected static PLURAL_NAME = 'payment_transactions'; + protected static HAS_ONE: {[key: string]: typeof Base} = { + currency: Currency + }; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "transactions", ids: [], path: "shopify_payments/balance/transactions.json"} + ]; + + public static async transactions( + { + session, + since_id = null, + last_id = null, + test = null, + payout_id = null, + payout_status = null, + ...otherArgs + }: TransactionsArgs + ): Promise { + const response = await PaymentTransaction.request({ + http_method: "get", + operation: "transactions", + session: session, + urlIds: {}, + params: {since_id: since_id, last_id: last_id, test: test, payout_id: payout_id, payout_status: payout_status, ...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public amount: string | null; + public currency: Currency | null | {[key: string]: any}; + public fee: string | null; + public id: number | null; + public net: string | null; + public payout_id: number | null; + public payout_status: string | null; + public processed_at: string | null; + public source_id: number | null; + public source_order_id: number | null; + public source_order_transaction_id: number | null; + public source_type: string | null; + public test: boolean | null; + public type: string | null; +} diff --git a/src/rest-resources/2021-10/payout.ts b/src/rest-resources/2021-10/payout.ts new file mode 100644 index 000000000..7b3eac3b7 --- /dev/null +++ b/src/rest-resources/2021-10/payout.ts @@ -0,0 +1,76 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Currency} from './currency'; + +interface FindArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + since_id?: unknown; + last_id?: unknown; + date_min?: unknown; + date_max?: unknown; + date?: unknown; + status?: unknown; +} + +export class Payout extends Base { + public static API_VERSION = ApiVersion.October21; + + protected static NAME = 'payout'; + protected static PLURAL_NAME = 'payouts'; + protected static HAS_ONE: {[key: string]: typeof Base} = { + currency: Currency + }; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "shopify_payments/payouts.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "shopify_payments/payouts/.json"} + ]; + + public static async find( + { + session, + id + }: FindArgs + ): Promise { + const result = await Payout.baseFind({ + session: session, + urlIds: {id: id}, + params: {}, + }); + return result ? result[0] as Payout : null; + } + + public static async all( + { + session, + since_id = null, + last_id = null, + date_min = null, + date_max = null, + date = null, + status = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Payout.baseFind({ + session: session, + urlIds: {}, + params: {since_id: since_id, last_id: last_id, date_min: date_min, date_max: date_max, date: date, status: status, ...otherArgs}, + }); + + return response as Payout[]; + } + + public amount: string | null; + public currency: Currency | null | {[key: string]: any}; + public date: string | null; + public id: number | null; + public status: string | null; +} diff --git a/src/rest-resources/2021-10/policy.ts b/src/rest-resources/2021-10/policy.ts new file mode 100644 index 000000000..a31341176 --- /dev/null +++ b/src/rest-resources/2021-10/policy.ts @@ -0,0 +1,42 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; +} + +export class Policy extends Base { + public static API_VERSION = ApiVersion.October21; + + protected static NAME = 'policy'; + protected static PLURAL_NAME = 'policies'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "policies.json"} + ]; + + public static async all( + { + session, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Policy.baseFind({ + session: session, + urlIds: {}, + params: {...otherArgs}, + }); + + return response as Policy[]; + } + + public body: string | null; + public created_at: string | null; + public handle: string | null; + public title: string | null; + public updated_at: string | null; + public url: string | null; +} diff --git a/src/rest-resources/2021-10/price_rule.ts b/src/rest-resources/2021-10/price_rule.ts new file mode 100644 index 000000000..a245f39af --- /dev/null +++ b/src/rest-resources/2021-10/price_rule.ts @@ -0,0 +1,154 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + limit?: unknown; + since_id?: unknown; + created_at_min?: unknown; + created_at_max?: unknown; + updated_at_min?: unknown; + updated_at_max?: unknown; + starts_at_min?: unknown; + starts_at_max?: unknown; + ends_at_min?: unknown; + ends_at_max?: unknown; + times_used?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; +} + +export class PriceRule extends Base { + public static API_VERSION = ApiVersion.October21; + + protected static NAME = 'price_rule'; + protected static PLURAL_NAME = 'price_rules'; + 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: "price_rules.json"}, + {http_method: "get", operation: "get", ids: [], path: "price_rules.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "price_rules/.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "price_rules/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "price_rules/.json"}, + {http_method: "get", operation: "count", ids: [], path: "price_rules/count.json"} + ]; + + public static async find( + { + session, + id + }: FindArgs + ): Promise { + const result = await PriceRule.baseFind({ + session: session, + urlIds: {id: id}, + params: {}, + }); + return result ? result[0] as PriceRule : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await PriceRule.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + limit = null, + since_id = null, + created_at_min = null, + created_at_max = null, + updated_at_min = null, + updated_at_max = null, + starts_at_min = null, + starts_at_max = null, + ends_at_min = null, + ends_at_max = null, + times_used = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await PriceRule.baseFind({ + session: session, + urlIds: {}, + params: {limit: limit, since_id: since_id, created_at_min: created_at_min, created_at_max: created_at_max, updated_at_min: updated_at_min, updated_at_max: updated_at_max, starts_at_min: starts_at_min, starts_at_max: starts_at_max, ends_at_min: ends_at_min, ends_at_max: ends_at_max, times_used: times_used, ...otherArgs}, + }); + + return response as PriceRule[]; + } + + public static async count( + { + session, + ...otherArgs + }: CountArgs + ): Promise { + const response = await PriceRule.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {}, + params: {...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public allocation_limit: number | null; + public allocation_method: string | null; + public created_at: string | null; + public customer_selection: string | null; + public ends_at: string | null; + public entitled_collection_ids: number[] | null; + public entitled_country_ids: number[] | null; + public entitled_product_ids: number[] | null; + public entitled_variant_ids: number[] | null; + public id: number | null; + public once_per_customer: boolean | null; + public prerequisite_collection_ids: number[] | null; + public prerequisite_customer_ids: number[] | null; + public prerequisite_product_ids: number[] | null; + public prerequisite_quantity_range: {[key: string]: unknown} | null; + public prerequisite_saved_search_ids: number[] | null; + public prerequisite_shipping_price_range: {[key: string]: unknown} | null; + public prerequisite_subtotal_range: {[key: string]: unknown} | null; + public prerequisite_to_entitlement_purchase: {[key: string]: unknown} | null; + public prerequisite_to_entitlement_quantity_ratio: {[key: string]: unknown} | null; + public prerequisite_variant_ids: number[] | null; + public starts_at: string | null; + public target_selection: string | null; + public target_type: string | null; + public title: string | null; + public updated_at: string | null; + public usage_limit: number | null; + public value: string | null; + public value_type: string | null; +} diff --git a/src/rest-resources/2021-10/product.ts b/src/rest-resources/2021-10/product.ts new file mode 100644 index 000000000..5d646b5d2 --- /dev/null +++ b/src/rest-resources/2021-10/product.ts @@ -0,0 +1,183 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Image} from './image'; +import {Variant} from './variant'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + ids?: unknown; + limit?: unknown; + since_id?: unknown; + title?: unknown; + vendor?: unknown; + handle?: unknown; + product_type?: unknown; + status?: unknown; + collection_id?: unknown; + created_at_min?: unknown; + created_at_max?: unknown; + updated_at_min?: unknown; + updated_at_max?: unknown; + published_at_min?: unknown; + published_at_max?: unknown; + published_status?: unknown; + fields?: unknown; + presentment_currencies?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; + vendor?: unknown; + product_type?: unknown; + collection_id?: unknown; + created_at_min?: unknown; + created_at_max?: unknown; + updated_at_min?: unknown; + updated_at_max?: unknown; + published_at_min?: unknown; + published_at_max?: unknown; + published_status?: unknown; +} + +export class Product extends Base { + public static API_VERSION = ApiVersion.October21; + + protected static NAME = 'product'; + protected static PLURAL_NAME = 'products'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = { + images: Image, + variants: Variant + }; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "products.json"}, + {http_method: "post", operation: "post", ids: [], path: "products.json"}, + {http_method: "get", operation: "count", ids: [], path: "products/count.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "products/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "products/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "products/.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await Product.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as Product : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await Product.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + ids = null, + limit = null, + since_id = null, + title = null, + vendor = null, + handle = null, + product_type = null, + status = null, + collection_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, + fields = null, + presentment_currencies = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Product.baseFind({ + session: session, + urlIds: {}, + params: {ids: ids, limit: limit, since_id: since_id, title: title, vendor: vendor, handle: handle, product_type: product_type, status: status, collection_id: collection_id, 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, fields: fields, presentment_currencies: presentment_currencies, ...otherArgs}, + }); + + return response as Product[]; + } + + public static async count( + { + session, + vendor = null, + product_type = null, + collection_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 + ): Promise { + const response = await Product.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {}, + params: {vendor: vendor, product_type: product_type, collection_id: collection_id, 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, + }); + + return response ? response.body : null; + } + + public title: string | null; + public body_html: string | null; + public created_at: string | null; + public handle: string | null; + public id: number | null; + public images: Image[] | null | {[key: string]: any}; + public options: {[key: string]: unknown} | {[key: string]: unknown}[] | null; + public product_type: string | null; + public published_at: string | null; + public published_scope: string | null; + public status: string | null; + public tags: string | string[] | null; + public template_suffix: string | null; + public updated_at: string | null; + public variants: Variant[] | null | {[key: string]: any}; + public vendor: string | null; +} diff --git a/src/rest-resources/2021-10/product_listing.ts b/src/rest-resources/2021-10/product_listing.ts new file mode 100644 index 000000000..f5a05ca86 --- /dev/null +++ b/src/rest-resources/2021-10/product_listing.ts @@ -0,0 +1,158 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Image} from './image'; +import {Variant} from './variant'; + +interface FindArgs { + session: SessionInterface; + product_id: number | string; +} +interface DeleteArgs { + session: SessionInterface; + product_id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + product_ids?: unknown; + limit?: unknown; + collection_id?: unknown; + updated_at_min?: unknown; + handle?: unknown; +} +interface ProductIdsArgs { + [key: string]: unknown; + session: SessionInterface; + limit?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; +} + +export class ProductListing extends Base { + public static API_VERSION = ApiVersion.October21; + + protected static NAME = 'product_listing'; + protected static PLURAL_NAME = 'product_listings'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = { + images: Image, + variants: Variant + }; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "product_listings.json"}, + {http_method: "get", operation: "product_ids", ids: [], path: "product_listings/product_ids.json"}, + {http_method: "get", operation: "count", ids: [], path: "product_listings/count.json"}, + {http_method: "get", operation: "get", ids: ["product_id"], path: "product_listings/.json"}, + {http_method: "put", operation: "put", ids: ["product_id"], path: "product_listings/.json"}, + {http_method: "delete", operation: "delete", ids: ["product_id"], path: "product_listings/.json"} + ]; + protected static PRIMARY_KEY: string = "product_id"; + + public static async find( + { + session, + product_id + }: FindArgs + ): Promise { + const result = await ProductListing.baseFind({ + session: session, + urlIds: {product_id: product_id}, + params: {}, + }); + return result ? result[0] as ProductListing : null; + } + + public static async delete( + { + session, + product_id + }: DeleteArgs + ): Promise { + const response = await ProductListing.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {product_id: product_id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + product_ids = null, + limit = null, + collection_id = null, + updated_at_min = null, + handle = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await ProductListing.baseFind({ + session: session, + urlIds: {}, + params: {product_ids: product_ids, limit: limit, collection_id: collection_id, updated_at_min: updated_at_min, handle: handle, ...otherArgs}, + }); + + return response as ProductListing[]; + } + + public static async product_ids( + { + session, + limit = null, + ...otherArgs + }: ProductIdsArgs + ): Promise { + const response = await ProductListing.request({ + http_method: "get", + operation: "product_ids", + session: session, + urlIds: {}, + params: {limit: limit, ...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public static async count( + { + session, + ...otherArgs + }: CountArgs + ): Promise { + const response = await ProductListing.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {}, + params: {...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public body_html: string | null; + public created_at: string | null; + public handle: string | null; + public images: Image[] | null | {[key: string]: any}; + public options: {[key: string]: unknown}[] | null; + public product_id: number | null; + public product_type: string | null; + public published_at: string | null; + public tags: string | null; + public title: string | null; + public updated_at: string | null; + public variants: Variant[] | null | {[key: string]: any}; + public vendor: string | null; +} diff --git a/src/rest-resources/2021-10/product_resource_feedback.ts b/src/rest-resources/2021-10/product_resource_feedback.ts new file mode 100644 index 000000000..238d32d83 --- /dev/null +++ b/src/rest-resources/2021-10/product_resource_feedback.ts @@ -0,0 +1,53 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + product_id?: number | string | null; +} + +export class ProductResourceFeedback extends Base { + public static API_VERSION = ApiVersion.October21; + + protected static NAME = 'product_resource_feedback'; + protected static PLURAL_NAME = 'product_resource_feedbacks'; + 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: ["product_id"], path: "products//resource_feedback.json"}, + {http_method: "get", operation: "get", ids: ["product_id"], path: "products//resource_feedback.json"} + ]; + + protected static getJsonBodyName(): string + { + return "resource_feedback"; + } + + public static async all( + { + session, + product_id = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await ProductResourceFeedback.baseFind({ + session: session, + urlIds: {product_id: product_id}, + params: {...otherArgs}, + }); + + return response as ProductResourceFeedback[]; + } + + public created_at: string | null; + public feedback_generated_at: string | null; + public messages: string[] | null; + public product_id: number | null; + public resource_id: number | null; + public resource_type: string | null; + public resource_updated_at: string | null; + public state: string | null; + public updated_at: string | null; +} diff --git a/src/rest-resources/2021-10/province.ts b/src/rest-resources/2021-10/province.ts new file mode 100644 index 000000000..4c8a7d9c9 --- /dev/null +++ b/src/rest-resources/2021-10/province.ts @@ -0,0 +1,101 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + country_id?: number | string | null; + fields?: unknown; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + country_id?: number | string | null; + since_id?: unknown; + fields?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; + country_id?: number | string | null; +} + +export class Province extends Base { + public static API_VERSION = ApiVersion.October21; + + protected static NAME = 'province'; + protected static PLURAL_NAME = 'provinces'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: ["country_id"], path: "countries//provinces.json"}, + {http_method: "get", operation: "count", ids: ["country_id"], path: "countries//provinces/count.json"}, + {http_method: "get", operation: "get", ids: ["country_id", "id"], path: "countries//provinces/.json"}, + {http_method: "put", operation: "put", ids: ["country_id", "id"], path: "countries//provinces/.json"} + ]; + + public static async find( + { + session, + id, + country_id = null, + fields = null + }: FindArgs + ): Promise { + const result = await Province.baseFind({ + session: session, + urlIds: {id: id, country_id: country_id}, + params: {fields: fields}, + }); + return result ? result[0] as Province : null; + } + + public static async all( + { + session, + country_id = null, + since_id = null, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Province.baseFind({ + session: session, + urlIds: {country_id: country_id}, + params: {since_id: since_id, fields: fields, ...otherArgs}, + }); + + return response as Province[]; + } + + public static async count( + { + session, + country_id = null, + ...otherArgs + }: CountArgs + ): Promise { + const response = await Province.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {country_id: country_id}, + params: {...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public code: string | null; + public country_id: number | null; + public id: number | null; + public name: string | null; + public shipping_zone_id: number | null; + public tax: number | null; + public tax_name: string | null; + public tax_percentage: number | null; + public tax_type: string | null; +} diff --git a/src/rest-resources/2021-10/recurring_application_charge.ts b/src/rest-resources/2021-10/recurring_application_charge.ts new file mode 100644 index 000000000..00db4d75a --- /dev/null +++ b/src/rest-resources/2021-10/recurring_application_charge.ts @@ -0,0 +1,124 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + since_id?: unknown; + fields?: unknown; +} +interface CustomizeArgs { + [key: string]: unknown; + body?: {[key: string]: unknown} | null; +} + +export class RecurringApplicationCharge extends Base { + public static API_VERSION = ApiVersion.October21; + + protected static NAME = 'recurring_application_charge'; + protected static PLURAL_NAME = 'recurring_application_charges'; + 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: "recurring_application_charges.json"}, + {http_method: "get", operation: "get", ids: [], path: "recurring_application_charges.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "recurring_application_charges/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "recurring_application_charges/.json"}, + {http_method: "put", operation: "customize", ids: ["id"], path: "recurring_application_charges//customize.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await RecurringApplicationCharge.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as RecurringApplicationCharge : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await RecurringApplicationCharge.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + since_id = null, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await RecurringApplicationCharge.baseFind({ + session: session, + urlIds: {}, + params: {since_id: since_id, fields: fields, ...otherArgs}, + }); + + return response as RecurringApplicationCharge[]; + } + + public async customize( + { + body = null, + ...otherArgs + }: CustomizeArgs + ): Promise { + const response = await RecurringApplicationCharge.request({ + http_method: "put", + operation: "customize", + session: this.session, + urlIds: {id: this.id}, + params: {...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public activated_on: string | null; + public billing_on: string | null; + public cancelled_on: string | null; + public capped_amount: string | number | null; + public confirmation_url: string | null; + public created_at: string | null; + public id: number | null; + public name: string | null; + public price: string | number | null; + public return_url: string | null; + public status: string | null; + public terms: string | null; + public test: boolean | null; + public trial_days: number | null; + public trial_ends_on: string | null; + public updated_at: string | null; +} diff --git a/src/rest-resources/2021-10/redirect.ts b/src/rest-resources/2021-10/redirect.ts new file mode 100644 index 000000000..39aeebae0 --- /dev/null +++ b/src/rest-resources/2021-10/redirect.ts @@ -0,0 +1,122 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + limit?: unknown; + since_id?: unknown; + path?: unknown; + target?: unknown; + fields?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; + path?: unknown; + target?: unknown; +} + +export class Redirect extends Base { + public static API_VERSION = ApiVersion.October21; + + protected static NAME = 'redirect'; + protected static PLURAL_NAME = 'redirects'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "redirects.json"}, + {http_method: "post", operation: "post", ids: [], path: "redirects.json"}, + {http_method: "get", operation: "count", ids: [], path: "redirects/count.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "redirects/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "redirects/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "redirects/.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await Redirect.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as Redirect : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await Redirect.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + limit = null, + since_id = null, + path = null, + target = null, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Redirect.baseFind({ + session: session, + urlIds: {}, + params: {limit: limit, since_id: since_id, path: path, target: target, fields: fields, ...otherArgs}, + }); + + return response as Redirect[]; + } + + public static async count( + { + session, + path = null, + target = null, + ...otherArgs + }: CountArgs + ): Promise { + const response = await Redirect.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {}, + params: {path: path, target: target, ...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public id: number | null; + public path: string | null; + public target: string | null; +} diff --git a/src/rest-resources/2021-10/refund.ts b/src/rest-resources/2021-10/refund.ts new file mode 100644 index 000000000..764658020 --- /dev/null +++ b/src/rest-resources/2021-10/refund.ts @@ -0,0 +1,116 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Transaction} from './transaction'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + order_id?: number | string | null; + fields?: unknown; + in_shop_currency?: unknown; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + order_id?: number | string | null; + limit?: unknown; + fields?: unknown; + in_shop_currency?: unknown; +} +interface CalculateArgs { + [key: string]: unknown; + shipping?: unknown; + refund_line_items?: unknown; + currency?: unknown; + body?: {[key: string]: unknown} | null; +} + +export class Refund extends Base { + public static API_VERSION = ApiVersion.October21; + + protected static NAME = 'refund'; + protected static PLURAL_NAME = 'refunds'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = { + transactions: Transaction + }; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: ["order_id"], path: "orders//refunds.json"}, + {http_method: "post", operation: "post", ids: ["order_id"], path: "orders//refunds.json"}, + {http_method: "get", operation: "get", ids: ["order_id", "id"], path: "orders//refunds/.json"}, + {http_method: "post", operation: "calculate", ids: ["order_id"], path: "orders//refunds/calculate.json"} + ]; + + public static async find( + { + session, + id, + order_id = null, + fields = null, + in_shop_currency = null + }: FindArgs + ): Promise { + const result = await Refund.baseFind({ + session: session, + urlIds: {id: id, order_id: order_id}, + params: {fields: fields, in_shop_currency: in_shop_currency}, + }); + return result ? result[0] as Refund : null; + } + + public static async all( + { + session, + order_id = null, + limit = null, + fields = null, + in_shop_currency = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Refund.baseFind({ + session: session, + urlIds: {order_id: order_id}, + params: {limit: limit, fields: fields, in_shop_currency: in_shop_currency, ...otherArgs}, + }); + + return response as Refund[]; + } + + public async calculate( + { + shipping = null, + refund_line_items = null, + currency = null, + body = null, + ...otherArgs + }: CalculateArgs + ): Promise { + const response = await Refund.request({ + http_method: "post", + operation: "calculate", + session: this.session, + urlIds: {order_id: this.order_id}, + params: {shipping: shipping, refund_line_items: refund_line_items, currency: currency, ...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public created_at: string | null; + public duties: {[key: string]: unknown}[] | null; + public id: number | null; + public note: string | null; + public order_adjustments: {[key: string]: unknown}[] | null; + public order_id: number | null; + public processed_at: string | null; + public refund_duties: {[key: string]: unknown}[] | null; + public refund_line_items: {[key: string]: unknown}[] | null; + public restock: boolean | null; + public transactions: Transaction[] | null | {[key: string]: any}; + public user_id: number | null; +} diff --git a/src/rest-resources/2021-10/report.ts b/src/rest-resources/2021-10/report.ts new file mode 100644 index 000000000..c4f3c53f7 --- /dev/null +++ b/src/rest-resources/2021-10/report.ts @@ -0,0 +1,98 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + ids?: unknown; + limit?: unknown; + since_id?: unknown; + updated_at_min?: unknown; + updated_at_max?: unknown; + fields?: unknown; +} + +export class Report extends Base { + public static API_VERSION = ApiVersion.October21; + + protected static NAME = 'report'; + protected static PLURAL_NAME = 'reports'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "reports.json"}, + {http_method: "post", operation: "post", ids: [], path: "reports.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "reports/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "reports/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "reports/.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await Report.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as Report : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await Report.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + ids = null, + limit = null, + since_id = null, + updated_at_min = null, + updated_at_max = null, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Report.baseFind({ + session: session, + urlIds: {}, + params: {ids: ids, limit: limit, since_id: since_id, updated_at_min: updated_at_min, updated_at_max: updated_at_max, fields: fields, ...otherArgs}, + }); + + return response as Report[]; + } + + public category: string | null; + public id: number | null; + public name: string | null; + public shopify_ql: string | null; + public updated_at: string | null; +} diff --git a/src/rest-resources/2021-10/resource_feedback.ts b/src/rest-resources/2021-10/resource_feedback.ts new file mode 100644 index 000000000..d42b9aee2 --- /dev/null +++ b/src/rest-resources/2021-10/resource_feedback.ts @@ -0,0 +1,44 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; +} + +export class ResourceFeedback extends Base { + public static API_VERSION = ApiVersion.October21; + + protected static NAME = 'resource_feedback'; + protected static PLURAL_NAME = 'resource_feedbacks'; + 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: "resource_feedback.json"}, + {http_method: "get", operation: "get", ids: [], path: "resource_feedback.json"} + ]; + + public static async all( + { + session, + ...otherArgs + }: AllArgs + ): Promise { + const response = await ResourceFeedback.baseFind({ + session: session, + urlIds: {}, + params: {...otherArgs}, + }); + + return response as ResourceFeedback[]; + } + + public created_at: string | null; + public feedback_generated_at: string | null; + public messages: string[] | null; + public resource_id: number | null; + public resource_type: string | null; + public state: string | null; + public updated_at: string | null; +} diff --git a/src/rest-resources/2021-10/script_tag.ts b/src/rest-resources/2021-10/script_tag.ts new file mode 100644 index 000000000..d6bea4495 --- /dev/null +++ b/src/rest-resources/2021-10/script_tag.ts @@ -0,0 +1,130 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + limit?: unknown; + since_id?: unknown; + created_at_min?: unknown; + created_at_max?: unknown; + updated_at_min?: unknown; + updated_at_max?: unknown; + src?: unknown; + fields?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; + src?: unknown; +} + +export class ScriptTag extends Base { + public static API_VERSION = ApiVersion.October21; + + protected static NAME = 'script_tag'; + protected static PLURAL_NAME = 'script_tags'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "script_tags.json"}, + {http_method: "post", operation: "post", ids: [], path: "script_tags.json"}, + {http_method: "get", operation: "count", ids: [], path: "script_tags/count.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "script_tags/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "script_tags/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "script_tags/.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await ScriptTag.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as ScriptTag : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await ScriptTag.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + limit = null, + since_id = null, + created_at_min = null, + created_at_max = null, + updated_at_min = null, + updated_at_max = null, + src = null, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await ScriptTag.baseFind({ + session: session, + urlIds: {}, + params: {limit: limit, since_id: since_id, created_at_min: created_at_min, created_at_max: created_at_max, updated_at_min: updated_at_min, updated_at_max: updated_at_max, src: src, fields: fields, ...otherArgs}, + }); + + return response as ScriptTag[]; + } + + public static async count( + { + session, + src = null, + ...otherArgs + }: CountArgs + ): Promise { + const response = await ScriptTag.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {}, + params: {src: src, ...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public event: string | null; + public src: string | null; + public cache: boolean | null; + public created_at: string | null; + public display_scope: string | null; + public id: number | null; + public updated_at: string | null; +} diff --git a/src/rest-resources/2021-10/shipping_zone.ts b/src/rest-resources/2021-10/shipping_zone.ts new file mode 100644 index 000000000..2b82dc50c --- /dev/null +++ b/src/rest-resources/2021-10/shipping_zone.ts @@ -0,0 +1,53 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Country} from './country'; +import {Province} from './province'; + +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + fields?: unknown; +} + +export class ShippingZone extends Base { + public static API_VERSION = ApiVersion.October21; + + protected static NAME = 'shipping_zone'; + protected static PLURAL_NAME = 'shipping_zones'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = { + countries: Country, + provinces: Province + }; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "shipping_zones.json"} + ]; + + public static async all( + { + session, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await ShippingZone.baseFind({ + session: session, + urlIds: {}, + params: {fields: fields, ...otherArgs}, + }); + + return response as ShippingZone[]; + } + + public carrier_shipping_rate_providers: unknown | null; + public countries: Country[] | null | {[key: string]: any}; + public id: number | null; + public location_group_id: number | null; + public name: string | null; + public price_based_shipping_rates: {[key: string]: unknown} | null; + public profile_id: number | null; + public provinces: Province[] | null | {[key: string]: any}; + public weight_based_shipping_rates: {[key: string]: unknown} | null; +} diff --git a/src/rest-resources/2021-10/shop.ts b/src/rest-resources/2021-10/shop.ts new file mode 100644 index 000000000..d0956e433 --- /dev/null +++ b/src/rest-resources/2021-10/shop.ts @@ -0,0 +1,100 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Country} from './country'; +import {Currency} from './currency'; +import {Province} from './province'; + +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + fields?: unknown; +} + +export class Shop extends Base { + public static API_VERSION = ApiVersion.October21; + + protected static NAME = 'shop'; + protected static PLURAL_NAME = 'shops'; + protected static HAS_ONE: {[key: string]: typeof Base} = { + country: Country, + currency: Currency, + province: Province + }; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "shop.json"} + ]; + + public static async all( + { + session, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Shop.baseFind({ + session: session, + urlIds: {}, + params: {fields: fields, ...otherArgs}, + }); + + return response as Shop[]; + } + + public address1: string | null; + public address2: string | null; + public checkout_api_supported: boolean | null; + public city: string | null; + public cookie_consent_level: string | null; + public country: Country | null | {[key: string]: any}; + public country_code: string | null; + public country_name: string | null; + public county_taxes: string | null; + public created_at: string | null; + public currency: Currency | null | {[key: string]: any}; + public customer_email: string | null; + public domain: string | null; + public eligible_for_card_reader_giveaway: boolean | null; + public eligible_for_payments: boolean | null; + public email: string | null; + public enabled_presentment_currencies: string[] | null; + public finances: boolean | null; + public force_ssl: boolean | null; + public google_apps_domain: string | null; + public google_apps_login_enabled: string | null; + public has_discounts: boolean | null; + public has_gift_cards: boolean | null; + public has_storefront: boolean | null; + public iana_timezone: string | null; + public id: number | null; + public latitude: number | null; + public longitude: number | null; + public money_format: string | null; + public money_in_emails_format: string | null; + public money_with_currency_format: string | null; + public money_with_currency_in_emails_format: string | null; + public multi_location_enabled: boolean | null; + public myshopify_domain: string | null; + public name: string | null; + public password_enabled: boolean | null; + public phone: string | null; + public plan_display_name: string | null; + public plan_name: string | null; + public pre_launch_enabled: boolean | null; + public primary_locale: string | null; + public primary_location_id: number | null; + public province: Province | null | {[key: string]: any}; + public province_code: string | null; + public requires_extra_payments_agreement: boolean | null; + public setup_required: boolean | null; + public shop_owner: string | null; + public source: string | null; + public tax_shipping: string | null; + public taxes_included: string | null; + public timezone: string | null; + public updated_at: string | null; + public weight_unit: string | null; + public zip: string | null; +} diff --git a/src/rest-resources/2021-10/smart_collection.ts b/src/rest-resources/2021-10/smart_collection.ts new file mode 100644 index 000000000..81c137010 --- /dev/null +++ b/src/rest-resources/2021-10/smart_collection.ts @@ -0,0 +1,183 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + limit?: unknown; + ids?: unknown; + since_id?: unknown; + title?: unknown; + product_id?: unknown; + handle?: unknown; + updated_at_min?: unknown; + updated_at_max?: unknown; + published_at_min?: unknown; + published_at_max?: unknown; + published_status?: unknown; + fields?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; + title?: unknown; + product_id?: unknown; + updated_at_min?: unknown; + updated_at_max?: unknown; + published_at_min?: unknown; + published_at_max?: unknown; + published_status?: unknown; +} +interface OrderArgs { + [key: string]: unknown; + products?: unknown; + sort_order?: unknown; + body?: {[key: string]: unknown} | null; +} + +export class SmartCollection extends Base { + public static API_VERSION = ApiVersion.October21; + + protected static NAME = 'smart_collection'; + protected static PLURAL_NAME = 'smart_collections'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "smart_collections.json"}, + {http_method: "post", operation: "post", ids: [], path: "smart_collections.json"}, + {http_method: "get", operation: "count", ids: [], path: "smart_collections/count.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "smart_collections/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "smart_collections/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "smart_collections/.json"}, + {http_method: "put", operation: "order", ids: ["id"], path: "smart_collections//order.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await SmartCollection.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as SmartCollection : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await SmartCollection.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + limit = null, + ids = null, + since_id = null, + title = null, + product_id = null, + handle = null, + updated_at_min = null, + updated_at_max = null, + published_at_min = null, + published_at_max = null, + published_status = null, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await SmartCollection.baseFind({ + session: session, + urlIds: {}, + params: {limit: limit, ids: ids, since_id: since_id, title: title, product_id: product_id, handle: handle, 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, fields: fields, ...otherArgs}, + }); + + return response as SmartCollection[]; + } + + public static async count( + { + session, + title = null, + product_id = null, + updated_at_min = null, + updated_at_max = null, + published_at_min = null, + published_at_max = null, + published_status = null, + ...otherArgs + }: CountArgs + ): Promise { + const response = await SmartCollection.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {}, + params: {title: title, product_id: product_id, 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, + }); + + return response ? response.body : null; + } + + public async order( + { + products = null, + sort_order = null, + body = null, + ...otherArgs + }: OrderArgs + ): Promise { + const response = await SmartCollection.request({ + http_method: "put", + operation: "order", + session: this.session, + urlIds: {id: this.id}, + params: {products: products, sort_order: sort_order, ...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public rules: {[key: string]: unknown} | {[key: string]: unknown}[] | null; + public title: string | null; + public body_html: string | null; + public disjunctive: boolean | null; + public handle: string | null; + public id: number | null; + public image: string | {[key: string]: unknown} | null; + public published_at: string | null; + public published_scope: string | null; + public sort_order: string | null; + public template_suffix: string | null; + public updated_at: string | null; +} diff --git a/src/rest-resources/2021-10/storefront_access_token.ts b/src/rest-resources/2021-10/storefront_access_token.ts new file mode 100644 index 000000000..9af1aaddb --- /dev/null +++ b/src/rest-resources/2021-10/storefront_access_token.ts @@ -0,0 +1,68 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {AccessScope} from './access_scope'; + +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; +} + +export class StorefrontAccessToken extends Base { + public static API_VERSION = ApiVersion.October21; + + protected static NAME = 'storefront_access_token'; + protected static PLURAL_NAME = 'storefront_access_tokens'; + protected static HAS_ONE: {[key: string]: typeof Base} = { + access_scope: AccessScope + }; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "post", operation: "post", ids: [], path: "storefront_access_tokens.json"}, + {http_method: "get", operation: "get", ids: [], path: "storefront_access_tokens.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "storefront_access_tokens/.json"} + ]; + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await StorefrontAccessToken.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + ...otherArgs + }: AllArgs + ): Promise { + const response = await StorefrontAccessToken.baseFind({ + session: session, + urlIds: {}, + params: {...otherArgs}, + }); + + return response as StorefrontAccessToken[]; + } + + public title: string | null; + public access_scope: AccessScope | null | {[key: string]: any}; + public access_token: string | null; + public created_at: string | null; + public id: number | null; +} diff --git a/src/rest-resources/2021-10/tender_transaction.ts b/src/rest-resources/2021-10/tender_transaction.ts new file mode 100644 index 000000000..551cac1a1 --- /dev/null +++ b/src/rest-resources/2021-10/tender_transaction.ts @@ -0,0 +1,62 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Currency} from './currency'; + +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + limit?: unknown; + since_id?: unknown; + processed_at_min?: unknown; + processed_at_max?: unknown; + processed_at?: unknown; + order?: unknown; +} + +export class TenderTransaction extends Base { + public static API_VERSION = ApiVersion.October21; + + protected static NAME = 'tender_transaction'; + protected static PLURAL_NAME = 'tender_transactions'; + protected static HAS_ONE: {[key: string]: typeof Base} = { + currency: Currency + }; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "tender_transactions.json"} + ]; + + public static async all( + { + session, + limit = null, + since_id = null, + processed_at_min = null, + processed_at_max = null, + processed_at = null, + order = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await TenderTransaction.baseFind({ + session: session, + urlIds: {}, + params: {limit: limit, since_id: since_id, processed_at_min: processed_at_min, processed_at_max: processed_at_max, processed_at: processed_at, order: order, ...otherArgs}, + }); + + return response as TenderTransaction[]; + } + + public amount: string | null; + public currency: Currency | null | {[key: string]: any}; + public id: number | null; + public order_id: number | null; + public payment_details: {[key: string]: unknown} | null; + public payment_method: string | null; + public processed_at: string | null; + public remote_reference: string | null; + public test: boolean | null; + public user_id: number | null; +} diff --git a/src/rest-resources/2021-10/theme.ts b/src/rest-resources/2021-10/theme.ts new file mode 100644 index 000000000..42a12b22f --- /dev/null +++ b/src/rest-resources/2021-10/theme.ts @@ -0,0 +1,91 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + fields?: unknown; +} + +export class Theme extends Base { + public static API_VERSION = ApiVersion.October21; + + protected static NAME = 'theme'; + protected static PLURAL_NAME = 'themes'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "themes.json"}, + {http_method: "post", operation: "post", ids: [], path: "themes.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "themes/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "themes/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "themes/.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await Theme.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as Theme : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await Theme.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Theme.baseFind({ + session: session, + urlIds: {}, + params: {fields: fields, ...otherArgs}, + }); + + return response as Theme[]; + } + + public created_at: string | null; + public id: number | null; + public name: string | null; + public previewable: boolean | null; + public processing: boolean | null; + public role: string | null; + public theme_store_id: number | null; + public updated_at: string | null; +} diff --git a/src/rest-resources/2021-10/transaction.ts b/src/rest-resources/2021-10/transaction.ts new file mode 100644 index 000000000..0e06adfd3 --- /dev/null +++ b/src/rest-resources/2021-10/transaction.ts @@ -0,0 +1,120 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + order_id?: number | string | null; + fields?: unknown; + in_shop_currency?: unknown; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + order_id?: number | string | null; + since_id?: unknown; + fields?: unknown; + in_shop_currency?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; + order_id?: number | string | null; +} + +export class Transaction extends Base { + public static API_VERSION = ApiVersion.October21; + + protected static NAME = 'transaction'; + protected static PLURAL_NAME = 'transactions'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: ["order_id"], path: "orders//transactions.json"}, + {http_method: "post", operation: "post", ids: ["order_id"], path: "orders//transactions.json"}, + {http_method: "get", operation: "count", ids: ["order_id"], path: "orders//transactions/count.json"}, + {http_method: "get", operation: "get", ids: ["order_id", "id"], path: "orders//transactions/.json"} + ]; + + public static async find( + { + session, + id, + order_id = null, + fields = null, + in_shop_currency = null + }: FindArgs + ): Promise { + const result = await Transaction.baseFind({ + session: session, + urlIds: {id: id, order_id: order_id}, + params: {fields: fields, in_shop_currency: in_shop_currency}, + }); + return result ? result[0] as Transaction : null; + } + + public static async all( + { + session, + order_id = null, + since_id = null, + fields = null, + in_shop_currency = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Transaction.baseFind({ + session: session, + urlIds: {order_id: order_id}, + params: {since_id: since_id, fields: fields, in_shop_currency: in_shop_currency, ...otherArgs}, + }); + + return response as Transaction[]; + } + + public static async count( + { + session, + order_id = null, + ...otherArgs + }: CountArgs + ): Promise { + const response = await Transaction.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {order_id: order_id}, + params: {...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public kind: string | null; + public amount: string | null; + public authorization: string | null; + public authorization_expires_at: string | null; + public created_at: string | null; + public currency: string | null; + public currency_exchange_adjustment: {[key: string]: unknown} | null; + public device_id: number | null; + public error_code: string | null; + public extended_authorization_attributes: {[key: string]: unknown} | null; + public gateway: string | null; + public id: number | null; + public location_id: number | null; + public message: string | null; + public order_id: number | null; + public parent_id: number | null; + public payment_details: {[key: string]: unknown} | null; + public payments_refund_attributes: {[key: string]: unknown} | null; + public processed_at: string | null; + public receipt: {[key: string]: unknown} | null; + public source_name: string | null; + public status: string | null; + public test: boolean | null; + public user_id: number | null; +} diff --git a/src/rest-resources/2021-10/usage_charge.ts b/src/rest-resources/2021-10/usage_charge.ts new file mode 100644 index 000000000..8d82a7935 --- /dev/null +++ b/src/rest-resources/2021-10/usage_charge.ts @@ -0,0 +1,70 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + recurring_application_charge_id?: number | string | null; + fields?: unknown; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + recurring_application_charge_id?: number | string | null; + fields?: unknown; +} + +export class UsageCharge extends Base { + public static API_VERSION = ApiVersion.October21; + + protected static NAME = 'usage_charge'; + protected static PLURAL_NAME = 'usage_charges'; + 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: ["recurring_application_charge_id"], path: "recurring_application_charges//usage_charges.json"}, + {http_method: "get", operation: "get", ids: ["recurring_application_charge_id"], path: "recurring_application_charges//usage_charges.json"}, + {http_method: "get", operation: "get", ids: ["recurring_application_charge_id", "id"], path: "recurring_application_charges//usage_charges/.json"} + ]; + + public static async find( + { + session, + id, + recurring_application_charge_id = null, + fields = null + }: FindArgs + ): Promise { + const result = await UsageCharge.baseFind({ + session: session, + urlIds: {id: id, recurring_application_charge_id: recurring_application_charge_id}, + params: {fields: fields}, + }); + return result ? result[0] as UsageCharge : null; + } + + public static async all( + { + session, + recurring_application_charge_id = null, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await UsageCharge.baseFind({ + session: session, + urlIds: {recurring_application_charge_id: recurring_application_charge_id}, + params: {fields: fields, ...otherArgs}, + }); + + return response as UsageCharge[]; + } + + public created_at: string | null; + public description: string | null; + public id: number | null; + public price: number | null; + public recurring_application_charge_id: number | null; + public updated_at: string | null; +} diff --git a/src/rest-resources/2021-10/user.ts b/src/rest-resources/2021-10/user.ts new file mode 100644 index 000000000..fedbb9b47 --- /dev/null +++ b/src/rest-resources/2021-10/user.ts @@ -0,0 +1,97 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + limit?: unknown; + page_info?: unknown; +} +interface CurrentArgs { + [key: string]: unknown; + session: SessionInterface; +} + +export class User extends Base { + public static API_VERSION = ApiVersion.October21; + + protected static NAME = 'user'; + protected static PLURAL_NAME = 'users'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "users.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "users/.json"}, + {http_method: "get", operation: "current", ids: [], path: "users/current.json"} + ]; + + public static async find( + { + session, + id + }: FindArgs + ): Promise { + const result = await User.baseFind({ + session: session, + urlIds: {id: id}, + params: {}, + }); + return result ? result[0] as User : null; + } + + public static async all( + { + session, + limit = null, + page_info = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await User.baseFind({ + session: session, + urlIds: {}, + params: {limit: limit, page_info: page_info, ...otherArgs}, + }); + + return response as User[]; + } + + public static async current( + { + session, + ...otherArgs + }: CurrentArgs + ): Promise { + const response = await User.request({ + http_method: "get", + operation: "current", + session: session, + urlIds: {}, + params: {...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public account_owner: boolean | null; + public bio: string | null; + public email: string | null; + public first_name: string | null; + public id: number | null; + public im: string | null; + public last_name: string | null; + public locale: string | null; + public permissions: string[] | null; + public phone: string | null; + public receive_announcements: number | null; + public screen_name: string | null; + public url: string | null; + public user_type: string | null; +} diff --git a/src/rest-resources/2021-10/variant.ts b/src/rest-resources/2021-10/variant.ts new file mode 100644 index 000000000..c70c468fd --- /dev/null +++ b/src/rest-resources/2021-10/variant.ts @@ -0,0 +1,145 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; + product_id?: number | string | null; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + product_id?: number | string | null; + limit?: unknown; + presentment_currencies?: unknown; + since_id?: unknown; + fields?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; + product_id?: number | string | null; +} + +export class Variant extends Base { + public static API_VERSION = ApiVersion.October21; + + protected static NAME = 'variant'; + protected static PLURAL_NAME = 'variants'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: ["product_id"], path: "products//variants.json"}, + {http_method: "get", operation: "count", ids: ["product_id"], path: "products//variants/count.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "variants/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "variants/.json"}, + {http_method: "post", operation: "post", ids: ["product_id"], path: "products//variants.json"}, + {http_method: "delete", operation: "delete", ids: ["product_id", "id"], path: "products//variants/.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await Variant.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as Variant : null; + } + + public static async delete( + { + session, + id, + product_id = null + }: DeleteArgs + ): Promise { + const response = await Variant.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id, product_id: product_id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + product_id = null, + limit = null, + presentment_currencies = null, + since_id = null, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Variant.baseFind({ + session: session, + urlIds: {product_id: product_id}, + params: {limit: limit, presentment_currencies: presentment_currencies, since_id: since_id, fields: fields, ...otherArgs}, + }); + + return response as Variant[]; + } + + public static async count( + { + session, + product_id = null, + ...otherArgs + }: CountArgs + ): Promise { + const response = await Variant.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {product_id: product_id}, + params: {...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public barcode: string | null; + public compare_at_price: string | null; + public created_at: string | null; + public fulfillment_service: string | null; + public grams: number | null; + public id: number | null; + public image_id: number | null; + public inventory_item_id: number | null; + public inventory_management: string | null; + public inventory_policy: string | null; + public inventory_quantity: number | null; + public inventory_quantity_adjustment: number | null; + public old_inventory_quantity: number | null; + public option: {[key: string]: unknown} | null; + public position: number | null; + public presentment_prices: {[key: string]: unknown}[] | null; + public price: string | null; + public product_id: number | null; + public requires_shipping: boolean | null; + public sku: string | null; + public tax_code: string | null; + public taxable: boolean | null; + public title: string | null; + public updated_at: string | null; + public weight: number | null; + public weight_unit: string | null; +} diff --git a/src/rest-resources/2021-10/webhook.ts b/src/rest-resources/2021-10/webhook.ts new file mode 100644 index 000000000..1dac55b03 --- /dev/null +++ b/src/rest-resources/2021-10/webhook.ts @@ -0,0 +1,137 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + address?: unknown; + created_at_max?: unknown; + created_at_min?: unknown; + fields?: unknown; + limit?: unknown; + since_id?: unknown; + topic?: unknown; + updated_at_min?: unknown; + updated_at_max?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; + address?: unknown; + topic?: unknown; +} + +export class Webhook extends Base { + public static API_VERSION = ApiVersion.October21; + + protected static NAME = 'webhook'; + protected static PLURAL_NAME = 'webhooks'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "webhooks.json"}, + {http_method: "post", operation: "post", ids: [], path: "webhooks.json"}, + {http_method: "get", operation: "count", ids: [], path: "webhooks/count.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "webhooks/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "webhooks/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "webhooks/.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await Webhook.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as Webhook : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await Webhook.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + address = null, + created_at_max = null, + created_at_min = null, + fields = null, + limit = null, + since_id = null, + topic = null, + updated_at_min = null, + updated_at_max = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Webhook.baseFind({ + session: session, + urlIds: {}, + params: {address: address, created_at_max: created_at_max, created_at_min: created_at_min, fields: fields, limit: limit, since_id: since_id, topic: topic, updated_at_min: updated_at_min, updated_at_max: updated_at_max, ...otherArgs}, + }); + + return response as Webhook[]; + } + + public static async count( + { + session, + address = null, + topic = null, + ...otherArgs + }: CountArgs + ): Promise { + const response = await Webhook.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {}, + params: {address: address, topic: topic, ...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public address: string | null; + public topic: string | null; + public api_version: string | null; + public created_at: string | null; + public fields: string[] | null; + public format: string | null; + public id: number | null; + public metafield_namespaces: string[] | null; + public private_metafield_namespaces: string[] | null; + public updated_at: string | null; +} diff --git a/src/rest-resources/2022-01/abandoned_checkout.ts b/src/rest-resources/2022-01/abandoned_checkout.ts new file mode 100644 index 000000000..935fa278d --- /dev/null +++ b/src/rest-resources/2022-01/abandoned_checkout.ts @@ -0,0 +1,103 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Currency} from './currency'; +import {Customer} from './customer'; +import {DiscountCode} from './discount_code'; + +interface CheckoutsArgs { + [key: string]: unknown; + session: SessionInterface; + since_id?: unknown; + created_at_min?: unknown; + created_at_max?: unknown; + updated_at_min?: unknown; + updated_at_max?: unknown; + status?: unknown; + limit?: unknown; +} + +export class AbandonedCheckout extends Base { + public static API_VERSION = ApiVersion.January22; + + protected static NAME = 'abandoned_checkout'; + protected static PLURAL_NAME = 'abandoned_checkouts'; + protected static HAS_ONE: {[key: string]: typeof Base} = { + currency: Currency, + customer: Customer + }; + protected static HAS_MANY: {[key: string]: typeof Base} = { + discount_codes: DiscountCode + }; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "checkouts", ids: [], path: "checkouts.json"}, + {http_method: "get", operation: "checkouts", ids: [], path: "checkouts.json"} + ]; + + public static async checkouts( + { + session, + since_id = null, + created_at_min = null, + created_at_max = null, + updated_at_min = null, + updated_at_max = null, + status = null, + limit = null, + ...otherArgs + }: CheckoutsArgs + ): Promise { + const response = await AbandonedCheckout.request({ + http_method: "get", + operation: "checkouts", + session: session, + urlIds: {}, + params: {since_id: since_id, created_at_min: created_at_min, created_at_max: created_at_max, updated_at_min: updated_at_min, updated_at_max: updated_at_max, status: status, limit: limit, ...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public abandoned_checkout_url: string | null; + public billing_address: {[key: string]: unknown} | null; + public buyer_accepts_marketing: boolean | null; + public buyer_accepts_sms_marketing: boolean | null; + public cart_token: string | null; + public closed_at: string | null; + public completed_at: string | null; + public created_at: string | null; + public currency: Currency | null | {[key: string]: any}; + public customer: Customer | null | {[key: string]: any}; + public customer_locale: string | null; + public device_id: number | null; + public discount_codes: DiscountCode[] | null | {[key: string]: any}; + public email: string | null; + public gateway: string | null; + public id: number | null; + public landing_site: string | null; + public line_items: {[key: string]: unknown} | null; + public location_id: number | null; + public note: string | null; + public phone: string | null; + public presentment_currency: string | null; + public referring_site: string | null; + public shipping_address: {[key: string]: unknown} | null; + public shipping_lines: {[key: string]: unknown} | null; + public sms_marketing_phone: string | null; + public source_name: string | null; + public subtotal_price: string | null; + public tax_lines: {[key: string]: unknown} | null; + public taxes_included: boolean | null; + public token: string | null; + public total_discounts: string | null; + public total_duties: string | null; + public total_line_items_price: string | null; + public total_price: string | null; + public total_tax: string | null; + public total_weight: number | null; + public updated_at: string | null; + public user_id: number | null; +} diff --git a/src/rest-resources/2022-01/access_scope.ts b/src/rest-resources/2022-01/access_scope.ts new file mode 100644 index 000000000..47a2e6333 --- /dev/null +++ b/src/rest-resources/2022-01/access_scope.ts @@ -0,0 +1,39 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; +} + +export class AccessScope extends Base { + public static API_VERSION = ApiVersion.January22; + + protected static NAME = 'access_scope'; + protected static PLURAL_NAME = 'access_scopes'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static CUSTOM_PREFIX: string | null = "/admin/oauth"; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "access_scopes.json"} + ]; + + public static async all( + { + session, + ...otherArgs + }: AllArgs + ): Promise { + const response = await AccessScope.baseFind({ + session: session, + urlIds: {}, + params: {...otherArgs}, + }); + + return response as AccessScope[]; + } + + public handle: string | null; + public access_scopes: {[key: string]: unknown}[] | null; +} diff --git a/src/rest-resources/2022-01/android_pay_key.ts b/src/rest-resources/2022-01/android_pay_key.ts new file mode 100644 index 000000000..465b191c9 --- /dev/null +++ b/src/rest-resources/2022-01/android_pay_key.ts @@ -0,0 +1,60 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} + +export class AndroidPayKey extends Base { + public static API_VERSION = ApiVersion.January22; + + protected static NAME = 'android_pay_key'; + protected static PLURAL_NAME = 'android_pay_keys'; + 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: "get", operation: "get", ids: ["id"], path: "android_pay_keys/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "android_pay_keys/.json"} + ]; + + public static async find( + { + session, + id + }: FindArgs + ): Promise { + const result = await AndroidPayKey.baseFind({ + session: session, + urlIds: {id: id}, + params: {}, + }); + return result ? result[0] as AndroidPayKey : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await AndroidPayKey.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public id: number | null; + public public_key: string | null; +} diff --git a/src/rest-resources/2022-01/apple_pay_certificate.ts b/src/rest-resources/2022-01/apple_pay_certificate.ts new file mode 100644 index 000000000..6b890b3f1 --- /dev/null +++ b/src/rest-resources/2022-01/apple_pay_certificate.ts @@ -0,0 +1,88 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface CsrArgs { + [key: string]: unknown; + session: SessionInterface; + id: number | string; +} + +export class ApplePayCertificate extends Base { + public static API_VERSION = ApiVersion.January22; + + protected static NAME = 'apple_pay_certificate'; + protected static PLURAL_NAME = 'apple_pay_certificates'; + 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/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "apple_pay_certificates/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "apple_pay_certificates/.json"}, + {http_method: "get", operation: "csr", ids: ["id"], path: "apple_pay_certificates//csr.json"} + ]; + + public static async find( + { + session, + id + }: FindArgs + ): Promise { + const result = await ApplePayCertificate.baseFind({ + session: session, + urlIds: {id: id}, + params: {}, + }); + return result ? result[0] as ApplePayCertificate : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await ApplePayCertificate.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async csr( + { + session, + id, + ...otherArgs + }: CsrArgs + ): Promise { + const response = await ApplePayCertificate.request({ + http_method: "get", + operation: "csr", + session: session, + urlIds: {id: id}, + params: {...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public id: number | null; + public merchant_id: string | null; + public status: string | null; +} diff --git a/src/rest-resources/2022-01/application_charge.ts b/src/rest-resources/2022-01/application_charge.ts new file mode 100644 index 000000000..d8aca44ac --- /dev/null +++ b/src/rest-resources/2022-01/application_charge.ts @@ -0,0 +1,71 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + since_id?: unknown; + fields?: unknown; +} + +export class ApplicationCharge extends Base { + public static API_VERSION = ApiVersion.January22; + + protected static NAME = 'application_charge'; + protected static PLURAL_NAME = 'application_charges'; + 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: ["id"], path: "application_charges/.json"}, + {http_method: "get", operation: "get", ids: [], path: "application_charges.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await ApplicationCharge.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as ApplicationCharge : null; + } + + public static async all( + { + session, + since_id = null, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await ApplicationCharge.baseFind({ + session: session, + urlIds: {}, + params: {since_id: since_id, fields: fields, ...otherArgs}, + }); + + return response as ApplicationCharge[]; + } + + public confirmation_url: string | null; + public created_at: string | null; + public id: number | null; + public name: string | null; + public price: string | number | null; + public return_url: string | null; + public status: string | null; + public test: boolean | null; + public updated_at: string | null; +} diff --git a/src/rest-resources/2022-01/application_credit.ts b/src/rest-resources/2022-01/application_credit.ts new file mode 100644 index 000000000..d79694f54 --- /dev/null +++ b/src/rest-resources/2022-01/application_credit.ts @@ -0,0 +1,64 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + fields?: unknown; +} + +export class ApplicationCredit extends Base { + public static API_VERSION = ApiVersion.January22; + + protected static NAME = 'application_credit'; + protected static PLURAL_NAME = 'application_credits'; + 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/.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await ApplicationCredit.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as ApplicationCredit : null; + } + + public static async all( + { + session, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await ApplicationCredit.baseFind({ + session: session, + urlIds: {}, + params: {fields: fields, ...otherArgs}, + }); + + return response as ApplicationCredit[]; + } + + public amount: number | null; + public description: string | null; + public id: number | null; + public test: boolean | null; +} diff --git a/src/rest-resources/2022-01/article.ts b/src/rest-resources/2022-01/article.ts new file mode 100644 index 000000000..4101c4e13 --- /dev/null +++ b/src/rest-resources/2022-01/article.ts @@ -0,0 +1,228 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Metafield} from './metafield'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + blog_id?: number | string | null; + fields?: unknown; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; + blog_id?: number | string | null; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + blog_id?: number | string | null; + limit?: unknown; + since_id?: unknown; + created_at_min?: unknown; + created_at_max?: unknown; + updated_at_min?: unknown; + updated_at_max?: unknown; + published_at_min?: unknown; + published_at_max?: unknown; + published_status?: unknown; + handle?: unknown; + tag?: unknown; + author?: unknown; + fields?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; + blog_id?: number | string | null; + created_at_min?: unknown; + created_at_max?: unknown; + updated_at_min?: unknown; + updated_at_max?: unknown; + published_at_min?: unknown; + 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 { + public static API_VERSION = ApiVersion.January22; + + protected static NAME = 'article'; + protected static PLURAL_NAME = 'articles'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = { + metafields: Metafield + }; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: ["blog_id"], path: "blogs//articles.json"}, + {http_method: "post", operation: "post", ids: ["blog_id"], path: "blogs//articles.json"}, + {http_method: "get", operation: "count", ids: ["blog_id"], path: "blogs//articles/count.json"}, + {http_method: "get", operation: "get", ids: ["blog_id", "id"], path: "blogs//articles/.json"}, + {http_method: "put", operation: "put", ids: ["blog_id", "id"], path: "blogs//articles/.json"}, + {http_method: "delete", operation: "delete", ids: ["blog_id", "id"], path: "blogs//articles/.json"}, + {http_method: "get", operation: "authors", ids: [], path: "articles/authors.json"}, + {http_method: "get", operation: "tags", ids: ["blog_id"], path: "blogs//articles/tags.json"}, + {http_method: "get", operation: "tags", ids: [], path: "articles/tags.json"} + ]; + + public static async find( + { + session, + id, + blog_id = null, + fields = null + }: FindArgs + ): Promise
{ + const result = await Article.baseFind({ + session: session, + urlIds: {id: id, blog_id: blog_id}, + params: {fields: fields}, + }); + return result ? result[0] as Article : null; + } + + public static async delete( + { + session, + id, + blog_id = null + }: DeleteArgs + ): Promise { + const response = await Article.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id, blog_id: blog_id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + blog_id = null, + limit = null, + since_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, + handle = null, + tag = null, + author = null, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Article.baseFind({ + session: session, + urlIds: {blog_id: blog_id}, + params: {limit: limit, since_id: since_id, 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, handle: handle, tag: tag, author: author, fields: fields, ...otherArgs}, + }); + + return response as Article[]; + } + + 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 + }: CountArgs + ): Promise { + const response = await Article.request({ + http_method: "get", + operation: "count", + 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}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public static async authors( + { + session, + ...otherArgs + }: AuthorsArgs + ): Promise { + const response = await Article.request({ + http_method: "get", + operation: "authors", + session: session, + urlIds: {}, + params: {...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public static async tags( + { + session, + blog_id = null, + limit = null, + popular = null, + ...otherArgs + }: TagsArgs + ): Promise { + const response = await Article.request({ + http_method: "get", + operation: "tags", + session: session, + urlIds: {blog_id: blog_id}, + params: {limit: limit, popular: popular, ...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public author: string | null; + public blog_id: number | null; + public body_html: string | null; + public created_at: string | null; + public handle: string | null; + public id: number | null; + public image: string | {[key: string]: unknown} | null; + public metafields: Metafield[] | null | {[key: string]: any}; + public published: boolean | null; + public published_at: string | null; + public summary_html: string | null; + public tags: string | null; + public template_suffix: string | null; + public title: string | null; + public updated_at: string | null; + public user_id: number | null; +} diff --git a/src/rest-resources/2022-01/asset.ts b/src/rest-resources/2022-01/asset.ts new file mode 100644 index 000000000..4b6504aa9 --- /dev/null +++ b/src/rest-resources/2022-01/asset.ts @@ -0,0 +1,79 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface DeleteArgs { + session: SessionInterface; + theme_id?: number | string | null; + asset?: {[key: string]: unknown} | null; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + theme_id?: number | string | null; + fields?: unknown; + asset?: {[key: string]: unknown} | null; +} + +export class Asset extends Base { + public static API_VERSION = ApiVersion.January22; + + protected static NAME = 'asset'; + protected static PLURAL_NAME = 'assets'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: ["theme_id"], path: "themes//assets.json"}, + {http_method: "put", operation: "put", ids: ["theme_id"], path: "themes//assets.json"}, + {http_method: "get", operation: "get", ids: ["theme_id"], path: "themes//assets.json"}, + {http_method: "delete", operation: "delete", ids: ["theme_id"], path: "themes//assets.json"} + ]; + protected static PRIMARY_KEY: string = "key"; + + public static async delete( + { + session, + theme_id = null, + asset = null + }: DeleteArgs + ): Promise { + const response = await Asset.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {theme_id: theme_id}, + params: {asset: asset}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + theme_id = null, + fields = null, + asset = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Asset.baseFind({ + session: session, + urlIds: {theme_id: theme_id}, + params: {fields: fields, asset: asset, ...otherArgs}, + }); + + return response as Asset[]; + } + + public attachment: string | null; + public checksum: string | null; + public content_type: string | null; + public created_at: string | null; + public key: string | null; + public public_url: string | null; + public size: number | null; + public theme_id: number | null; + public updated_at: string | null; + public value: string | null; +} diff --git a/src/rest-resources/2022-01/assigned_fulfillment_order.ts b/src/rest-resources/2022-01/assigned_fulfillment_order.ts new file mode 100644 index 000000000..6180c0f96 --- /dev/null +++ b/src/rest-resources/2022-01/assigned_fulfillment_order.ts @@ -0,0 +1,48 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + assignment_status?: unknown; + location_ids?: unknown[] | number | string | null; +} + +export class AssignedFulfillmentOrder extends Base { + public static API_VERSION = ApiVersion.January22; + + protected static NAME = 'assigned_fulfillment_order'; + protected static PLURAL_NAME = 'assigned_fulfillment_orders'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "assigned_fulfillment_orders.json"} + ]; + + public static async all( + { + session, + assignment_status = null, + location_ids = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await AssignedFulfillmentOrder.baseFind({ + session: session, + urlIds: {}, + params: {assignment_status: assignment_status, location_ids: location_ids, ...otherArgs}, + }); + + return response as AssignedFulfillmentOrder[]; + } + + public assigned_location_id: number | null; + public destination: {[key: string]: unknown} | null; + public id: number | null; + public line_items: {[key: string]: unknown}[] | null; + public order_id: number | null; + public request_status: string | null; + public shop_id: number | null; + public status: string | null; +} diff --git a/src/rest-resources/2022-01/balance.ts b/src/rest-resources/2022-01/balance.ts new file mode 100644 index 000000000..a6a44046e --- /dev/null +++ b/src/rest-resources/2022-01/balance.ts @@ -0,0 +1,36 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; +} + +export class Balance extends Base { + public static API_VERSION = ApiVersion.January22; + + protected static NAME = 'balance'; + protected static PLURAL_NAME = 'balances'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "shopify_payments/balance.json"} + ]; + + public static async all( + { + session, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Balance.baseFind({ + session: session, + urlIds: {}, + params: {...otherArgs}, + }); + + return response as Balance[]; + } + +} diff --git a/src/rest-resources/2022-01/blog.ts b/src/rest-resources/2022-01/blog.ts new file mode 100644 index 000000000..beda69436 --- /dev/null +++ b/src/rest-resources/2022-01/blog.ts @@ -0,0 +1,129 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Metafield} from './metafield'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + limit?: unknown; + since_id?: unknown; + handle?: unknown; + fields?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; +} + +export class Blog extends Base { + public static API_VERSION = ApiVersion.January22; + + protected static NAME = 'blog'; + protected static PLURAL_NAME = 'blogs'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof 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: "get", operation: "count", ids: [], path: "blogs/count.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "blogs/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "blogs/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "blogs/.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await Blog.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as Blog : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await Blog.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + limit = null, + since_id = null, + handle = null, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Blog.baseFind({ + session: session, + urlIds: {}, + params: {limit: limit, since_id: since_id, handle: handle, fields: fields, ...otherArgs}, + }); + + return response as Blog[]; + } + + public static async count( + { + session, + ...otherArgs + }: CountArgs + ): Promise { + const response = await Blog.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {}, + params: {...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public admin_graphql_api_id: string | null; + public commentable: string | null; + public created_at: string | null; + public feedburner: string | null; + public feedburner_location: string | null; + public handle: string | null; + public id: number | null; + public metafields: Metafield[] | null | {[key: string]: any}; + public tags: string | null; + public template_suffix: string | null; + public title: string | null; + public updated_at: string | null; +} diff --git a/src/rest-resources/2022-01/cancellation_request.ts b/src/rest-resources/2022-01/cancellation_request.ts new file mode 100644 index 000000000..51140143a --- /dev/null +++ b/src/rest-resources/2022-01/cancellation_request.ts @@ -0,0 +1,69 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {ApiVersion} from '../../base-types'; + +interface AcceptArgs { + [key: string]: unknown; + message?: unknown; + body?: {[key: string]: unknown} | null; +} +interface RejectArgs { + [key: string]: unknown; + message?: unknown; + body?: {[key: string]: unknown} | null; +} + +export class CancellationRequest extends Base { + public static API_VERSION = ApiVersion.January22; + + protected static NAME = 'cancellation_request'; + protected static PLURAL_NAME = 'cancellation_requests'; + 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//cancellation_request.json"}, + {http_method: "post", operation: "accept", ids: ["fulfillment_order_id"], path: "fulfillment_orders//cancellation_request/accept.json"}, + {http_method: "post", operation: "reject", ids: ["fulfillment_order_id"], path: "fulfillment_orders//cancellation_request/reject.json"} + ]; + + public async accept( + { + message = null, + body = null, + ...otherArgs + }: AcceptArgs + ): Promise { + const response = await CancellationRequest.request({ + http_method: "post", + operation: "accept", + session: this.session, + urlIds: {fulfillment_order_id: this.fulfillment_order_id}, + params: {message: message, ...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public async reject( + { + message = null, + body = null, + ...otherArgs + }: RejectArgs + ): Promise { + const response = await CancellationRequest.request({ + http_method: "post", + operation: "reject", + session: this.session, + urlIds: {fulfillment_order_id: this.fulfillment_order_id}, + params: {message: message, ...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public fulfillment_order_id: number | null; +} diff --git a/src/rest-resources/2022-01/carrier_service.ts b/src/rest-resources/2022-01/carrier_service.ts new file mode 100644 index 000000000..59fcfec3d --- /dev/null +++ b/src/rest-resources/2022-01/carrier_service.ts @@ -0,0 +1,87 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; +} + +export class CarrierService extends Base { + public static API_VERSION = ApiVersion.January22; + + protected static NAME = 'carrier_service'; + protected static PLURAL_NAME = 'carrier_services'; + 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: "get", operation: "get", ids: [], path: "carrier_services.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "carrier_services/.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "carrier_services/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "carrier_services/.json"} + ]; + + public static async find( + { + session, + id + }: FindArgs + ): Promise { + const result = await CarrierService.baseFind({ + session: session, + urlIds: {id: id}, + params: {}, + }); + return result ? result[0] as CarrierService : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await CarrierService.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + ...otherArgs + }: AllArgs + ): Promise { + const response = await CarrierService.baseFind({ + session: session, + urlIds: {}, + params: {...otherArgs}, + }); + + return response as CarrierService[]; + } + + public active: boolean | null; + public admin_graphql_api_id: string | null; + public callback_url: string | null; + public carrier_service_type: string | null; + public format: string | null; + public id: number | null; + public name: string | null; + public service_discovery: boolean | null; +} diff --git a/src/rest-resources/2022-01/checkout.ts b/src/rest-resources/2022-01/checkout.ts new file mode 100644 index 000000000..36df10914 --- /dev/null +++ b/src/rest-resources/2022-01/checkout.ts @@ -0,0 +1,130 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Currency} from './currency'; +import {DiscountCode} from './discount_code'; +import {Order} from './order'; +import {GiftCard} from './gift_card'; + +interface FindArgs { + session: SessionInterface; + token: number | string; +} +interface ShippingRatesArgs { + [key: string]: unknown; + session: SessionInterface; + token: number | string; +} +interface CompleteArgs { + [key: string]: unknown; + body?: {[key: string]: unknown} | null; +} + +export class Checkout extends Base { + public static API_VERSION = ApiVersion.January22; + + protected static NAME = 'checkout'; + protected static PLURAL_NAME = 'checkouts'; + protected static HAS_ONE: {[key: string]: typeof Base} = { + currency: Currency, + discount_code: DiscountCode, + order: Order + }; + protected static HAS_MANY: {[key: string]: typeof 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//complete.json"}, + {http_method: "get", operation: "get", ids: ["token"], path: "checkouts/.json"}, + {http_method: "put", operation: "put", ids: ["token"], path: "checkouts/.json"}, + {http_method: "get", operation: "shipping_rates", ids: ["token"], path: "checkouts//shipping_rates.json"} + ]; + protected static PRIMARY_KEY: string = "token"; + + public static async find( + { + session, + token + }: FindArgs + ): Promise { + const result = await Checkout.baseFind({ + session: session, + urlIds: {token: token}, + params: {}, + }); + return result ? result[0] as Checkout : null; + } + + public static async shipping_rates( + { + session, + token, + ...otherArgs + }: ShippingRatesArgs + ): Promise { + const response = await Checkout.request({ + http_method: "get", + operation: "shipping_rates", + session: session, + urlIds: {token: token}, + params: {...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public async complete( + { + body = null, + ...otherArgs + }: CompleteArgs + ): Promise { + const response = await Checkout.request({ + http_method: "post", + operation: "complete", + session: this.session, + urlIds: {token: this.token}, + params: {...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public billing_address: {[key: string]: unknown} | null; + public line_items: {[key: string]: unknown}[] | null; + public applied_discount: {[key: string]: unknown} | null; + public buyer_accepts_marketing: boolean | null; + public created_at: string | null; + public currency: Currency | null | {[key: string]: any}; + public customer_id: number | null; + public discount_code: DiscountCode | null | {[key: string]: any}; + public email: string | null; + public gift_cards: GiftCard[] | null | {[key: string]: any}; + public order: Order | null | {[key: string]: any}; + public payment_due: string | null; + public payment_url: string | null; + public phone: string | null; + public presentment_currency: string | null; + public requires_shipping: boolean | null; + public reservation_time: string | null; + public reservation_time_left: number | null; + public shipping_address: {[key: string]: unknown} | null; + public shipping_line: {[key: string]: unknown} | null; + public shipping_rate: {[key: string]: unknown} | null; + public source_name: string | null; + public subtotal_price: string | null; + public tax_lines: {[key: string]: unknown}[] | null; + public taxes_included: boolean | null; + public token: string | null; + public total_price: string | null; + public total_tax: string | null; + public updated_at: string | null; + public user_id: number | null; + public web_url: string | null; +} diff --git a/src/rest-resources/2022-01/collect.ts b/src/rest-resources/2022-01/collect.ts new file mode 100644 index 000000000..fbb7faa76 --- /dev/null +++ b/src/rest-resources/2022-01/collect.ts @@ -0,0 +1,117 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + limit?: unknown; + since_id?: unknown; + fields?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; +} + +export class Collect extends Base { + public static API_VERSION = ApiVersion.January22; + + protected static NAME = 'collect'; + protected static PLURAL_NAME = 'collects'; + 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/.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "collects/.json"}, + {http_method: "get", operation: "count", ids: [], path: "collects/count.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await Collect.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as Collect : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await Collect.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + limit = null, + since_id = null, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Collect.baseFind({ + session: session, + urlIds: {}, + params: {limit: limit, since_id: since_id, fields: fields, ...otherArgs}, + }); + + return response as Collect[]; + } + + public static async count( + { + session, + ...otherArgs + }: CountArgs + ): Promise { + const response = await Collect.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {}, + params: {...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public collection_id: number | null; + public created_at: string | null; + public id: number | null; + public position: number | null; + public product_id: number | null; + public sort_value: string | null; + public updated_at: string | null; +} diff --git a/src/rest-resources/2022-01/collection.ts b/src/rest-resources/2022-01/collection.ts new file mode 100644 index 000000000..d3a888c74 --- /dev/null +++ b/src/rest-resources/2022-01/collection.ts @@ -0,0 +1,79 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Image} from './image'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface ProductsArgs { + [key: string]: unknown; + session: SessionInterface; + id: number | string; + limit?: unknown; +} + +export class Collection extends Base { + public static API_VERSION = ApiVersion.January22; + + protected static NAME = 'collection'; + protected static PLURAL_NAME = 'collections'; + protected static HAS_ONE: {[key: string]: typeof Base} = { + image: Image + }; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: ["id"], path: "collections/.json"}, + {http_method: "get", operation: "products", ids: ["id"], path: "collections//products.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await Collection.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as Collection : null; + } + + public static async products( + { + session, + id, + limit = null, + ...otherArgs + }: ProductsArgs + ): Promise { + const response = await Collection.request({ + http_method: "get", + operation: "products", + session: session, + urlIds: {id: id}, + params: {limit: limit, ...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public title: string | null; + public body_html: string | null; + public handle: string | null; + public id: number | null; + public image: Image | null | {[key: string]: any}; + public published_at: string | null; + public published_scope: string | null; + public sort_order: string | null; + public template_suffix: string | null; + public updated_at: string | null; +} diff --git a/src/rest-resources/2022-01/collection_listing.ts b/src/rest-resources/2022-01/collection_listing.ts new file mode 100644 index 000000000..7840b2bd6 --- /dev/null +++ b/src/rest-resources/2022-01/collection_listing.ts @@ -0,0 +1,122 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Image} from './image'; + +interface FindArgs { + session: SessionInterface; + collection_id: number | string; +} +interface DeleteArgs { + session: SessionInterface; + collection_id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + limit?: unknown; +} +interface ProductIdsArgs { + [key: string]: unknown; + session: SessionInterface; + collection_id: number | string; + limit?: unknown; +} + +export class CollectionListing extends Base { + public static API_VERSION = ApiVersion.January22; + + protected static NAME = 'collection_listing'; + protected static PLURAL_NAME = 'collection_listings'; + protected static HAS_ONE: {[key: string]: typeof Base} = { + image: Image + }; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "collection_listings.json"}, + {http_method: "get", operation: "product_ids", ids: ["collection_id"], path: "collection_listings//product_ids.json"}, + {http_method: "get", operation: "get", ids: ["collection_id"], path: "collection_listings/.json"}, + {http_method: "put", operation: "put", ids: ["collection_id"], path: "collection_listings/.json"}, + {http_method: "delete", operation: "delete", ids: ["collection_id"], path: "collection_listings/.json"} + ]; + protected static PRIMARY_KEY: string = "collection_id"; + + public static async find( + { + session, + collection_id + }: FindArgs + ): Promise { + const result = await CollectionListing.baseFind({ + session: session, + urlIds: {collection_id: collection_id}, + params: {}, + }); + return result ? result[0] as CollectionListing : null; + } + + public static async delete( + { + session, + collection_id + }: DeleteArgs + ): Promise { + const response = await CollectionListing.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {collection_id: collection_id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + limit = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await CollectionListing.baseFind({ + session: session, + urlIds: {}, + params: {limit: limit, ...otherArgs}, + }); + + return response as CollectionListing[]; + } + + public static async product_ids( + { + session, + collection_id, + limit = null, + ...otherArgs + }: ProductIdsArgs + ): Promise { + const response = await CollectionListing.request({ + http_method: "get", + operation: "product_ids", + session: session, + urlIds: {collection_id: collection_id}, + params: {limit: limit, ...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public body_html: string | null; + public collection_id: number | null; + public default_product_image: {[key: string]: unknown}[] | null; + public handle: string | null; + public image: Image | null | {[key: string]: any}; + public published_at: string | null; + public sort_order: string | null; + public title: string | null; + public updated_at: string | null; +} diff --git a/src/rest-resources/2022-01/comment.ts b/src/rest-resources/2022-01/comment.ts new file mode 100644 index 000000000..2e3804d87 --- /dev/null +++ b/src/rest-resources/2022-01/comment.ts @@ -0,0 +1,254 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + limit?: unknown; + since_id?: unknown; + created_at_min?: unknown; + created_at_max?: unknown; + updated_at_min?: unknown; + updated_at_max?: unknown; + published_at_min?: unknown; + published_at_max?: unknown; + fields?: unknown; + published_status?: unknown; + status?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; + created_at_min?: unknown; + created_at_max?: unknown; + updated_at_min?: unknown; + updated_at_max?: unknown; + published_at_min?: unknown; + published_at_max?: unknown; + published_status?: unknown; + status?: unknown; +} +interface SpamArgs { + [key: string]: unknown; + body?: {[key: string]: unknown} | null; +} +interface NotSpamArgs { + [key: string]: unknown; + body?: {[key: string]: unknown} | null; +} +interface ApproveArgs { + [key: string]: unknown; + body?: {[key: string]: unknown} | null; +} +interface RemoveArgs { + [key: string]: unknown; + body?: {[key: string]: unknown} | null; +} +interface RestoreArgs { + [key: string]: unknown; + body?: {[key: string]: unknown} | null; +} + +export class Comment extends Base { + public static API_VERSION = ApiVersion.January22; + + protected static NAME = 'comment'; + protected static PLURAL_NAME = 'comments'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "comments.json"}, + {http_method: "get", operation: "count", ids: [], path: "comments/count.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "comments/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "comments/.json"}, + {http_method: "post", operation: "post", ids: [], path: "comments.json"}, + {http_method: "post", operation: "spam", ids: ["id"], path: "comments//spam.json"}, + {http_method: "post", operation: "not_spam", ids: ["id"], path: "comments//not_spam.json"}, + {http_method: "post", operation: "approve", ids: ["id"], path: "comments//approve.json"}, + {http_method: "post", operation: "remove", ids: ["id"], path: "comments//remove.json"}, + {http_method: "post", operation: "restore", ids: ["id"], path: "comments//restore.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await Comment.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as Comment : null; + } + + public static async all( + { + session, + limit = null, + since_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, + fields = null, + published_status = null, + status = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Comment.baseFind({ + session: session, + urlIds: {}, + params: {limit: limit, since_id: since_id, 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, fields: fields, published_status: published_status, status: status, ...otherArgs}, + }); + + return response as Comment[]; + } + + public static async count( + { + session, + 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, + status = null, + ...otherArgs + }: CountArgs + ): Promise { + const response = await Comment.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {}, + 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, status: status, ...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public async spam( + { + body = null, + ...otherArgs + }: SpamArgs + ): Promise { + const response = await Comment.request({ + http_method: "post", + operation: "spam", + session: this.session, + urlIds: {id: this.id}, + params: {...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public async not_spam( + { + body = null, + ...otherArgs + }: NotSpamArgs + ): Promise { + const response = await Comment.request({ + http_method: "post", + operation: "not_spam", + session: this.session, + urlIds: {id: this.id}, + params: {...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public async approve( + { + body = null, + ...otherArgs + }: ApproveArgs + ): Promise { + const response = await Comment.request({ + http_method: "post", + operation: "approve", + session: this.session, + urlIds: {id: this.id}, + params: {...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public async remove( + { + body = null, + ...otherArgs + }: RemoveArgs + ): Promise { + const response = await Comment.request({ + http_method: "post", + operation: "remove", + session: this.session, + urlIds: {id: this.id}, + params: {...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public async restore( + { + body = null, + ...otherArgs + }: RestoreArgs + ): Promise { + const response = await Comment.request({ + http_method: "post", + operation: "restore", + session: this.session, + urlIds: {id: this.id}, + params: {...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public article_id: number | null; + public author: string | null; + public blog_id: number | null; + public body: string | null; + public body_html: string | null; + public created_at: string | null; + public email: string | null; + public id: number | null; + public ip: string | null; + public published_at: string | null; + public status: string | null; + public updated_at: string | null; + public user_agent: string | null; +} diff --git a/src/rest-resources/2022-01/country.ts b/src/rest-resources/2022-01/country.ts new file mode 100644 index 000000000..e351e87eb --- /dev/null +++ b/src/rest-resources/2022-01/country.ts @@ -0,0 +1,118 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Province} from './province'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + since_id?: unknown; + fields?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; +} + +export class Country extends Base { + public static API_VERSION = ApiVersion.January22; + + protected static NAME = 'country'; + protected static PLURAL_NAME = 'countries'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = { + provinces: Province + }; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "countries.json"}, + {http_method: "post", operation: "post", ids: [], path: "countries.json"}, + {http_method: "get", operation: "count", ids: [], path: "countries/count.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "countries/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "countries/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "countries/.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await Country.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as Country : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await Country.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + since_id = null, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Country.baseFind({ + session: session, + urlIds: {}, + params: {since_id: since_id, fields: fields, ...otherArgs}, + }); + + return response as Country[]; + } + + public static async count( + { + session, + ...otherArgs + }: CountArgs + ): Promise { + const response = await Country.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {}, + params: {...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public code: string | null; + public id: number | null; + public name: string | null; + public provinces: Province[] | null | {[key: string]: any}; + public tax: number | null; +} diff --git a/src/rest-resources/2022-01/currency.ts b/src/rest-resources/2022-01/currency.ts new file mode 100644 index 000000000..0e3e98484 --- /dev/null +++ b/src/rest-resources/2022-01/currency.ts @@ -0,0 +1,38 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; +} + +export class Currency extends Base { + public static API_VERSION = ApiVersion.January22; + + protected static NAME = 'currency'; + protected static PLURAL_NAME = 'currencies'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "currencies.json"} + ]; + + public static async all( + { + session, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Currency.baseFind({ + session: session, + urlIds: {}, + params: {...otherArgs}, + }); + + return response as Currency[]; + } + + public currency: string | null; + public rate_updated_at: string | null; +} diff --git a/src/rest-resources/2022-01/custom_collection.ts b/src/rest-resources/2022-01/custom_collection.ts new file mode 100644 index 000000000..bcbb5feb4 --- /dev/null +++ b/src/rest-resources/2022-01/custom_collection.ts @@ -0,0 +1,154 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + limit?: unknown; + ids?: unknown; + since_id?: unknown; + title?: unknown; + product_id?: unknown; + handle?: unknown; + updated_at_min?: unknown; + updated_at_max?: unknown; + published_at_min?: unknown; + published_at_max?: unknown; + published_status?: unknown; + fields?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; + title?: unknown; + product_id?: unknown; + updated_at_min?: unknown; + updated_at_max?: unknown; + published_at_min?: unknown; + published_at_max?: unknown; + published_status?: unknown; +} + +export class CustomCollection extends Base { + public static API_VERSION = ApiVersion.January22; + + protected static NAME = 'custom_collection'; + protected static PLURAL_NAME = 'custom_collections'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "custom_collections.json"}, + {http_method: "post", operation: "post", ids: [], path: "custom_collections.json"}, + {http_method: "get", operation: "count", ids: [], path: "custom_collections/count.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "custom_collections/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "custom_collections/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "custom_collections/.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await CustomCollection.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as CustomCollection : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await CustomCollection.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + limit = null, + ids = null, + since_id = null, + title = null, + product_id = null, + handle = null, + updated_at_min = null, + updated_at_max = null, + published_at_min = null, + published_at_max = null, + published_status = null, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await CustomCollection.baseFind({ + session: session, + urlIds: {}, + params: {limit: limit, ids: ids, since_id: since_id, title: title, product_id: product_id, handle: handle, 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, fields: fields, ...otherArgs}, + }); + + return response as CustomCollection[]; + } + + public static async count( + { + session, + title = null, + product_id = null, + updated_at_min = null, + updated_at_max = null, + published_at_min = null, + published_at_max = null, + published_status = null, + ...otherArgs + }: CountArgs + ): Promise { + const response = await CustomCollection.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {}, + params: {title: title, product_id: product_id, 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, + }); + + return response ? response.body : null; + } + + public title: string | null; + public body_html: string | null; + public handle: string | null; + public id: number | null; + public image: string | {[key: string]: unknown} | null; + public published: boolean | null; + public published_at: string | null; + public published_scope: string | null; + public sort_order: string | null; + public template_suffix: string | null; + public updated_at: string | null; +} diff --git a/src/rest-resources/2022-01/customer.ts b/src/rest-resources/2022-01/customer.ts new file mode 100644 index 000000000..9634fb1fe --- /dev/null +++ b/src/rest-resources/2022-01/customer.ts @@ -0,0 +1,259 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Currency} from './currency'; +import {Metafield} from './metafield'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + ids?: unknown; + since_id?: unknown; + created_at_min?: unknown; + created_at_max?: unknown; + updated_at_min?: unknown; + updated_at_max?: unknown; + limit?: unknown; + fields?: unknown; +} +interface SearchArgs { + [key: string]: unknown; + session: SessionInterface; + order?: unknown; + query?: unknown; + limit?: unknown; + fields?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; +} +interface OrdersArgs { + [key: string]: unknown; + session: SessionInterface; + id: number | string; +} +interface AccountActivationUrlArgs { + [key: string]: unknown; + body?: {[key: string]: unknown} | null; +} +interface SendInviteArgs { + [key: string]: unknown; + body?: {[key: string]: unknown} | null; +} + +export class Customer extends Base { + public static API_VERSION = ApiVersion.January22; + + protected static NAME = 'customer'; + protected static PLURAL_NAME = 'customers'; + protected static HAS_ONE: {[key: string]: typeof Base} = { + currency: Currency, + metafield: Metafield + }; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "customers.json"}, + {http_method: "post", operation: "post", ids: [], path: "customers.json"}, + {http_method: "get", operation: "search", ids: [], path: "customers/search.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "customers/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "customers/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "customers/.json"}, + {http_method: "post", operation: "account_activation_url", ids: ["id"], path: "customers//account_activation_url.json"}, + {http_method: "post", operation: "send_invite", ids: ["id"], path: "customers//send_invite.json"}, + {http_method: "get", operation: "count", ids: [], path: "customers/count.json"}, + {http_method: "get", operation: "orders", ids: ["id"], path: "customers//orders.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await Customer.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as Customer : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await Customer.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + ids = null, + since_id = null, + created_at_min = null, + created_at_max = null, + updated_at_min = null, + updated_at_max = null, + limit = null, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Customer.baseFind({ + session: session, + urlIds: {}, + params: {ids: ids, since_id: since_id, created_at_min: created_at_min, created_at_max: created_at_max, updated_at_min: updated_at_min, updated_at_max: updated_at_max, limit: limit, fields: fields, ...otherArgs}, + }); + + return response as Customer[]; + } + + public static async search( + { + session, + order = null, + query = null, + limit = null, + fields = null, + ...otherArgs + }: SearchArgs + ): Promise { + const response = await Customer.request({ + http_method: "get", + operation: "search", + session: session, + urlIds: {}, + params: {order: order, query: query, limit: limit, fields: fields, ...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public static async count( + { + session, + ...otherArgs + }: CountArgs + ): Promise { + const response = await Customer.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {}, + params: {...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public static async orders( + { + session, + id, + ...otherArgs + }: OrdersArgs + ): Promise { + const response = await Customer.request({ + http_method: "get", + operation: "orders", + session: session, + urlIds: {id: id}, + params: {...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public async account_activation_url( + { + body = null, + ...otherArgs + }: AccountActivationUrlArgs + ): Promise { + const response = await Customer.request({ + http_method: "post", + operation: "account_activation_url", + session: this.session, + urlIds: {id: this.id}, + params: {...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public async send_invite( + { + body = null, + ...otherArgs + }: SendInviteArgs + ): Promise { + const response = await Customer.request({ + http_method: "post", + operation: "send_invite", + session: this.session, + urlIds: {id: this.id}, + params: {...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public accepts_marketing: boolean | null; + public accepts_marketing_updated_at: string | null; + public addresses: {[key: string]: unknown}[] | null; + public created_at: string | null; + public currency: Currency | null | {[key: string]: any}; + public default_address: {[key: string]: unknown} | null; + public email: string | null; + public first_name: string | null; + public id: number | null; + public last_name: string | null; + public last_order_id: number | null; + public last_order_name: string | null; + public marketing_opt_in_level: string | null; + public metafield: Metafield | null | {[key: string]: any}; + public multipass_identifier: string | null; + public note: string | null; + public orders_count: number | null; + public phone: string | null; + public sms_marketing_consent: {[key: string]: unknown} | null; + public state: string | null; + public tags: string | null; + public tax_exempt: boolean | null; + public tax_exemptions: string[] | null; + public total_spent: string | null; + public updated_at: string | null; + public verified_email: boolean | null; +} diff --git a/src/rest-resources/2022-01/customer_address.ts b/src/rest-resources/2022-01/customer_address.ts new file mode 100644 index 000000000..9d4479efa --- /dev/null +++ b/src/rest-resources/2022-01/customer_address.ts @@ -0,0 +1,158 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + customer_id?: number | string | null; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; + customer_id?: number | string | null; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + customer_id?: number | string | null; +} +interface SetArgs { + [key: string]: unknown; + address_ids?: unknown[] | number | string | null; + operation?: unknown; + body?: {[key: string]: unknown} | null; +} +interface DefaultArgs { + [key: string]: unknown; + body?: {[key: string]: unknown} | null; +} + +export class CustomerAddress extends Base { + public static API_VERSION = ApiVersion.January22; + + protected static NAME = 'customer_address'; + protected static PLURAL_NAME = 'customer_addresses'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: ["customer_id"], path: "customers//addresses.json"}, + {http_method: "post", operation: "post", ids: ["customer_id"], path: "customers//addresses.json"}, + {http_method: "get", operation: "get", ids: ["customer_id", "id"], path: "customers//addresses/.json"}, + {http_method: "put", operation: "put", ids: ["customer_id", "id"], path: "customers//addresses/.json"}, + {http_method: "delete", operation: "delete", ids: ["customer_id", "id"], path: "customers//addresses/.json"}, + {http_method: "put", operation: "set", ids: ["customer_id"], path: "customers//addresses/set.json"}, + {http_method: "put", operation: "default", ids: ["customer_id", "id"], path: "customers//addresses//default.json"} + ]; + + protected static getJsonBodyName(): string + { + return "address"; + } + + public static async find( + { + session, + id, + customer_id = null + }: FindArgs + ): Promise { + const result = await CustomerAddress.baseFind({ + session: session, + urlIds: {id: id, customer_id: customer_id}, + params: {}, + }); + return result ? result[0] as CustomerAddress : null; + } + + public static async delete( + { + session, + id, + customer_id = null + }: DeleteArgs + ): Promise { + const response = await CustomerAddress.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id, customer_id: customer_id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + customer_id = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await CustomerAddress.baseFind({ + session: session, + urlIds: {customer_id: customer_id}, + params: {...otherArgs}, + }); + + return response as CustomerAddress[]; + } + + public async set( + { + address_ids = null, + operation = null, + body = null, + ...otherArgs + }: SetArgs + ): Promise { + const response = await CustomerAddress.request({ + http_method: "put", + operation: "set", + session: this.session, + urlIds: {customer_id: this.customer_id}, + params: {address_ids: address_ids, operation: operation, ...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public async default( + { + body = null, + ...otherArgs + }: DefaultArgs + ): Promise { + const response = await CustomerAddress.request({ + http_method: "put", + operation: "default", + session: this.session, + urlIds: {id: this.id, customer_id: this.customer_id}, + params: {...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public address1: string | null; + public address2: string | null; + public city: string | null; + public company: string | null; + public country: string | null; + public country_code: string | null; + public country_name: string | null; + public customer_id: number | null; + public first_name: string | null; + public id: number | null; + public last_name: string | null; + public name: string | null; + public phone: string | null; + public province: string | null; + public province_code: string | null; + public zip: string | null; +} diff --git a/src/rest-resources/2022-01/customer_saved_search.ts b/src/rest-resources/2022-01/customer_saved_search.ts new file mode 100644 index 000000000..762c4d271 --- /dev/null +++ b/src/rest-resources/2022-01/customer_saved_search.ts @@ -0,0 +1,150 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + limit?: unknown; + since_id?: unknown; + fields?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; + since_id?: unknown; +} +interface CustomersArgs { + [key: string]: unknown; + session: SessionInterface; + id: number | string; + order?: unknown; + limit?: unknown; + fields?: unknown; +} + +export class CustomerSavedSearch extends Base { + public static API_VERSION = ApiVersion.January22; + + protected static NAME = 'customer_saved_search'; + protected static PLURAL_NAME = 'customer_saved_searches'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "customer_saved_searches.json"}, + {http_method: "post", operation: "post", ids: [], path: "customer_saved_searches.json"}, + {http_method: "get", operation: "count", ids: [], path: "customer_saved_searches/count.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "customer_saved_searches/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "customer_saved_searches/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "customer_saved_searches/.json"}, + {http_method: "get", operation: "customers", ids: ["id"], path: "customer_saved_searches//customers.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await CustomerSavedSearch.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as CustomerSavedSearch : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await CustomerSavedSearch.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + limit = null, + since_id = null, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await CustomerSavedSearch.baseFind({ + session: session, + urlIds: {}, + params: {limit: limit, since_id: since_id, fields: fields, ...otherArgs}, + }); + + return response as CustomerSavedSearch[]; + } + + public static async count( + { + session, + since_id = null, + ...otherArgs + }: CountArgs + ): Promise { + const response = await CustomerSavedSearch.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {}, + params: {since_id: since_id, ...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public static async customers( + { + session, + id, + order = null, + limit = null, + fields = null, + ...otherArgs + }: CustomersArgs + ): Promise { + const response = await CustomerSavedSearch.request({ + http_method: "get", + operation: "customers", + session: session, + urlIds: {id: id}, + params: {order: order, limit: limit, fields: fields, ...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public created_at: string | null; + public id: number | null; + public name: string | null; + public query: string | null; + public updated_at: string | null; +} diff --git a/src/rest-resources/2022-01/deprecated_api_call.ts b/src/rest-resources/2022-01/deprecated_api_call.ts new file mode 100644 index 000000000..23985cbad --- /dev/null +++ b/src/rest-resources/2022-01/deprecated_api_call.ts @@ -0,0 +1,38 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; +} + +export class DeprecatedApiCall extends Base { + public static API_VERSION = ApiVersion.January22; + + protected static NAME = 'deprecated_api_call'; + protected static PLURAL_NAME = 'deprecated_api_calls'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "deprecated_api_calls.json"} + ]; + + public static async all( + { + session, + ...otherArgs + }: AllArgs + ): Promise { + const response = await DeprecatedApiCall.baseFind({ + session: session, + urlIds: {}, + params: {...otherArgs}, + }); + + return response as DeprecatedApiCall[]; + } + + public data_updated_at: string | null; + public deprecated_api_calls: {[key: string]: unknown}[] | null; +} diff --git a/src/rest-resources/2022-01/discount_code.ts b/src/rest-resources/2022-01/discount_code.ts new file mode 100644 index 000000000..39473c290 --- /dev/null +++ b/src/rest-resources/2022-01/discount_code.ts @@ -0,0 +1,202 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + price_rule_id?: number | string | null; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; + price_rule_id?: number | string | null; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + price_rule_id?: number | string | null; + batch_id?: number | string | null; +} +interface LookupArgs { + [key: string]: unknown; + session: SessionInterface; + code?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; + times_used?: unknown; + times_used_min?: unknown; + times_used_max?: unknown; +} +interface GetAllArgs { + [key: string]: unknown; + session: SessionInterface; + price_rule_id?: number | string | null; + batch_id?: number | string | null; +} +interface BatchArgs { + [key: string]: unknown; + body?: {[key: string]: unknown} | null; +} + +export class DiscountCode extends Base { + public static API_VERSION = ApiVersion.January22; + + protected static NAME = 'discount_code'; + protected static PLURAL_NAME = 'discount_codes'; + 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: ["price_rule_id"], path: "price_rules//discount_codes.json"}, + {http_method: "get", operation: "get", ids: ["price_rule_id"], path: "price_rules//discount_codes.json"}, + {http_method: "put", operation: "put", ids: ["price_rule_id", "id"], path: "price_rules//discount_codes/.json"}, + {http_method: "get", operation: "get", ids: ["price_rule_id", "id"], path: "price_rules//discount_codes/.json"}, + {http_method: "delete", operation: "delete", ids: ["price_rule_id", "id"], path: "price_rules//discount_codes/.json"}, + {http_method: "get", operation: "lookup", ids: [], path: "discount_codes/lookup.json"}, + {http_method: "get", operation: "count", ids: [], path: "discount_codes/count.json"}, + {http_method: "post", operation: "batch", ids: ["price_rule_id"], path: "price_rules//batch.json"}, + {http_method: "get", operation: "get_all", ids: ["price_rule_id", "batch_id"], path: "price_rules//batch/.json"}, + {http_method: "get", operation: "get", ids: ["price_rule_id", "batch_id"], path: "price_rules//batch//discount_codes.json"} + ]; + + public static async find( + { + session, + id, + price_rule_id = null + }: FindArgs + ): Promise { + const result = await DiscountCode.baseFind({ + session: session, + urlIds: {id: id, price_rule_id: price_rule_id}, + params: {}, + }); + return result ? result[0] as DiscountCode : null; + } + + public static async delete( + { + session, + id, + price_rule_id = null + }: DeleteArgs + ): Promise { + const response = await DiscountCode.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id, price_rule_id: price_rule_id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + price_rule_id = null, + batch_id = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await DiscountCode.baseFind({ + session: session, + urlIds: {price_rule_id: price_rule_id, batch_id: batch_id}, + params: {...otherArgs}, + }); + + return response as DiscountCode[]; + } + + public static async lookup( + { + session, + code = null, + ...otherArgs + }: LookupArgs + ): Promise { + const response = await DiscountCode.request({ + http_method: "get", + operation: "lookup", + session: session, + urlIds: {}, + params: {code: code, ...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public static async count( + { + session, + times_used = null, + times_used_min = null, + times_used_max = null, + ...otherArgs + }: CountArgs + ): Promise { + const response = await DiscountCode.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {}, + params: {times_used: times_used, times_used_min: times_used_min, times_used_max: times_used_max, ...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public static async get_all( + { + session, + price_rule_id = null, + batch_id = null, + ...otherArgs + }: GetAllArgs + ): Promise { + const response = await DiscountCode.request({ + http_method: "get", + operation: "get_all", + session: session, + urlIds: {price_rule_id: price_rule_id, batch_id: batch_id}, + params: {...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public async batch( + { + body = null, + ...otherArgs + }: BatchArgs + ): Promise { + const response = await DiscountCode.request({ + http_method: "post", + operation: "batch", + session: this.session, + urlIds: {price_rule_id: this.price_rule_id}, + params: {...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public code: string | null; + public created_at: string | null; + public id: number | null; + public price_rule_id: number | null; + public updated_at: string | null; + public usage_count: number | null; +} diff --git a/src/rest-resources/2022-01/dispute.ts b/src/rest-resources/2022-01/dispute.ts new file mode 100644 index 000000000..19ae01f9f --- /dev/null +++ b/src/rest-resources/2022-01/dispute.ts @@ -0,0 +1,78 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Currency} from './currency'; + +interface FindArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + since_id?: unknown; + last_id?: unknown; + status?: unknown; + initiated_at?: unknown; +} + +export class Dispute extends Base { + public static API_VERSION = ApiVersion.January22; + + protected static NAME = 'dispute'; + protected static PLURAL_NAME = 'disputes'; + protected static HAS_ONE: {[key: string]: typeof Base} = { + currency: Currency + }; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "shopify_payments/disputes.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "shopify_payments/disputes/.json"} + ]; + + public static async find( + { + session, + id + }: FindArgs + ): Promise { + const result = await Dispute.baseFind({ + session: session, + urlIds: {id: id}, + params: {}, + }); + return result ? result[0] as Dispute : null; + } + + public static async all( + { + session, + since_id = null, + last_id = null, + status = null, + initiated_at = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Dispute.baseFind({ + session: session, + urlIds: {}, + params: {since_id: since_id, last_id: last_id, status: status, initiated_at: initiated_at, ...otherArgs}, + }); + + return response as Dispute[]; + } + + public amount: string | null; + public currency: Currency | null | {[key: string]: any}; + public evidence_due_by: string | null; + public evidence_sent_on: string | null; + public finalized_on: string | null; + public id: number | null; + public network_reason_code: number | null; + public order_id: number | null; + public reason: string | null; + public status: string | null; + public type: string | null; +} diff --git a/src/rest-resources/2022-01/draft_order.ts b/src/rest-resources/2022-01/draft_order.ts new file mode 100644 index 000000000..4020410c7 --- /dev/null +++ b/src/rest-resources/2022-01/draft_order.ts @@ -0,0 +1,211 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Customer} from './customer'; +import {Currency} from './currency'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + fields?: unknown; + limit?: unknown; + since_id?: unknown; + updated_at_min?: unknown; + updated_at_max?: unknown; + ids?: unknown; + status?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; + since_id?: unknown; + status?: unknown; + updated_at_max?: unknown; + updated_at_min?: unknown; +} +interface SendInvoiceArgs { + [key: string]: unknown; + body?: {[key: string]: unknown} | null; +} +interface CompleteArgs { + [key: string]: unknown; + payment_pending?: unknown; + body?: {[key: string]: unknown} | null; +} + +export class DraftOrder extends Base { + public static API_VERSION = ApiVersion.January22; + + protected static NAME = 'draft_order'; + protected static PLURAL_NAME = 'draft_orders'; + protected static HAS_ONE: {[key: string]: typeof Base} = { + customer: Customer, + currency: Currency + }; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "post", operation: "post", ids: [], path: "draft_orders.json"}, + {http_method: "get", operation: "get", ids: [], path: "draft_orders.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "draft_orders/.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "draft_orders/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "draft_orders/.json"}, + {http_method: "get", operation: "count", ids: [], path: "draft_orders/count.json"}, + {http_method: "post", operation: "send_invoice", ids: ["id"], path: "draft_orders//send_invoice.json"}, + {http_method: "put", operation: "complete", ids: ["id"], path: "draft_orders//complete.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await DraftOrder.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as DraftOrder : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await DraftOrder.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + fields = null, + limit = null, + since_id = null, + updated_at_min = null, + updated_at_max = null, + ids = null, + status = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await DraftOrder.baseFind({ + session: session, + urlIds: {}, + params: {fields: fields, limit: limit, since_id: since_id, updated_at_min: updated_at_min, updated_at_max: updated_at_max, ids: ids, status: status, ...otherArgs}, + }); + + return response as DraftOrder[]; + } + + public static async count( + { + session, + since_id = null, + status = null, + updated_at_max = null, + updated_at_min = null, + ...otherArgs + }: CountArgs + ): Promise { + const response = await DraftOrder.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {}, + params: {since_id: since_id, status: status, updated_at_max: updated_at_max, updated_at_min: updated_at_min, ...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public async send_invoice( + { + body = null, + ...otherArgs + }: SendInvoiceArgs + ): Promise { + const response = await DraftOrder.request({ + http_method: "post", + operation: "send_invoice", + session: this.session, + urlIds: {id: this.id}, + params: {...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public async complete( + { + payment_pending = null, + body = null, + ...otherArgs + }: CompleteArgs + ): Promise { + const response = await DraftOrder.request({ + http_method: "put", + operation: "complete", + session: this.session, + urlIds: {id: this.id}, + params: {payment_pending: payment_pending, ...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public applied_discount: {[key: string]: unknown} | null; + public billing_address: {[key: string]: unknown} | null; + public completed_at: string | null; + public created_at: string | null; + public currency: Currency | null | {[key: string]: any}; + public customer: Customer | null | {[key: string]: any}; + public email: string | null; + public id: number | null; + public invoice_sent_at: string | null; + public invoice_url: string | null; + public line_items: {[key: string]: unknown}[] | null; + public name: string | null; + public note: string | null; + public note_attributes: {[key: string]: unknown}[] | null; + public order_id: number | null; + public payment_terms: {[key: string]: unknown} | null; + public shipping_address: {[key: string]: unknown} | null; + public shipping_line: {[key: string]: unknown} | null; + public status: string | null; + public subtotal_price: number | null; + public tags: string | null; + public tax_exempt: boolean | null; + public tax_exemptions: string[] | null; + public tax_lines: {[key: string]: unknown}[] | null; + public taxes_included: boolean | null; + public total_price: string | null; + public total_tax: string | null; + public updated_at: string | null; +} diff --git a/src/rest-resources/2022-01/event.ts b/src/rest-resources/2022-01/event.ts new file mode 100644 index 000000000..d76c70a5d --- /dev/null +++ b/src/rest-resources/2022-01/event.ts @@ -0,0 +1,115 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + order_id?: number | string | null; + product_id?: number | string | null; + limit?: unknown; + since_id?: unknown; + created_at_min?: unknown; + created_at_max?: unknown; + filter?: unknown; + verb?: unknown; + fields?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; + created_at_min?: unknown; + created_at_max?: unknown; +} + +export class Event extends Base { + public static API_VERSION = ApiVersion.January22; + + protected static NAME = 'event'; + protected static PLURAL_NAME = 'events'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "events.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "events/.json"}, + {http_method: "get", operation: "count", ids: [], path: "events/count.json"}, + {http_method: "get", operation: "get", ids: ["order_id"], path: "orders//events.json"}, + {http_method: "get", operation: "get", ids: ["product_id"], path: "products//events.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await Event.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as Event : null; + } + + public static async all( + { + session, + order_id = null, + product_id = null, + limit = null, + since_id = null, + created_at_min = null, + created_at_max = null, + filter = null, + verb = null, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Event.baseFind({ + session: session, + urlIds: {order_id: order_id, product_id: product_id}, + params: {limit: limit, since_id: since_id, created_at_min: created_at_min, created_at_max: created_at_max, filter: filter, verb: verb, fields: fields, ...otherArgs}, + }); + + return response as Event[]; + } + + public static async count( + { + session, + created_at_min = null, + created_at_max = null, + ...otherArgs + }: CountArgs + ): Promise { + const response = await Event.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {}, + params: {created_at_min: created_at_min, created_at_max: created_at_max, ...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public arguments: string | null; + public body: string | null; + public created_at: string | null; + public description: string | null; + public id: number | null; + public message: string | null; + public path: string | null; + public subject_id: number | null; + public subject_type: string | null; + public verb: string | null; +} diff --git a/src/rest-resources/2022-01/fulfillment.ts b/src/rest-resources/2022-01/fulfillment.ts new file mode 100644 index 000000000..d94dc120e --- /dev/null +++ b/src/rest-resources/2022-01/fulfillment.ts @@ -0,0 +1,229 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + order_id?: number | string | null; + fields?: unknown; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + order_id?: number | string | null; + fulfillment_order_id?: number | string | null; + created_at_max?: unknown; + created_at_min?: unknown; + fields?: unknown; + limit?: unknown; + since_id?: unknown; + updated_at_max?: unknown; + updated_at_min?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; + order_id?: number | string | null; + created_at_min?: unknown; + created_at_max?: unknown; + updated_at_min?: unknown; + updated_at_max?: unknown; +} +interface UpdateTrackingArgs { + [key: string]: unknown; + body?: {[key: string]: unknown} | null; +} +interface CompleteArgs { + [key: string]: unknown; + body?: {[key: string]: unknown} | null; +} +interface OpenArgs { + [key: string]: unknown; + body?: {[key: string]: unknown} | null; +} +interface CancelArgs { + [key: string]: unknown; + body?: {[key: string]: unknown} | null; +} + +export class Fulfillment extends Base { + public static API_VERSION = ApiVersion.January22; + + protected static NAME = 'fulfillment'; + protected static PLURAL_NAME = 'fulfillments'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: ["order_id"], path: "orders//fulfillments.json"}, + {http_method: "post", operation: "post", ids: ["order_id"], path: "orders//fulfillments.json"}, + {http_method: "get", operation: "get", ids: ["fulfillment_order_id"], path: "fulfillment_orders//fulfillments.json"}, + {http_method: "get", operation: "count", ids: ["order_id"], path: "orders//fulfillments/count.json"}, + {http_method: "get", operation: "get", ids: ["order_id", "id"], path: "orders//fulfillments/.json"}, + {http_method: "put", operation: "put", ids: ["order_id", "id"], path: "orders//fulfillments/.json"}, + {http_method: "post", operation: "post", ids: [], path: "fulfillments.json"}, + {http_method: "post", operation: "update_tracking", ids: ["id"], path: "fulfillments//update_tracking.json"}, + {http_method: "post", operation: "complete", ids: ["order_id", "id"], path: "orders//fulfillments//complete.json"}, + {http_method: "post", operation: "open", ids: ["order_id", "id"], path: "orders//fulfillments//open.json"}, + {http_method: "post", operation: "cancel", ids: ["order_id", "id"], path: "orders//fulfillments//cancel.json"}, + {http_method: "post", operation: "cancel", ids: ["id"], path: "fulfillments//cancel.json"} + ]; + + public static async find( + { + session, + id, + order_id = null, + fields = null + }: FindArgs + ): Promise { + const result = await Fulfillment.baseFind({ + session: session, + urlIds: {id: id, order_id: order_id}, + params: {fields: fields}, + }); + return result ? result[0] as Fulfillment : null; + } + + public static async all( + { + session, + order_id = null, + fulfillment_order_id = null, + created_at_max = null, + created_at_min = null, + fields = null, + limit = null, + since_id = null, + updated_at_max = null, + updated_at_min = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Fulfillment.baseFind({ + session: session, + urlIds: {order_id: order_id, fulfillment_order_id: fulfillment_order_id}, + params: {created_at_max: created_at_max, created_at_min: created_at_min, fields: fields, limit: limit, since_id: since_id, updated_at_max: updated_at_max, updated_at_min: updated_at_min, ...otherArgs}, + }); + + return response as Fulfillment[]; + } + + public static async count( + { + session, + order_id = null, + created_at_min = null, + created_at_max = null, + updated_at_min = null, + updated_at_max = null, + ...otherArgs + }: CountArgs + ): Promise { + const response = await Fulfillment.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {order_id: order_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, ...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public async update_tracking( + { + body = null, + ...otherArgs + }: UpdateTrackingArgs + ): Promise { + const response = await Fulfillment.request({ + http_method: "post", + operation: "update_tracking", + session: this.session, + urlIds: {id: this.id}, + params: {...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public async complete( + { + body = null, + ...otherArgs + }: CompleteArgs + ): Promise { + const response = await Fulfillment.request({ + http_method: "post", + operation: "complete", + session: this.session, + urlIds: {id: this.id, order_id: this.order_id}, + params: {...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public async open( + { + body = null, + ...otherArgs + }: OpenArgs + ): Promise { + const response = await Fulfillment.request({ + http_method: "post", + operation: "open", + session: this.session, + urlIds: {id: this.id, order_id: this.order_id}, + params: {...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public async cancel( + { + body = null, + ...otherArgs + }: CancelArgs + ): Promise { + const response = await Fulfillment.request({ + http_method: "post", + operation: "cancel", + session: this.session, + urlIds: {id: this.id, order_id: this.order_id}, + params: {...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public created_at: string | null; + public id: number | null; + public line_items: {[key: string]: unknown}[] | null; + public location_id: number | null; + public name: string | null; + public notify_customer: boolean | null; + public order_id: number | null; + public origin_address: {[key: string]: unknown}[] | null; + public receipt: {[key: string]: unknown} | null; + public service: string | null; + public shipment_status: string | null; + public status: string | null; + public tracking_company: string | null; + public tracking_numbers: string[] | null; + public tracking_urls: string[] | null; + public updated_at: string | null; + public variant_inventory_management: string | null; +} diff --git a/src/rest-resources/2022-01/fulfillment_event.ts b/src/rest-resources/2022-01/fulfillment_event.ts new file mode 100644 index 000000000..69962608b --- /dev/null +++ b/src/rest-resources/2022-01/fulfillment_event.ts @@ -0,0 +1,120 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Country} from './country'; +import {Province} from './province'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + order_id?: number | string | null; + fulfillment_id?: number | string | null; + event_id?: unknown; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; + order_id?: number | string | null; + fulfillment_id?: number | string | null; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + order_id?: number | string | null; + fulfillment_id?: number | string | null; +} + +export class FulfillmentEvent extends Base { + public static API_VERSION = ApiVersion.January22; + + protected static NAME = 'fulfillment_event'; + protected static PLURAL_NAME = 'fulfillment_events'; + protected static HAS_ONE: {[key: string]: typeof Base} = { + country: Country, + province: Province + }; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: ["order_id", "fulfillment_id"], path: "orders//fulfillments//events.json"}, + {http_method: "post", operation: "post", ids: ["order_id", "fulfillment_id"], path: "orders//fulfillments//events.json"}, + {http_method: "get", operation: "get", ids: ["order_id", "fulfillment_id", "id"], path: "orders//fulfillments//events/.json"}, + {http_method: "delete", operation: "delete", ids: ["order_id", "fulfillment_id", "id"], path: "orders//fulfillments//events/.json"} + ]; + + protected static getJsonBodyName(): string + { + return "event"; + } + + public static async find( + { + session, + id, + order_id = null, + fulfillment_id = null, + event_id = null + }: FindArgs + ): Promise { + const result = await FulfillmentEvent.baseFind({ + session: session, + urlIds: {id: id, order_id: order_id, fulfillment_id: fulfillment_id}, + params: {event_id: event_id}, + }); + return result ? result[0] as FulfillmentEvent : null; + } + + public static async delete( + { + session, + id, + order_id = null, + fulfillment_id = null + }: DeleteArgs + ): Promise { + const response = await FulfillmentEvent.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id, order_id: order_id, fulfillment_id: fulfillment_id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + order_id = null, + fulfillment_id = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await FulfillmentEvent.baseFind({ + session: session, + urlIds: {order_id: order_id, fulfillment_id: fulfillment_id}, + params: {...otherArgs}, + }); + + return response as FulfillmentEvent[]; + } + + public address1: string | null; + public city: string | null; + public country: Country | null | {[key: string]: any}; + public created_at: string | null; + public estimated_delivery_at: string | null; + public fulfillment_id: number | null; + public happened_at: string | null; + public id: number | null; + public latitude: number | null; + public longitude: number | null; + public message: string | null; + public order_id: number | null; + public province: Province | null | {[key: string]: any}; + public shop_id: number | null; + public status: string | null; + public updated_at: string | null; + public zip: string | null; +} diff --git a/src/rest-resources/2022-01/fulfillment_order.ts b/src/rest-resources/2022-01/fulfillment_order.ts new file mode 100644 index 000000000..05783bdf8 --- /dev/null +++ b/src/rest-resources/2022-01/fulfillment_order.ts @@ -0,0 +1,250 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + order_id?: number | string | null; +} +interface CancelArgs { + [key: string]: unknown; + body?: {[key: string]: unknown} | null; +} +interface CloseArgs { + [key: string]: unknown; + message?: unknown; + body?: {[key: string]: unknown} | null; +} +interface MoveArgs { + [key: string]: unknown; + new_location_id?: unknown; + body?: {[key: string]: unknown} | null; +} +interface OpenArgs { + [key: string]: unknown; + body?: {[key: string]: unknown} | null; +} +interface RescheduleArgs { + [key: string]: unknown; + body?: {[key: string]: unknown} | null; +} +interface HoldArgs { + [key: string]: unknown; + reason?: unknown; + reason_notes?: unknown; + notify_merchant?: unknown; + body?: {[key: string]: unknown} | null; +} +interface ReleaseHoldArgs { + [key: string]: unknown; + body?: {[key: string]: unknown} | null; +} + +export class FulfillmentOrder extends Base { + public static API_VERSION = ApiVersion.January22; + + protected static NAME = 'fulfillment_order'; + protected static PLURAL_NAME = 'fulfillment_orders'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: ["order_id"], path: "orders//fulfillment_orders.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "fulfillment_orders/.json"}, + {http_method: "post", operation: "cancel", ids: ["id"], path: "fulfillment_orders//cancel.json"}, + {http_method: "post", operation: "close", ids: ["id"], path: "fulfillment_orders//close.json"}, + {http_method: "post", operation: "move", ids: ["id"], path: "fulfillment_orders//move.json"}, + {http_method: "post", operation: "open", ids: ["id"], path: "fulfillment_orders//open.json"}, + {http_method: "post", operation: "reschedule", ids: ["id"], path: "fulfillment_orders//reschedule.json"}, + {http_method: "post", operation: "hold", ids: ["id"], path: "fulfillment_orders//hold.json"}, + {http_method: "post", operation: "release_hold", ids: ["id"], path: "fulfillment_orders//release_hold.json"} + ]; + + public static async find( + { + session, + id + }: FindArgs + ): Promise { + const result = await FulfillmentOrder.baseFind({ + session: session, + urlIds: {id: id}, + params: {}, + }); + return result ? result[0] as FulfillmentOrder : null; + } + + public static async all( + { + session, + order_id = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await FulfillmentOrder.baseFind({ + session: session, + urlIds: {order_id: order_id}, + params: {...otherArgs}, + }); + + return response as FulfillmentOrder[]; + } + + public async cancel( + { + body = null, + ...otherArgs + }: CancelArgs + ): Promise { + const response = await FulfillmentOrder.request({ + http_method: "post", + operation: "cancel", + session: this.session, + urlIds: {id: this.id}, + params: {...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public async close( + { + message = null, + body = null, + ...otherArgs + }: CloseArgs + ): Promise { + const response = await FulfillmentOrder.request({ + http_method: "post", + operation: "close", + session: this.session, + urlIds: {id: this.id}, + params: {message: message, ...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public async move( + { + new_location_id = null, + body = null, + ...otherArgs + }: MoveArgs + ): Promise { + const response = await FulfillmentOrder.request({ + http_method: "post", + operation: "move", + session: this.session, + urlIds: {id: this.id}, + params: {new_location_id: new_location_id, ...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public async open( + { + body = null, + ...otherArgs + }: OpenArgs + ): Promise { + const response = await FulfillmentOrder.request({ + http_method: "post", + operation: "open", + session: this.session, + urlIds: {id: this.id}, + params: {...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public async reschedule( + { + body = null, + ...otherArgs + }: RescheduleArgs + ): Promise { + const response = await FulfillmentOrder.request({ + http_method: "post", + operation: "reschedule", + session: this.session, + urlIds: {id: this.id}, + params: {...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public async hold( + { + reason = null, + reason_notes = null, + notify_merchant = null, + body = null, + ...otherArgs + }: HoldArgs + ): Promise { + const response = await FulfillmentOrder.request({ + http_method: "post", + operation: "hold", + session: this.session, + urlIds: {id: this.id}, + params: {reason: reason, reason_notes: reason_notes, notify_merchant: notify_merchant, ...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public async release_hold( + { + body = null, + ...otherArgs + }: ReleaseHoldArgs + ): Promise { + const response = await FulfillmentOrder.request({ + http_method: "post", + operation: "release_hold", + session: this.session, + urlIds: {id: this.id}, + params: {...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public assigned_location: {[key: string]: unknown} | null; + public assigned_location_id: number | null; + public delivery_method: {[key: string]: unknown} | null; + public destination: {[key: string]: unknown} | null; + public fulfill_at: string | null; + public fulfillment_holds: {[key: string]: unknown}[] | null; + public id: number | null; + public international_duties: {[key: string]: unknown} | null; + public line_items: {[key: string]: unknown}[] | null; + public merchant_requests: {[key: string]: unknown}[] | null; + public order_id: number | null; + public request_status: string | null; + public shop_id: number | null; + public status: string | null; + public supported_actions: string[] | null; +} diff --git a/src/rest-resources/2022-01/fulfillment_request.ts b/src/rest-resources/2022-01/fulfillment_request.ts new file mode 100644 index 000000000..d8231f0e1 --- /dev/null +++ b/src/rest-resources/2022-01/fulfillment_request.ts @@ -0,0 +1,69 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {ApiVersion} from '../../base-types'; + +interface AcceptArgs { + [key: string]: unknown; + message?: unknown; + body?: {[key: string]: unknown} | null; +} +interface RejectArgs { + [key: string]: unknown; + message?: unknown; + body?: {[key: string]: unknown} | null; +} + +export class FulfillmentRequest extends Base { + public static API_VERSION = ApiVersion.January22; + + protected static NAME = 'fulfillment_request'; + protected static PLURAL_NAME = 'fulfillment_requests'; + 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_request.json"}, + {http_method: "post", operation: "accept", ids: ["fulfillment_order_id"], path: "fulfillment_orders//fulfillment_request/accept.json"}, + {http_method: "post", operation: "reject", ids: ["fulfillment_order_id"], path: "fulfillment_orders//fulfillment_request/reject.json"} + ]; + + public async accept( + { + message = null, + body = null, + ...otherArgs + }: AcceptArgs + ): Promise { + const response = await FulfillmentRequest.request({ + http_method: "post", + operation: "accept", + session: this.session, + urlIds: {fulfillment_order_id: this.fulfillment_order_id}, + params: {message: message, ...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public async reject( + { + message = null, + body = null, + ...otherArgs + }: RejectArgs + ): Promise { + const response = await FulfillmentRequest.request({ + http_method: "post", + operation: "reject", + session: this.session, + urlIds: {fulfillment_order_id: this.fulfillment_order_id}, + params: {message: message, ...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public fulfillment_order_id: number | null; +} diff --git a/src/rest-resources/2022-01/fulfillment_service.ts b/src/rest-resources/2022-01/fulfillment_service.ts new file mode 100644 index 000000000..e88b27dea --- /dev/null +++ b/src/rest-resources/2022-01/fulfillment_service.ts @@ -0,0 +1,93 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + scope?: unknown; +} + +export class FulfillmentService extends Base { + public static API_VERSION = ApiVersion.January22; + + protected static NAME = 'fulfillment_service'; + protected static PLURAL_NAME = 'fulfillment_services'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "fulfillment_services.json"}, + {http_method: "post", operation: "post", ids: [], path: "fulfillment_services.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "fulfillment_services/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "fulfillment_services/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "fulfillment_services/.json"} + ]; + + public static async find( + { + session, + id + }: FindArgs + ): Promise { + const result = await FulfillmentService.baseFind({ + session: session, + urlIds: {id: id}, + params: {}, + }); + return result ? result[0] as FulfillmentService : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await FulfillmentService.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + scope = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await FulfillmentService.baseFind({ + session: session, + urlIds: {}, + params: {scope: scope, ...otherArgs}, + }); + + return response as FulfillmentService[]; + } + + public admin_graphql_api_id: string | null; + public callback_url: string | null; + public format: string | null; + public fulfillment_orders_opt_in: boolean | null; + public handle: string | null; + public id: number | null; + public inventory_management: boolean | null; + public location_id: number | null; + public name: string | null; + public provider_id: string | null; + public requires_shipping_method: boolean | null; + public tracking_support: boolean | null; +} diff --git a/src/rest-resources/2022-01/gift_card.ts b/src/rest-resources/2022-01/gift_card.ts new file mode 100644 index 000000000..aef368cca --- /dev/null +++ b/src/rest-resources/2022-01/gift_card.ts @@ -0,0 +1,170 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Balance} from './balance'; +import {Currency} from './currency'; + +interface FindArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + status?: unknown; + limit?: unknown; + since_id?: unknown; + fields?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; + status?: unknown; +} +interface SearchArgs { + [key: string]: unknown; + session: SessionInterface; + order?: unknown; + query?: unknown; + limit?: unknown; + fields?: unknown; +} +interface DisableArgs { + [key: string]: unknown; + body?: {[key: string]: unknown} | null; +} + +export class GiftCard extends Base { + public static API_VERSION = ApiVersion.January22; + + protected static NAME = 'gift_card'; + protected static PLURAL_NAME = 'gift_cards'; + protected static HAS_ONE: {[key: string]: typeof Base} = { + balance: Balance, + currency: Currency + }; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "gift_cards.json"}, + {http_method: "post", operation: "post", ids: [], path: "gift_cards.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "gift_cards/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "gift_cards/.json"}, + {http_method: "get", operation: "count", ids: [], path: "gift_cards/count.json"}, + {http_method: "post", operation: "disable", ids: ["id"], path: "gift_cards//disable.json"}, + {http_method: "get", operation: "search", ids: [], path: "gift_cards/search.json"} + ]; + + public static async find( + { + session, + id + }: FindArgs + ): Promise { + const result = await GiftCard.baseFind({ + session: session, + urlIds: {id: id}, + params: {}, + }); + return result ? result[0] as GiftCard : null; + } + + public static async all( + { + session, + status = null, + limit = null, + since_id = null, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await GiftCard.baseFind({ + session: session, + urlIds: {}, + params: {status: status, limit: limit, since_id: since_id, fields: fields, ...otherArgs}, + }); + + return response as GiftCard[]; + } + + public static async count( + { + session, + status = null, + ...otherArgs + }: CountArgs + ): Promise { + const response = await GiftCard.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {}, + params: {status: status, ...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public static async search( + { + session, + order = null, + query = null, + limit = null, + fields = null, + ...otherArgs + }: SearchArgs + ): Promise { + const response = await GiftCard.request({ + http_method: "get", + operation: "search", + session: session, + urlIds: {}, + params: {order: order, query: query, limit: limit, fields: fields, ...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public async disable( + { + body = null, + ...otherArgs + }: DisableArgs + ): Promise { + const response = await GiftCard.request({ + http_method: "post", + operation: "disable", + session: this.session, + urlIds: {id: this.id}, + params: {...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public api_client_id: number | null; + public balance: Balance | null | {[key: string]: any}; + public code: string | null; + public created_at: string | null; + public currency: Currency | null | {[key: string]: any}; + public customer_id: number | null; + public disabled_at: string | null; + public expires_on: string | null; + public id: number | null; + public initial_value: number | null; + public last_characters: string | null; + public line_item_id: number | null; + public note: string | null; + public order_id: number | null; + public template_suffix: string | null; + public updated_at: string | null; + public user_id: number | null; +} diff --git a/src/rest-resources/2022-01/gift_card_adjustment.ts b/src/rest-resources/2022-01/gift_card_adjustment.ts new file mode 100644 index 000000000..fbc67358a --- /dev/null +++ b/src/rest-resources/2022-01/gift_card_adjustment.ts @@ -0,0 +1,77 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + gift_card_id?: number | string | null; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + gift_card_id?: number | string | null; +} + +export class GiftCardAdjustment extends Base { + public static API_VERSION = ApiVersion.January22; + + protected static NAME = 'gift_card_adjustment'; + protected static PLURAL_NAME = 'gift_card_adjustments'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: ["gift_card_id"], path: "gift_cards//adjustments.json"}, + {http_method: "post", operation: "post", ids: ["gift_card_id"], path: "gift_cards//adjustments.json"}, + {http_method: "get", operation: "get", ids: ["gift_card_id", "id"], path: "gift_cards//adjustments/9.json"} + ]; + + protected static getJsonBodyName(): string + { + return "adjustment"; + } + + public static async find( + { + session, + id, + gift_card_id = null + }: FindArgs + ): Promise { + const result = await GiftCardAdjustment.baseFind({ + session: session, + urlIds: {id: id, gift_card_id: gift_card_id}, + params: {}, + }); + return result ? result[0] as GiftCardAdjustment : null; + } + + public static async all( + { + session, + gift_card_id = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await GiftCardAdjustment.baseFind({ + session: session, + urlIds: {gift_card_id: gift_card_id}, + params: {...otherArgs}, + }); + + return response as GiftCardAdjustment[]; + } + + public amount: number | null; + public api_client_id: number | null; + public created_at: string | null; + public gift_card_id: number | null; + public id: number | null; + public note: string | null; + public number: number | null; + public order_transaction_id: number | null; + public processed_at: string | null; + public remote_transaction_ref: string | null; + public remote_transaction_url: string | null; + public user_id: number | null; +} diff --git a/src/rest-resources/2022-01/image.ts b/src/rest-resources/2022-01/image.ts new file mode 100644 index 000000000..01568a1b2 --- /dev/null +++ b/src/rest-resources/2022-01/image.ts @@ -0,0 +1,128 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + product_id?: number | string | null; + fields?: unknown; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; + product_id?: number | string | null; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + product_id?: number | string | null; + since_id?: unknown; + fields?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; + product_id?: number | string | null; + since_id?: unknown; +} + +export class Image extends Base { + public static API_VERSION = ApiVersion.January22; + + protected static NAME = 'image'; + protected static PLURAL_NAME = 'images'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: ["product_id"], path: "products//images.json"}, + {http_method: "post", operation: "post", ids: ["product_id"], path: "products//images.json"}, + {http_method: "get", operation: "count", ids: ["product_id"], path: "products//images/count.json"}, + {http_method: "get", operation: "get", ids: ["product_id", "id"], path: "products//images/.json"}, + {http_method: "put", operation: "put", ids: ["product_id", "id"], path: "products//images/.json"}, + {http_method: "delete", operation: "delete", ids: ["product_id", "id"], path: "products//images/.json"} + ]; + + public static async find( + { + session, + id, + product_id = null, + fields = null + }: FindArgs + ): Promise { + const result = await Image.baseFind({ + session: session, + urlIds: {id: id, product_id: product_id}, + params: {fields: fields}, + }); + return result ? result[0] as Image : null; + } + + public static async delete( + { + session, + id, + product_id = null + }: DeleteArgs + ): Promise { + const response = await Image.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id, product_id: product_id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + product_id = null, + since_id = null, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Image.baseFind({ + session: session, + urlIds: {product_id: product_id}, + params: {since_id: since_id, fields: fields, ...otherArgs}, + }); + + return response as Image[]; + } + + public static async count( + { + session, + product_id = null, + since_id = null, + ...otherArgs + }: CountArgs + ): Promise { + const response = await Image.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {product_id: product_id}, + params: {since_id: since_id, ...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public created_at: string | null; + public height: number | null; + public id: number | null; + public position: number | null; + public product_id: number | null; + public src: string | null; + public updated_at: string | null; + public variant_ids: number[] | null; + public width: number | null; +} diff --git a/src/rest-resources/2022-01/index.ts b/src/rest-resources/2022-01/index.ts new file mode 100644 index 000000000..ed825721a --- /dev/null +++ b/src/rest-resources/2022-01/index.ts @@ -0,0 +1,74 @@ +export {AbandonedCheckout} from './abandoned_checkout'; +export {AccessScope} from './access_scope'; +export {AndroidPayKey} from './android_pay_key'; +export {ApplePayCertificate} from './apple_pay_certificate'; +export {ApplicationCharge} from './application_charge'; +export {ApplicationCredit} from './application_credit'; +export {Article} from './article'; +export {Asset} from './asset'; +export {AssignedFulfillmentOrder} from './assigned_fulfillment_order'; +export {Balance} from './balance'; +export {Blog} from './blog'; +export {CancellationRequest} from './cancellation_request'; +export {CarrierService} from './carrier_service'; +export {Checkout} from './checkout'; +export {Collect} from './collect'; +export {Collection} from './collection'; +export {CollectionListing} from './collection_listing'; +export {Comment} from './comment'; +export {Country} from './country'; +export {Currency} from './currency'; +export {CustomCollection} from './custom_collection'; +export {Customer} from './customer'; +export {CustomerAddress} from './customer_address'; +export {CustomerSavedSearch} from './customer_saved_search'; +export {DeprecatedApiCall} from './deprecated_api_call'; +export {DiscountCode} from './discount_code'; +export {Dispute} from './dispute'; +export {DraftOrder} from './draft_order'; +export {Event} from './event'; +export {Fulfillment} from './fulfillment'; +export {FulfillmentEvent} from './fulfillment_event'; +export {FulfillmentOrder} from './fulfillment_order'; +export {FulfillmentRequest} from './fulfillment_request'; +export {FulfillmentService} from './fulfillment_service'; +export {GiftCard} from './gift_card'; +export {GiftCardAdjustment} from './gift_card_adjustment'; +export {Image} from './image'; +export {InventoryItem} from './inventory_item'; +export {InventoryLevel} from './inventory_level'; +export {Location} from './location'; +export {LocationsForMove} from './locations_for_move'; +export {MarketingEvent} from './marketing_event'; +export {Metafield} from './metafield'; +export {MobilePlatformApplication} from './mobile_platform_application'; +export {Order} from './order'; +export {OrderRisk} from './order_risk'; +export {Page} from './page'; +export {Payment} from './payment'; +export {PaymentGateway} from './payment_gateway'; +export {PaymentTransaction} from './payment_transaction'; +export {Payout} from './payout'; +export {Policy} from './policy'; +export {PriceRule} from './price_rule'; +export {Product} from './product'; +export {ProductListing} from './product_listing'; +export {ProductResourceFeedback} from './product_resource_feedback'; +export {Province} from './province'; +export {RecurringApplicationCharge} from './recurring_application_charge'; +export {Redirect} from './redirect'; +export {Refund} from './refund'; +export {Report} from './report'; +export {ResourceFeedback} from './resource_feedback'; +export {ScriptTag} from './script_tag'; +export {ShippingZone} from './shipping_zone'; +export {Shop} from './shop'; +export {SmartCollection} from './smart_collection'; +export {StorefrontAccessToken} from './storefront_access_token'; +export {TenderTransaction} from './tender_transaction'; +export {Theme} from './theme'; +export {Transaction} from './transaction'; +export {UsageCharge} from './usage_charge'; +export {User} from './user'; +export {Variant} from './variant'; +export {Webhook} from './webhook'; \ No newline at end of file diff --git a/src/rest-resources/2022-01/inventory_item.ts b/src/rest-resources/2022-01/inventory_item.ts new file mode 100644 index 000000000..a630b842a --- /dev/null +++ b/src/rest-resources/2022-01/inventory_item.ts @@ -0,0 +1,71 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + ids?: unknown; + limit?: unknown; +} + +export class InventoryItem extends Base { + public static API_VERSION = ApiVersion.January22; + + protected static NAME = 'inventory_item'; + protected static PLURAL_NAME = 'inventory_items'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "inventory_items.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "inventory_items/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "inventory_items/.json"} + ]; + + public static async find( + { + session, + id + }: FindArgs + ): Promise { + const result = await InventoryItem.baseFind({ + session: session, + urlIds: {id: id}, + params: {}, + }); + return result ? result[0] as InventoryItem : null; + } + + public static async all( + { + session, + ids = null, + limit = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await InventoryItem.baseFind({ + session: session, + urlIds: {}, + params: {ids: ids, limit: limit, ...otherArgs}, + }); + + return response as InventoryItem[]; + } + + public cost: string | null; + public country_code_of_origin: string | null; + public country_harmonized_system_codes: {[key: string]: unknown}[] | null; + public created_at: string | null; + public harmonized_system_code: number | null; + public id: number | null; + public province_code_of_origin: string | null; + public requires_shipping: boolean | null; + public sku: string | null; + public tracked: boolean | null; + public updated_at: string | null; +} diff --git a/src/rest-resources/2022-01/inventory_level.ts b/src/rest-resources/2022-01/inventory_level.ts new file mode 100644 index 000000000..7018ea533 --- /dev/null +++ b/src/rest-resources/2022-01/inventory_level.ts @@ -0,0 +1,164 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface DeleteArgs { + session: SessionInterface; + inventory_item_id?: unknown; + location_id?: unknown; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + inventory_item_ids?: unknown; + location_ids?: unknown; + limit?: unknown; + updated_at_min?: unknown; +} +interface AdjustArgs { + [key: string]: unknown; + inventory_item_id?: unknown; + location_id?: unknown; + available_adjustment?: unknown; + body?: {[key: string]: unknown} | null; +} +interface ConnectArgs { + [key: string]: unknown; + inventory_item_id?: unknown; + location_id?: unknown; + relocate_if_necessary?: unknown; + body?: {[key: string]: unknown} | null; +} +interface SetArgs { + [key: string]: unknown; + inventory_item_id?: unknown; + location_id?: unknown; + available?: unknown; + disconnect_if_necessary?: unknown; + body?: {[key: string]: unknown} | null; +} + +export class InventoryLevel extends Base { + public static API_VERSION = ApiVersion.January22; + + protected static NAME = 'inventory_level'; + protected static PLURAL_NAME = 'inventory_levels'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "inventory_levels.json"}, + {http_method: "post", operation: "adjust", ids: [], path: "inventory_levels/adjust.json"}, + {http_method: "delete", operation: "delete", ids: [], path: "inventory_levels.json"}, + {http_method: "post", operation: "connect", ids: [], path: "inventory_levels/connect.json"}, + {http_method: "post", operation: "set", ids: [], path: "inventory_levels/set.json"} + ]; + + public static async delete( + { + session, + inventory_item_id = null, + location_id = null + }: DeleteArgs + ): Promise { + const response = await InventoryLevel.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {}, + params: {inventory_item_id: inventory_item_id, location_id: location_id}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + inventory_item_ids = null, + location_ids = null, + limit = null, + updated_at_min = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await InventoryLevel.baseFind({ + session: session, + urlIds: {}, + params: {inventory_item_ids: inventory_item_ids, location_ids: location_ids, limit: limit, updated_at_min: updated_at_min, ...otherArgs}, + }); + + return response as InventoryLevel[]; + } + + public async adjust( + { + inventory_item_id = null, + location_id = null, + available_adjustment = null, + body = null, + ...otherArgs + }: AdjustArgs + ): Promise { + const response = await InventoryLevel.request({ + http_method: "post", + operation: "adjust", + session: this.session, + urlIds: {}, + params: {inventory_item_id: inventory_item_id, location_id: location_id, available_adjustment: available_adjustment, ...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public async connect( + { + inventory_item_id = null, + location_id = null, + relocate_if_necessary = null, + body = null, + ...otherArgs + }: ConnectArgs + ): Promise { + const response = await InventoryLevel.request({ + http_method: "post", + operation: "connect", + session: this.session, + urlIds: {}, + params: {inventory_item_id: inventory_item_id, location_id: location_id, relocate_if_necessary: relocate_if_necessary, ...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public async set( + { + inventory_item_id = null, + location_id = null, + available = null, + disconnect_if_necessary = null, + body = null, + ...otherArgs + }: SetArgs + ): Promise { + const response = await InventoryLevel.request({ + http_method: "post", + operation: "set", + session: this.session, + urlIds: {}, + params: {inventory_item_id: inventory_item_id, location_id: location_id, available: available, disconnect_if_necessary: disconnect_if_necessary, ...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public available: number | null; + public inventory_item_id: number | null; + public location_id: number | null; + public updated_at: string | null; +} diff --git a/src/rest-resources/2022-01/location.ts b/src/rest-resources/2022-01/location.ts new file mode 100644 index 000000000..a0a7ded51 --- /dev/null +++ b/src/rest-resources/2022-01/location.ts @@ -0,0 +1,128 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Country} from './country'; +import {Province} from './province'; + +interface FindArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; +} +interface InventoryLevelsArgs { + [key: string]: unknown; + session: SessionInterface; + id: number | string; +} + +export class Location extends Base { + public static API_VERSION = ApiVersion.January22; + + protected static NAME = 'location'; + protected static PLURAL_NAME = 'locations'; + protected static HAS_ONE: {[key: string]: typeof Base} = { + country: Country, + province: Province + }; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "locations.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "locations/.json"}, + {http_method: "get", operation: "count", ids: [], path: "locations/count.json"}, + {http_method: "get", operation: "inventory_levels", ids: ["id"], path: "locations//inventory_levels.json"} + ]; + + public static async find( + { + session, + id + }: FindArgs + ): Promise { + const result = await Location.baseFind({ + session: session, + urlIds: {id: id}, + params: {}, + }); + return result ? result[0] as Location : null; + } + + public static async all( + { + session, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Location.baseFind({ + session: session, + urlIds: {}, + params: {...otherArgs}, + }); + + return response as Location[]; + } + + public static async count( + { + session, + ...otherArgs + }: CountArgs + ): Promise { + const response = await Location.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {}, + params: {...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public static async inventory_levels( + { + session, + id, + ...otherArgs + }: InventoryLevelsArgs + ): Promise { + const response = await Location.request({ + http_method: "get", + operation: "inventory_levels", + session: session, + urlIds: {id: id}, + params: {...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public active: boolean | null; + public address1: string | null; + public address2: string | null; + public city: string | null; + public country: Country | null | {[key: string]: any}; + public country_code: string | null; + public created_at: string | null; + public id: number | null; + public legacy: boolean | null; + public localized_country_name: string | null; + public localized_province_name: string | null; + public name: string | null; + public phone: string | null; + public province: Province | null | {[key: string]: any}; + public province_code: string | null; + public updated_at: string | null; + public zip: string | null; +} diff --git a/src/rest-resources/2022-01/locations_for_move.ts b/src/rest-resources/2022-01/locations_for_move.ts new file mode 100644 index 000000000..e58cf9fa3 --- /dev/null +++ b/src/rest-resources/2022-01/locations_for_move.ts @@ -0,0 +1,39 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + fulfillment_order_id?: number | string | null; +} + +export class LocationsForMove extends Base { + public static API_VERSION = ApiVersion.January22; + + protected static NAME = 'locations_for_move'; + protected static PLURAL_NAME = 'locations_for_moves'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: ["fulfillment_order_id"], path: "fulfillment_orders//locations_for_move.json"} + ]; + + public static async all( + { + session, + fulfillment_order_id = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await LocationsForMove.baseFind({ + session: session, + urlIds: {fulfillment_order_id: fulfillment_order_id}, + params: {...otherArgs}, + }); + + return response as LocationsForMove[]; + } + + public locations_for_move: {[key: string]: unknown}[] | null; +} diff --git a/src/rest-resources/2022-01/marketing_event.ts b/src/rest-resources/2022-01/marketing_event.ts new file mode 100644 index 000000000..9bc33f0bd --- /dev/null +++ b/src/rest-resources/2022-01/marketing_event.ts @@ -0,0 +1,166 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + limit?: unknown; + offset?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; +} +interface EngagementsArgs { + [key: string]: unknown; + occurred_on?: unknown; + impressions_count?: unknown; + views_count?: unknown; + clicks_count?: unknown; + shares_count?: unknown; + favorites_count?: unknown; + comments_count?: unknown; + ad_spend?: unknown; + is_cumulative?: unknown; + body?: {[key: string]: unknown} | null; +} + +export class MarketingEvent extends Base { + public static API_VERSION = ApiVersion.January22; + + protected static NAME = 'marketing_event'; + protected static PLURAL_NAME = 'marketing_events'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "marketing_events.json"}, + {http_method: "post", operation: "post", ids: [], path: "marketing_events.json"}, + {http_method: "get", operation: "count", ids: [], path: "marketing_events/count.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "marketing_events/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "marketing_events/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "marketing_events/.json"}, + {http_method: "post", operation: "engagements", ids: ["id"], path: "marketing_events//engagements.json"} + ]; + + public static async find( + { + session, + id + }: FindArgs + ): Promise { + const result = await MarketingEvent.baseFind({ + session: session, + urlIds: {id: id}, + params: {}, + }); + return result ? result[0] as MarketingEvent : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await MarketingEvent.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + limit = null, + offset = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await MarketingEvent.baseFind({ + session: session, + urlIds: {}, + params: {limit: limit, offset: offset, ...otherArgs}, + }); + + return response as MarketingEvent[]; + } + + public static async count( + { + session, + ...otherArgs + }: CountArgs + ): Promise { + const response = await MarketingEvent.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {}, + params: {...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public async engagements( + { + occurred_on = null, + impressions_count = null, + views_count = null, + clicks_count = null, + shares_count = null, + favorites_count = null, + comments_count = null, + ad_spend = null, + is_cumulative = null, + body = null, + ...otherArgs + }: EngagementsArgs + ): Promise { + const response = await MarketingEvent.request({ + http_method: "post", + operation: "engagements", + session: this.session, + urlIds: {id: this.id}, + params: {occurred_on: occurred_on, impressions_count: impressions_count, views_count: views_count, clicks_count: clicks_count, shares_count: shares_count, favorites_count: favorites_count, comments_count: comments_count, ad_spend: ad_spend, is_cumulative: is_cumulative, ...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public event_type: string | null; + public marketing_channel: string | null; + public paid: boolean | null; + public started_at: string | null; + public UTM_parameters: {[key: string]: unknown} | null; + public budget: string | null; + public budget_type: string | null; + public currency: string | null; + public description: string | null; + public ended_at: string | null; + public id: number | null; + public manage_url: string | null; + public marketed_resources: {[key: string]: unknown}[] | null; + public preview_url: string | null; + public referring_domain: string | null; + public remote_id: string | null; + public scheduled_to_end_at: string | null; +} diff --git a/src/rest-resources/2022-01/metafield.ts b/src/rest-resources/2022-01/metafield.ts new file mode 100644 index 000000000..57c4e71c9 --- /dev/null +++ b/src/rest-resources/2022-01/metafield.ts @@ -0,0 +1,141 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + limit?: unknown; + since_id?: unknown; + created_at_min?: unknown; + created_at_max?: unknown; + updated_at_min?: unknown; + updated_at_max?: unknown; + namespace?: unknown; + key?: unknown; + type?: unknown; + value_type?: unknown; + fields?: unknown; + metafield?: {[key: string]: unknown} | null; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; +} + +export class Metafield extends Base { + public static API_VERSION = ApiVersion.January22; + + protected static NAME = 'metafield'; + protected static PLURAL_NAME = 'metafields'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "metafields.json"}, + {http_method: "post", operation: "post", ids: [], path: "metafields.json"}, + {http_method: "get", operation: "get", ids: [], path: "metafields.json"}, + {http_method: "get", operation: "count", ids: [], path: "metafields/count.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "metafields/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "metafields/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "metafields/.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await Metafield.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as Metafield : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await Metafield.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + limit = null, + since_id = null, + created_at_min = null, + created_at_max = null, + updated_at_min = null, + updated_at_max = null, + namespace = null, + key = null, + type = null, + value_type = null, + fields = null, + metafield = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Metafield.baseFind({ + session: session, + urlIds: {}, + params: {limit: limit, since_id: since_id, created_at_min: created_at_min, created_at_max: created_at_max, updated_at_min: updated_at_min, updated_at_max: updated_at_max, namespace: namespace, key: key, type: type, value_type: value_type, fields: fields, metafield: metafield, ...otherArgs}, + }); + + return response as Metafield[]; + } + + public static async count( + { + session, + ...otherArgs + }: CountArgs + ): Promise { + const response = await Metafield.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {}, + params: {...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public key: string | null; + public namespace: string | null; + public value: string | number | number | null; + public created_at: string | null; + public description: string | null; + public id: number | null; + public owner_id: number | null; + public owner_resource: string | null; + public type: string | null; + public updated_at: string | null; + public value_type: string | null; +} diff --git a/src/rest-resources/2022-01/mobile_platform_application.ts b/src/rest-resources/2022-01/mobile_platform_application.ts new file mode 100644 index 000000000..b3fd1bd2f --- /dev/null +++ b/src/rest-resources/2022-01/mobile_platform_application.ts @@ -0,0 +1,85 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; +} + +export class MobilePlatformApplication extends Base { + public static API_VERSION = ApiVersion.January22; + + protected static NAME = 'mobile_platform_application'; + protected static PLURAL_NAME = 'mobile_platform_applications'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "mobile_platform_applications.json"}, + {http_method: "post", operation: "post", ids: [], path: "mobile_platform_applications.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "mobile_platform_applications/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "mobile_platform_applications/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "mobile_platform_applications/.json"} + ]; + + public static async find( + { + session, + id + }: FindArgs + ): Promise { + const result = await MobilePlatformApplication.baseFind({ + session: session, + urlIds: {id: id}, + params: {}, + }); + return result ? result[0] as MobilePlatformApplication : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await MobilePlatformApplication.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + ...otherArgs + }: AllArgs + ): Promise { + const response = await MobilePlatformApplication.baseFind({ + session: session, + urlIds: {}, + params: {...otherArgs}, + }); + + return response as MobilePlatformApplication[]; + } + + public application_id: string | null; + public enabled_shared_webcredentials: boolean | null; + public enabled_universal_or_app_links: boolean | null; + public id: number | null; + public platform: string | null; + public sha256_cert_fingerprints: string[] | null; +} diff --git a/src/rest-resources/2022-01/order.ts b/src/rest-resources/2022-01/order.ts new file mode 100644 index 000000000..08120b2ef --- /dev/null +++ b/src/rest-resources/2022-01/order.ts @@ -0,0 +1,317 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Customer} from './customer'; +import {DiscountCode} from './discount_code'; +import {Fulfillment} from './fulfillment'; +import {Refund} from './refund'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + ids?: unknown; + limit?: unknown; + since_id?: unknown; + created_at_min?: unknown; + created_at_max?: unknown; + updated_at_min?: unknown; + updated_at_max?: unknown; + processed_at_min?: unknown; + processed_at_max?: unknown; + attribution_app_id?: unknown; + status?: unknown; + financial_status?: unknown; + fulfillment_status?: unknown; + fields?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; + created_at_min?: unknown; + created_at_max?: unknown; + updated_at_min?: unknown; + updated_at_max?: unknown; + status?: unknown; + financial_status?: unknown; + fulfillment_status?: unknown; +} +interface CloseArgs { + [key: string]: unknown; + body?: {[key: string]: unknown} | null; +} +interface OpenArgs { + [key: string]: unknown; + body?: {[key: string]: unknown} | null; +} +interface CancelArgs { + [key: string]: unknown; + amount?: unknown; + currency?: unknown; + restock?: unknown; + reason?: unknown; + email?: unknown; + refund?: unknown; + body?: {[key: string]: unknown} | null; +} + +export class Order extends Base { + public static API_VERSION = ApiVersion.January22; + + protected static NAME = 'order'; + protected static PLURAL_NAME = 'orders'; + protected static HAS_ONE: {[key: string]: typeof Base} = { + customer: Customer + }; + protected static HAS_MANY: {[key: string]: typeof Base} = { + discount_codes: DiscountCode, + fulfillments: Fulfillment, + refunds: Refund + }; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "orders.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "orders/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "orders/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "orders/.json"}, + {http_method: "get", operation: "count", ids: [], path: "orders/count.json"}, + {http_method: "post", operation: "close", ids: ["id"], path: "orders//close.json"}, + {http_method: "post", operation: "open", ids: ["id"], path: "orders//open.json"}, + {http_method: "post", operation: "cancel", ids: ["id"], path: "orders//cancel.json"}, + {http_method: "post", operation: "post", ids: [], path: "orders.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await Order.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as Order : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await Order.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + ids = null, + limit = null, + since_id = null, + created_at_min = null, + created_at_max = null, + updated_at_min = null, + updated_at_max = null, + processed_at_min = null, + processed_at_max = null, + attribution_app_id = null, + status = null, + financial_status = null, + fulfillment_status = null, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Order.baseFind({ + session: session, + urlIds: {}, + params: {ids: ids, limit: limit, since_id: since_id, created_at_min: created_at_min, created_at_max: created_at_max, updated_at_min: updated_at_min, updated_at_max: updated_at_max, processed_at_min: processed_at_min, processed_at_max: processed_at_max, attribution_app_id: attribution_app_id, status: status, financial_status: financial_status, fulfillment_status: fulfillment_status, fields: fields, ...otherArgs}, + }); + + return response as Order[]; + } + + public static async count( + { + session, + created_at_min = null, + created_at_max = null, + updated_at_min = null, + updated_at_max = null, + status = null, + financial_status = null, + fulfillment_status = null, + ...otherArgs + }: CountArgs + ): Promise { + const response = await Order.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {}, + 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, status: status, financial_status: financial_status, fulfillment_status: fulfillment_status, ...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public async close( + { + body = null, + ...otherArgs + }: CloseArgs + ): Promise { + const response = await Order.request({ + http_method: "post", + operation: "close", + session: this.session, + urlIds: {id: this.id}, + params: {...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public async open( + { + body = null, + ...otherArgs + }: OpenArgs + ): Promise { + const response = await Order.request({ + http_method: "post", + operation: "open", + session: this.session, + urlIds: {id: this.id}, + params: {...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public async cancel( + { + amount = null, + currency = null, + restock = null, + reason = null, + email = null, + refund = null, + body = null, + ...otherArgs + }: CancelArgs + ): Promise { + const response = await Order.request({ + http_method: "post", + operation: "cancel", + session: this.session, + urlIds: {id: this.id}, + params: {amount: amount, currency: currency, restock: restock, reason: reason, email: email, refund: refund, ...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public line_items: {[key: string]: unknown}[] | null; + public app_id: number | null; + public billing_address: {[key: string]: unknown} | null; + public browser_ip: string | null; + public buyer_accepts_marketing: boolean | null; + public cancel_reason: string | null; + public cancelled_at: string | null; + public cart_token: string | null; + public checkout_token: string | null; + public client_details: {[key: string]: unknown} | null; + public closed_at: string | null; + public created_at: string | null; + public currency: string | null; + public current_subtotal_price: string | null; + public current_subtotal_price_set: {[key: string]: unknown} | null; + public current_total_discounts: string | null; + public current_total_discounts_set: {[key: string]: unknown} | null; + public current_total_duties_set: {[key: string]: unknown} | null; + public current_total_price: string | null; + public current_total_price_set: {[key: string]: unknown} | null; + public current_total_tax: string | null; + public current_total_tax_set: {[key: string]: unknown} | null; + public customer: Customer | null | {[key: string]: any}; + public customer_locale: string | null; + public discount_applications: {[key: string]: unknown}[] | null; + public discount_codes: DiscountCode[] | null | {[key: string]: any}; + public email: string | null; + public estimated_taxes: boolean | null; + public financial_status: string | null; + public fulfillment_status: string | null; + public fulfillments: Fulfillment[] | null | {[key: string]: any}; + public gateway: string | null; + public id: number | null; + public landing_site: string | null; + public location_id: number | null; + public name: string | null; + public note: string | null; + public note_attributes: {[key: string]: unknown}[] | null; + public number: number | null; + public order_number: number | null; + public order_status_url: string | null; + public original_total_duties_set: {[key: string]: unknown} | null; + public payment_details: {[key: string]: unknown} | null; + public payment_gateway_names: string[] | null; + public payment_terms: {[key: string]: unknown} | null; + public phone: string | null; + public presentment_currency: string | null; + public processed_at: string | null; + public processing_method: string | null; + public referring_site: string | null; + public refunds: Refund[] | null | {[key: string]: any}; + public shipping_address: {[key: string]: unknown} | null; + public shipping_lines: {[key: string]: unknown}[] | null; + public source_name: string | null; + public subtotal_price: number | null; + public subtotal_price_set: {[key: string]: unknown} | null; + public tags: string | null; + public tax_lines: {[key: string]: unknown}[] | null; + public taxes_included: boolean | null; + public test: boolean | null; + public token: string | null; + public total_discounts: string | null; + public total_discounts_set: {[key: string]: unknown} | null; + public total_line_items_price: string | null; + public total_line_items_price_set: {[key: string]: unknown} | null; + public total_outstanding: string | null; + public total_price: string | null; + public total_price_set: {[key: string]: unknown} | null; + public total_shipping_price_set: {[key: string]: unknown} | null; + public total_tax: string | number | null; + public total_tax_set: {[key: string]: unknown} | null; + public total_tip_received: string | null; + public total_weight: number | null; + public updated_at: string | null; + public user_id: number | null; +} diff --git a/src/rest-resources/2022-01/order_risk.ts b/src/rest-resources/2022-01/order_risk.ts new file mode 100644 index 000000000..6245c5702 --- /dev/null +++ b/src/rest-resources/2022-01/order_risk.ts @@ -0,0 +1,100 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + order_id?: number | string | null; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; + order_id?: number | string | null; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + order_id?: number | string | null; +} + +export class OrderRisk extends Base { + public static API_VERSION = ApiVersion.January22; + + protected static NAME = 'order_risk'; + protected static PLURAL_NAME = 'order_risks'; + 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: ["order_id"], path: "orders//risks.json"}, + {http_method: "get", operation: "get", ids: ["order_id"], path: "orders//risks.json"}, + {http_method: "get", operation: "get", ids: ["order_id", "id"], path: "orders//risks/.json"}, + {http_method: "put", operation: "put", ids: ["order_id", "id"], path: "orders//risks/.json"}, + {http_method: "delete", operation: "delete", ids: ["order_id", "id"], path: "orders//risks/.json"} + ]; + + protected static getJsonBodyName(): string + { + return "risk"; + } + + public static async find( + { + session, + id, + order_id = null + }: FindArgs + ): Promise { + const result = await OrderRisk.baseFind({ + session: session, + urlIds: {id: id, order_id: order_id}, + params: {}, + }); + return result ? result[0] as OrderRisk : null; + } + + public static async delete( + { + session, + id, + order_id = null + }: DeleteArgs + ): Promise { + const response = await OrderRisk.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id, order_id: order_id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + order_id = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await OrderRisk.baseFind({ + session: session, + urlIds: {order_id: order_id}, + params: {...otherArgs}, + }); + + return response as OrderRisk[]; + } + + public cause_cancel: boolean | null; + public checkout_id: number | null; + public display: boolean | null; + public id: number | null; + public merchant_message: string | null; + public message: string | null; + public order_id: number | null; + public recommendation: string | null; + public score: number | null; + public source: string | null; +} diff --git a/src/rest-resources/2022-01/page.ts b/src/rest-resources/2022-01/page.ts new file mode 100644 index 000000000..5e64a9957 --- /dev/null +++ b/src/rest-resources/2022-01/page.ts @@ -0,0 +1,161 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Metafield} from './metafield'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + limit?: unknown; + since_id?: unknown; + title?: unknown; + handle?: unknown; + created_at_min?: unknown; + created_at_max?: unknown; + updated_at_min?: unknown; + updated_at_max?: unknown; + published_at_min?: unknown; + published_at_max?: unknown; + fields?: unknown; + published_status?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; + title?: unknown; + created_at_min?: unknown; + created_at_max?: unknown; + updated_at_min?: unknown; + updated_at_max?: unknown; + published_at_min?: unknown; + published_at_max?: unknown; + published_status?: unknown; +} + +export class Page extends Base { + public static API_VERSION = ApiVersion.January22; + + protected static NAME = 'page'; + protected static PLURAL_NAME = 'pages'; + protected static HAS_ONE: {[key: string]: typeof Base} = { + metafield: Metafield + }; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "pages.json"}, + {http_method: "post", operation: "post", ids: [], path: "pages.json"}, + {http_method: "get", operation: "count", ids: [], path: "pages/count.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "pages/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "pages/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "pages/.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await Page.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as Page : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await Page.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + limit = null, + since_id = null, + title = null, + handle = 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, + fields = null, + published_status = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Page.baseFind({ + session: session, + urlIds: {}, + params: {limit: limit, since_id: since_id, title: title, handle: handle, 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, fields: fields, published_status: published_status, ...otherArgs}, + }); + + return response as Page[]; + } + + public static async count( + { + session, + title = 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 + ): Promise { + const response = await Page.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {}, + params: {title: title, 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, + }); + + return response ? response.body : null; + } + + public admin_graphql_api_id: string | null; + public author: string | null; + public body_html: string | null; + public created_at: string | null; + public handle: string | null; + public id: number | null; + public metafield: Metafield | null | {[key: string]: any}; + public published_at: string | null; + public shop_id: number | null; + public template_suffix: string | null; + public title: string | null; + public updated_at: string | null; +} diff --git a/src/rest-resources/2022-01/payment.ts b/src/rest-resources/2022-01/payment.ts new file mode 100644 index 000000000..748f2fc0c --- /dev/null +++ b/src/rest-resources/2022-01/payment.ts @@ -0,0 +1,99 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Transaction} from './transaction'; +import {Checkout} from './checkout'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + checkout_id?: number | string | null; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + checkout_id?: number | string | null; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; + checkout_id?: number | string | null; +} + +export class Payment extends Base { + public static API_VERSION = ApiVersion.January22; + + protected static NAME = 'payment'; + protected static PLURAL_NAME = 'payments'; + protected static HAS_ONE: {[key: string]: typeof Base} = { + transaction: Transaction, + checkout: Checkout + }; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "post", operation: "post", ids: ["checkout_id"], path: "checkouts//payments.json"}, + {http_method: "get", operation: "get", ids: ["checkout_id"], path: "checkouts//payments.json"}, + {http_method: "get", operation: "get", ids: ["checkout_id", "id"], path: "checkouts//payments/.json"}, + {http_method: "get", operation: "count", ids: ["checkout_id"], path: "checkouts//payments/count.json"} + ]; + + public static async find( + { + session, + id, + checkout_id = null + }: FindArgs + ): Promise { + const result = await Payment.baseFind({ + session: session, + urlIds: {id: id, checkout_id: checkout_id}, + params: {}, + }); + return result ? result[0] as Payment : null; + } + + public static async all( + { + session, + checkout_id = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Payment.baseFind({ + session: session, + urlIds: {checkout_id: checkout_id}, + params: {...otherArgs}, + }); + + return response as Payment[]; + } + + public static async count( + { + session, + checkout_id = null, + ...otherArgs + }: CountArgs + ): Promise { + const response = await Payment.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {checkout_id: checkout_id}, + params: {...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public checkout: Checkout | null | {[key: string]: any}; + public credit_card: {[key: string]: unknown} | null; + public id: number | null; + public next_action: {[key: string]: unknown} | null; + public payment_processing_error_message: string | null; + public transaction: Transaction | null | {[key: string]: any}; + public unique_token: string | null; +} diff --git a/src/rest-resources/2022-01/payment_gateway.ts b/src/rest-resources/2022-01/payment_gateway.ts new file mode 100644 index 000000000..9a3eb3cc9 --- /dev/null +++ b/src/rest-resources/2022-01/payment_gateway.ts @@ -0,0 +1,96 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; +} + +export class PaymentGateway extends Base { + public static API_VERSION = ApiVersion.January22; + + protected static NAME = 'payment_gateway'; + protected static PLURAL_NAME = 'payment_gateways'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "payment_gateways.json"}, + {http_method: "post", operation: "post", ids: [], path: "payment_gateways.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "payment_gateways/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "payment_gateways/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "payment_gateways/.json"} + ]; + + public static async find( + { + session, + id + }: FindArgs + ): Promise { + const result = await PaymentGateway.baseFind({ + session: session, + urlIds: {id: id}, + params: {}, + }); + return result ? result[0] as PaymentGateway : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await PaymentGateway.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + ...otherArgs + }: AllArgs + ): Promise { + const response = await PaymentGateway.baseFind({ + session: session, + urlIds: {}, + params: {...otherArgs}, + }); + + return response as PaymentGateway[]; + } + + public attachment: string | null; + public created_at: string | null; + public credential1: string | null; + public credential2: string | null; + public credential3: string | null; + public credential4: string | null; + public disabled: boolean | null; + public enabled_card_brands: string[] | null; + public id: number | null; + public name: string | null; + public processing_method: string | null; + public provider_id: number | null; + public sandbox: boolean | null; + public service_name: string | null; + public supports_network_tokenization: boolean | null; + public type: string | null; + public updated_at: string | null; +} diff --git a/src/rest-resources/2022-01/payment_transaction.ts b/src/rest-resources/2022-01/payment_transaction.ts new file mode 100644 index 000000000..d97b4b55d --- /dev/null +++ b/src/rest-resources/2022-01/payment_transaction.ts @@ -0,0 +1,68 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Currency} from './currency'; + +interface TransactionsArgs { + [key: string]: unknown; + session: SessionInterface; + since_id?: unknown; + last_id?: unknown; + test?: unknown; + payout_id?: unknown; + payout_status?: unknown; +} + +export class PaymentTransaction extends Base { + public static API_VERSION = ApiVersion.January22; + + protected static NAME = 'payment_transaction'; + protected static PLURAL_NAME = 'payment_transactions'; + protected static HAS_ONE: {[key: string]: typeof Base} = { + currency: Currency + }; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "transactions", ids: [], path: "shopify_payments/balance/transactions.json"} + ]; + + public static async transactions( + { + session, + since_id = null, + last_id = null, + test = null, + payout_id = null, + payout_status = null, + ...otherArgs + }: TransactionsArgs + ): Promise { + const response = await PaymentTransaction.request({ + http_method: "get", + operation: "transactions", + session: session, + urlIds: {}, + params: {since_id: since_id, last_id: last_id, test: test, payout_id: payout_id, payout_status: payout_status, ...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public amount: string | null; + public currency: Currency | null | {[key: string]: any}; + public fee: string | null; + public id: number | null; + public net: string | null; + public payout_id: number | null; + public payout_status: string | null; + public processed_at: string | null; + public source_id: number | null; + public source_order_id: number | null; + public source_order_transaction_id: number | null; + public source_type: string | null; + public test: boolean | null; + public type: string | null; +} diff --git a/src/rest-resources/2022-01/payout.ts b/src/rest-resources/2022-01/payout.ts new file mode 100644 index 000000000..7fd184ee8 --- /dev/null +++ b/src/rest-resources/2022-01/payout.ts @@ -0,0 +1,76 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Currency} from './currency'; + +interface FindArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + since_id?: unknown; + last_id?: unknown; + date_min?: unknown; + date_max?: unknown; + date?: unknown; + status?: unknown; +} + +export class Payout extends Base { + public static API_VERSION = ApiVersion.January22; + + protected static NAME = 'payout'; + protected static PLURAL_NAME = 'payouts'; + protected static HAS_ONE: {[key: string]: typeof Base} = { + currency: Currency + }; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "shopify_payments/payouts.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "shopify_payments/payouts/.json"} + ]; + + public static async find( + { + session, + id + }: FindArgs + ): Promise { + const result = await Payout.baseFind({ + session: session, + urlIds: {id: id}, + params: {}, + }); + return result ? result[0] as Payout : null; + } + + public static async all( + { + session, + since_id = null, + last_id = null, + date_min = null, + date_max = null, + date = null, + status = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Payout.baseFind({ + session: session, + urlIds: {}, + params: {since_id: since_id, last_id: last_id, date_min: date_min, date_max: date_max, date: date, status: status, ...otherArgs}, + }); + + return response as Payout[]; + } + + public amount: string | null; + public currency: Currency | null | {[key: string]: any}; + public date: string | null; + public id: number | null; + public status: string | null; +} diff --git a/src/rest-resources/2022-01/policy.ts b/src/rest-resources/2022-01/policy.ts new file mode 100644 index 000000000..a3a28c547 --- /dev/null +++ b/src/rest-resources/2022-01/policy.ts @@ -0,0 +1,42 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; +} + +export class Policy extends Base { + public static API_VERSION = ApiVersion.January22; + + protected static NAME = 'policy'; + protected static PLURAL_NAME = 'policies'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "policies.json"} + ]; + + public static async all( + { + session, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Policy.baseFind({ + session: session, + urlIds: {}, + params: {...otherArgs}, + }); + + return response as Policy[]; + } + + public body: string | null; + public created_at: string | null; + public handle: string | null; + public title: string | null; + public updated_at: string | null; + public url: string | null; +} diff --git a/src/rest-resources/2022-01/price_rule.ts b/src/rest-resources/2022-01/price_rule.ts new file mode 100644 index 000000000..86216e352 --- /dev/null +++ b/src/rest-resources/2022-01/price_rule.ts @@ -0,0 +1,154 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + limit?: unknown; + since_id?: unknown; + created_at_min?: unknown; + created_at_max?: unknown; + updated_at_min?: unknown; + updated_at_max?: unknown; + starts_at_min?: unknown; + starts_at_max?: unknown; + ends_at_min?: unknown; + ends_at_max?: unknown; + times_used?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; +} + +export class PriceRule extends Base { + public static API_VERSION = ApiVersion.January22; + + protected static NAME = 'price_rule'; + protected static PLURAL_NAME = 'price_rules'; + 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: "price_rules.json"}, + {http_method: "get", operation: "get", ids: [], path: "price_rules.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "price_rules/.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "price_rules/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "price_rules/.json"}, + {http_method: "get", operation: "count", ids: [], path: "price_rules/count.json"} + ]; + + public static async find( + { + session, + id + }: FindArgs + ): Promise { + const result = await PriceRule.baseFind({ + session: session, + urlIds: {id: id}, + params: {}, + }); + return result ? result[0] as PriceRule : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await PriceRule.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + limit = null, + since_id = null, + created_at_min = null, + created_at_max = null, + updated_at_min = null, + updated_at_max = null, + starts_at_min = null, + starts_at_max = null, + ends_at_min = null, + ends_at_max = null, + times_used = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await PriceRule.baseFind({ + session: session, + urlIds: {}, + params: {limit: limit, since_id: since_id, created_at_min: created_at_min, created_at_max: created_at_max, updated_at_min: updated_at_min, updated_at_max: updated_at_max, starts_at_min: starts_at_min, starts_at_max: starts_at_max, ends_at_min: ends_at_min, ends_at_max: ends_at_max, times_used: times_used, ...otherArgs}, + }); + + return response as PriceRule[]; + } + + public static async count( + { + session, + ...otherArgs + }: CountArgs + ): Promise { + const response = await PriceRule.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {}, + params: {...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public allocation_limit: number | null; + public allocation_method: string | null; + public created_at: string | null; + public customer_selection: string | null; + public ends_at: string | null; + public entitled_collection_ids: number[] | null; + public entitled_country_ids: number[] | null; + public entitled_product_ids: number[] | null; + public entitled_variant_ids: number[] | null; + public id: number | null; + public once_per_customer: boolean | null; + public prerequisite_collection_ids: number[] | null; + public prerequisite_customer_ids: number[] | null; + public prerequisite_product_ids: number[] | null; + public prerequisite_quantity_range: {[key: string]: unknown} | null; + public prerequisite_saved_search_ids: number[] | null; + public prerequisite_shipping_price_range: {[key: string]: unknown} | null; + public prerequisite_subtotal_range: {[key: string]: unknown} | null; + public prerequisite_to_entitlement_purchase: {[key: string]: unknown} | null; + public prerequisite_to_entitlement_quantity_ratio: {[key: string]: unknown} | null; + public prerequisite_variant_ids: number[] | null; + public starts_at: string | null; + public target_selection: string | null; + public target_type: string | null; + public title: string | null; + public updated_at: string | null; + public usage_limit: number | null; + public value: string | null; + public value_type: string | null; +} diff --git a/src/rest-resources/2022-01/product.ts b/src/rest-resources/2022-01/product.ts new file mode 100644 index 000000000..b9a80582a --- /dev/null +++ b/src/rest-resources/2022-01/product.ts @@ -0,0 +1,183 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Image} from './image'; +import {Variant} from './variant'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + ids?: unknown; + limit?: unknown; + since_id?: unknown; + title?: unknown; + vendor?: unknown; + handle?: unknown; + product_type?: unknown; + status?: unknown; + collection_id?: unknown; + created_at_min?: unknown; + created_at_max?: unknown; + updated_at_min?: unknown; + updated_at_max?: unknown; + published_at_min?: unknown; + published_at_max?: unknown; + published_status?: unknown; + fields?: unknown; + presentment_currencies?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; + vendor?: unknown; + product_type?: unknown; + collection_id?: unknown; + created_at_min?: unknown; + created_at_max?: unknown; + updated_at_min?: unknown; + updated_at_max?: unknown; + published_at_min?: unknown; + published_at_max?: unknown; + published_status?: unknown; +} + +export class Product extends Base { + public static API_VERSION = ApiVersion.January22; + + protected static NAME = 'product'; + protected static PLURAL_NAME = 'products'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = { + images: Image, + variants: Variant + }; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "products.json"}, + {http_method: "post", operation: "post", ids: [], path: "products.json"}, + {http_method: "get", operation: "count", ids: [], path: "products/count.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "products/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "products/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "products/.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await Product.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as Product : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await Product.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + ids = null, + limit = null, + since_id = null, + title = null, + vendor = null, + handle = null, + product_type = null, + status = null, + collection_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, + fields = null, + presentment_currencies = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Product.baseFind({ + session: session, + urlIds: {}, + params: {ids: ids, limit: limit, since_id: since_id, title: title, vendor: vendor, handle: handle, product_type: product_type, status: status, collection_id: collection_id, 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, fields: fields, presentment_currencies: presentment_currencies, ...otherArgs}, + }); + + return response as Product[]; + } + + public static async count( + { + session, + vendor = null, + product_type = null, + collection_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 + ): Promise { + const response = await Product.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {}, + params: {vendor: vendor, product_type: product_type, collection_id: collection_id, 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, + }); + + return response ? response.body : null; + } + + public title: string | null; + public body_html: string | null; + public created_at: string | null; + public handle: string | null; + public id: number | null; + public images: Image[] | null | {[key: string]: any}; + public options: {[key: string]: unknown} | {[key: string]: unknown}[] | null; + public product_type: string | null; + public published_at: string | null; + public published_scope: string | null; + public status: string | null; + public tags: string | string[] | null; + public template_suffix: string | null; + public updated_at: string | null; + public variants: Variant[] | null | {[key: string]: any}; + public vendor: string | null; +} diff --git a/src/rest-resources/2022-01/product_listing.ts b/src/rest-resources/2022-01/product_listing.ts new file mode 100644 index 000000000..b0fabe915 --- /dev/null +++ b/src/rest-resources/2022-01/product_listing.ts @@ -0,0 +1,158 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Image} from './image'; +import {Variant} from './variant'; + +interface FindArgs { + session: SessionInterface; + product_id: number | string; +} +interface DeleteArgs { + session: SessionInterface; + product_id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + product_ids?: unknown; + limit?: unknown; + collection_id?: unknown; + updated_at_min?: unknown; + handle?: unknown; +} +interface ProductIdsArgs { + [key: string]: unknown; + session: SessionInterface; + limit?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; +} + +export class ProductListing extends Base { + public static API_VERSION = ApiVersion.January22; + + protected static NAME = 'product_listing'; + protected static PLURAL_NAME = 'product_listings'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = { + images: Image, + variants: Variant + }; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "product_listings.json"}, + {http_method: "get", operation: "product_ids", ids: [], path: "product_listings/product_ids.json"}, + {http_method: "get", operation: "count", ids: [], path: "product_listings/count.json"}, + {http_method: "get", operation: "get", ids: ["product_id"], path: "product_listings/.json"}, + {http_method: "put", operation: "put", ids: ["product_id"], path: "product_listings/.json"}, + {http_method: "delete", operation: "delete", ids: ["product_id"], path: "product_listings/.json"} + ]; + protected static PRIMARY_KEY: string = "product_id"; + + public static async find( + { + session, + product_id + }: FindArgs + ): Promise { + const result = await ProductListing.baseFind({ + session: session, + urlIds: {product_id: product_id}, + params: {}, + }); + return result ? result[0] as ProductListing : null; + } + + public static async delete( + { + session, + product_id + }: DeleteArgs + ): Promise { + const response = await ProductListing.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {product_id: product_id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + product_ids = null, + limit = null, + collection_id = null, + updated_at_min = null, + handle = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await ProductListing.baseFind({ + session: session, + urlIds: {}, + params: {product_ids: product_ids, limit: limit, collection_id: collection_id, updated_at_min: updated_at_min, handle: handle, ...otherArgs}, + }); + + return response as ProductListing[]; + } + + public static async product_ids( + { + session, + limit = null, + ...otherArgs + }: ProductIdsArgs + ): Promise { + const response = await ProductListing.request({ + http_method: "get", + operation: "product_ids", + session: session, + urlIds: {}, + params: {limit: limit, ...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public static async count( + { + session, + ...otherArgs + }: CountArgs + ): Promise { + const response = await ProductListing.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {}, + params: {...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public body_html: string | null; + public created_at: string | null; + public handle: string | null; + public images: Image[] | null | {[key: string]: any}; + public options: {[key: string]: unknown}[] | null; + public product_id: number | null; + public product_type: string | null; + public published_at: string | null; + public tags: string | null; + public title: string | null; + public updated_at: string | null; + public variants: Variant[] | null | {[key: string]: any}; + public vendor: string | null; +} diff --git a/src/rest-resources/2022-01/product_resource_feedback.ts b/src/rest-resources/2022-01/product_resource_feedback.ts new file mode 100644 index 000000000..d945333fb --- /dev/null +++ b/src/rest-resources/2022-01/product_resource_feedback.ts @@ -0,0 +1,53 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + product_id?: number | string | null; +} + +export class ProductResourceFeedback extends Base { + public static API_VERSION = ApiVersion.January22; + + protected static NAME = 'product_resource_feedback'; + protected static PLURAL_NAME = 'product_resource_feedbacks'; + 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: ["product_id"], path: "products//resource_feedback.json"}, + {http_method: "get", operation: "get", ids: ["product_id"], path: "products//resource_feedback.json"} + ]; + + protected static getJsonBodyName(): string + { + return "resource_feedback"; + } + + public static async all( + { + session, + product_id = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await ProductResourceFeedback.baseFind({ + session: session, + urlIds: {product_id: product_id}, + params: {...otherArgs}, + }); + + return response as ProductResourceFeedback[]; + } + + public created_at: string | null; + public feedback_generated_at: string | null; + public messages: string[] | null; + public product_id: number | null; + public resource_id: number | null; + public resource_type: string | null; + public resource_updated_at: string | null; + public state: string | null; + public updated_at: string | null; +} diff --git a/src/rest-resources/2022-01/province.ts b/src/rest-resources/2022-01/province.ts new file mode 100644 index 000000000..c9b78d499 --- /dev/null +++ b/src/rest-resources/2022-01/province.ts @@ -0,0 +1,101 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + country_id?: number | string | null; + fields?: unknown; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + country_id?: number | string | null; + since_id?: unknown; + fields?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; + country_id?: number | string | null; +} + +export class Province extends Base { + public static API_VERSION = ApiVersion.January22; + + protected static NAME = 'province'; + protected static PLURAL_NAME = 'provinces'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: ["country_id"], path: "countries//provinces.json"}, + {http_method: "get", operation: "count", ids: ["country_id"], path: "countries//provinces/count.json"}, + {http_method: "get", operation: "get", ids: ["country_id", "id"], path: "countries//provinces/.json"}, + {http_method: "put", operation: "put", ids: ["country_id", "id"], path: "countries//provinces/.json"} + ]; + + public static async find( + { + session, + id, + country_id = null, + fields = null + }: FindArgs + ): Promise { + const result = await Province.baseFind({ + session: session, + urlIds: {id: id, country_id: country_id}, + params: {fields: fields}, + }); + return result ? result[0] as Province : null; + } + + public static async all( + { + session, + country_id = null, + since_id = null, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Province.baseFind({ + session: session, + urlIds: {country_id: country_id}, + params: {since_id: since_id, fields: fields, ...otherArgs}, + }); + + return response as Province[]; + } + + public static async count( + { + session, + country_id = null, + ...otherArgs + }: CountArgs + ): Promise { + const response = await Province.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {country_id: country_id}, + params: {...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public code: string | null; + public country_id: number | null; + public id: number | null; + public name: string | null; + public shipping_zone_id: number | null; + public tax: number | null; + public tax_name: string | null; + public tax_percentage: number | null; + public tax_type: string | null; +} diff --git a/src/rest-resources/2022-01/recurring_application_charge.ts b/src/rest-resources/2022-01/recurring_application_charge.ts new file mode 100644 index 000000000..3e8f1d393 --- /dev/null +++ b/src/rest-resources/2022-01/recurring_application_charge.ts @@ -0,0 +1,124 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + since_id?: unknown; + fields?: unknown; +} +interface CustomizeArgs { + [key: string]: unknown; + body?: {[key: string]: unknown} | null; +} + +export class RecurringApplicationCharge extends Base { + public static API_VERSION = ApiVersion.January22; + + protected static NAME = 'recurring_application_charge'; + protected static PLURAL_NAME = 'recurring_application_charges'; + 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: "recurring_application_charges.json"}, + {http_method: "get", operation: "get", ids: [], path: "recurring_application_charges.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "recurring_application_charges/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "recurring_application_charges/.json"}, + {http_method: "put", operation: "customize", ids: ["id"], path: "recurring_application_charges//customize.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await RecurringApplicationCharge.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as RecurringApplicationCharge : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await RecurringApplicationCharge.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + since_id = null, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await RecurringApplicationCharge.baseFind({ + session: session, + urlIds: {}, + params: {since_id: since_id, fields: fields, ...otherArgs}, + }); + + return response as RecurringApplicationCharge[]; + } + + public async customize( + { + body = null, + ...otherArgs + }: CustomizeArgs + ): Promise { + const response = await RecurringApplicationCharge.request({ + http_method: "put", + operation: "customize", + session: this.session, + urlIds: {id: this.id}, + params: {...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public activated_on: string | null; + public billing_on: string | null; + public cancelled_on: string | null; + public capped_amount: string | number | null; + public confirmation_url: string | null; + public created_at: string | null; + public id: number | null; + public name: string | null; + public price: string | number | null; + public return_url: string | null; + public status: string | null; + public terms: string | null; + public test: boolean | null; + public trial_days: number | null; + public trial_ends_on: string | null; + public updated_at: string | null; +} diff --git a/src/rest-resources/2022-01/redirect.ts b/src/rest-resources/2022-01/redirect.ts new file mode 100644 index 000000000..04d1deb61 --- /dev/null +++ b/src/rest-resources/2022-01/redirect.ts @@ -0,0 +1,122 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + limit?: unknown; + since_id?: unknown; + path?: unknown; + target?: unknown; + fields?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; + path?: unknown; + target?: unknown; +} + +export class Redirect extends Base { + public static API_VERSION = ApiVersion.January22; + + protected static NAME = 'redirect'; + protected static PLURAL_NAME = 'redirects'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "redirects.json"}, + {http_method: "post", operation: "post", ids: [], path: "redirects.json"}, + {http_method: "get", operation: "count", ids: [], path: "redirects/count.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "redirects/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "redirects/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "redirects/.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await Redirect.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as Redirect : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await Redirect.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + limit = null, + since_id = null, + path = null, + target = null, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Redirect.baseFind({ + session: session, + urlIds: {}, + params: {limit: limit, since_id: since_id, path: path, target: target, fields: fields, ...otherArgs}, + }); + + return response as Redirect[]; + } + + public static async count( + { + session, + path = null, + target = null, + ...otherArgs + }: CountArgs + ): Promise { + const response = await Redirect.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {}, + params: {path: path, target: target, ...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public id: number | null; + public path: string | null; + public target: string | null; +} diff --git a/src/rest-resources/2022-01/refund.ts b/src/rest-resources/2022-01/refund.ts new file mode 100644 index 000000000..45ac5712c --- /dev/null +++ b/src/rest-resources/2022-01/refund.ts @@ -0,0 +1,116 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Transaction} from './transaction'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + order_id?: number | string | null; + fields?: unknown; + in_shop_currency?: unknown; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + order_id?: number | string | null; + limit?: unknown; + fields?: unknown; + in_shop_currency?: unknown; +} +interface CalculateArgs { + [key: string]: unknown; + shipping?: unknown; + refund_line_items?: unknown; + currency?: unknown; + body?: {[key: string]: unknown} | null; +} + +export class Refund extends Base { + public static API_VERSION = ApiVersion.January22; + + protected static NAME = 'refund'; + protected static PLURAL_NAME = 'refunds'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = { + transactions: Transaction + }; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: ["order_id"], path: "orders//refunds.json"}, + {http_method: "post", operation: "post", ids: ["order_id"], path: "orders//refunds.json"}, + {http_method: "get", operation: "get", ids: ["order_id", "id"], path: "orders//refunds/.json"}, + {http_method: "post", operation: "calculate", ids: ["order_id"], path: "orders//refunds/calculate.json"} + ]; + + public static async find( + { + session, + id, + order_id = null, + fields = null, + in_shop_currency = null + }: FindArgs + ): Promise { + const result = await Refund.baseFind({ + session: session, + urlIds: {id: id, order_id: order_id}, + params: {fields: fields, in_shop_currency: in_shop_currency}, + }); + return result ? result[0] as Refund : null; + } + + public static async all( + { + session, + order_id = null, + limit = null, + fields = null, + in_shop_currency = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Refund.baseFind({ + session: session, + urlIds: {order_id: order_id}, + params: {limit: limit, fields: fields, in_shop_currency: in_shop_currency, ...otherArgs}, + }); + + return response as Refund[]; + } + + public async calculate( + { + shipping = null, + refund_line_items = null, + currency = null, + body = null, + ...otherArgs + }: CalculateArgs + ): Promise { + const response = await Refund.request({ + http_method: "post", + operation: "calculate", + session: this.session, + urlIds: {order_id: this.order_id}, + params: {shipping: shipping, refund_line_items: refund_line_items, currency: currency, ...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public created_at: string | null; + public duties: {[key: string]: unknown}[] | null; + public id: number | null; + public note: string | null; + public order_adjustments: {[key: string]: unknown}[] | null; + public order_id: number | null; + public processed_at: string | null; + public refund_duties: {[key: string]: unknown}[] | null; + public refund_line_items: {[key: string]: unknown}[] | null; + public restock: boolean | null; + public transactions: Transaction[] | null | {[key: string]: any}; + public user_id: number | null; +} diff --git a/src/rest-resources/2022-01/report.ts b/src/rest-resources/2022-01/report.ts new file mode 100644 index 000000000..bfb65b33a --- /dev/null +++ b/src/rest-resources/2022-01/report.ts @@ -0,0 +1,98 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + ids?: unknown; + limit?: unknown; + since_id?: unknown; + updated_at_min?: unknown; + updated_at_max?: unknown; + fields?: unknown; +} + +export class Report extends Base { + public static API_VERSION = ApiVersion.January22; + + protected static NAME = 'report'; + protected static PLURAL_NAME = 'reports'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "reports.json"}, + {http_method: "post", operation: "post", ids: [], path: "reports.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "reports/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "reports/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "reports/.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await Report.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as Report : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await Report.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + ids = null, + limit = null, + since_id = null, + updated_at_min = null, + updated_at_max = null, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Report.baseFind({ + session: session, + urlIds: {}, + params: {ids: ids, limit: limit, since_id: since_id, updated_at_min: updated_at_min, updated_at_max: updated_at_max, fields: fields, ...otherArgs}, + }); + + return response as Report[]; + } + + public category: string | null; + public id: number | null; + public name: string | null; + public shopify_ql: string | null; + public updated_at: string | null; +} diff --git a/src/rest-resources/2022-01/resource_feedback.ts b/src/rest-resources/2022-01/resource_feedback.ts new file mode 100644 index 000000000..2b3e9ab6f --- /dev/null +++ b/src/rest-resources/2022-01/resource_feedback.ts @@ -0,0 +1,44 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; +} + +export class ResourceFeedback extends Base { + public static API_VERSION = ApiVersion.January22; + + protected static NAME = 'resource_feedback'; + protected static PLURAL_NAME = 'resource_feedbacks'; + 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: "resource_feedback.json"}, + {http_method: "get", operation: "get", ids: [], path: "resource_feedback.json"} + ]; + + public static async all( + { + session, + ...otherArgs + }: AllArgs + ): Promise { + const response = await ResourceFeedback.baseFind({ + session: session, + urlIds: {}, + params: {...otherArgs}, + }); + + return response as ResourceFeedback[]; + } + + public created_at: string | null; + public feedback_generated_at: string | null; + public messages: string[] | null; + public resource_id: number | null; + public resource_type: string | null; + public state: string | null; + public updated_at: string | null; +} diff --git a/src/rest-resources/2022-01/script_tag.ts b/src/rest-resources/2022-01/script_tag.ts new file mode 100644 index 000000000..a756724e6 --- /dev/null +++ b/src/rest-resources/2022-01/script_tag.ts @@ -0,0 +1,130 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + limit?: unknown; + since_id?: unknown; + created_at_min?: unknown; + created_at_max?: unknown; + updated_at_min?: unknown; + updated_at_max?: unknown; + src?: unknown; + fields?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; + src?: unknown; +} + +export class ScriptTag extends Base { + public static API_VERSION = ApiVersion.January22; + + protected static NAME = 'script_tag'; + protected static PLURAL_NAME = 'script_tags'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "script_tags.json"}, + {http_method: "post", operation: "post", ids: [], path: "script_tags.json"}, + {http_method: "get", operation: "count", ids: [], path: "script_tags/count.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "script_tags/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "script_tags/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "script_tags/.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await ScriptTag.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as ScriptTag : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await ScriptTag.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + limit = null, + since_id = null, + created_at_min = null, + created_at_max = null, + updated_at_min = null, + updated_at_max = null, + src = null, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await ScriptTag.baseFind({ + session: session, + urlIds: {}, + params: {limit: limit, since_id: since_id, created_at_min: created_at_min, created_at_max: created_at_max, updated_at_min: updated_at_min, updated_at_max: updated_at_max, src: src, fields: fields, ...otherArgs}, + }); + + return response as ScriptTag[]; + } + + public static async count( + { + session, + src = null, + ...otherArgs + }: CountArgs + ): Promise { + const response = await ScriptTag.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {}, + params: {src: src, ...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public event: string | null; + public src: string | null; + public cache: boolean | null; + public created_at: string | null; + public display_scope: string | null; + public id: number | null; + public updated_at: string | null; +} diff --git a/src/rest-resources/2022-01/shipping_zone.ts b/src/rest-resources/2022-01/shipping_zone.ts new file mode 100644 index 000000000..45d13ac7d --- /dev/null +++ b/src/rest-resources/2022-01/shipping_zone.ts @@ -0,0 +1,53 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Country} from './country'; +import {Province} from './province'; + +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + fields?: unknown; +} + +export class ShippingZone extends Base { + public static API_VERSION = ApiVersion.January22; + + protected static NAME = 'shipping_zone'; + protected static PLURAL_NAME = 'shipping_zones'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = { + countries: Country, + provinces: Province + }; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "shipping_zones.json"} + ]; + + public static async all( + { + session, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await ShippingZone.baseFind({ + session: session, + urlIds: {}, + params: {fields: fields, ...otherArgs}, + }); + + return response as ShippingZone[]; + } + + public carrier_shipping_rate_providers: unknown | null; + public countries: Country[] | null | {[key: string]: any}; + public id: number | null; + public location_group_id: number | null; + public name: string | null; + public price_based_shipping_rates: {[key: string]: unknown} | null; + public profile_id: number | null; + public provinces: Province[] | null | {[key: string]: any}; + public weight_based_shipping_rates: {[key: string]: unknown} | null; +} diff --git a/src/rest-resources/2022-01/shop.ts b/src/rest-resources/2022-01/shop.ts new file mode 100644 index 000000000..531900a24 --- /dev/null +++ b/src/rest-resources/2022-01/shop.ts @@ -0,0 +1,100 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Country} from './country'; +import {Currency} from './currency'; +import {Province} from './province'; + +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + fields?: unknown; +} + +export class Shop extends Base { + public static API_VERSION = ApiVersion.January22; + + protected static NAME = 'shop'; + protected static PLURAL_NAME = 'shops'; + protected static HAS_ONE: {[key: string]: typeof Base} = { + country: Country, + currency: Currency, + province: Province + }; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "shop.json"} + ]; + + public static async all( + { + session, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Shop.baseFind({ + session: session, + urlIds: {}, + params: {fields: fields, ...otherArgs}, + }); + + return response as Shop[]; + } + + public address1: string | null; + public address2: string | null; + public checkout_api_supported: boolean | null; + public city: string | null; + public cookie_consent_level: string | null; + public country: Country | null | {[key: string]: any}; + public country_code: string | null; + public country_name: string | null; + public county_taxes: string | null; + public created_at: string | null; + public currency: Currency | null | {[key: string]: any}; + public customer_email: string | null; + public domain: string | null; + public eligible_for_card_reader_giveaway: boolean | null; + public eligible_for_payments: boolean | null; + public email: string | null; + public enabled_presentment_currencies: string[] | null; + public finances: boolean | null; + public force_ssl: boolean | null; + public google_apps_domain: string | null; + public google_apps_login_enabled: string | null; + public has_discounts: boolean | null; + public has_gift_cards: boolean | null; + public has_storefront: boolean | null; + public iana_timezone: string | null; + public id: number | null; + public latitude: number | null; + public longitude: number | null; + public money_format: string | null; + public money_in_emails_format: string | null; + public money_with_currency_format: string | null; + public money_with_currency_in_emails_format: string | null; + public multi_location_enabled: boolean | null; + public myshopify_domain: string | null; + public name: string | null; + public password_enabled: boolean | null; + public phone: string | null; + public plan_display_name: string | null; + public plan_name: string | null; + public pre_launch_enabled: boolean | null; + public primary_locale: string | null; + public primary_location_id: number | null; + public province: Province | null | {[key: string]: any}; + public province_code: string | null; + public requires_extra_payments_agreement: boolean | null; + public setup_required: boolean | null; + public shop_owner: string | null; + public source: string | null; + public tax_shipping: string | null; + public taxes_included: string | null; + public timezone: string | null; + public updated_at: string | null; + public weight_unit: string | null; + public zip: string | null; +} diff --git a/src/rest-resources/2022-01/smart_collection.ts b/src/rest-resources/2022-01/smart_collection.ts new file mode 100644 index 000000000..d2d134534 --- /dev/null +++ b/src/rest-resources/2022-01/smart_collection.ts @@ -0,0 +1,183 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + limit?: unknown; + ids?: unknown; + since_id?: unknown; + title?: unknown; + product_id?: unknown; + handle?: unknown; + updated_at_min?: unknown; + updated_at_max?: unknown; + published_at_min?: unknown; + published_at_max?: unknown; + published_status?: unknown; + fields?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; + title?: unknown; + product_id?: unknown; + updated_at_min?: unknown; + updated_at_max?: unknown; + published_at_min?: unknown; + published_at_max?: unknown; + published_status?: unknown; +} +interface OrderArgs { + [key: string]: unknown; + products?: unknown; + sort_order?: unknown; + body?: {[key: string]: unknown} | null; +} + +export class SmartCollection extends Base { + public static API_VERSION = ApiVersion.January22; + + protected static NAME = 'smart_collection'; + protected static PLURAL_NAME = 'smart_collections'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "smart_collections.json"}, + {http_method: "post", operation: "post", ids: [], path: "smart_collections.json"}, + {http_method: "get", operation: "count", ids: [], path: "smart_collections/count.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "smart_collections/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "smart_collections/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "smart_collections/.json"}, + {http_method: "put", operation: "order", ids: ["id"], path: "smart_collections//order.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await SmartCollection.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as SmartCollection : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await SmartCollection.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + limit = null, + ids = null, + since_id = null, + title = null, + product_id = null, + handle = null, + updated_at_min = null, + updated_at_max = null, + published_at_min = null, + published_at_max = null, + published_status = null, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await SmartCollection.baseFind({ + session: session, + urlIds: {}, + params: {limit: limit, ids: ids, since_id: since_id, title: title, product_id: product_id, handle: handle, 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, fields: fields, ...otherArgs}, + }); + + return response as SmartCollection[]; + } + + public static async count( + { + session, + title = null, + product_id = null, + updated_at_min = null, + updated_at_max = null, + published_at_min = null, + published_at_max = null, + published_status = null, + ...otherArgs + }: CountArgs + ): Promise { + const response = await SmartCollection.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {}, + params: {title: title, product_id: product_id, 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, + }); + + return response ? response.body : null; + } + + public async order( + { + products = null, + sort_order = null, + body = null, + ...otherArgs + }: OrderArgs + ): Promise { + const response = await SmartCollection.request({ + http_method: "put", + operation: "order", + session: this.session, + urlIds: {id: this.id}, + params: {products: products, sort_order: sort_order, ...otherArgs}, + body: body, + entity: this, + }); + + return response ? response.body : null; + } + + public rules: {[key: string]: unknown} | {[key: string]: unknown}[] | null; + public title: string | null; + public body_html: string | null; + public disjunctive: boolean | null; + public handle: string | null; + public id: number | null; + public image: string | {[key: string]: unknown} | null; + public published_at: string | null; + public published_scope: string | null; + public sort_order: string | null; + public template_suffix: string | null; + public updated_at: string | null; +} diff --git a/src/rest-resources/2022-01/storefront_access_token.ts b/src/rest-resources/2022-01/storefront_access_token.ts new file mode 100644 index 000000000..f49f4b7f1 --- /dev/null +++ b/src/rest-resources/2022-01/storefront_access_token.ts @@ -0,0 +1,68 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {AccessScope} from './access_scope'; + +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; +} + +export class StorefrontAccessToken extends Base { + public static API_VERSION = ApiVersion.January22; + + protected static NAME = 'storefront_access_token'; + protected static PLURAL_NAME = 'storefront_access_tokens'; + protected static HAS_ONE: {[key: string]: typeof Base} = { + access_scope: AccessScope + }; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "post", operation: "post", ids: [], path: "storefront_access_tokens.json"}, + {http_method: "get", operation: "get", ids: [], path: "storefront_access_tokens.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "storefront_access_tokens/.json"} + ]; + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await StorefrontAccessToken.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + ...otherArgs + }: AllArgs + ): Promise { + const response = await StorefrontAccessToken.baseFind({ + session: session, + urlIds: {}, + params: {...otherArgs}, + }); + + return response as StorefrontAccessToken[]; + } + + public title: string | null; + public access_scope: AccessScope | null | {[key: string]: any}; + public access_token: string | null; + public created_at: string | null; + public id: number | null; +} diff --git a/src/rest-resources/2022-01/tender_transaction.ts b/src/rest-resources/2022-01/tender_transaction.ts new file mode 100644 index 000000000..fecb79c96 --- /dev/null +++ b/src/rest-resources/2022-01/tender_transaction.ts @@ -0,0 +1,62 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +import {Currency} from './currency'; + +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + limit?: unknown; + since_id?: unknown; + processed_at_min?: unknown; + processed_at_max?: unknown; + processed_at?: unknown; + order?: unknown; +} + +export class TenderTransaction extends Base { + public static API_VERSION = ApiVersion.January22; + + protected static NAME = 'tender_transaction'; + protected static PLURAL_NAME = 'tender_transactions'; + protected static HAS_ONE: {[key: string]: typeof Base} = { + currency: Currency + }; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "tender_transactions.json"} + ]; + + public static async all( + { + session, + limit = null, + since_id = null, + processed_at_min = null, + processed_at_max = null, + processed_at = null, + order = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await TenderTransaction.baseFind({ + session: session, + urlIds: {}, + params: {limit: limit, since_id: since_id, processed_at_min: processed_at_min, processed_at_max: processed_at_max, processed_at: processed_at, order: order, ...otherArgs}, + }); + + return response as TenderTransaction[]; + } + + public amount: string | null; + public currency: Currency | null | {[key: string]: any}; + public id: number | null; + public order_id: number | null; + public payment_details: {[key: string]: unknown} | null; + public payment_method: string | null; + public processed_at: string | null; + public remote_reference: string | null; + public test: boolean | null; + public user_id: number | null; +} diff --git a/src/rest-resources/2022-01/theme.ts b/src/rest-resources/2022-01/theme.ts new file mode 100644 index 000000000..c39b7f0c3 --- /dev/null +++ b/src/rest-resources/2022-01/theme.ts @@ -0,0 +1,91 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + fields?: unknown; +} + +export class Theme extends Base { + public static API_VERSION = ApiVersion.January22; + + protected static NAME = 'theme'; + protected static PLURAL_NAME = 'themes'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "themes.json"}, + {http_method: "post", operation: "post", ids: [], path: "themes.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "themes/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "themes/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "themes/.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await Theme.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as Theme : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await Theme.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Theme.baseFind({ + session: session, + urlIds: {}, + params: {fields: fields, ...otherArgs}, + }); + + return response as Theme[]; + } + + public created_at: string | null; + public id: number | null; + public name: string | null; + public previewable: boolean | null; + public processing: boolean | null; + public role: string | null; + public theme_store_id: number | null; + public updated_at: string | null; +} diff --git a/src/rest-resources/2022-01/transaction.ts b/src/rest-resources/2022-01/transaction.ts new file mode 100644 index 000000000..d6d3ef91d --- /dev/null +++ b/src/rest-resources/2022-01/transaction.ts @@ -0,0 +1,120 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + order_id?: number | string | null; + fields?: unknown; + in_shop_currency?: unknown; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + order_id?: number | string | null; + since_id?: unknown; + fields?: unknown; + in_shop_currency?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; + order_id?: number | string | null; +} + +export class Transaction extends Base { + public static API_VERSION = ApiVersion.January22; + + protected static NAME = 'transaction'; + protected static PLURAL_NAME = 'transactions'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: ["order_id"], path: "orders//transactions.json"}, + {http_method: "post", operation: "post", ids: ["order_id"], path: "orders//transactions.json"}, + {http_method: "get", operation: "count", ids: ["order_id"], path: "orders//transactions/count.json"}, + {http_method: "get", operation: "get", ids: ["order_id", "id"], path: "orders//transactions/.json"} + ]; + + public static async find( + { + session, + id, + order_id = null, + fields = null, + in_shop_currency = null + }: FindArgs + ): Promise { + const result = await Transaction.baseFind({ + session: session, + urlIds: {id: id, order_id: order_id}, + params: {fields: fields, in_shop_currency: in_shop_currency}, + }); + return result ? result[0] as Transaction : null; + } + + public static async all( + { + session, + order_id = null, + since_id = null, + fields = null, + in_shop_currency = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Transaction.baseFind({ + session: session, + urlIds: {order_id: order_id}, + params: {since_id: since_id, fields: fields, in_shop_currency: in_shop_currency, ...otherArgs}, + }); + + return response as Transaction[]; + } + + public static async count( + { + session, + order_id = null, + ...otherArgs + }: CountArgs + ): Promise { + const response = await Transaction.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {order_id: order_id}, + params: {...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public kind: string | null; + public amount: string | null; + public authorization: string | null; + public authorization_expires_at: string | null; + public created_at: string | null; + public currency: string | null; + public currency_exchange_adjustment: {[key: string]: unknown} | null; + public device_id: number | null; + public error_code: string | null; + public extended_authorization_attributes: {[key: string]: unknown} | null; + public gateway: string | null; + public id: number | null; + public location_id: number | null; + public message: string | null; + public order_id: number | null; + public parent_id: number | null; + public payment_details: {[key: string]: unknown} | null; + public payments_refund_attributes: {[key: string]: unknown} | null; + public processed_at: string | null; + public receipt: {[key: string]: unknown} | null; + public source_name: string | null; + public status: string | null; + public test: boolean | null; + public user_id: number | null; +} diff --git a/src/rest-resources/2022-01/usage_charge.ts b/src/rest-resources/2022-01/usage_charge.ts new file mode 100644 index 000000000..5b15338f8 --- /dev/null +++ b/src/rest-resources/2022-01/usage_charge.ts @@ -0,0 +1,70 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + recurring_application_charge_id?: number | string | null; + fields?: unknown; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + recurring_application_charge_id?: number | string | null; + fields?: unknown; +} + +export class UsageCharge extends Base { + public static API_VERSION = ApiVersion.January22; + + protected static NAME = 'usage_charge'; + protected static PLURAL_NAME = 'usage_charges'; + 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: ["recurring_application_charge_id"], path: "recurring_application_charges//usage_charges.json"}, + {http_method: "get", operation: "get", ids: ["recurring_application_charge_id"], path: "recurring_application_charges//usage_charges.json"}, + {http_method: "get", operation: "get", ids: ["recurring_application_charge_id", "id"], path: "recurring_application_charges//usage_charges/.json"} + ]; + + public static async find( + { + session, + id, + recurring_application_charge_id = null, + fields = null + }: FindArgs + ): Promise { + const result = await UsageCharge.baseFind({ + session: session, + urlIds: {id: id, recurring_application_charge_id: recurring_application_charge_id}, + params: {fields: fields}, + }); + return result ? result[0] as UsageCharge : null; + } + + public static async all( + { + session, + recurring_application_charge_id = null, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await UsageCharge.baseFind({ + session: session, + urlIds: {recurring_application_charge_id: recurring_application_charge_id}, + params: {fields: fields, ...otherArgs}, + }); + + return response as UsageCharge[]; + } + + public created_at: string | null; + public description: string | null; + public id: number | null; + public price: number | null; + public recurring_application_charge_id: number | null; + public updated_at: string | null; +} diff --git a/src/rest-resources/2022-01/user.ts b/src/rest-resources/2022-01/user.ts new file mode 100644 index 000000000..b3b422b57 --- /dev/null +++ b/src/rest-resources/2022-01/user.ts @@ -0,0 +1,97 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + limit?: unknown; + page_info?: unknown; +} +interface CurrentArgs { + [key: string]: unknown; + session: SessionInterface; +} + +export class User extends Base { + public static API_VERSION = ApiVersion.January22; + + protected static NAME = 'user'; + protected static PLURAL_NAME = 'users'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "users.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "users/.json"}, + {http_method: "get", operation: "current", ids: [], path: "users/current.json"} + ]; + + public static async find( + { + session, + id + }: FindArgs + ): Promise { + const result = await User.baseFind({ + session: session, + urlIds: {id: id}, + params: {}, + }); + return result ? result[0] as User : null; + } + + public static async all( + { + session, + limit = null, + page_info = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await User.baseFind({ + session: session, + urlIds: {}, + params: {limit: limit, page_info: page_info, ...otherArgs}, + }); + + return response as User[]; + } + + public static async current( + { + session, + ...otherArgs + }: CurrentArgs + ): Promise { + const response = await User.request({ + http_method: "get", + operation: "current", + session: session, + urlIds: {}, + params: {...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public account_owner: boolean | null; + public bio: string | null; + public email: string | null; + public first_name: string | null; + public id: number | null; + public im: string | null; + public last_name: string | null; + public locale: string | null; + public permissions: string[] | null; + public phone: string | null; + public receive_announcements: number | null; + public screen_name: string | null; + public url: string | null; + public user_type: string | null; +} diff --git a/src/rest-resources/2022-01/variant.ts b/src/rest-resources/2022-01/variant.ts new file mode 100644 index 000000000..a1a12a251 --- /dev/null +++ b/src/rest-resources/2022-01/variant.ts @@ -0,0 +1,145 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; + product_id?: number | string | null; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + product_id?: number | string | null; + limit?: unknown; + presentment_currencies?: unknown; + since_id?: unknown; + fields?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; + product_id?: number | string | null; +} + +export class Variant extends Base { + public static API_VERSION = ApiVersion.January22; + + protected static NAME = 'variant'; + protected static PLURAL_NAME = 'variants'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: ["product_id"], path: "products//variants.json"}, + {http_method: "get", operation: "count", ids: ["product_id"], path: "products//variants/count.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "variants/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "variants/.json"}, + {http_method: "post", operation: "post", ids: ["product_id"], path: "products//variants.json"}, + {http_method: "delete", operation: "delete", ids: ["product_id", "id"], path: "products//variants/.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await Variant.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as Variant : null; + } + + public static async delete( + { + session, + id, + product_id = null + }: DeleteArgs + ): Promise { + const response = await Variant.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id, product_id: product_id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + product_id = null, + limit = null, + presentment_currencies = null, + since_id = null, + fields = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Variant.baseFind({ + session: session, + urlIds: {product_id: product_id}, + params: {limit: limit, presentment_currencies: presentment_currencies, since_id: since_id, fields: fields, ...otherArgs}, + }); + + return response as Variant[]; + } + + public static async count( + { + session, + product_id = null, + ...otherArgs + }: CountArgs + ): Promise { + const response = await Variant.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {product_id: product_id}, + params: {...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public barcode: string | null; + public compare_at_price: string | null; + public created_at: string | null; + public fulfillment_service: string | null; + public grams: number | null; + public id: number | null; + public image_id: number | null; + public inventory_item_id: number | null; + public inventory_management: string | null; + public inventory_policy: string | null; + public inventory_quantity: number | null; + public inventory_quantity_adjustment: number | null; + public old_inventory_quantity: number | null; + public option: {[key: string]: unknown} | null; + public position: number | null; + public presentment_prices: {[key: string]: unknown}[] | null; + public price: string | null; + public product_id: number | null; + public requires_shipping: boolean | null; + public sku: string | null; + public tax_code: string | null; + public taxable: boolean | null; + public title: string | null; + public updated_at: string | null; + public weight: number | null; + public weight_unit: string | null; +} diff --git a/src/rest-resources/2022-01/webhook.ts b/src/rest-resources/2022-01/webhook.ts new file mode 100644 index 000000000..544dc2029 --- /dev/null +++ b/src/rest-resources/2022-01/webhook.ts @@ -0,0 +1,137 @@ +import Base, {ResourcePath} from '../../base-rest-resource'; +import {SessionInterface} from '../../auth/session/types'; +import {ApiVersion} from '../../base-types'; + +interface FindArgs { + session: SessionInterface; + id: number | string; + fields?: unknown; +} +interface DeleteArgs { + session: SessionInterface; + id: number | string; +} +interface AllArgs { + [key: string]: unknown; + session: SessionInterface; + address?: unknown; + created_at_max?: unknown; + created_at_min?: unknown; + fields?: unknown; + limit?: unknown; + since_id?: unknown; + topic?: unknown; + updated_at_min?: unknown; + updated_at_max?: unknown; +} +interface CountArgs { + [key: string]: unknown; + session: SessionInterface; + address?: unknown; + topic?: unknown; +} + +export class Webhook extends Base { + public static API_VERSION = ApiVersion.January22; + + protected static NAME = 'webhook'; + protected static PLURAL_NAME = 'webhooks'; + protected static HAS_ONE: {[key: string]: typeof Base} = {}; + protected static HAS_MANY: {[key: string]: typeof Base} = {}; + protected static PATHS: ResourcePath[] = [ + {http_method: "get", operation: "get", ids: [], path: "webhooks.json"}, + {http_method: "post", operation: "post", ids: [], path: "webhooks.json"}, + {http_method: "get", operation: "count", ids: [], path: "webhooks/count.json"}, + {http_method: "get", operation: "get", ids: ["id"], path: "webhooks/.json"}, + {http_method: "put", operation: "put", ids: ["id"], path: "webhooks/.json"}, + {http_method: "delete", operation: "delete", ids: ["id"], path: "webhooks/.json"} + ]; + + public static async find( + { + session, + id, + fields = null + }: FindArgs + ): Promise { + const result = await Webhook.baseFind({ + session: session, + urlIds: {id: id}, + params: {fields: fields}, + }); + return result ? result[0] as Webhook : null; + } + + public static async delete( + { + session, + id + }: DeleteArgs + ): Promise { + const response = await Webhook.request({ + http_method: "delete", + operation: "delete", + session: session, + urlIds: {id: id}, + params: {}, + }); + + return response ? response.body : null; + } + + public static async all( + { + session, + address = null, + created_at_max = null, + created_at_min = null, + fields = null, + limit = null, + since_id = null, + topic = null, + updated_at_min = null, + updated_at_max = null, + ...otherArgs + }: AllArgs + ): Promise { + const response = await Webhook.baseFind({ + session: session, + urlIds: {}, + params: {address: address, created_at_max: created_at_max, created_at_min: created_at_min, fields: fields, limit: limit, since_id: since_id, topic: topic, updated_at_min: updated_at_min, updated_at_max: updated_at_max, ...otherArgs}, + }); + + return response as Webhook[]; + } + + public static async count( + { + session, + address = null, + topic = null, + ...otherArgs + }: CountArgs + ): Promise { + const response = await Webhook.request({ + http_method: "get", + operation: "count", + session: session, + urlIds: {}, + params: {address: address, topic: topic, ...otherArgs}, + body: {}, + entity: null, + }); + + return response ? response.body : null; + } + + public address: string | null; + public topic: string | null; + public api_version: string | null; + public created_at: string | null; + public fields: string[] | null; + public format: string | null; + public id: number | null; + public metafield_namespaces: string[] | null; + public private_metafield_namespaces: string[] | null; + public updated_at: string | null; +} diff --git a/src/rest-resources/__tests__/2021-04/abandoned_checkout.test.ts b/src/rest-resources/__tests__/2021-04/abandoned_checkout.test.ts new file mode 100644 index 000000000..81ae6d773 --- /dev/null +++ b/src/rest-resources/__tests__/2021-04/abandoned_checkout.test.ts @@ -0,0 +1,141 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {AbandonedCheckout} from '../../2021-04'; + +describe('AbandonedCheckout resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.April21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await AbandonedCheckout.checkouts({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/checkouts.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await AbandonedCheckout.checkouts({ + session: test_session, + status: "closed", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/checkouts.json', + query: 'status=closed', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await AbandonedCheckout.checkouts({ + session: test_session, + created_at_max: "2013-10-12T07:05:27-02:00", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/checkouts.json', + query: 'created_at_max=2013-10-12T07%3A05%3A27-02%3A00', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await AbandonedCheckout.checkouts({ + session: test_session, + limit: "1", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/checkouts.json', + query: 'limit=1', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await AbandonedCheckout.checkouts({ + session: test_session, + status: "closed", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/checkouts.json', + query: 'status=closed', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await AbandonedCheckout.checkouts({ + session: test_session, + created_at_max: "2013-10-12T07:05:27-02:00", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/checkouts.json', + query: 'created_at_max=2013-10-12T07%3A05%3A27-02%3A00', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await AbandonedCheckout.checkouts({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/checkouts.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-04/access_scope.test.ts b/src/rest-resources/__tests__/2021-04/access_scope.test.ts new file mode 100644 index 000000000..89a4a2691 --- /dev/null +++ b/src/rest-resources/__tests__/2021-04/access_scope.test.ts @@ -0,0 +1,34 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {AccessScope} from '../../2021-04'; + +describe('AccessScope resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.April21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await AccessScope.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/oauth/access_scopes.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-04/android_pay_key.test.ts b/src/rest-resources/__tests__/2021-04/android_pay_key.test.ts new file mode 100644 index 000000000..7ef9f8ba8 --- /dev/null +++ b/src/rest-resources/__tests__/2021-04/android_pay_key.test.ts @@ -0,0 +1,70 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {AndroidPayKey} from '../../2021-04'; + +describe('AndroidPayKey resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.April21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const android_pay_key = new AndroidPayKey({session: test_session}); + + await android_pay_key.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/android_pay_keys.json', + query: '', + headers, + data: { "android_pay_key": {} } + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await AndroidPayKey.find({ + session: test_session, + id: 964811897, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/android_pay_keys/964811897.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await AndroidPayKey.delete({ + session: test_session, + id: 964811898, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-04/android_pay_keys/964811898.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-04/apple_pay_certificate.test.ts b/src/rest-resources/__tests__/2021-04/apple_pay_certificate.test.ts new file mode 100644 index 000000000..3823270f0 --- /dev/null +++ b/src/rest-resources/__tests__/2021-04/apple_pay_certificate.test.ts @@ -0,0 +1,108 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {ApplePayCertificate} from '../../2021-04'; + +describe('ApplePayCertificate resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.April21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const apple_pay_certificate = new ApplePayCertificate({session: test_session}); + + await apple_pay_certificate.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/apple_pay_certificates.json', + query: '', + headers, + data: { "apple_pay_certificate": {} } + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await ApplePayCertificate.find({ + session: test_session, + id: 1068938280, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/apple_pay_certificates/1068938280.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const apple_pay_certificate = new ApplePayCertificate({session: test_session}); + apple_pay_certificate.id = 1068938282; + apple_pay_certificate.status = "completed"; + apple_pay_certificate.merchant_id = "merchant.something"; + apple_pay_certificate.encoded_signed_certificate = "MIIEZzCCBA6gAwIBAgIIWGMideLkDJAwCgYIKoZIzj0EAwIwgYAxNDAyBgNV\nBAMMK0FwcGxlIFdvcmxkd2lkZSBEZXZlbG9wZXIgUmVsYXRpb25zIENBIC0g\nRzIxJjAkBgNVBAsMHUFwcGxlIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MRMw\nEQYDVQQKDApBcHBsZSBJbmMuMQswCQYDVQQGEwJVUzAeFw0xNDEyMDgyMTMy\nMDBaFw0xNzAxMDYyMTMyMDBaMIGZMSowKAYKCZImiZPyLGQBAQwabWVyY2hh\nbnQuY29tLm5vcm1vcmUuamFzb24xMDAuBgNVBAMMJ01lcmNoYW50IElEOiBt\nZXJjaGFudC5jb20ubm9ybW9yZS5qYXNvbjETMBEGA1UECwwKNVVZMzJOTE5O\nOTEXMBUGA1UECgwOSm9zaHVhIFRlc3NpZXIxCzAJBgNVBAYTAkNBMFkwEwYH\nKoZIzj0CAQYIKoZIzj0DAQcDQgAEAxDDCvzG6MnsZSJOtbr0hr3MRq 4HzTZ\nx8J4FD34E3kU5CallEnZLBmnzfqmjP8644SO28LLJxvWBnrg7lHFtaOCAlUw\nggJRMEcGCCsGAQUFBwEBBDswOTA3BggrBgEFBQcwAYYraHR0cDovL29jc3Au\nYXBwbGUuY29tL29jc3AwNC1hcHBsZXd3ZHJjYTIwMTAdBgNVHQ4EFgQUkPsO\nKEKvhL/takKomy5GWXtCd8wwDAYDVR0TAQH/BAIwADAfBgNVHSMEGDAWgBSE\ntoTMOoZichZZlOgao71I3zrfCzCCAR0GA1UdIASCARQwggEQMIIBDAYJKoZI\nhvdjZAUBMIH MIHDBggrBgEFBQcCAjCBtgyBs1JlbGlhbmNlIG9uIHRoaXMg\nY2VydGlmaWNhdGUgYnkgYW55IHBhcnR5IGFzc3VtZXMgYWNjZXB0YW5jZSBv\nZiB0aGUgdGhlbiBhcHBsaWNhYmxlIHN0YW5kYXJkIHRlcm1zIGFuZCBjb25k\naXRpb25zIG9mIHVzZSwgY2VydGlmaWNhdGUgcG9saWN5IGFuZCBjZXJ0aWZp\nY2F0aW9uIHByYWN0aWNlIHN0YXRlbWVudHMuMDYGCCsGAQUFBwIBFipodHRw\nOi8vd3d3LmFwcGxlLmNvbS9jZXJ0aWZpY2F0ZWF1dGhvcml0eS8wNgYDVR0f\nBC8wLTAroCmgJ4YlaHR0cDovL2NybC5hcHBsZS5jb20vYXBwbGV3d2RyY2Ey\nLmNybDAOBgNVHQ8BAf8EBAMCAygwTwYJKoZIhvdjZAYgBEIMQDM0NTBBMjhB\nOTlGRjIyRkI5OTdDRERFODU1REREOTI5NTE4RjVGMDdBQUM4NzdDMzRCQjM3\nODFCQTg2MzkyNjIwCgYIKoZIzj0EAwIDRwAwRAIgZ/oNx0gCc/PM4pYhOWL2\nCecFQrIgzHr/fZd8qcy3Be8CIEQCaAPpmvQrXEX0hFexoYMHtOHY9dgN2D8L\nNKpVyn3t\n"; + await apple_pay_certificate.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/apple_pay_certificates/1068938282.json', + query: '', + headers, + data: { "apple_pay_certificate": {id: 1068938282, status: "completed", merchant_id: "merchant.something", encoded_signed_certificate: "MIIEZzCCBA6gAwIBAgIIWGMideLkDJAwCgYIKoZIzj0EAwIwgYAxNDAyBgNV\nBAMMK0FwcGxlIFdvcmxkd2lkZSBEZXZlbG9wZXIgUmVsYXRpb25zIENBIC0g\nRzIxJjAkBgNVBAsMHUFwcGxlIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MRMw\nEQYDVQQKDApBcHBsZSBJbmMuMQswCQYDVQQGEwJVUzAeFw0xNDEyMDgyMTMy\nMDBaFw0xNzAxMDYyMTMyMDBaMIGZMSowKAYKCZImiZPyLGQBAQwabWVyY2hh\nbnQuY29tLm5vcm1vcmUuamFzb24xMDAuBg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DMzRCQjM3\nODFCQTg2MzkyNjIwCgYIKoZIzj0EAwIDRwAwRAIgZ/oNx0gCc/PM4pYhOWL2\nCecFQrIgzHr/fZd8qcy3Be8CIEQCaAPpmvQrXEX0hFexoYMHtOHY9dgN2D8L\nNKpVyn3t\n"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await ApplePayCertificate.delete({ + session: test_session, + id: 1068938283, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-04/apple_pay_certificates/1068938283.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await ApplePayCertificate.csr({ + session: test_session, + id: 1068938281, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/apple_pay_certificates/1068938281/csr.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-04/application_charge.test.ts b/src/rest-resources/__tests__/2021-04/application_charge.test.ts new file mode 100644 index 000000000..f7b3d0c37 --- /dev/null +++ b/src/rest-resources/__tests__/2021-04/application_charge.test.ts @@ -0,0 +1,109 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {ApplicationCharge} from '../../2021-04'; + +describe('ApplicationCharge resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.April21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const application_charge = new ApplicationCharge({session: test_session}); + application_charge.name = "Super Duper Expensive action"; + application_charge.price = 100.0; + application_charge.return_url = "http://super-duper.shopifyapps.com"; + await application_charge.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/application_charges.json', + query: '', + headers, + data: { "application_charge": {name: "Super Duper Expensive action", price: 100.0, return_url: "http://super-duper.shopifyapps.com"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const application_charge = new ApplicationCharge({session: test_session}); + application_charge.name = "Super Duper Expensive action"; + application_charge.price = 100.0; + application_charge.return_url = "http://super-duper.shopifyapps.com"; + application_charge.test = true; + await application_charge.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/application_charges.json', + query: '', + headers, + data: { "application_charge": {name: "Super Duper Expensive action", price: 100.0, return_url: "http://super-duper.shopifyapps.com", test: true} } + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await ApplicationCharge.find({ + session: test_session, + id: 675931192, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/application_charges/675931192.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await ApplicationCharge.all({ + session: test_session, + since_id: "556467234", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/application_charges.json', + query: 'since_id=556467234', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await ApplicationCharge.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/application_charges.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-04/application_credit.test.ts b/src/rest-resources/__tests__/2021-04/application_credit.test.ts new file mode 100644 index 000000000..ec91363e0 --- /dev/null +++ b/src/rest-resources/__tests__/2021-04/application_credit.test.ts @@ -0,0 +1,89 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {ApplicationCredit} from '../../2021-04'; + +describe('ApplicationCredit resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.April21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const application_credit = new ApplicationCredit({session: test_session}); + application_credit.description = "application credit for refund"; + application_credit.amount = 5.0; + await application_credit.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/application_credits.json', + query: '', + headers, + data: { "application_credit": {description: "application credit for refund", amount: 5.0} } + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const application_credit = new ApplicationCredit({session: test_session}); + application_credit.description = "application credit for refund"; + application_credit.amount = 5.0; + application_credit.test = true; + await application_credit.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/application_credits.json', + query: '', + headers, + data: { "application_credit": {description: "application credit for refund", amount: 5.0, test: true} } + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await ApplicationCredit.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/application_credits.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await ApplicationCredit.find({ + session: test_session, + id: 140583599, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/application_credits/140583599.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-04/article.test.ts b/src/rest-resources/__tests__/2021-04/article.test.ts new file mode 100644 index 000000000..6014ae54d --- /dev/null +++ b/src/rest-resources/__tests__/2021-04/article.test.ts @@ -0,0 +1,484 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Article} from '../../2021-04'; + +describe('Article resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.April21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Article.all({ + session: test_session, + blog_id: 241253187, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/blogs/241253187/articles.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Article.all({ + session: test_session, + blog_id: 241253187, + since_id: "134645308", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/blogs/241253187/articles.json', + query: 'since_id=134645308', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const article = new Article({session: test_session}); + article.blog_id = 241253187; + article.title = "My new Article title"; + article.author = "John Smith"; + article.tags = "This Post, Has Been Tagged"; + article.body_html = "

I like articles

\n

Yea, I like posting them through REST.

"; + article.published_at = "Thu Mar 24 15:45:47 UTC 2011"; + await article.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/blogs/241253187/articles.json', + query: '', + headers, + data: { "article": {title: "My new Article title", author: "John Smith", tags: "This Post, Has Been Tagged", body_html: "

I like articles

\n

Yea, I like posting them through REST.

", published_at: "Thu Mar 24 15:45:47 UTC 2011"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const article = new Article({session: test_session}); + article.blog_id = 241253187; + article.title = "My new Article title"; + article.author = "John Smith"; + article.tags = "This Post, Has Been Tagged"; + article.body_html = "

I like articles

\n

Yea, I like posting them through REST.

"; + article.published = false; + await article.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/blogs/241253187/articles.json', + query: '', + headers, + data: { "article": {title: "My new Article title", author: "John Smith", tags: "This Post, Has Been Tagged", body_html: "

I like articles

\n

Yea, I like posting them through REST.

", published: false} } + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const article = new Article({session: test_session}); + article.blog_id = 241253187; + article.title = "My new Article title"; + article.author = "John Smith"; + article.tags = "This Post, Has Been Tagged"; + article.body_html = "

I like articles

\n

Yea, I like posting them through REST.

"; + article.published_at = "Thu Mar 24 15:45:47 UTC 2011"; + article.image = { + attachment: "R0lGODlhAQABAIAAAAAAAAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==\n" + }; + await article.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/blogs/241253187/articles.json', + query: '', + headers, + data: { "article": {title: "My new Article title", author: "John Smith", tags: "This Post, Has Been Tagged", body_html: "

I like articles

\n

Yea, I like posting them through REST.

", published_at: "Thu Mar 24 15:45:47 UTC 2011", image: {attachment: "R0lGODlhAQABAIAAAAAAAAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==\n"}} } + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const article = new Article({session: test_session}); + article.blog_id = 241253187; + article.title = "My new Article title"; + article.author = "John Smith"; + article.tags = "This Post, Has Been Tagged"; + article.body_html = "

I like articles

\n

Yea, I like posting them through REST.

"; + article.published_at = "Thu Mar 24 15:45:47 UTC 2011"; + article.image = { + src: "http://example.com/rails_logo.gif", + alt: "Rails logo" + }; + await article.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/blogs/241253187/articles.json', + query: '', + headers, + data: { "article": {title: "My new Article title", author: "John Smith", tags: "This Post, Has Been Tagged", body_html: "

I like articles

\n

Yea, I like posting them through REST.

", published_at: "Thu Mar 24 15:45:47 UTC 2011", image: {src: "http://example.com/rails_logo.gif", alt: "Rails logo"}} } + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const article = new Article({session: test_session}); + article.blog_id = 241253187; + article.title = "My new Article title"; + article.author = "John Smith"; + article.tags = "This Post, Has Been Tagged"; + article.body_html = "

I like articles

\n

Yea, I like posting them through REST.

"; + article.published_at = "Thu Mar 24 15:45:47 UTC 2011"; + article.metafields = [ + { + key: "new", + value: "newvalue", + value_type: "string", + namespace: "global" + } + ]; + await article.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/blogs/241253187/articles.json', + query: '', + headers, + data: { "article": {title: "My new Article title", author: "John Smith", tags: "This Post, Has Been Tagged", body_html: "

I like articles

\n

Yea, I like posting them through REST.

", published_at: "Thu Mar 24 15:45:47 UTC 2011", metafields: [{key: "new", value: "newvalue", value_type: "string", namespace: "global"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Article.count({ + session: test_session, + blog_id: 241253187, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/blogs/241253187/articles/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Article.find({ + session: test_session, + blog_id: 241253187, + id: 134645308, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/blogs/241253187/articles/134645308.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_10', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const article = new Article({session: test_session}); + article.blog_id = 241253187; + article.id = 134645308; + article.title = "My new Title"; + article.author = "Your name"; + article.tags = "Tags, Will Be, Updated"; + article.body_html = "

Look, I can even update through a web service.

"; + article.published_at = "Thu Mar 24 15:45:47 UTC 2011"; + await article.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/blogs/241253187/articles/134645308.json', + query: '', + headers, + data: { "article": {id: 134645308, title: "My new Title", author: "Your name", tags: "Tags, Will Be, Updated", body_html: "

Look, I can even update through a web service.

", published_at: "Thu Mar 24 15:45:47 UTC 2011"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_11', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const article = new Article({session: test_session}); + article.blog_id = 241253187; + article.id = 134645308; + article.published = true; + await article.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/blogs/241253187/articles/134645308.json', + query: '', + headers, + data: { "article": {id: 134645308, published: true} } + }).toMatchMadeHttpRequest(); + }); + + it('test_12', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const article = new Article({session: test_session}); + article.blog_id = 241253187; + article.id = 134645308; + article.published = false; + await article.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/blogs/241253187/articles/134645308.json', + query: '', + headers, + data: { "article": {id: 134645308, published: false} } + }).toMatchMadeHttpRequest(); + }); + + it('test_13', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const article = new Article({session: test_session}); + article.blog_id = 241253187; + article.id = 134645308; + article.title = "My new Title"; + article.author = "Your name"; + article.tags = "Tags, Will Be, Updated"; + article.body_html = "

Look, I can even update through a web service.

"; + article.published_at = "Thu Mar 24 15:45:47 UTC 2011"; + article.image = { + attachment: "R0lGODlhbgCMAPf/APbr48VySrxTO7IgKt2qmKQdJeK8lsFjROG5p/nz7Zg3\nMNmnd7Q1MLNVS9GId71hSJMZIuzTu4UtKbeEeakhKMl8U8WYjfr18YQaIbAf\nKKwhKdKzqpQtLebFortOOejKrOjZ1Mt7aMNpVbAqLLV7bsNqR 3WwMqEWenN\nsZYxL/Ddy/Pm2e7ZxLlUQrIjNPXp3bU5MbhENbEtLtqhj5ZQTfHh0bMxL7Ip\nNsNyUYkZIrZJPcqGdYIUHb5aPKkeJnoUHd2yiJkiLKYiKLRFOsyJXKVDO8up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awDzP8Q ZwAICLckbgd08i290eh9V\nCIadQw3qO5Oa1H1GNRlSjeorO2HLruZ2rLudAm Dm9Gxcx/GXmSIMbnjH5W2\nzy2RbOzM cENBRAWs0N9b3zXWdp8pra1r61tbXdb4N/2Nv8i5gzeIJd5Gjui\nwT AzQ9YVGrYnNO0Agm27GBkvNnNzje 921qf/ b1QEfuMDFPe5lk/lspUG3\nWKbQCofLBBBuwNEs3C3aikcrB2TTeM81HgmOd3zf/PZ3yFPNaqSXfODF0EDK\nE9e6liZmCvJwOLD7AQhU2efSbG6zm7VgiG1ofBc //nGgZ7vbYw67aVux4v/\nfXSSK53by/HVrzIwDZTBBANUrzpMeAAIWASeB4P/AQ9 cHjEJx7xWgDE5nLQ\neMdHXvKbg/zkMZ23H/1oFRjYPOc9v3nQ58Aw0xn9LACvO7HQAOZVf/jl0ii1\nHcXe9bPX3euftaPL5R71tIf97nsy7/o0WlP2r4/JOU7B r5nqva7jz1EdZ97\n4qNe bonfvCfVXvly1762beOOdLBd Q7PCAAOw==\n" + }; + await article.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/blogs/241253187/articles/134645308.json', + query: '', + headers, + data: { "article": {id: 134645308, title: "My new Title", author: "Your name", tags: "Tags, Will Be, Updated", body_html: "

Look, I can even update through a web service.

", published_at: "Thu Mar 24 15:45:47 UTC 2011", image: {attachment: "R0lGODlhbgCMAPf/APbr48VySrxTO7IgKt2qmKQdJeK8lsFjROG5p/nz7Zg3\nMNmnd7Q1MLNVS9GId71hSJMZIuzTu4UtKbeEeakhKMl8U8WYjfr18YQaIbAf\nKKwhKdKzqpQtLebFortOOejKrOjZ1Mt7aMNpVbAqLLV7bsNqR 3WwMqEWenN\nsZYxL/Ddy/Pm2e7ZxLlUQrIjNPXp3bU5MbhENbEtLtqhj5ZQTfHh0bMxL7Ip\nNsNyUYkZIrZJPcqGdYIUHb5aPKkeJnoUHd2yiJkiLKYiKLRFOsyJXKVDO8up\nosFaS TBnK4kKti5sNa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i290eh9V\nCIadQw3qO5Oa1H1GNRlSjeorO2HLruZ2rLudAm Dm9Gxcx/GXmSIMbnjH5W2\nzy2RbOzM cENBRAWs0N9b3zXWdp8pra1r61tbXdb4N/2Nv8i5gzeIJd5Gjui\nwT AzQ9YVGrYnNO0Agm27GBkvNnNzje 921qf/ b1QEfuMDFPe5lk/lspUG3\nWKbQCofLBBBuwNEs3C3aikcrB2TTeM81HgmOd3zf/PZ3yFPNaqSXfODF0EDK\nE9e6liZmCvJwOLD7AQhU2efSbG6zm7VgiG1ofBc //nGgZ7vbYw67aVux4v/\nfXSSK53by/HVrzIwDZTBBANUrzpMeAAIWASeB4P/AQ9 cHjEJx7xWgDE5nLQ\neMdHXvKbg/zkMZ23H/1oFRjYPOc9v3nQ58Aw0xn9LACvO7HQAOZVf/jl0ii1\nHcXe9bPX3euftaPL5R71tIf97nsy7/o0WlP2r4/JOU7B r5nqva7jz1EdZ97\n4qNe bonfvCfVXvly1762beOOdLBd Q7PCAAOw==\n"}} } + }).toMatchMadeHttpRequest(); + }); + + it('test_14', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const article = new Article({session: test_session}); + article.blog_id = 241253187; + article.id = 134645308; + article.title = "My new Title"; + article.author = "Your name"; + article.tags = "Tags, Will Be, Updated"; + article.body_html = "

Look, I can even update through a web service.

"; + article.published_at = "Thu Mar 24 15:45:47 UTC 2011"; + article.image = { + alt: "Rails logo" + }; + await article.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/blogs/241253187/articles/134645308.json', + query: '', + headers, + data: { "article": {id: 134645308, title: "My new Title", author: "Your name", tags: "Tags, Will Be, Updated", body_html: "

Look, I can even update through a web service.

", published_at: "Thu Mar 24 15:45:47 UTC 2011", image: {alt: "Rails logo"}} } + }).toMatchMadeHttpRequest(); + }); + + it('test_15', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const article = new Article({session: test_session}); + article.blog_id = 241253187; + article.id = 134645308; + article.image = ""; + await article.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/blogs/241253187/articles/134645308.json', + query: '', + headers, + data: { "article": {id: 134645308, image: ""} } + }).toMatchMadeHttpRequest(); + }); + + it('test_16', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const article = new Article({session: test_session}); + article.blog_id = 241253187; + article.id = 134645308; + article.metafields = [ + { + key: "new", + value: "newvalue", + value_type: "string", + namespace: "global" + } + ]; + await article.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/blogs/241253187/articles/134645308.json', + query: '', + headers, + data: { "article": {id: 134645308, metafields: [{key: "new", value: "newvalue", value_type: "string", namespace: "global"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_17', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Article.delete({ + session: test_session, + blog_id: 241253187, + id: 134645308, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-04/blogs/241253187/articles/134645308.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_18', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Article.authors({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/articles/authors.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_19', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Article.tags({ + session: test_session, + blog_id: 241253187, + limit: "1", + popular: "1", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/blogs/241253187/articles/tags.json', + query: 'limit=1&popular=1', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_20', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Article.tags({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/articles/tags.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_21', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Article.tags({ + session: test_session, + blog_id: 241253187, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/blogs/241253187/articles/tags.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_22', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Article.tags({ + session: test_session, + limit: "1", + popular: "1", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/articles/tags.json', + query: 'limit=1&popular=1', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-04/asset.test.ts b/src/rest-resources/__tests__/2021-04/asset.test.ts new file mode 100644 index 000000000..57887c948 --- /dev/null +++ b/src/rest-resources/__tests__/2021-04/asset.test.ts @@ -0,0 +1,149 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Asset} from '../../2021-04'; + +describe('Asset resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.April21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Asset.all({ + session: test_session, + theme_id: 828155753, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/themes/828155753/assets.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const asset = new Asset({session: test_session}); + asset.theme_id = 828155753; + asset.key = "templates/index.liquid"; + asset.value = "

We are busy updating the store for you and will be back within the hour.

"; + await asset.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/themes/828155753/assets.json', + query: '', + headers, + data: { "asset": {key: "templates/index.liquid", value: "

We are busy updating the store for you and will be back within the hour.

"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const asset = new Asset({session: test_session}); + asset.theme_id = 828155753; + asset.key = "assets/empty.gif"; + asset.attachment = "R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw==\n"; + await asset.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/themes/828155753/assets.json', + query: '', + headers, + data: { "asset": {key: "assets/empty.gif", attachment: "R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw==\n"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const asset = new Asset({session: test_session}); + asset.theme_id = 828155753; + asset.key = "assets/bg-body.gif"; + asset.src = "http://apple.com/new_bg.gif"; + await asset.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/themes/828155753/assets.json', + query: '', + headers, + data: { "asset": {key: "assets/bg-body.gif", src: "http://apple.com/new_bg.gif"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const asset = new Asset({session: test_session}); + asset.theme_id = 828155753; + asset.key = "layout/alternate.liquid"; + asset.source_key = "layout/theme.liquid"; + await asset.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/themes/828155753/assets.json', + query: '', + headers, + data: { "asset": {key: "layout/alternate.liquid", source_key: "layout/theme.liquid"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Asset.all({ + session: test_session, + theme_id: 828155753, + asset: {key: "templates/index.liquid"}, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/themes/828155753/assets.json', + query: 'asset%5Bkey%5D=templates%2Findex.liquid', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Asset.delete({ + session: test_session, + theme_id: 828155753, + asset: {key: "assets/bg-body.gif"}, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-04/themes/828155753/assets.json', + query: 'asset%5Bkey%5D=assets%2Fbg-body.gif', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-04/assigned_fulfillment_order.test.ts b/src/rest-resources/__tests__/2021-04/assigned_fulfillment_order.test.ts new file mode 100644 index 000000000..ec02649c0 --- /dev/null +++ b/src/rest-resources/__tests__/2021-04/assigned_fulfillment_order.test.ts @@ -0,0 +1,36 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {AssignedFulfillmentOrder} from '../../2021-04'; + +describe('AssignedFulfillmentOrder resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.April21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await AssignedFulfillmentOrder.all({ + session: test_session, + assignment_status: "cancellation_requested", + location_ids: ["24826418"], + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/assigned_fulfillment_orders.json', + query: 'assignment_status=cancellation_requested&location_ids%5B%5D=24826418', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-04/balance.test.ts b/src/rest-resources/__tests__/2021-04/balance.test.ts new file mode 100644 index 000000000..450eee81c --- /dev/null +++ b/src/rest-resources/__tests__/2021-04/balance.test.ts @@ -0,0 +1,34 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Balance} from '../../2021-04'; + +describe('Balance resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.April21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Balance.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/shopify_payments/balance.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-04/blog.test.ts b/src/rest-resources/__tests__/2021-04/blog.test.ts new file mode 100644 index 000000000..3ded9357e --- /dev/null +++ b/src/rest-resources/__tests__/2021-04/blog.test.ts @@ -0,0 +1,229 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Blog} from '../../2021-04'; + +describe('Blog resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.April21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Blog.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/blogs.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Blog.all({ + session: test_session, + since_id: "241253187", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/blogs.json', + query: 'since_id=241253187', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const blog = new Blog({session: test_session}); + blog.title = "Apple main blog"; + await blog.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/blogs.json', + query: '', + headers, + data: { "blog": {title: "Apple main blog"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const blog = new Blog({session: test_session}); + blog.title = "Apple main blog"; + blog.metafields = [ + { + key: "sponsor", + value: "Shopify", + value_type: "string", + namespace: "global" + } + ]; + await blog.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/blogs.json', + query: '', + headers, + data: { "blog": {title: "Apple main blog", metafields: [{key: "sponsor", value: "Shopify", value_type: "string", namespace: "global"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Blog.count({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/blogs/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Blog.find({ + session: test_session, + id: 241253187, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/blogs/241253187.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Blog.find({ + session: test_session, + id: 241253187, + fields: "id,title", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/blogs/241253187.json', + query: 'fields=id%2Ctitle', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const blog = new Blog({session: test_session}); + blog.id = 241253187; + blog.title = "IPod Updates"; + await blog.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/blogs/241253187.json', + query: '', + headers, + data: { "blog": {id: 241253187, title: "IPod Updates"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const blog = new Blog({session: test_session}); + blog.id = 241253187; + blog.title = "IPod Updates"; + blog.handle = "ipod-updates"; + blog.commentable = "moderate"; + await blog.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/blogs/241253187.json', + query: '', + headers, + data: { "blog": {id: 241253187, title: "IPod Updates", handle: "ipod-updates", commentable: "moderate"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_10', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const blog = new Blog({session: test_session}); + blog.id = 241253187; + blog.metafields = [ + { + key: "sponsor", + value: "Shopify", + value_type: "string", + namespace: "global" + } + ]; + await blog.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/blogs/241253187.json', + query: '', + headers, + data: { "blog": {id: 241253187, metafields: [{key: "sponsor", value: "Shopify", value_type: "string", namespace: "global"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_11', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Blog.delete({ + session: test_session, + id: 241253187, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-04/blogs/241253187.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-04/cancellation_request.test.ts b/src/rest-resources/__tests__/2021-04/cancellation_request.test.ts new file mode 100644 index 000000000..10df8871e --- /dev/null +++ b/src/rest-resources/__tests__/2021-04/cancellation_request.test.ts @@ -0,0 +1,73 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {CancellationRequest} from '../../2021-04'; + +describe('CancellationRequest resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.April21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const cancellation_request = new CancellationRequest({session: test_session}); + cancellation_request.fulfillment_order_id = 1046000837; + cancellation_request.message = "The customer changed his mind."; + await cancellation_request.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/fulfillment_orders/1046000837/cancellation_request.json', + query: '', + headers, + data: { "cancellation_request": {message: "The customer changed his mind."} } + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const cancellation_request = new CancellationRequest({session: test_session}); + cancellation_request.fulfillment_order_id = 1046000838; + await cancellation_request.accept({ + body: {cancellation_request: {message: "We had not started any processing yet."}}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/fulfillment_orders/1046000838/cancellation_request/accept.json', + query: '', + headers, + data: { "cancellation_request": {message: "We had not started any processing yet."} } + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const cancellation_request = new CancellationRequest({session: test_session}); + cancellation_request.fulfillment_order_id = 1046000839; + await cancellation_request.reject({ + body: {cancellation_request: {message: "We have already send the shipment out."}}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/fulfillment_orders/1046000839/cancellation_request/reject.json', + query: '', + headers, + data: { "cancellation_request": {message: "We have already send the shipment out."} } + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-04/carrier_service.test.ts b/src/rest-resources/__tests__/2021-04/carrier_service.test.ts new file mode 100644 index 000000000..0f00fb57f --- /dev/null +++ b/src/rest-resources/__tests__/2021-04/carrier_service.test.ts @@ -0,0 +1,108 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {CarrierService} from '../../2021-04'; + +describe('CarrierService resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.April21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const carrier_service = new CarrierService({session: test_session}); + carrier_service.name = "Shipping Rate Provider"; + carrier_service.callback_url = "http://shippingrateprovider.com"; + carrier_service.service_discovery = true; + await carrier_service.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/carrier_services.json', + query: '', + headers, + data: { "carrier_service": {name: "Shipping Rate Provider", callback_url: "http://shippingrateprovider.com", service_discovery: true} } + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CarrierService.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/carrier_services.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const carrier_service = new CarrierService({session: test_session}); + carrier_service.id = 1036894964; + carrier_service.name = "Some new name"; + carrier_service.active = false; + await carrier_service.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/carrier_services/1036894964.json', + query: '', + headers, + data: { "carrier_service": {id: 1036894964, name: "Some new name", active: false} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CarrierService.find({ + session: test_session, + id: 1036894966, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/carrier_services/1036894966.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CarrierService.delete({ + session: test_session, + id: 1036894967, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-04/carrier_services/1036894967.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-04/checkout.test.ts b/src/rest-resources/__tests__/2021-04/checkout.test.ts new file mode 100644 index 000000000..733b80c3f --- /dev/null +++ b/src/rest-resources/__tests__/2021-04/checkout.test.ts @@ -0,0 +1,229 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Checkout} from '../../2021-04'; + +describe('Checkout resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.April21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const checkout = new Checkout({session: test_session}); + checkout.line_items = [ + { + variant_id: 39072856, + quantity: 5 + } + ]; + await checkout.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/checkouts.json', + query: '', + headers, + data: { "checkout": {line_items: [{variant_id: 39072856, quantity: 5}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const checkout = new Checkout({session: test_session}); + checkout.email = "me@example.com"; + await checkout.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/checkouts.json', + query: '', + headers, + data: { "checkout": {email: "me@example.com"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const checkout = new Checkout({session: test_session}); + checkout.token = "b490a9220cd14d7344024f4874f640a6"; + await checkout.complete({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/checkouts/b490a9220cd14d7344024f4874f640a6/complete.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Checkout.find({ + session: test_session, + token: "bd5a8aa1ecd019dd3520ff791ee3a24c", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/checkouts/bd5a8aa1ecd019dd3520ff791ee3a24c.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Checkout.find({ + session: test_session, + token: "7yjf4v2we7gamku6a6h7tvm8h3mmvs4x", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/checkouts/7yjf4v2we7gamku6a6h7tvm8h3mmvs4x.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Checkout.find({ + session: test_session, + token: "exuw7apwoycchjuwtiqg8nytfhphr62a", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/checkouts/exuw7apwoycchjuwtiqg8nytfhphr62a.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const checkout = new Checkout({session: test_session}); + checkout.token = "exuw7apwoycchjuwtiqg8nytfhphr62a"; + checkout.email = "john.smith@example.com"; + checkout.shipping_address = { + first_name: "John", + last_name: "Smith", + address1: "126 York St.", + city: "Los Angeles", + province_code: "CA", + country_code: "US", + phone: "(123)456-7890", + zip: "90002" + }; + await checkout.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/checkouts/exuw7apwoycchjuwtiqg8nytfhphr62a.json', + query: '', + headers, + data: { "checkout": {token: "exuw7apwoycchjuwtiqg8nytfhphr62a", email: "john.smith@example.com", shipping_address: {first_name: "John", last_name: "Smith", address1: "126 York St.", city: "Los Angeles", province_code: "CA", country_code: "US", phone: "(123)456-7890", zip: "90002"}} } + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const checkout = new Checkout({session: test_session}); + checkout.token = "exuw7apwoycchjuwtiqg8nytfhphr62a"; + checkout.shipping_line = { + handle: "shopify-Free Shipping-0.00" + }; + await checkout.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/checkouts/exuw7apwoycchjuwtiqg8nytfhphr62a.json', + query: '', + headers, + data: { "checkout": {token: "exuw7apwoycchjuwtiqg8nytfhphr62a", shipping_line: {handle: "shopify-Free Shipping-0.00"}} } + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Checkout.shipping_rates({ + session: test_session, + token: "exuw7apwoycchjuwtiqg8nytfhphr62a", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/checkouts/exuw7apwoycchjuwtiqg8nytfhphr62a/shipping_rates.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_10', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Checkout.shipping_rates({ + session: test_session, + token: "exuw7apwoycchjuwtiqg8nytfhphr62a", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/checkouts/exuw7apwoycchjuwtiqg8nytfhphr62a/shipping_rates.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_11', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Checkout.shipping_rates({ + session: test_session, + token: "zs9ru89kuqcdagk8bz4r9hnxt22wwd42", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/checkouts/zs9ru89kuqcdagk8bz4r9hnxt22wwd42/shipping_rates.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-04/collect.test.ts b/src/rest-resources/__tests__/2021-04/collect.test.ts new file mode 100644 index 000000000..e2fbc4160 --- /dev/null +++ b/src/rest-resources/__tests__/2021-04/collect.test.ts @@ -0,0 +1,177 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Collect} from '../../2021-04'; + +describe('Collect resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.April21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const collect = new Collect({session: test_session}); + collect.product_id = 921728736; + collect.collection_id = 841564295; + await collect.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/collects.json', + query: '', + headers, + data: { "collect": {product_id: 921728736, collection_id: 841564295} } + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Collect.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/collects.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Collect.all({ + session: test_session, + product_id: "632910392", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/collects.json', + query: 'product_id=632910392', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Collect.all({ + session: test_session, + collection_id: "841564295", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/collects.json', + query: 'collection_id=841564295', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Collect.delete({ + session: test_session, + id: 455204334, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-04/collects/455204334.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Collect.find({ + session: test_session, + id: 455204334, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/collects/455204334.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Collect.count({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/collects/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Collect.count({ + session: test_session, + product_id: "632910392", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/collects/count.json', + query: 'product_id=632910392', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Collect.count({ + session: test_session, + collection_id: "841564295", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/collects/count.json', + query: 'collection_id=841564295', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-04/collection.test.ts b/src/rest-resources/__tests__/2021-04/collection.test.ts new file mode 100644 index 000000000..4100ccd3a --- /dev/null +++ b/src/rest-resources/__tests__/2021-04/collection.test.ts @@ -0,0 +1,53 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Collection} from '../../2021-04'; + +describe('Collection resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.April21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Collection.find({ + session: test_session, + id: 841564295, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/collections/841564295.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Collection.products({ + session: test_session, + id: 841564295, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/collections/841564295/products.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-04/collection_listing.test.ts b/src/rest-resources/__tests__/2021-04/collection_listing.test.ts new file mode 100644 index 000000000..c7c42bde2 --- /dev/null +++ b/src/rest-resources/__tests__/2021-04/collection_listing.test.ts @@ -0,0 +1,105 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {CollectionListing} from '../../2021-04'; + +describe('CollectionListing resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.April21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CollectionListing.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/collection_listings.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CollectionListing.product_ids({ + session: test_session, + collection_id: 841564295, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/collection_listings/841564295/product_ids.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CollectionListing.find({ + session: test_session, + collection_id: 482865238, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/collection_listings/482865238.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const collection_listing = new CollectionListing({session: test_session}); + collection_listing.collection_id = 482865238; + await collection_listing.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/collection_listings/482865238.json', + query: '', + headers, + data: { "collection_listing": {collection_id: 482865238} } + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CollectionListing.delete({ + session: test_session, + collection_id: 482865238, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-04/collection_listings/482865238.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-04/comment.test.ts b/src/rest-resources/__tests__/2021-04/comment.test.ts new file mode 100644 index 000000000..6968ec703 --- /dev/null +++ b/src/rest-resources/__tests__/2021-04/comment.test.ts @@ -0,0 +1,289 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Comment} from '../../2021-04'; + +describe('Comment resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.April21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Comment.all({ + session: test_session, + article_id: "134645308", + blog_id: "241253187", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/comments.json', + query: 'article_id=134645308&blog_id=241253187', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Comment.all({ + session: test_session, + blog_id: "241253187", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/comments.json', + query: 'blog_id=241253187', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Comment.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/comments.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Comment.all({ + session: test_session, + since_id: "118373535", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/comments.json', + query: 'since_id=118373535', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Comment.count({ + session: test_session, + article_id: "134645308", + blog_id: "241253187", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/comments/count.json', + query: 'article_id=134645308&blog_id=241253187', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Comment.count({ + session: test_session, + blog_id: "241253187", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/comments/count.json', + query: 'blog_id=241253187', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Comment.count({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/comments/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Comment.find({ + session: test_session, + id: 118373535, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/comments/118373535.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const comment = new Comment({session: test_session}); + comment.id = 118373535; + comment.body = "You can even update through a web service."; + comment.author = "Your new name"; + comment.email = "your@updated-email.com"; + comment.published_at = "2022-02-03T22:13:53.233Z"; + await comment.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/comments/118373535.json', + query: '', + headers, + data: { "comment": {id: 118373535, body: "You can even update through a web service.", author: "Your new name", email: "your@updated-email.com", published_at: "2022-02-03T22:13:53.233Z"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_10', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const comment = new Comment({session: test_session}); + comment.body = "I like comments\nAnd I like posting them *RESTfully*."; + comment.author = "Your name"; + comment.email = "your@email.com"; + comment.ip = "107.20.160.121"; + comment.blog_id = 241253187; + comment.article_id = 134645308; + await comment.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/comments.json', + query: '', + headers, + data: { "comment": {body: "I like comments\nAnd I like posting them *RESTfully*.", author: "Your name", email: "your@email.com", ip: "107.20.160.121", blog_id: 241253187, article_id: 134645308} } + }).toMatchMadeHttpRequest(); + }); + + it('test_11', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const comment = new Comment({session: test_session}); + comment.id = 653537639; + await comment.spam({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/comments/653537639/spam.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_12', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const comment = new Comment({session: test_session}); + comment.id = 653537639; + await comment.not_spam({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/comments/653537639/not_spam.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_13', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const comment = new Comment({session: test_session}); + comment.id = 653537639; + await comment.approve({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/comments/653537639/approve.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_14', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const comment = new Comment({session: test_session}); + comment.id = 653537639; + await comment.remove({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/comments/653537639/remove.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_15', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const comment = new Comment({session: test_session}); + comment.id = 653537639; + await comment.restore({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/comments/653537639/restore.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-04/country.test.ts b/src/rest-resources/__tests__/2021-04/country.test.ts new file mode 100644 index 000000000..d9254d5d9 --- /dev/null +++ b/src/rest-resources/__tests__/2021-04/country.test.ts @@ -0,0 +1,158 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Country} from '../../2021-04'; + +describe('Country resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.April21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Country.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/countries.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Country.all({ + session: test_session, + since_id: "359115488", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/countries.json', + query: 'since_id=359115488', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const country = new Country({session: test_session}); + country.code = "FR"; + await country.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/countries.json', + query: '', + headers, + data: { "country": {code: "FR"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const country = new Country({session: test_session}); + country.code = "FR"; + country.tax = 0.2; + await country.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/countries.json', + query: '', + headers, + data: { "country": {code: "FR", tax: 0.2} } + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Country.count({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/countries/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Country.find({ + session: test_session, + id: 879921427, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/countries/879921427.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const country = new Country({session: test_session}); + country.id = 879921427; + country.tax = 0.05; + await country.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/countries/879921427.json', + query: '', + headers, + data: { "country": {id: 879921427, tax: 0.05} } + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Country.delete({ + session: test_session, + id: 879921427, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-04/countries/879921427.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-04/currency.test.ts b/src/rest-resources/__tests__/2021-04/currency.test.ts new file mode 100644 index 000000000..fc4038428 --- /dev/null +++ b/src/rest-resources/__tests__/2021-04/currency.test.ts @@ -0,0 +1,34 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Currency} from '../../2021-04'; + +describe('Currency resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.April21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Currency.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/currencies.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-04/custom_collection.test.ts b/src/rest-resources/__tests__/2021-04/custom_collection.test.ts new file mode 100644 index 000000000..89fd869fd --- /dev/null +++ b/src/rest-resources/__tests__/2021-04/custom_collection.test.ts @@ -0,0 +1,436 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {CustomCollection} from '../../2021-04'; + +describe('CustomCollection resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.April21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CustomCollection.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/custom_collections.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CustomCollection.all({ + session: test_session, + since_id: "841564295", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/custom_collections.json', + query: 'since_id=841564295', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CustomCollection.all({ + session: test_session, + product_id: "632910392", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/custom_collections.json', + query: 'product_id=632910392', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CustomCollection.all({ + session: test_session, + ids: "395646240,691652237,841564295", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/custom_collections.json', + query: 'ids=395646240%2C691652237%2C841564295', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const custom_collection = new CustomCollection({session: test_session}); + custom_collection.title = "Macbooks"; + await custom_collection.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/custom_collections.json', + query: '', + headers, + data: { "custom_collection": {title: "Macbooks"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const custom_collection = new CustomCollection({session: test_session}); + custom_collection.title = "Macbooks"; + custom_collection.published = false; + await custom_collection.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/custom_collections.json', + query: '', + headers, + data: { "custom_collection": {title: "Macbooks", published: false} } + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const custom_collection = new CustomCollection({session: test_session}); + custom_collection.title = "Macbooks"; + custom_collection.image = { + src: "http://example.com/rails_logo.gif", + alt: "Rails Logo" + }; + await custom_collection.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/custom_collections.json', + query: '', + headers, + data: { "custom_collection": {title: "Macbooks", image: {src: "http://example.com/rails_logo.gif", alt: "Rails Logo"}} } + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const custom_collection = new CustomCollection({session: test_session}); + custom_collection.title = "IPods"; + custom_collection.collects = [ + { + product_id: 921728736 + } + ]; + await custom_collection.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/custom_collections.json', + query: '', + headers, + data: { "custom_collection": {title: "IPods", collects: [{product_id: 921728736}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const custom_collection = new CustomCollection({session: test_session}); + custom_collection.title = "Macbooks"; + custom_collection.metafields = [ + { + key: "new", + value: "newvalue", + value_type: "string", + namespace: "global" + } + ]; + await custom_collection.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/custom_collections.json', + query: '', + headers, + data: { "custom_collection": {title: "Macbooks", metafields: [{key: "new", value: "newvalue", value_type: "string", namespace: "global"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_10', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CustomCollection.count({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/custom_collections/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_11', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CustomCollection.count({ + session: test_session, + product_id: "632910392", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/custom_collections/count.json', + query: 'product_id=632910392', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_12', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CustomCollection.find({ + session: test_session, + id: 841564295, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/custom_collections/841564295.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_13', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const custom_collection = new CustomCollection({session: test_session}); + custom_collection.id = 841564295; + custom_collection.body_html = "

5000 songs in your pocket

"; + await custom_collection.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/custom_collections/841564295.json', + query: '', + headers, + data: { "custom_collection": {id: 841564295, body_html: "

5000 songs in your pocket

"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_14', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const custom_collection = new CustomCollection({session: test_session}); + custom_collection.id = 841564295; + custom_collection.collects = [ + { + product_id: 921728736, + position: 1 + }, + { + id: 455204334, + position: 2 + } + ]; + await custom_collection.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/custom_collections/841564295.json', + query: '', + headers, + data: { "custom_collection": {id: 841564295, collects: [{product_id: 921728736, position: 1}, {id: 455204334, position: 2}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_15', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const custom_collection = new CustomCollection({session: test_session}); + custom_collection.id = 841564295; + custom_collection.published = true; + await custom_collection.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/custom_collections/841564295.json', + query: '', + headers, + data: { "custom_collection": {id: 841564295, published: true} } + }).toMatchMadeHttpRequest(); + }); + + it('test_16', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const custom_collection = new CustomCollection({session: test_session}); + custom_collection.id = 841564295; + custom_collection.published = false; + await custom_collection.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/custom_collections/841564295.json', + query: '', + headers, + data: { "custom_collection": {id: 841564295, published: false} } + }).toMatchMadeHttpRequest(); + }); + + it('test_17', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const custom_collection = new CustomCollection({session: test_session}); + custom_collection.id = 841564295; + custom_collection.image = { + attachment: "R0lGODlhbgCMAPf/APbr48VySrxTO7IgKt2qmKQdJeK8lsFjROG5p/nz7Zg3\nMNmnd7Q1MLNVS9GId71hSJMZIuzTu4UtKbeEeakhKMl8U8WYjfr18YQaIbAf\nKKwhKdKzqpQtLebFortOOejKrOjZ1Mt7aMNpVbAqLLV7bsNqR 3WwMqEWenN\nsZYxL/Ddy/Pm2e7ZxLlUQrIjNPXp3bU5MbhENbEtLtqhj5ZQTfHh0bMxL7Ip\nNsNyUYkZIrZJPcqGdYIUHb5aPKkeJnoUHd2yiJkiLKYiKLRFOsyJXKVDO8up\nosFaS TBnK4kKti5sNaYg/z49aqYl5kqLrljUtORfMOlo/36 H4ZH8yDYq0f\nKKFYTaU9MrY8MrZBNXwXHpgaIdGVYu/byLZNP9SaZLIyOuXCtHkpJst Wpcm\nLMyCa8BfP9GMb9KQdPDd1PPk1sd5VP79/L5dQZ0bI9 ymqssK9WcfIoXHdzG\nxdWWfteib79lSr1YP86MYurQxKdcUKdMQr5ZSfPs6YEZH8uhl4oWIenMuurQ\nttmejaqoqsqBVaAcJLlJN5kvMLlZRMNsSL5fRak0LbdQQMVvSPjw6cJnRpkf\nKtmjhvfu5cJtT7IuOMVvWLY/M/37 o0YH9ibhtSYdObErc6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UrzpMeAAIWASeB4P/AQ9 cHjEJx7xWgDE5nLQ\neMdHXvKbg/zkMZ23H/1oFRjYPOc9v3nQ58Aw0xn9LACvO7HQAOZVf/jl0ii1\nHcXe9bPX3euftaPL5R71tIf97nsy7/o0WlP2r4/JOU7B r5nqva7jz1EdZ97\n4qNe bonfvCfVXvly1762beOOdLBd Q7PCAAOw==\n", + alt: "Rails logo" + }; + await custom_collection.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/custom_collections/841564295.json', + query: '', + headers, + data: { "custom_collection": {id: 841564295, image: {attachment: "R0lGODlhbgCMAPf/APbr48VySrxTO7IgKt2qmKQdJeK8lsFjROG5p/nz7Zg3\nMNmnd7Q1MLNVS9GId71hSJMZIuzTu4UtKbeEeakhKMl8U8WYjfr18YQaIbAf\nKKwhKdKzqpQtLebFortOOejKrOjZ1Mt7aMNpVbAqLLV7bsNqR 3WwMqEWenN\nsZYxL/Ddy/Pm2e7ZxLlUQrIjNPXp3bU5MbhENbEtLtqhj5ZQTfHh0bMxL7Ip\nNsNyUYkZIrZJPcqGdYIUHb5aPKkeJnoUHd2yiJkiLKYiKLRFOsyJXKVDO8up\nosFaS TBnK4kKti5sNaYg/z49aqYl5kqLrljUtORfMOlo/36 H4ZH8yDYq0f\nKKFYTaU9MrY8MrZBNXwXHpgaIdGVYu/byLZNP9SaZLIyOuXCtHkpJst Wpcm\nLMyCa8BfP9GMb9KQdPDd1PPk1sd5VP79/L5dQZ0bI9 ymqssK9WcfIoXHdzG\nxdWWfteib79lSr1YP86MYurQxKdcUKdMQr5ZSfPs6YEZH8uhl4oWIenMuurQ\nttmejaqoqsqBVaAcJLlJN5kvMLlZRMNsSL5fRak0LbdQQMVvSPjw6cJnRpkf\nKtmjhvfu5cJtT7IuOMVvWLY/M/37 o0YH9ibhtSYdObErc6HarM9NnYSGNGR\navLi09unje3WyeO8rsVrT7tdRtK3uffu6NWeaL9pTJIjJrM4NPbx8cdyX7M7\nPYYVHu7j4KgoN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O7HQAOZVf/jl0ii1\nHcXe9bPX3euftaPL5R71tIf97nsy7/o0WlP2r4/JOU7B r5nqva7jz1EdZ97\n4qNe bonfvCfVXvly1762beOOdLBd Q7PCAAOw==\n", alt: "Rails logo"}} } + }).toMatchMadeHttpRequest(); + }); + + it('test_18', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const custom_collection = new CustomCollection({session: test_session}); + custom_collection.id = 841564295; + custom_collection.image = { + alt: "Rails logo" + }; + await custom_collection.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/custom_collections/841564295.json', + query: '', + headers, + data: { "custom_collection": {id: 841564295, image: {alt: "Rails logo"}} } + }).toMatchMadeHttpRequest(); + }); + + it('test_19', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const custom_collection = new CustomCollection({session: test_session}); + custom_collection.id = 841564295; + custom_collection.image = ""; + custom_collection.updated_at = "2022-02-03T17:12:38-05:00"; + custom_collection.title = "IPods"; + custom_collection.handle = "ipods"; + custom_collection.body_html = "

The best selling ipod ever

"; + custom_collection.published_at = "2008-02-01T19:00:00-05:00"; + custom_collection.sort_order = "manual"; + custom_collection.template_suffix = null; + custom_collection.published_scope = "web"; + custom_collection.admin_graphql_api_id = "gid://shopify/Collection/841564295"; + await custom_collection.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/custom_collections/841564295.json', + query: '', + headers, + data: { "custom_collection": {id: 841564295, image: "", updated_at: "2022-02-03T17:12:38-05:00", title: "IPods", handle: "ipods", body_html: "

The best selling ipod ever

", published_at: "2008-02-01T19:00:00-05:00", sort_order: "manual", template_suffix: null, published_scope: "web", admin_graphql_api_id: "gid://shopify/Collection/841564295"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_20', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const custom_collection = new CustomCollection({session: test_session}); + custom_collection.id = 841564295; + custom_collection.metafields = [ + { + key: "new", + value: "newvalue", + value_type: "string", + namespace: "global" + } + ]; + await custom_collection.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/custom_collections/841564295.json', + query: '', + headers, + data: { "custom_collection": {id: 841564295, metafields: [{key: "new", value: "newvalue", value_type: "string", namespace: "global"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_21', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CustomCollection.delete({ + session: test_session, + id: 841564295, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-04/custom_collections/841564295.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-04/customer.test.ts b/src/rest-resources/__tests__/2021-04/customer.test.ts new file mode 100644 index 000000000..6d37ab827 --- /dev/null +++ b/src/rest-resources/__tests__/2021-04/customer.test.ts @@ -0,0 +1,440 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Customer} from '../../2021-04'; + +describe('Customer resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.April21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Customer.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/customers.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Customer.all({ + session: test_session, + since_id: "207119551", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/customers.json', + query: 'since_id=207119551', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Customer.all({ + session: test_session, + updated_at_min: "2022-02-02 21:51:21", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/customers.json', + query: 'updated_at_min=2022-02-02+21%3A51%3A21', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Customer.all({ + session: test_session, + ids: "207119551,1073339489", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/customers.json', + query: 'ids=207119551%2C1073339489', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const customer = new Customer({session: test_session}); + customer.first_name = "Steve"; + customer.last_name = "Lastnameson"; + customer.email = "steve.lastnameson@example.com"; + customer.phone = " 15142546011"; + customer.verified_email = true; + customer.addresses = [ + { + address1: "123 Oak St", + city: "Ottawa", + province: "ON", + phone: "555-1212", + zip: "123 ABC", + last_name: "Lastnameson", + first_name: "Mother", + country: "CA" + } + ]; + customer.password = "newpass"; + customer.password_confirmation = "newpass"; + customer.send_email_welcome = false; + await customer.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/customers.json', + query: '', + headers, + data: { "customer": {first_name: "Steve", last_name: "Lastnameson", email: "steve.lastnameson@example.com", phone: " 15142546011", verified_email: true, addresses: [{address1: "123 Oak St", city: "Ottawa", province: "ON", phone: "555-1212", zip: "123 ABC", last_name: "Lastnameson", first_name: "Mother", country: "CA"}], password: "newpass", password_confirmation: "newpass", send_email_welcome: false} } + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const customer = new Customer({session: test_session}); + customer.first_name = "Steve"; + customer.last_name = "Lastnameson"; + customer.email = "steve.lastnameson@example.com"; + customer.phone = " 15142546011"; + customer.verified_email = true; + customer.addresses = [ + { + address1: "123 Oak St", + city: "Ottawa", + province: "ON", + phone: "555-1212", + zip: "123 ABC", + last_name: "Lastnameson", + first_name: "Mother", + country: "CA" + } + ]; + await customer.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/customers.json', + query: '', + headers, + data: { "customer": {first_name: "Steve", last_name: "Lastnameson", email: "steve.lastnameson@example.com", phone: " 15142546011", verified_email: true, addresses: [{address1: "123 Oak St", city: "Ottawa", province: "ON", phone: "555-1212", zip: "123 ABC", last_name: "Lastnameson", first_name: "Mother", country: "CA"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const customer = new Customer({session: test_session}); + customer.first_name = "Steve"; + customer.last_name = "Lastnameson"; + customer.email = "steve.lastnameson@example.com"; + customer.phone = " 15142546011"; + customer.verified_email = true; + customer.addresses = [ + { + address1: "123 Oak St", + city: "Ottawa", + province: "ON", + phone: "555-1212", + zip: "123 ABC", + last_name: "Lastnameson", + first_name: "Mother", + country: "CA" + } + ]; + customer.metafields = [ + { + key: "new", + value: "newvalue", + value_type: "string", + namespace: "global" + } + ]; + await customer.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/customers.json', + query: '', + headers, + data: { "customer": {first_name: "Steve", last_name: "Lastnameson", email: "steve.lastnameson@example.com", phone: " 15142546011", verified_email: true, addresses: [{address1: "123 Oak St", city: "Ottawa", province: "ON", phone: "555-1212", zip: "123 ABC", last_name: "Lastnameson", first_name: "Mother", country: "CA"}], metafields: [{key: "new", value: "newvalue", value_type: "string", namespace: "global"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const customer = new Customer({session: test_session}); + customer.first_name = "Steve"; + customer.last_name = "Lastnameson"; + customer.email = "steve.lastnameson@example.com"; + customer.phone = " 15142546011"; + customer.verified_email = true; + customer.addresses = [ + { + address1: "123 Oak St", + city: "Ottawa", + province: "ON", + phone: "555-1212", + zip: "123 ABC", + last_name: "Lastnameson", + first_name: "Mother", + country: "CA" + } + ]; + customer.send_email_invite = true; + await customer.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/customers.json', + query: '', + headers, + data: { "customer": {first_name: "Steve", last_name: "Lastnameson", email: "steve.lastnameson@example.com", phone: " 15142546011", verified_email: true, addresses: [{address1: "123 Oak St", city: "Ottawa", province: "ON", phone: "555-1212", zip: "123 ABC", last_name: "Lastnameson", first_name: "Mother", country: "CA"}], send_email_invite: true} } + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Customer.search({ + session: test_session, + query: "Bob country:United States", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/customers/search.json', + query: 'query=Bob+country%3AUnited+States', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_10', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Customer.find({ + session: test_session, + id: 207119551, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/customers/207119551.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_11', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const customer = new Customer({session: test_session}); + customer.id = 207119551; + customer.email = "changed@email.address.com"; + customer.note = "Customer is a great guy"; + await customer.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/customers/207119551.json', + query: '', + headers, + data: { "customer": {id: 207119551, email: "changed@email.address.com", note: "Customer is a great guy"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_12', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const customer = new Customer({session: test_session}); + customer.id = 207119551; + customer.metafields = [ + { + key: "new", + value: "newvalue", + value_type: "string", + namespace: "global" + } + ]; + await customer.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/customers/207119551.json', + query: '', + headers, + data: { "customer": {id: 207119551, metafields: [{key: "new", value: "newvalue", value_type: "string", namespace: "global"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_13', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const customer = new Customer({session: test_session}); + customer.id = 207119551; + customer.tags = "New Customer, Repeat Customer"; + await customer.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/customers/207119551.json', + query: '', + headers, + data: { "customer": {id: 207119551, tags: "New Customer, Repeat Customer"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_14', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const customer = new Customer({session: test_session}); + customer.id = 207119551; + customer.accepts_marketing = true; + customer.accepts_marketing_updated_at = "2022-01-31T16:45:55-05:00"; + customer.marketing_opt_in_level = "confirmed_opt_in"; + await customer.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/customers/207119551.json', + query: '', + headers, + data: { "customer": {id: 207119551, accepts_marketing: true, accepts_marketing_updated_at: "2022-01-31T16:45:55-05:00", marketing_opt_in_level: "confirmed_opt_in"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_15', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const customer = new Customer({session: test_session}); + customer.id = 207119551; + await customer.account_activation_url({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/customers/207119551/account_activation_url.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_16', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const customer = new Customer({session: test_session}); + customer.id = 207119551; + await customer.send_invite({ + body: {customer_invite: {}}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/customers/207119551/send_invite.json', + query: '', + headers, + data: {customer_invite: {}} + }).toMatchMadeHttpRequest(); + }); + + it('test_17', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const customer = new Customer({session: test_session}); + customer.id = 207119551; + await customer.send_invite({ + body: {customer_invite: {to: "new_test_email@shopify.com", from: "j.limited@example.com", bcc: ["j.limited@example.com"], subject: "Welcome to my new shop", custom_message: "My awesome new store"}}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/customers/207119551/send_invite.json', + query: '', + headers, + data: {customer_invite: {to: "new_test_email@shopify.com", from: "j.limited@example.com", bcc: ["j.limited@example.com"], subject: "Welcome to my new shop", custom_message: "My awesome new store"}} + }).toMatchMadeHttpRequest(); + }); + + it('test_18', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Customer.count({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/customers/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_19', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Customer.orders({ + session: test_session, + id: 207119551, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/customers/207119551/orders.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-04/customer_address.test.ts b/src/rest-resources/__tests__/2021-04/customer_address.test.ts new file mode 100644 index 000000000..4fb25f21d --- /dev/null +++ b/src/rest-resources/__tests__/2021-04/customer_address.test.ts @@ -0,0 +1,180 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {CustomerAddress} from '../../2021-04'; + +describe('CustomerAddress resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.April21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CustomerAddress.all({ + session: test_session, + customer_id: 207119551, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/customers/207119551/addresses.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CustomerAddress.all({ + session: test_session, + customer_id: 207119551, + limit: "1", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/customers/207119551/addresses.json', + query: 'limit=1', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const customer_address = new CustomerAddress({session: test_session}); + customer_address.customer_id = 207119551; + customer_address.address1 = "1 Rue des Carrieres"; + customer_address.address2 = "Suite 1234"; + customer_address.city = "Montreal"; + customer_address.company = "Fancy Co."; + customer_address.first_name = "Samuel"; + customer_address.last_name = "de Champlain"; + customer_address.phone = "819-555-5555"; + customer_address.province = "Quebec"; + customer_address.country = "Canada"; + customer_address.zip = "G1R 4P5"; + customer_address.name = "Samuel de Champlain"; + customer_address.province_code = "QC"; + customer_address.country_code = "CA"; + customer_address.country_name = "Canada"; + await customer_address.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/customers/207119551/addresses.json', + query: '', + headers, + data: { "address": {address1: "1 Rue des Carrieres", address2: "Suite 1234", city: "Montreal", company: "Fancy Co.", first_name: "Samuel", last_name: "de Champlain", phone: "819-555-5555", province: "Quebec", country: "Canada", zip: "G1R 4P5", name: "Samuel de Champlain", province_code: "QC", country_code: "CA", country_name: "Canada"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CustomerAddress.find({ + session: test_session, + customer_id: 207119551, + id: 207119551, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/customers/207119551/addresses/207119551.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const customer_address = new CustomerAddress({session: test_session}); + customer_address.customer_id = 207119551; + customer_address.id = 207119551; + customer_address.zip = "90210"; + await customer_address.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/customers/207119551/addresses/207119551.json', + query: '', + headers, + data: { "address": {id: 207119551, zip: "90210"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CustomerAddress.delete({ + session: test_session, + customer_id: 207119551, + id: 1053317335, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-04/customers/207119551/addresses/1053317335.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const customer_address = new CustomerAddress({session: test_session}); + customer_address.customer_id = 207119551; + await customer_address.set({ + address_ids: ["1053317336"], + operation: "destroy", + }); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/customers/207119551/addresses/set.json', + query: 'address_ids%5B%5D=1053317336&operation=destroy', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const customer_address = new CustomerAddress({session: test_session}); + customer_address.customer_id = 207119551; + customer_address.id = 1053317337; + await customer_address.default({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/customers/207119551/addresses/1053317337/default.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-04/customer_saved_search.test.ts b/src/rest-resources/__tests__/2021-04/customer_saved_search.test.ts new file mode 100644 index 000000000..37135c9d2 --- /dev/null +++ b/src/rest-resources/__tests__/2021-04/customer_saved_search.test.ts @@ -0,0 +1,195 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {CustomerSavedSearch} from '../../2021-04'; + +describe('CustomerSavedSearch resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.April21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CustomerSavedSearch.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/customer_saved_searches.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CustomerSavedSearch.all({ + session: test_session, + since_id: "20610973", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/customer_saved_searches.json', + query: 'since_id=20610973', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const customer_saved_search = new CustomerSavedSearch({session: test_session}); + customer_saved_search.name = "Spent more than $50"; + customer_saved_search.query = "total_spent:>50"; + await customer_saved_search.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/customer_saved_searches.json', + query: '', + headers, + data: { "customer_saved_search": {name: "Spent more than $50", query: "total_spent:>50"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const customer_saved_search = new CustomerSavedSearch({session: test_session}); + customer_saved_search.name = "Spent more than $50 and after 2013"; + customer_saved_search.query = "total_spent:>50 order_date:>=2013-01-01"; + await customer_saved_search.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/customer_saved_searches.json', + query: '', + headers, + data: { "customer_saved_search": {name: "Spent more than $50 and after 2013", query: "total_spent:>50 order_date:>=2013-01-01"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CustomerSavedSearch.count({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/customer_saved_searches/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CustomerSavedSearch.count({ + session: test_session, + since_id: "20610973", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/customer_saved_searches/count.json', + query: 'since_id=20610973', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CustomerSavedSearch.find({ + session: test_session, + id: 789629109, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/customer_saved_searches/789629109.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const customer_saved_search = new CustomerSavedSearch({session: test_session}); + customer_saved_search.id = 789629109; + customer_saved_search.name = "This Name Has Been Changed"; + await customer_saved_search.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/customer_saved_searches/789629109.json', + query: '', + headers, + data: { "customer_saved_search": {id: 789629109, name: "This Name Has Been Changed"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CustomerSavedSearch.delete({ + session: test_session, + id: 789629109, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-04/customer_saved_searches/789629109.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_10', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CustomerSavedSearch.customers({ + session: test_session, + id: 789629109, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/customer_saved_searches/789629109/customers.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-04/deprecated_api_call.test.ts b/src/rest-resources/__tests__/2021-04/deprecated_api_call.test.ts new file mode 100644 index 000000000..3b510532a --- /dev/null +++ b/src/rest-resources/__tests__/2021-04/deprecated_api_call.test.ts @@ -0,0 +1,34 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {DeprecatedApiCall} from '../../2021-04'; + +describe('DeprecatedApiCall resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.April21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await DeprecatedApiCall.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/deprecated_api_calls.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-04/discount_code.test.ts b/src/rest-resources/__tests__/2021-04/discount_code.test.ts new file mode 100644 index 000000000..41118ec73 --- /dev/null +++ b/src/rest-resources/__tests__/2021-04/discount_code.test.ts @@ -0,0 +1,184 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {DiscountCode} from '../../2021-04'; + +describe('DiscountCode resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.April21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const discount_code = new DiscountCode({session: test_session}); + discount_code.price_rule_id = 507328175; + discount_code.code = "SUMMERSALE10OFF"; + await discount_code.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/price_rules/507328175/discount_codes.json', + query: '', + headers, + data: { "discount_code": {code: "SUMMERSALE10OFF"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await DiscountCode.all({ + session: test_session, + price_rule_id: 507328175, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/price_rules/507328175/discount_codes.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const discount_code = new DiscountCode({session: test_session}); + discount_code.price_rule_id = 507328175; + discount_code.id = 507328175; + discount_code.code = "WINTERSALE20OFF"; + await discount_code.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/price_rules/507328175/discount_codes/507328175.json', + query: '', + headers, + data: { "discount_code": {id: 507328175, code: "WINTERSALE20OFF"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await DiscountCode.find({ + session: test_session, + price_rule_id: 507328175, + id: 507328175, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/price_rules/507328175/discount_codes/507328175.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await DiscountCode.delete({ + session: test_session, + price_rule_id: 507328175, + id: 507328175, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-04/price_rules/507328175/discount_codes/507328175.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await DiscountCode.count({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/discount_codes/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const discount_code = new DiscountCode({session: test_session}); + discount_code.price_rule_id = 507328175; + await discount_code.batch({ + body: {discount_codes: [{code: "SUMMER1"}, {code: "SUMMER2"}, {code: "SUMMER3"}]}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/price_rules/507328175/batch.json', + query: '', + headers, + data: {discount_codes: [{code: "SUMMER1"}, {code: "SUMMER2"}, {code: "SUMMER3"}]} + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await DiscountCode.get_all({ + session: test_session, + price_rule_id: 507328175, + batch_id: 173232803, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/price_rules/507328175/batch/173232803.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await DiscountCode.all({ + session: test_session, + price_rule_id: 507328175, + batch_id: 173232803, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/price_rules/507328175/batch/173232803/discount_codes.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-04/dispute.test.ts b/src/rest-resources/__tests__/2021-04/dispute.test.ts new file mode 100644 index 000000000..c4782e75a --- /dev/null +++ b/src/rest-resources/__tests__/2021-04/dispute.test.ts @@ -0,0 +1,88 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Dispute} from '../../2021-04'; + +describe('Dispute resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.April21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Dispute.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/shopify_payments/disputes.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Dispute.all({ + session: test_session, + status: "won", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/shopify_payments/disputes.json', + query: 'status=won', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Dispute.all({ + session: test_session, + initiated_at: "2013-05-03", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/shopify_payments/disputes.json', + query: 'initiated_at=2013-05-03', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Dispute.find({ + session: test_session, + id: 598735659, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/shopify_payments/disputes/598735659.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-04/draft_order.test.ts b/src/rest-resources/__tests__/2021-04/draft_order.test.ts new file mode 100644 index 000000000..3e7bb2ea1 --- /dev/null +++ b/src/rest-resources/__tests__/2021-04/draft_order.test.ts @@ -0,0 +1,346 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {DraftOrder} from '../../2021-04'; + +describe('DraftOrder resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.April21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const draft_order = new DraftOrder({session: test_session}); + draft_order.line_items = [ + { + variant_id: 447654529, + quantity: 1 + } + ]; + await draft_order.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/draft_orders.json', + query: '', + headers, + data: { "draft_order": {line_items: [{variant_id: 447654529, quantity: 1}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const draft_order = new DraftOrder({session: test_session}); + draft_order.line_items = [ + { + title: "Custom Tee", + price: "20.00", + quantity: 2 + } + ]; + draft_order.applied_discount = { + description: "Custom discount", + value_type: "fixed_amount", + value: "10.0", + amount: "10.00", + title: "Custom" + }; + draft_order.customer = { + id: 207119551 + }; + draft_order.use_customer_default_address = true; + await draft_order.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/draft_orders.json', + query: '', + headers, + data: { "draft_order": {line_items: [{title: "Custom Tee", price: "20.00", quantity: 2}], applied_discount: {description: "Custom discount", value_type: "fixed_amount", value: "10.0", amount: "10.00", title: "Custom"}, customer: {id: 207119551}, use_customer_default_address: true} } + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const draft_order = new DraftOrder({session: test_session}); + draft_order.line_items = [ + { + title: "Custom Tee", + price: "20.00", + quantity: 1, + applied_discount: { + description: "Custom discount", + value_type: "fixed_amount", + value: "10.0", + amount: "10.0", + title: "Custom" + } + } + ]; + await draft_order.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/draft_orders.json', + query: '', + headers, + data: { "draft_order": {line_items: [{title: "Custom Tee", price: "20.00", quantity: 1, applied_discount: {description: "Custom discount", value_type: "fixed_amount", value: "10.0", amount: "10.0", title: "Custom"}}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const draft_order = new DraftOrder({session: test_session}); + draft_order.line_items = [ + { + title: "Custom Tee", + price: "20.00", + quantity: 1, + applied_discount: { + description: "Custom discount", + value_type: "percentage", + value: "10.0", + amount: "2.0", + title: "Custom" + } + } + ]; + await draft_order.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/draft_orders.json', + query: '', + headers, + data: { "draft_order": {line_items: [{title: "Custom Tee", price: "20.00", quantity: 1, applied_discount: {description: "Custom discount", value_type: "percentage", value: "10.0", amount: "2.0", title: "Custom"}}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const draft_order = new DraftOrder({session: test_session}); + draft_order.line_items = [ + { + title: "Custom Tee", + price: "20.00", + quantity: 2 + } + ]; + draft_order.customer = { + id: 207119551 + }; + draft_order.use_customer_default_address = true; + await draft_order.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/draft_orders.json', + query: '', + headers, + data: { "draft_order": {line_items: [{title: "Custom Tee", price: "20.00", quantity: 2}], customer: {id: 207119551}, use_customer_default_address: true} } + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await DraftOrder.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/draft_orders.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const draft_order = new DraftOrder({session: test_session}); + draft_order.id = 994118539; + draft_order.note = "Customer contacted us about a custom engraving on this iPod"; + await draft_order.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/draft_orders/994118539.json', + query: '', + headers, + data: { "draft_order": {id: 994118539, note: "Customer contacted us about a custom engraving on this iPod"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const draft_order = new DraftOrder({session: test_session}); + draft_order.id = 994118539; + draft_order.applied_discount = { + description: "Custom discount", + value_type: "percentage", + value: "10.0", + amount: "19.90", + title: "Custom" + }; + await draft_order.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/draft_orders/994118539.json', + query: '', + headers, + data: { "draft_order": {id: 994118539, applied_discount: {description: "Custom discount", value_type: "percentage", value: "10.0", amount: "19.90", title: "Custom"}} } + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await DraftOrder.find({ + session: test_session, + id: 994118539, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/draft_orders/994118539.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_10', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await DraftOrder.delete({ + session: test_session, + id: 994118539, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-04/draft_orders/994118539.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_11', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await DraftOrder.count({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/draft_orders/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_12', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const draft_order = new DraftOrder({session: test_session}); + draft_order.id = 994118539; + await draft_order.send_invoice({ + body: {draft_order_invoice: {to: "first@example.com", from: "j.smith@example.com", bcc: ["j.smith@example.com"], subject: "Apple Computer Invoice", custom_message: "Thank you for ordering!"}}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/draft_orders/994118539/send_invoice.json', + query: '', + headers, + data: {draft_order_invoice: {to: "first@example.com", from: "j.smith@example.com", bcc: ["j.smith@example.com"], subject: "Apple Computer Invoice", custom_message: "Thank you for ordering!"}} + }).toMatchMadeHttpRequest(); + }); + + it('test_13', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const draft_order = new DraftOrder({session: test_session}); + draft_order.id = 994118539; + await draft_order.send_invoice({ + body: {draft_order_invoice: {}}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/draft_orders/994118539/send_invoice.json', + query: '', + headers, + data: {draft_order_invoice: {}} + }).toMatchMadeHttpRequest(); + }); + + it('test_14', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const draft_order = new DraftOrder({session: test_session}); + draft_order.id = 994118539; + await draft_order.complete({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/draft_orders/994118539/complete.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_15', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const draft_order = new DraftOrder({session: test_session}); + draft_order.id = 994118539; + await draft_order.complete({ + payment_pending: "true", + }); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/draft_orders/994118539/complete.json', + query: 'payment_pending=true', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-04/event.test.ts b/src/rest-resources/__tests__/2021-04/event.test.ts new file mode 100644 index 000000000..dc4673c5a --- /dev/null +++ b/src/rest-resources/__tests__/2021-04/event.test.ts @@ -0,0 +1,216 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Event} from '../../2021-04'; + +describe('Event resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.April21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Event.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/events.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Event.all({ + session: test_session, + created_at_min: "2008-01-10 12:30:00+00:00", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/events.json', + query: 'created_at_min=2008-01-10+12%3A30%3A00%2B00%3A00', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Event.all({ + session: test_session, + order_id: 450789469, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/orders/450789469/events.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Event.all({ + session: test_session, + order_id: 450789469, + limit: "1", + since_id: "164748010", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/orders/450789469/events.json', + query: 'limit=1&since_id=164748010', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Event.all({ + session: test_session, + product_id: 921728736, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/products/921728736/events.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Event.all({ + session: test_session, + since_id: "164748010", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/events.json', + query: 'since_id=164748010', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Event.all({ + session: test_session, + filter: "Product,Order", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/events.json', + query: 'filter=Product%2COrder', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Event.all({ + session: test_session, + filter: "Product", + verb: "destroy", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/events.json', + query: 'filter=Product&verb=destroy', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Event.find({ + session: test_session, + id: 677313116, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/events/677313116.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_10', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Event.count({ + session: test_session, + created_at_min: "2008-01-10T13:00:00+00:00", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/events/count.json', + query: 'created_at_min=2008-01-10T13%3A00%3A00%2B00%3A00', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_11', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Event.count({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/events/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-04/fulfillment.test.ts b/src/rest-resources/__tests__/2021-04/fulfillment.test.ts new file mode 100644 index 000000000..3311f8e3f --- /dev/null +++ b/src/rest-resources/__tests__/2021-04/fulfillment.test.ts @@ -0,0 +1,581 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Fulfillment} from '../../2021-04'; + +describe('Fulfillment resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.April21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Fulfillment.all({ + session: test_session, + order_id: 450789469, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/orders/450789469/fulfillments.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Fulfillment.all({ + session: test_session, + order_id: 450789469, + since_id: "255858046", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/orders/450789469/fulfillments.json', + query: 'since_id=255858046', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment = new Fulfillment({session: test_session}); + fulfillment.order_id = 450789469; + fulfillment.location_id = 487838322; + fulfillment.tracking_number = "123456789"; + fulfillment.tracking_urls = [ + "https://shipping.xyz/track.php?num=123456789", + "https://anothershipper.corp/track.php?code=abc" + ]; + fulfillment.notify_customer = true; + await fulfillment.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/orders/450789469/fulfillments.json', + query: '', + headers, + data: { "fulfillment": {location_id: 487838322, tracking_number: "123456789", tracking_urls: ["https://shipping.xyz/track.php?num=123456789", "https://anothershipper.corp/track.php?code=abc"], notify_customer: true} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment = new Fulfillment({session: test_session}); + fulfillment.order_id = 450789469; + fulfillment.location_id = 655441491; + fulfillment.tracking_number = null; + fulfillment.line_items = [ + { + id: 518995019 + } + ]; + await fulfillment.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/orders/450789469/fulfillments.json', + query: '', + headers, + data: { "fulfillment": {location_id: 655441491, tracking_number: null, line_items: [{id: 518995019}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment = new Fulfillment({session: test_session}); + fulfillment.order_id = 450789469; + fulfillment.location_id = 655441491; + fulfillment.tracking_numbers = [ + "88b451840563b72cc15d3fcb6179f302", + "aee587edbd98ad725d27974c808ec7d6", + "94e71192ecf091ea5c25b69c385c2b1b" + ]; + fulfillment.line_items = [ + { + id: 518995019 + } + ]; + await fulfillment.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/orders/450789469/fulfillments.json', + query: '', + headers, + data: { "fulfillment": {location_id: 655441491, tracking_numbers: ["88b451840563b72cc15d3fcb6179f302", "aee587edbd98ad725d27974c808ec7d6", "94e71192ecf091ea5c25b69c385c2b1b"], line_items: [{id: 518995019}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment = new Fulfillment({session: test_session}); + fulfillment.order_id = 450789469; + fulfillment.location_id = 655441491; + fulfillment.tracking_url = "http://www.packagetrackr.com/track/somecarrier/1234567"; + fulfillment.tracking_company = "Jack Black's Pack, Stack and Track"; + fulfillment.line_items = [ + { + id: 518995019 + } + ]; + await fulfillment.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/orders/450789469/fulfillments.json', + query: '', + headers, + data: { "fulfillment": {location_id: 655441491, tracking_url: "http://www.packagetrackr.com/track/somecarrier/1234567", tracking_company: "Jack Black's Pack, Stack and Track", line_items: [{id: 518995019}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment = new Fulfillment({session: test_session}); + fulfillment.order_id = 450789469; + fulfillment.location_id = 655441491; + fulfillment.tracking_number = "123456789"; + fulfillment.tracking_company = "4PX"; + fulfillment.line_items = [ + { + id: 518995019 + } + ]; + await fulfillment.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/orders/450789469/fulfillments.json', + query: '', + headers, + data: { "fulfillment": {location_id: 655441491, tracking_number: "123456789", tracking_company: "4PX", line_items: [{id: 518995019}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment = new Fulfillment({session: test_session}); + fulfillment.order_id = 450789469; + fulfillment.location_id = 655441491; + fulfillment.tracking_number = "123456789010"; + fulfillment.tracking_company = "fed ex"; + fulfillment.line_items = [ + { + id: 518995019 + } + ]; + await fulfillment.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/orders/450789469/fulfillments.json', + query: '', + headers, + data: { "fulfillment": {location_id: 655441491, tracking_number: "123456789010", tracking_company: "fed ex", line_items: [{id: 518995019}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment = new Fulfillment({session: test_session}); + fulfillment.order_id = 450789469; + fulfillment.location_id = 655441491; + fulfillment.tracking_number = "123456789010"; + fulfillment.tracking_company = "fed ex"; + fulfillment.tracking_url = "https://www.new-fedex-tracking.com/?number=123456789010"; + fulfillment.line_items = [ + { + id: 518995019 + } + ]; + await fulfillment.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/orders/450789469/fulfillments.json', + query: '', + headers, + data: { "fulfillment": {location_id: 655441491, tracking_number: "123456789010", tracking_company: "fed ex", tracking_url: "https://www.new-fedex-tracking.com/?number=123456789010", line_items: [{id: 518995019}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_10', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment = new Fulfillment({session: test_session}); + fulfillment.order_id = 450789469; + fulfillment.location_id = 655441491; + fulfillment.tracking_number = "RR123456789CN"; + fulfillment.tracking_company = "Chinese Post"; + fulfillment.line_items = [ + { + id: 518995019 + } + ]; + await fulfillment.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/orders/450789469/fulfillments.json', + query: '', + headers, + data: { "fulfillment": {location_id: 655441491, tracking_number: "RR123456789CN", tracking_company: "Chinese Post", line_items: [{id: 518995019}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_11', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment = new Fulfillment({session: test_session}); + fulfillment.order_id = 450789469; + fulfillment.location_id = 655441491; + fulfillment.tracking_number = "1234567"; + fulfillment.tracking_company = "Custom Tracking Company"; + fulfillment.line_items = [ + { + id: 518995019 + } + ]; + await fulfillment.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/orders/450789469/fulfillments.json', + query: '', + headers, + data: { "fulfillment": {location_id: 655441491, tracking_number: "1234567", tracking_company: "Custom Tracking Company", line_items: [{id: 518995019}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_12', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment = new Fulfillment({session: test_session}); + fulfillment.order_id = 450789469; + fulfillment.location_id = 655441491; + fulfillment.tracking_number = "CJ274101086US"; + fulfillment.tracking_url = "http://www.custom-tracking.com/?tracking_number=CJ274101086US"; + fulfillment.line_items = [ + { + id: 518995019 + } + ]; + await fulfillment.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/orders/450789469/fulfillments.json', + query: '', + headers, + data: { "fulfillment": {location_id: 655441491, tracking_number: "CJ274101086US", tracking_url: "http://www.custom-tracking.com/?tracking_number=CJ274101086US", line_items: [{id: 518995019}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_13', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment = new Fulfillment({session: test_session}); + fulfillment.order_id = 450789469; + fulfillment.location_id = 655441491; + fulfillment.tracking_number = null; + fulfillment.line_items = [ + { + id: 518995019 + } + ]; + await fulfillment.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/orders/450789469/fulfillments.json', + query: '', + headers, + data: { "fulfillment": {location_id: 655441491, tracking_number: null, line_items: [{id: 518995019}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_14', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment = new Fulfillment({session: test_session}); + fulfillment.order_id = 450789469; + fulfillment.location_id = 655441491; + fulfillment.tracking_number = null; + fulfillment.line_items = [ + { + id: 518995019, + quantity: 1 + } + ]; + await fulfillment.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/orders/450789469/fulfillments.json', + query: '', + headers, + data: { "fulfillment": {location_id: 655441491, tracking_number: null, line_items: [{id: 518995019, quantity: 1}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_15', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Fulfillment.all({ + session: test_session, + fulfillment_order_id: 1046000859, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/fulfillment_orders/1046000859/fulfillments.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_16', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Fulfillment.count({ + session: test_session, + order_id: 450789469, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/orders/450789469/fulfillments/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_17', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Fulfillment.find({ + session: test_session, + order_id: 450789469, + id: 255858046, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/orders/450789469/fulfillments/255858046.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_18', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment = new Fulfillment({session: test_session}); + fulfillment.order_id = 450789469; + fulfillment.id = 255858046; + fulfillment.tracking_number = "987654321"; + await fulfillment.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/orders/450789469/fulfillments/255858046.json', + query: '', + headers, + data: { "fulfillment": {tracking_number: "987654321", id: 255858046} } + }).toMatchMadeHttpRequest(); + }); + + it('test_19', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment = new Fulfillment({session: test_session}); + fulfillment.message = "The package was shipped this morning."; + fulfillment.notify_customer = false; + fulfillment.tracking_info = { + number: 1562678, + url: "https://www.my-shipping-company.com", + company: "my-shipping-company" + }; + fulfillment.line_items_by_fulfillment_order = [ + { + fulfillment_order_id: 1046000873, + fulfillment_order_line_items: [ + { + id: 1058737644, + quantity: 1 + } + ] + } + ]; + await fulfillment.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/fulfillments.json', + query: '', + headers, + data: { "fulfillment": {message: "The package was shipped this morning.", notify_customer: false, tracking_info: {number: 1562678, url: "https://www.my-shipping-company.com", company: "my-shipping-company"}, line_items_by_fulfillment_order: [{fulfillment_order_id: 1046000873, fulfillment_order_line_items: [{id: 1058737644, quantity: 1}]}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_20', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment = new Fulfillment({session: test_session}); + fulfillment.message = "The package was shipped this morning."; + fulfillment.notify_customer = false; + fulfillment.tracking_info = { + number: 1562678, + url: "https://www.my-shipping-company.com", + company: "my-shipping-company" + }; + fulfillment.line_items_by_fulfillment_order = [ + { + fulfillment_order_id: 1046000874 + } + ]; + await fulfillment.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/fulfillments.json', + query: '', + headers, + data: { "fulfillment": {message: "The package was shipped this morning.", notify_customer: false, tracking_info: {number: 1562678, url: "https://www.my-shipping-company.com", company: "my-shipping-company"}, line_items_by_fulfillment_order: [{fulfillment_order_id: 1046000874}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_21', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment = new Fulfillment({session: test_session}); + fulfillment.id = 1069019908; + await fulfillment.update_tracking({ + body: {fulfillment: {notify_customer: true, tracking_info: {number: "1111", url: "http://www.my-url.com", company: "my-company"}}}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/fulfillments/1069019908/update_tracking.json', + query: '', + headers, + data: { "fulfillment": {notify_customer: true, tracking_info: {number: "1111", url: "http://www.my-url.com", company: "my-company"}} } + }).toMatchMadeHttpRequest(); + }); + + it('test_22', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment = new Fulfillment({session: test_session}); + fulfillment.order_id = 450789469; + fulfillment.id = 255858046; + await fulfillment.complete({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/orders/450789469/fulfillments/255858046/complete.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_23', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment = new Fulfillment({session: test_session}); + fulfillment.order_id = 450789469; + fulfillment.id = 255858046; + await fulfillment.open({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/orders/450789469/fulfillments/255858046/open.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_24', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment = new Fulfillment({session: test_session}); + fulfillment.order_id = 450789469; + fulfillment.id = 255858046; + await fulfillment.cancel({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/orders/450789469/fulfillments/255858046/cancel.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_25', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment = new Fulfillment({session: test_session}); + fulfillment.id = 1069019909; + await fulfillment.cancel({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/fulfillments/1069019909/cancel.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-04/fulfillment_event.test.ts b/src/rest-resources/__tests__/2021-04/fulfillment_event.test.ts new file mode 100644 index 000000000..52ed9c84e --- /dev/null +++ b/src/rest-resources/__tests__/2021-04/fulfillment_event.test.ts @@ -0,0 +1,95 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {FulfillmentEvent} from '../../2021-04'; + +describe('FulfillmentEvent resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.April21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await FulfillmentEvent.all({ + session: test_session, + order_id: 450789469, + fulfillment_id: 255858046, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/orders/450789469/fulfillments/255858046/events.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment_event = new FulfillmentEvent({session: test_session}); + fulfillment_event.order_id = 450789469; + fulfillment_event.fulfillment_id = 255858046; + fulfillment_event.status = "in_transit"; + await fulfillment_event.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/orders/450789469/fulfillments/255858046/events.json', + query: '', + headers, + data: { "event": {status: "in_transit"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await FulfillmentEvent.find({ + session: test_session, + order_id: 450789469, + fulfillment_id: 255858046, + id: 944956395, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/orders/450789469/fulfillments/255858046/events/944956395.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await FulfillmentEvent.delete({ + session: test_session, + order_id: 450789469, + fulfillment_id: 255858046, + id: 944956397, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-04/orders/450789469/fulfillments/255858046/events/944956397.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-04/fulfillment_order.test.ts b/src/rest-resources/__tests__/2021-04/fulfillment_order.test.ts new file mode 100644 index 000000000..94e8707bf --- /dev/null +++ b/src/rest-resources/__tests__/2021-04/fulfillment_order.test.ts @@ -0,0 +1,144 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {FulfillmentOrder} from '../../2021-04'; + +describe('FulfillmentOrder resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.April21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await FulfillmentOrder.all({ + session: test_session, + order_id: 450789469, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/orders/450789469/fulfillment_orders.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await FulfillmentOrder.find({ + session: test_session, + id: 1046000847, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/fulfillment_orders/1046000847.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment_order = new FulfillmentOrder({session: test_session}); + fulfillment_order.id = 1046000848; + await fulfillment_order.cancel({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/fulfillment_orders/1046000848/cancel.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment_order = new FulfillmentOrder({session: test_session}); + fulfillment_order.id = 1046000851; + await fulfillment_order.close({ + body: {fulfillment_order: {message: "Not enough inventory to complete this work."}}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/fulfillment_orders/1046000851/close.json', + query: '', + headers, + data: { "fulfillment_order": {message: "Not enough inventory to complete this work."} } + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment_order = new FulfillmentOrder({session: test_session}); + fulfillment_order.id = 1046000852; + await fulfillment_order.move({ + body: {fulfillment_order: {new_location_id: 655441491}}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/fulfillment_orders/1046000852/move.json', + query: '', + headers, + data: { "fulfillment_order": {new_location_id: 655441491} } + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment_order = new FulfillmentOrder({session: test_session}); + fulfillment_order.id = 1046000854; + await fulfillment_order.open({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/fulfillment_orders/1046000854/open.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment_order = new FulfillmentOrder({session: test_session}); + fulfillment_order.id = 1046000855; + await fulfillment_order.reschedule({ + body: {fulfillment_order: {new_fulfill_at: "2023-03-03"}}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/fulfillment_orders/1046000855/reschedule.json', + query: '', + headers, + data: { "fulfillment_order": {new_fulfill_at: "2023-03-03"} } + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-04/fulfillment_request.test.ts b/src/rest-resources/__tests__/2021-04/fulfillment_request.test.ts new file mode 100644 index 000000000..911316ef4 --- /dev/null +++ b/src/rest-resources/__tests__/2021-04/fulfillment_request.test.ts @@ -0,0 +1,101 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {FulfillmentRequest} from '../../2021-04'; + +describe('FulfillmentRequest resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.April21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment_request = new FulfillmentRequest({session: test_session}); + fulfillment_request.fulfillment_order_id = 1046000840; + fulfillment_request.message = "Fulfill this ASAP please."; + fulfillment_request.fulfillment_order_line_items = [ + { + id: 1058737578, + quantity: 1 + }, + { + id: 1058737579, + quantity: 1 + } + ]; + await fulfillment_request.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/fulfillment_orders/1046000840/fulfillment_request.json', + query: '', + headers, + data: { "fulfillment_request": {message: "Fulfill this ASAP please.", fulfillment_order_line_items: [{id: 1058737578, quantity: 1}, {id: 1058737579, quantity: 1}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment_request = new FulfillmentRequest({session: test_session}); + fulfillment_request.fulfillment_order_id = 1046000843; + fulfillment_request.message = "Fulfill this ASAP please."; + await fulfillment_request.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/fulfillment_orders/1046000843/fulfillment_request.json', + query: '', + headers, + data: { "fulfillment_request": {message: "Fulfill this ASAP please."} } + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment_request = new FulfillmentRequest({session: test_session}); + fulfillment_request.fulfillment_order_id = 1046000844; + await fulfillment_request.accept({ + body: {fulfillment_request: {message: "We will start processing your fulfillment on the next business day."}}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/fulfillment_orders/1046000844/fulfillment_request/accept.json', + query: '', + headers, + data: { "fulfillment_request": {message: "We will start processing your fulfillment on the next business day."} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment_request = new FulfillmentRequest({session: test_session}); + fulfillment_request.fulfillment_order_id = 1046000845; + await fulfillment_request.reject({ + body: {fulfillment_request: {message: "Not enough inventory on hand to complete the work."}}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/fulfillment_orders/1046000845/fulfillment_request/reject.json', + query: '', + headers, + data: { "fulfillment_request": {message: "Not enough inventory on hand to complete the work."} } + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-04/fulfillment_service.test.ts b/src/rest-resources/__tests__/2021-04/fulfillment_service.test.ts new file mode 100644 index 000000000..407f5dc27 --- /dev/null +++ b/src/rest-resources/__tests__/2021-04/fulfillment_service.test.ts @@ -0,0 +1,128 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {FulfillmentService} from '../../2021-04'; + +describe('FulfillmentService resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.April21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await FulfillmentService.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/fulfillment_services.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await FulfillmentService.all({ + session: test_session, + scope: "all", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/fulfillment_services.json', + query: 'scope=all', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment_service = new FulfillmentService({session: test_session}); + fulfillment_service.name = "Jupiter Fulfillment"; + fulfillment_service.callback_url = "http://google.com"; + fulfillment_service.inventory_management = true; + fulfillment_service.tracking_support = true; + fulfillment_service.requires_shipping_method = true; + fulfillment_service.format = "json"; + await fulfillment_service.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/fulfillment_services.json', + query: '', + headers, + data: { "fulfillment_service": {name: "Jupiter Fulfillment", callback_url: "http://google.com", inventory_management: true, tracking_support: true, requires_shipping_method: true, format: "json"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await FulfillmentService.find({ + session: test_session, + id: 755357713, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/fulfillment_services/755357713.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment_service = new FulfillmentService({session: test_session}); + fulfillment_service.id = 755357713; + fulfillment_service.name = "New Fulfillment Service Name"; + await fulfillment_service.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/fulfillment_services/755357713.json', + query: '', + headers, + data: { "fulfillment_service": {id: 755357713, name: "New Fulfillment Service Name"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await FulfillmentService.delete({ + session: test_session, + id: 755357713, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-04/fulfillment_services/755357713.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-04/gift_card.test.ts b/src/rest-resources/__tests__/2021-04/gift_card.test.ts new file mode 100644 index 000000000..9d99e7209 --- /dev/null +++ b/src/rest-resources/__tests__/2021-04/gift_card.test.ts @@ -0,0 +1,215 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {GiftCard} from '../../2021-04'; + +describe('GiftCard resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.April21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await GiftCard.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/gift_cards.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await GiftCard.all({ + session: test_session, + status: "enabled", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/gift_cards.json', + query: 'status=enabled', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const gift_card = new GiftCard({session: test_session}); + gift_card.note = "This is a note"; + gift_card.initial_value = 100.0; + gift_card.code = "ABCD EFGH IJKL MNOP"; + gift_card.template_suffix = "gift_cards.birthday.liquid"; + await gift_card.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/gift_cards.json', + query: '', + headers, + data: { "gift_card": {note: "This is a note", initial_value: 100.0, code: "ABCD EFGH IJKL MNOP", template_suffix: "gift_cards.birthday.liquid"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const gift_card = new GiftCard({session: test_session}); + gift_card.initial_value = 25.0; + await gift_card.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/gift_cards.json', + query: '', + headers, + data: { "gift_card": {initial_value: 25.0} } + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await GiftCard.find({ + session: test_session, + id: 1035197676, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/gift_cards/1035197676.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const gift_card = new GiftCard({session: test_session}); + gift_card.id = 1035197676; + gift_card.note = "Updating with a new note"; + await gift_card.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/gift_cards/1035197676.json', + query: '', + headers, + data: { "gift_card": {id: 1035197676, note: "Updating with a new note"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const gift_card = new GiftCard({session: test_session}); + gift_card.id = 1035197676; + gift_card.expires_on = "2020-01-01"; + await gift_card.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/gift_cards/1035197676.json', + query: '', + headers, + data: { "gift_card": {id: 1035197676, expires_on: "2020-01-01"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await GiftCard.count({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/gift_cards/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await GiftCard.count({ + session: test_session, + status: "enabled", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/gift_cards/count.json', + query: 'status=enabled', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_10', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const gift_card = new GiftCard({session: test_session}); + gift_card.id = 1035197676; + await gift_card.disable({ + body: {gift_card: {id: 1035197676}}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/gift_cards/1035197676/disable.json', + query: '', + headers, + data: { "gift_card": {id: 1035197676} } + }).toMatchMadeHttpRequest(); + }); + + it('test_11', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await GiftCard.search({ + session: test_session, + query: "last_characters:mnop", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/gift_cards/search.json', + query: 'query=last_characters%3Amnop', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-04/gift_card_adjustment.test.ts b/src/rest-resources/__tests__/2021-04/gift_card_adjustment.test.ts new file mode 100644 index 000000000..22c0ee05d --- /dev/null +++ b/src/rest-resources/__tests__/2021-04/gift_card_adjustment.test.ts @@ -0,0 +1,131 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {GiftCardAdjustment} from '../../2021-04'; + +describe('GiftCardAdjustment resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.April21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await GiftCardAdjustment.all({ + session: test_session, + gift_card_id: 1035197676, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/gift_cards/1035197676/adjustments.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const gift_card_adjustment = new GiftCardAdjustment({session: test_session}); + gift_card_adjustment.gift_card_id = 1035197676; + gift_card_adjustment.amount = 10.0; + gift_card_adjustment.note = "Customer refilled gift card by $10"; + await gift_card_adjustment.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/gift_cards/1035197676/adjustments.json', + query: '', + headers, + data: { "adjustment": {amount: 10.0, note: "Customer refilled gift card by $10"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const gift_card_adjustment = new GiftCardAdjustment({session: test_session}); + gift_card_adjustment.gift_card_id = 1035197676; + gift_card_adjustment.amount = -20.0; + gift_card_adjustment.note = "Customer spent $20 via external service"; + await gift_card_adjustment.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/gift_cards/1035197676/adjustments.json', + query: '', + headers, + data: { "adjustment": {amount: -20.0, note: "Customer spent $20 via external service"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const gift_card_adjustment = new GiftCardAdjustment({session: test_session}); + gift_card_adjustment.gift_card_id = 1035197676; + gift_card_adjustment.amount = 10.0; + gift_card_adjustment.remote_transaction_ref = "gift_card_app_transaction_193402"; + gift_card_adjustment.remote_transaction_url = "http://example.com/my-gift-card-app/gift_card_adjustments/193402"; + await gift_card_adjustment.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/gift_cards/1035197676/adjustments.json', + query: '', + headers, + data: { "adjustment": {amount: 10.0, remote_transaction_ref: "gift_card_app_transaction_193402", remote_transaction_url: "http://example.com/my-gift-card-app/gift_card_adjustments/193402"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const gift_card_adjustment = new GiftCardAdjustment({session: test_session}); + gift_card_adjustment.gift_card_id = 1035197676; + gift_card_adjustment.amount = 10.0; + gift_card_adjustment.processed_at = "2021-08-03T16:57:35-04:00"; + await gift_card_adjustment.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/gift_cards/1035197676/adjustments.json', + query: '', + headers, + data: { "adjustment": {amount: 10.0, processed_at: "2021-08-03T16:57:35-04:00"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await GiftCardAdjustment.find({ + session: test_session, + gift_card_id: 1035197676, + id: 9, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/gift_cards/1035197676/adjustments/9.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-04/image.test.ts b/src/rest-resources/__tests__/2021-04/image.test.ts new file mode 100644 index 000000000..abf0f6b44 --- /dev/null +++ b/src/rest-resources/__tests__/2021-04/image.test.ts @@ -0,0 +1,305 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Image} from '../../2021-04'; + +describe('Image resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.April21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Image.all({ + session: test_session, + product_id: 632910392, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/products/632910392/images.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Image.all({ + session: test_session, + product_id: 632910392, + since_id: "850703190", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/products/632910392/images.json', + query: 'since_id=850703190', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const image = new Image({session: test_session}); + image.product_id = 632910392; + image.attachment = "R0lGODlhbgCMAPf/APbr48VySrxTO7IgKt2qmKQdJeK8lsFjROG5p/nz7Zg3\nMNmnd7Q1MLNVS9GId71hSJMZIuzTu4UtKbeEeakhKMl8U8WYjfr18YQaIbAf\nKKwhKdKzqpQtLebFortOOejKrOjZ1Mt7aMNpVbAqLLV7bsNqR 3WwMqEWenN\nsZYxL/Ddy/Pm2e7ZxLlUQrIjNPXp3bU5MbhENbEtLtqhj5ZQTfHh0bMxL7Ip\nNsNyUYkZIrZJPcqGdYIUHb5aPKkeJnoUHd2yiJkiLKYiKLRFOsyJXKVDO8up\nosFaS TBnK4kKti5sNaYg/z49aqYl5kqLrljUtORfMOlo/36 H4ZH8yDYq0f\nKKFYTaU9MrY8MrZBNXwXHpgaIdGVYu/byLZNP9SaZLIyOuXCtHkpJst Wpcm\nLMyCa8BfP9GMb9KQdPDd1PPk1sd5VP79/L5dQZ0bI9 ymqssK9WcfIoXHdzG\nxdWWfteib79lSr1YP86MYurQxKdcUKdMQr5ZSfPs6YEZH8uhl4oWIenMuurQ\nttmejaqoqsqBVaAcJLlJN5kvMLlZRMNsSL5fRak0LbdQQMVvSPjw6cJnRpkf\nKtmjhvfu5cJtT7IuOMVvWLY/M/37 o0YH9ibhtSYdObErc6HarM9NnYSGNGR\navLi09unje3WyeO8rsVrT7tdRtK3uffu6NWeaL9pTJIjJrM4NPbx8cdyX7M7\nPYYVHu7j4KgoNJAYIKtkV5o9MsOcldicis RYNutfrhFOZ0hJbqinZ8bI8h5\nUObFuOfItJsfJrJfUOfIqc PXqQtK8RnSbA4Mcd3Tm0SGbpXQ8aqp7RLNs s\novHfzpVhV9iggMd1TLtbRKUdKXEQFsd4XrZRPLIgMZUeJ jKvrAlK6AhJ65A\nMpMpKuC3j5obIsRwS7hAN8l/YtvDvnYXHbAoLI47SIUsOMenorF4gO/m4 fH\npo4vLZ8oKMukqp0cJ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O13tMrW7lwkB0BiUoR3x4EfmrYlCNjAF\nCRAoIWmwQexQqQcyxHe 9eXAfVOQAg7k16v7jQsAHGi2Bv0gUzyQQ05Ga Cy\n0MBEDsZgN8gQ4QnXt7oJ0QOGOZACDTeEu0aTCwC80EKhDcAHMDGHWATMsuMC\nFsVl/9GnP0Jg0kw24MUv/qUTOGDlCj8WETfGsVx2vI UzsATIFZUaTIRk3QY\n ZYlFq0Ce5QJHBXgdU MRCSwEYlVBCHPQZhyn7vhhD9fWdAc2DKhKXxhRCc6\n0Yi4LOPcl6hGVUFqc4gJLGaxufKO1s2VkrOj63znOkciCKMedZ n7ARUp1rQ\niLAyIlyNYURcONaInrWs9ci4JyJOaFYawDzP8Q ZwAICLckbgd08i290eh9V\nCIadQw3qO5Oa1H1GNRlSjeorO2HLruZ2rLudAm Dm9Gxcx/GXmSIMbnjH5W2\nzy2RbOzM cENBRAWs0N9b3zXWdp8pra1r61tbXdb4N/2Nv8i5gzeIJd5Gjui\nwT AzQ9YVGrYnNO0Agm27GBkvNnNzje 921qf/ b1QEfuMDFPe5lk/lspUG3\nWKbQCofLBBBuwNEs3C3aikcrB2TTeM81HgmOd3zf/PZ3yFPNaqSXfODF0EDK\nE9e6liZmCvJwOLD7AQhU2efSbG6zm7VgiG1ofBc //nGgZ7vbYw67aVux4v/\nfXSSK53by/HVrzIwDZTBBANUrzpMeAAIWASeB4P/AQ9 cHjEJx7xWgDE5nLQ\neMdHXvKbg/zkMZ23H/1oFRjYPOc9v3nQ58Aw0xn9LACvO7HQAOZVf/jl0ii1\nHcXe9bPX3euftaPL5R71tIf97nsy7/o0WlP2r4/JOU7B r5nqva7jz1EdZ97\n4qNe bonfvCfVXvly1762beOOdLBd Q7PCAAOw==\n"; + image.filename = "rails_logo.gif"; + await image.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/products/632910392/images.json', + query: '', + headers, + data: { "image": {attachment: "R0lGODlhbgCMAPf/APbr48VySrxTO7IgKt2qmKQdJe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sZgN8gQ4QnXt7oJ0QOGOZACDTeEu0aTCwC80EKhDcAHMDGHWATMsuMC\nFsVl/9GnP0Jg0kw24MUv/qUTOGDlCj8WETfGsVx2vI UzsATIFZUaTIRk3QY\n ZYlFq0Ce5QJHBXgdU MRCSwEYlVBCHPQZhyn7vhhD9fWdAc2DKhKXxhRCc6\n0Yi4LOPcl6hGVUFqc4gJLGaxufKO1s2VkrOj63znOkciCKMedZ n7ARUp1rQ\niLAyIlyNYURcONaInrWs9ci4JyJOaFYawDzP8Q ZwAICLckbgd08i290eh9V\nCIadQw3qO5Oa1H1GNRlSjeorO2HLruZ2rLudAm Dm9Gxcx/GXmSIMbnjH5W2\nzy2RbOzM cENBRAWs0N9b3zXWdp8pra1r61tbXdb4N/2Nv8i5gzeIJd5Gjui\nwT AzQ9YVGrYnNO0Agm27GBkvNnNzje 921qf/ b1QEfuMDFPe5lk/lspUG3\nWKbQCofLBBBuwNEs3C3aikcrB2TTeM81HgmOd3zf/PZ3yFPNaqSXfODF0EDK\nE9e6liZmCvJwOLD7AQhU2efSbG6zm7VgiG1ofBc //nGgZ7vbYw67aVux4v/\nfXSSK53by/HVrzIwDZTBBANUrzpMeAAIWASeB4P/AQ9 cHjEJx7xWgDE5nLQ\neMdHXvKbg/zkMZ23H/1oFRjYPOc9v3nQ58Aw0xn9LACvO7HQAOZVf/jl0ii1\nHcXe9bPX3euftaPL5R71tIf97nsy7/o0WlP2r4/JOU7B r5nqva7jz1EdZ97\n4qNe bonfvCfVXvly1762beOOdLBd Q7PCAAOw==\n", filename: "rails_logo.gif"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const image = new Image({session: test_session}); + image.product_id = 632910392; + image.src = "http://example.com/rails_logo.gif"; + await image.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/products/632910392/images.json', + query: '', + headers, + data: { "image": {src: "http://example.com/rails_logo.gif"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const image = new Image({session: test_session}); + image.product_id = 632910392; + image.position = 1; + image.attachment = "R0lGODlhbgCMAPf/APbr48VySrxTO7IgKt2qmKQdJeK8lsFjROG5p/nz7Zg3\nMNmnd7Q1MLNVS9GId71hSJMZIuzTu4UtKbeEeakhKMl8U8WYjfr18YQaIbAf\nKKwhKdKzqpQtLebFortOOejKrOjZ1Mt7aMNpVbAqLLV7bsNqR 3WwMqEWenN\nsZYxL/Ddy/Pm2e7ZxLlUQrIjNPXp3bU5MbhENbEtLtqhj5ZQTfHh0bMxL7Ip\nNsNyUYkZIrZJPcqGdYIUHb5aPKkeJnoUHd2yiJkiLKYiKLRFOsyJXKVDO8up\nosFaS TBnK4kKti5sNaYg/z49aqYl5kqLrljUtORfMOlo/36 H4ZH8yDYq0f\nKKFYTaU9MrY8MrZBNXwXHpgaIdGVYu/byLZNP9SaZLIyOuXCtHkpJst Wpcm\nLMyCa8BfP9GMb9KQdPDd1PPk1sd5VP79/L5dQZ0bI9 ymqssK9WcfIoXHdzG\nxdWWfteib79lSr1YP86MYurQxKdcUKdMQr5ZSfPs6YEZH8uhl4oWIenMuurQ\nttmejaqoqsqBVaAcJLlJN5kvMLlZRMNsSL5fRak0LbdQQMVvSPjw6cJnRpkf\nKtmjhvfu5cJtT7IuOMVvWLY/M/37 o0YH9ibhtSYdObErc6HarM9NnYSGNGR\navLi09unje3WyeO8rsVrT7tdRtK3uffu6NWeaL9pTJIjJrM4NPbx8cdyX7M7\nPYYVHu7j4KgoNJAYIKtkV5o9MsOcldicis RYNutfrhFOZ0hJbqinZ8bI8h5\nUObFuOfItJsfJrJfUOfIqc PXqQtK8RnSbA4Mcd3Tm0SGbpXQ8aqp7RLNs s\novHfzpVhV9iggMd1TLtbRKUdKXEQFsd4XrZRPLIgMZUeJ jKvrAlK6AhJ65A\nMpMpKuC3j5obIsRwS7hAN8l/YtvDvnYXHbAoLI47SIUsOMenorF4gO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ClsQCHq0AF0QdkN HbjlxygL31hO13tMrW7lwkB0BiUoR3x4EfmrYlCNjAF\nCRAoIWmwQexQqQcyxHe 9eXAfVOQAg7k16v7jQsAHGi2Bv0gUzyQQ05Ga Cy\n0MBEDsZgN8gQ4QnXt7oJ0QOGOZACDTeEu0aTCwC80EKhDcAHMDGHWATMsuMC\nFsVl/9GnP0Jg0kw24MUv/qUTOGDlCj8WETfGsVx2vI UzsATIFZUaTIRk3QY\n ZYlFq0Ce5QJHBXgdU MRCSwEYlVBCHPQZhyn7vhhD9fWdAc2DKhKXxhRCc6\n0Yi4LOPcl6hGVUFqc4gJLGaxufKO1s2VkrOj63znOkciCKMedZ n7ARUp1rQ\niLAyIlyNYURcONaInrWs9ci4JyJOaFYawDzP8Q ZwAICLckbgd08i290eh9V\nCIadQw3qO5Oa1H1GNRlSjeorO2HLruZ2rLudAm Dm9Gxcx/GXmSIMbnjH5W2\nzy2RbOzM cENBRAWs0N9b3zXWdp8pra1r61tbXdb4N/2Nv8i5gzeIJd5Gjui\nwT AzQ9YVGrYnNO0Agm27GBkvNnNzje 921qf/ b1QEfuMDFPe5lk/lspUG3\nWKbQCofLBBBuwNEs3C3aikcrB2TTeM81HgmOd3zf/PZ3yFPNaqSXfODF0EDK\nE9e6liZmCvJwOLD7AQhU2efSbG6zm7VgiG1ofBc //nGgZ7vbYw67aVux4v/\nfXSSK53by/HVrzIwDZTBBANUrzpMeAAIWASeB4P/AQ9 cHjEJx7xWgDE5nLQ\neMdHXvKbg/zkMZ23H/1oFRjYPOc9v3nQ58Aw0xn9LACvO7HQAOZVf/jl0ii1\nHcXe9bPX3euftaPL5R71tIf97nsy7/o0WlP2r4/JOU7B r5nqva7jz1EdZ97\n4qNe bonfvCfVXvly1762beOOdLBd Q7PCAAOw==\n"; + image.filename = "rails_logo.gif"; + await image.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/products/632910392/images.json', + query: '', + headers, + data: { "image": {position: 1, attachment: "R0lGODlhbg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HGi2Bv0gUzyQQ05Ga Cy\n0MBEDsZgN8gQ4QnXt7oJ0QOGOZACDTeEu0aTCwC80EKhDcAHMDGHWATMsuMC\nFsVl/9GnP0Jg0kw24MUv/qUTOGDlCj8WETfGsVx2vI UzsATIFZUaTIRk3QY\n ZYlFq0Ce5QJHBXgdU MRCSwEYlVBCHPQZhyn7vhhD9fWdAc2DKhKXxhRCc6\n0Yi4LOPcl6hGVUFqc4gJLGaxufKO1s2VkrOj63znOkciCKMedZ n7ARUp1rQ\niLAyIlyNYURcONaInrWs9ci4JyJOaFYawDzP8Q ZwAICLckbgd08i290eh9V\nCIadQw3qO5Oa1H1GNRlSjeorO2HLruZ2rLudAm Dm9Gxcx/GXmSIMbnjH5W2\nzy2RbOzM cENBRAWs0N9b3zXWdp8pra1r61tbXdb4N/2Nv8i5gzeIJd5Gjui\nwT AzQ9YVGrYnNO0Agm27GBkvNnNzje 921qf/ b1QEfuMDFPe5lk/lspUG3\nWKbQCofLBBBuwNEs3C3aikcrB2TTeM81HgmOd3zf/PZ3yFPNaqSXfODF0EDK\nE9e6liZmCvJwOLD7AQhU2efSbG6zm7VgiG1ofBc //nGgZ7vbYw67aVux4v/\nfXSSK53by/HVrzIwDZTBBANUrzpMeAAIWASeB4P/AQ9 cHjEJx7xWgDE5nLQ\neMdHXvKbg/zkMZ23H/1oFRjYPOc9v3nQ58Aw0xn9LACvO7HQAOZVf/jl0ii1\nHcXe9bPX3euftaPL5R71tIf97nsy7/o0WlP2r4/JOU7B r5nqva7jz1EdZ97\n4qNe bonfvCfVXvly1762beOOdLBd Q7PCAAOw==\n", filename: "rails_logo.gif"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const image = new Image({session: test_session}); + image.product_id = 632910392; + image.variant_ids = [ + 808950810, + 457924702 + ]; + image.attachment = "R0lGODlhbgCMAPf/APbr48VySrxTO7IgKt2qmKQdJeK8lsFjROG5p/nz7Zg3\nMNmnd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TeEu0aTCwC80EKhDcAHMDGHWATMsuMC\nFsVl/9GnP0Jg0kw24MUv/qUTOGDlCj8WETfGsVx2vI UzsATIFZUaTIRk3QY\n ZYlFq0Ce5QJHBXgdU MRCSwEYlVBCHPQZhyn7vhhD9fWdAc2DKhKXxhRCc6\n0Yi4LOPcl6hGVUFqc4gJLGaxufKO1s2VkrOj63znOkciCKMedZ n7ARUp1rQ\niLAyIlyNYURcONaInrWs9ci4JyJOaFYawDzP8Q ZwAICLckbgd08i290eh9V\nCIadQw3qO5Oa1H1GNRlSjeorO2HLruZ2rLudAm Dm9Gxcx/GXmSIMbnjH5W2\nzy2RbOzM cENBRAWs0N9b3zXWdp8pra1r61tbXdb4N/2Nv8i5gzeIJd5Gjui\nwT AzQ9YVGrYnNO0Agm27GBkvNnNzje 921qf/ b1QEfuMDFPe5lk/lspUG3\nWKbQCofLBBBuwNEs3C3aikcrB2TTeM81HgmOd3zf/PZ3yFPNaqSXfODF0EDK\nE9e6liZmCvJwOLD7AQhU2efSbG6zm7VgiG1ofBc //nGgZ7vbYw67aVux4v/\nfXSSK53by/HVrzIwDZTBBANUrzpMeAAIWASeB4P/AQ9 cHjEJx7xWgDE5nLQ\neMdHXvKbg/zkMZ23H/1oFRjYPOc9v3nQ58Aw0xn9LACvO7HQAOZVf/jl0ii1\nHcXe9bPX3euftaPL5R71tIf97nsy7/o0WlP2r4/JOU7B r5nqva7jz1EdZ97\n4qNe bonfvCfVXvly1762beOOdLBd Q7PCAAOw==\n"; + image.filename = "rails_logo.gif"; + await image.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/products/632910392/images.json', + query: '', + headers, + data: { "image": {variant_ids: [808950810, 457924702], attachment: "R0lGODlhbgCMAPf/APbr48VySrxTO7IgKt2qmKQdJeK8lsFjROG5p/nz7Zg3\nMNmnd7Q1MLNVS9GId71hSJMZIuzTu4UtKbeEeakhKMl8U8WYjfr18YQaIbAf\nKKwhKdKzqpQtLebFortOOejKrOjZ1Mt7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k3QY\n ZYlFq0Ce5QJHBXgdU MRCSwEYlVBCHPQZhyn7vhhD9fWdAc2DKhKXxhRCc6\n0Yi4LOPcl6hGVUFqc4gJLGaxufKO1s2VkrOj63znOkciCKMedZ n7ARUp1rQ\niLAyIlyNYURcONaInrWs9ci4JyJOaFYawDzP8Q ZwAICLckbgd08i290eh9V\nCIadQw3qO5Oa1H1GNRlSjeorO2HLruZ2rLudAm Dm9Gxcx/GXmSIMbnjH5W2\nzy2RbOzM cENBRAWs0N9b3zXWdp8pra1r61tbXdb4N/2Nv8i5gzeIJd5Gjui\nwT AzQ9YVGrYnNO0Agm27GBkvNnNzje 921qf/ b1QEfuMDFPe5lk/lspUG3\nWKbQCofLBBBuwNEs3C3aikcrB2TTeM81HgmOd3zf/PZ3yFPNaqSXfODF0EDK\nE9e6liZmCvJwOLD7AQhU2efSbG6zm7VgiG1ofBc //nGgZ7vbYw67aVux4v/\nfXSSK53by/HVrzIwDZTBBANUrzpMeAAIWASeB4P/AQ9 cHjEJx7xWgDE5nLQ\neMdHXvKbg/zkMZ23H/1oFRjYPOc9v3nQ58Aw0xn9LACvO7HQAOZVf/jl0ii1\nHcXe9bPX3euftaPL5R71tIf97nsy7/o0WlP2r4/JOU7B r5nqva7jz1EdZ97\n4qNe bonfvCfVXvly1762beOOdLBd Q7PCAAOw==\n", filename: "rails_logo.gif"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const image = new Image({session: test_session}); + image.product_id = 632910392; + image.position = 1; + image.metafields = [ + { + key: "new", + value: "newvalue", + value_type: "string", + namespace: "global" + } + ]; + image.attachment = "R0lGODlhbgCMAPf/APbr48VySrxTO7IgKt2qmKQdJeK8lsFjROG5p/nz7Zg3\nMNmnd7Q1MLNVS9GId71hSJMZIuzTu4UtKbeEeakhKMl8U8WYjfr18YQaIbAf\nKKwhKdKzqpQtLebFortOOejKrOjZ1Mt7aMNpVbAqLLV7bsNqR 3WwMqEW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MRCSwEYlVBCHPQZhyn7vhhD9fWdAc2DKhKXxhRCc6\n0Yi4LOPcl6hGVUFqc4gJLGaxufKO1s2VkrOj63znOkciCKMedZ n7ARUp1rQ\niLAyIlyNYURcONaInrWs9ci4JyJOaFYawDzP8Q ZwAICLckbgd08i290eh9V\nCIadQw3qO5Oa1H1GNRlSjeorO2HLruZ2rLudAm Dm9Gxcx/GXmSIMbnjH5W2\nzy2RbOzM cENBRAWs0N9b3zXWdp8pra1r61tbXdb4N/2Nv8i5gzeIJd5Gjui\nwT AzQ9YVGrYnNO0Agm27GBkvNnNzje 921qf/ b1QEfuMDFPe5lk/lspUG3\nWKbQCofLBBBuwNEs3C3aikcrB2TTeM81HgmOd3zf/PZ3yFPNaqSXfODF0EDK\nE9e6liZmCvJwOLD7AQhU2efSbG6zm7VgiG1ofBc //nGgZ7vbYw67aVux4v/\nfXSSK53by/HVrzIwDZTBBANUrzpMeAAIWASeB4P/AQ9 cHjEJx7xWgDE5nLQ\neMdHXvKbg/zkMZ23H/1oFRjYPOc9v3nQ58Aw0xn9LACvO7HQAOZVf/jl0ii1\nHcXe9bPX3euftaPL5R71tIf97nsy7/o0WlP2r4/JOU7B r5nqva7jz1EdZ97\n4qNe bonfvCfVXvly1762beOOdLBd Q7PCAAOw==\n"; + image.filename = "rails_logo.gif"; + await image.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/products/632910392/images.json', + query: '', + headers, + data: { "image": {position: 1, metafields: [{key: "new", value: "newvalue", value_type: "string", namespace: "global"}], attachment: "R0lGODlhbgCMAPf/APbr48VySrxTO7IgKt2qmKQdJeK8lsFjROG5p/nz7Zg3\nMNmnd7Q1MLNVS9GId71hSJMZIuzTu4UtKbeEeakhKMl8U8WYjfr18YQaIbAf\nKKwhKdKzqpQtLebFortOOejKrOjZ1Mt7aMNpVbAqLLV7bsNqR 3WwMqEWenN\nsZYxL/Ddy/Pm2e7ZxLlUQrIjNPXp3bU5MbhENbEtLtqhj5ZQTfHh0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c4gJLGaxufKO1s2VkrOj63znOkciCKMedZ n7ARUp1rQ\niLAyIlyNYURcONaInrWs9ci4JyJOaFYawDzP8Q ZwAICLckbgd08i290eh9V\nCIadQw3qO5Oa1H1GNRlSjeorO2HLruZ2rLudAm Dm9Gxcx/GXmSIMbnjH5W2\nzy2RbOzM cENBRAWs0N9b3zXWdp8pra1r61tbXdb4N/2Nv8i5gzeIJd5Gjui\nwT AzQ9YVGrYnNO0Agm27GBkvNnNzje 921qf/ b1QEfuMDFPe5lk/lspUG3\nWKbQCofLBBBuwNEs3C3aikcrB2TTeM81HgmOd3zf/PZ3yFPNaqSXfODF0EDK\nE9e6liZmCvJwOLD7AQhU2efSbG6zm7VgiG1ofBc //nGgZ7vbYw67aVux4v/\nfXSSK53by/HVrzIwDZTBBANUrzpMeAAIWASeB4P/AQ9 cHjEJx7xWgDE5nLQ\neMdHXvKbg/zkMZ23H/1oFRjYPOc9v3nQ58Aw0xn9LACvO7HQAOZVf/jl0ii1\nHcXe9bPX3euftaPL5R71tIf97nsy7/o0WlP2r4/JOU7B r5nqva7jz1EdZ97\n4qNe bonfvCfVXvly1762beOOdLBd Q7PCAAOw==\n", filename: "rails_logo.gif"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Image.count({ + session: test_session, + product_id: 632910392, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/products/632910392/images/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Image.count({ + session: test_session, + product_id: 632910392, + since_id: "850703190", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/products/632910392/images/count.json', + query: 'since_id=850703190', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_10', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Image.find({ + session: test_session, + product_id: 632910392, + id: 850703190, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/products/632910392/images/850703190.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_11', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const image = new Image({session: test_session}); + image.product_id = 632910392; + image.id = 850703190; + image.position = 2; + image.alt = "new alt tag content"; + await image.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/products/632910392/images/850703190.json', + query: '', + headers, + data: { "image": {id: 850703190, position: 2, alt: "new alt tag content"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_12', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const image = new Image({session: test_session}); + image.product_id = 632910392; + image.id = 850703190; + image.variant_ids = [ + 808950810, + 457924702 + ]; + await image.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/products/632910392/images/850703190.json', + query: '', + headers, + data: { "image": {id: 850703190, variant_ids: [808950810, 457924702]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_13', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const image = new Image({session: test_session}); + image.product_id = 632910392; + image.id = 850703190; + image.metafields = [ + { + key: "my_new_metafield", + value: "my_new_value", + value_type: "string", + namespace: "tags" + } + ]; + await image.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/products/632910392/images/850703190.json', + query: '', + headers, + data: { "image": {id: 850703190, metafields: [{key: "my_new_metafield", value: "my_new_value", value_type: "string", namespace: "tags"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_14', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Image.delete({ + session: test_session, + product_id: 632910392, + id: 850703190, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-04/products/632910392/images/850703190.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-04/inventory_item.test.ts b/src/rest-resources/__tests__/2021-04/inventory_item.test.ts new file mode 100644 index 000000000..ddfa34c11 --- /dev/null +++ b/src/rest-resources/__tests__/2021-04/inventory_item.test.ts @@ -0,0 +1,89 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {InventoryItem} from '../../2021-04'; + +describe('InventoryItem resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.April21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await InventoryItem.all({ + session: test_session, + ids: "808950810,39072856,457924702", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/inventory_items.json', + query: 'ids=808950810%2C39072856%2C457924702', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await InventoryItem.find({ + session: test_session, + id: 808950810, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/inventory_items/808950810.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const inventory_item = new InventoryItem({session: test_session}); + inventory_item.id = 808950810; + inventory_item.sku = "new sku"; + await inventory_item.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/inventory_items/808950810.json', + query: '', + headers, + data: { "inventory_item": {id: 808950810, sku: "new sku"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const inventory_item = new InventoryItem({session: test_session}); + inventory_item.id = 808950810; + inventory_item.cost = "25.00"; + await inventory_item.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/inventory_items/808950810.json', + query: '', + headers, + data: { "inventory_item": {id: 808950810, cost: "25.00"} } + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-04/inventory_level.test.ts b/src/rest-resources/__tests__/2021-04/inventory_level.test.ts new file mode 100644 index 000000000..2c3ffb345 --- /dev/null +++ b/src/rest-resources/__tests__/2021-04/inventory_level.test.ts @@ -0,0 +1,148 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {InventoryLevel} from '../../2021-04'; + +describe('InventoryLevel resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.April21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await InventoryLevel.all({ + session: test_session, + inventory_item_ids: "808950810,39072856", + location_ids: "655441491,487838322", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/inventory_levels.json', + query: 'inventory_item_ids=808950810%2C39072856&location_ids=655441491%2C487838322', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await InventoryLevel.all({ + session: test_session, + inventory_item_ids: "808950810", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/inventory_levels.json', + query: 'inventory_item_ids=808950810', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await InventoryLevel.all({ + session: test_session, + location_ids: "655441491", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/inventory_levels.json', + query: 'location_ids=655441491', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const inventory_level = new InventoryLevel({session: test_session}); + + await inventory_level.adjust({ + body: {location_id: 655441491, inventory_item_id: 808950810, available_adjustment: 5}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/inventory_levels/adjust.json', + query: '', + headers, + data: {location_id: 655441491, inventory_item_id: 808950810, available_adjustment: 5} + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await InventoryLevel.delete({ + session: test_session, + inventory_item_id: "808950810", + location_id: "655441491", + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-04/inventory_levels.json', + query: 'inventory_item_id=808950810&location_id=655441491', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const inventory_level = new InventoryLevel({session: test_session}); + + await inventory_level.connect({ + body: {location_id: 844681632, inventory_item_id: 457924702}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/inventory_levels/connect.json', + query: '', + headers, + data: {location_id: 844681632, inventory_item_id: 457924702} + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const inventory_level = new InventoryLevel({session: test_session}); + + await inventory_level.set({ + body: {location_id: 655441491, inventory_item_id: 808950810, available: 42}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/inventory_levels/set.json', + query: '', + headers, + data: {location_id: 655441491, inventory_item_id: 808950810, available: 42} + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-04/location.test.ts b/src/rest-resources/__tests__/2021-04/location.test.ts new file mode 100644 index 000000000..c84a8ed20 --- /dev/null +++ b/src/rest-resources/__tests__/2021-04/location.test.ts @@ -0,0 +1,87 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Location} from '../../2021-04'; + +describe('Location resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.April21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Location.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/locations.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Location.find({ + session: test_session, + id: 487838322, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/locations/487838322.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Location.count({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/locations/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Location.inventory_levels({ + session: test_session, + id: 487838322, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/locations/487838322/inventory_levels.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-04/locations_for_move.test.ts b/src/rest-resources/__tests__/2021-04/locations_for_move.test.ts new file mode 100644 index 000000000..e9f284a61 --- /dev/null +++ b/src/rest-resources/__tests__/2021-04/locations_for_move.test.ts @@ -0,0 +1,35 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {LocationsForMove} from '../../2021-04'; + +describe('LocationsForMove resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.April21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await LocationsForMove.all({ + session: test_session, + fulfillment_order_id: 1046000833, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/fulfillment_orders/1046000833/locations_for_move.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-04/marketing_event.test.ts b/src/rest-resources/__tests__/2021-04/marketing_event.test.ts new file mode 100644 index 000000000..a7b94dde9 --- /dev/null +++ b/src/rest-resources/__tests__/2021-04/marketing_event.test.ts @@ -0,0 +1,159 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {MarketingEvent} from '../../2021-04'; + +describe('MarketingEvent resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.April21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await MarketingEvent.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/marketing_events.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const marketing_event = new MarketingEvent({session: test_session}); + marketing_event.started_at = "2022-12-15"; + marketing_event.utm_campaign = "Christmas2022"; + marketing_event.utm_source = "facebook"; + marketing_event.utm_medium = "cpc"; + marketing_event.event_type = "ad"; + marketing_event.referring_domain = "facebook.com"; + marketing_event.marketing_channel = "social"; + marketing_event.paid = true; + await marketing_event.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/marketing_events.json', + query: '', + headers, + data: { "marketing_event": {started_at: "2022-12-15", utm_campaign: "Christmas2022", utm_source: "facebook", utm_medium: "cpc", event_type: "ad", referring_domain: "facebook.com", marketing_channel: "social", paid: true} } + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await MarketingEvent.count({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/marketing_events/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await MarketingEvent.find({ + session: test_session, + id: 998730532, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/marketing_events/998730532.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const marketing_event = new MarketingEvent({session: test_session}); + marketing_event.id = 998730532; + marketing_event.remote_id = "1000:2000"; + marketing_event.started_at = "2022-02-02T00:00 00:00"; + marketing_event.ended_at = "2022-02-03T00:00 00:00"; + marketing_event.scheduled_to_end_at = "2022-02-04T00:00 00:00"; + marketing_event.budget = "11.1"; + marketing_event.budget_type = "daily"; + marketing_event.currency = "CAD"; + marketing_event.utm_campaign = "other"; + marketing_event.utm_source = "other"; + marketing_event.utm_medium = "other"; + marketing_event.event_type = "ad"; + marketing_event.referring_domain = "instagram.com"; + await marketing_event.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/marketing_events/998730532.json', + query: '', + headers, + data: { "marketing_event": {id: 998730532, remote_id: "1000:2000", started_at: "2022-02-02T00:00 00:00", ended_at: "2022-02-03T00:00 00:00", scheduled_to_end_at: "2022-02-04T00:00 00:00", budget: "11.1", budget_type: "daily", currency: "CAD", utm_campaign: "other", utm_source: "other", utm_medium: "other", event_type: "ad", referring_domain: "instagram.com"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await MarketingEvent.delete({ + session: test_session, + id: 998730532, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-04/marketing_events/998730532.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const marketing_event = new MarketingEvent({session: test_session}); + marketing_event.id = 998730532; + await marketing_event.engagements({ + body: {engagements: [{occurred_on: "2022-01-15", views_count: 0, clicks_count: 0, favorites_count: 0, ad_spend: 10.0, is_cumulative: true}, {occurred_on: "2022-01-16", views_count: 100, clicks_count: 50, is_cumulative: true}, {occurred_on: "2022-01-17", views_count: 200, clicks_count: 100, is_cumulative: true}]}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/marketing_events/998730532/engagements.json', + query: '', + headers, + data: {engagements: [{occurred_on: "2022-01-15", views_count: 0, clicks_count: 0, favorites_count: 0, ad_spend: 10.0, is_cumulative: true}, {occurred_on: "2022-01-16", views_count: 100, clicks_count: 50, is_cumulative: true}, {occurred_on: "2022-01-17", views_count: 200, clicks_count: 100, is_cumulative: true}]} + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-04/metafield.test.ts b/src/rest-resources/__tests__/2021-04/metafield.test.ts new file mode 100644 index 000000000..ac2c246ab --- /dev/null +++ b/src/rest-resources/__tests__/2021-04/metafield.test.ts @@ -0,0 +1,164 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Metafield} from '../../2021-04'; + +describe('Metafield resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.April21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Metafield.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/metafields.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Metafield.all({ + session: test_session, + since_id: "721389482", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/metafields.json', + query: 'since_id=721389482', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const metafield = new Metafield({session: test_session}); + metafield.namespace = "inventory"; + metafield.key = "warehouse"; + metafield.value = 25; + metafield.type = "number_integer"; + metafield.value_type = "integer"; + await metafield.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/metafields.json', + query: '', + headers, + data: { "metafield": {namespace: "inventory", key: "warehouse", value: 25, type: "number_integer", value_type: "integer"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Metafield.all({ + session: test_session, + metafield: {owner_id: "850703190", owner_resource: "product_image"}, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/metafields.json', + query: 'metafield%5Bowner_id%5D=850703190&metafield%5Bowner_resource%5D=product_image', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Metafield.count({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/metafields/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Metafield.find({ + session: test_session, + id: 721389482, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/metafields/721389482.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const metafield = new Metafield({session: test_session}); + metafield.id = 721389482; + metafield.value = "something new"; + metafield.type = "single_line_text_field"; + metafield.value_type = "string"; + await metafield.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/metafields/721389482.json', + query: '', + headers, + data: { "metafield": {id: 721389482, value: "something new", type: "single_line_text_field", value_type: "string"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Metafield.delete({ + session: test_session, + id: 721389482, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-04/metafields/721389482.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-04/mobile_platform_application.test.ts b/src/rest-resources/__tests__/2021-04/mobile_platform_application.test.ts new file mode 100644 index 000000000..367d92b16 --- /dev/null +++ b/src/rest-resources/__tests__/2021-04/mobile_platform_application.test.ts @@ -0,0 +1,162 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {MobilePlatformApplication} from '../../2021-04'; + +describe('MobilePlatformApplication resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.April21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await MobilePlatformApplication.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/mobile_platform_applications.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const mobile_platform_application = new MobilePlatformApplication({session: test_session}); + mobile_platform_application.platform = "ios"; + mobile_platform_application.application_id = "X1Y2.ca.domain.app"; + mobile_platform_application.enabled_universal_or_app_links = true; + mobile_platform_application.enabled_shared_webcredentials = true; + await mobile_platform_application.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/mobile_platform_applications.json', + query: '', + headers, + data: { "mobile_platform_application": {platform: "ios", application_id: "X1Y2.ca.domain.app", enabled_universal_or_app_links: true, enabled_shared_webcredentials: true} } + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const mobile_platform_application = new MobilePlatformApplication({session: test_session}); + mobile_platform_application.platform = "android"; + mobile_platform_application.application_id = "com.example"; + mobile_platform_application.sha256_cert_fingerprints = [ + "14:6D:E9:83:C5:73:06:50:D8:EE:B9:95:2F:34:FC:64:16:A0:83:42:E6:1D:BE:A8:8A:04:96:B2:3F:CF:44:E5" + ]; + mobile_platform_application.enabled_universal_or_app_links = true; + await mobile_platform_application.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/mobile_platform_applications.json', + query: '', + headers, + data: { "mobile_platform_application": {platform: "android", application_id: "com.example", sha256_cert_fingerprints: ["14:6D:E9:83:C5:73:06:50:D8:EE:B9:95:2F:34:FC:64:16:A0:83:42:E6:1D:BE:A8:8A:04:96:B2:3F:CF:44:E5"], enabled_universal_or_app_links: true} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await MobilePlatformApplication.find({ + session: test_session, + id: 1066176008, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/mobile_platform_applications/1066176008.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const mobile_platform_application = new MobilePlatformApplication({session: test_session}); + mobile_platform_application.id = 1066176009; + mobile_platform_application.application_id = "A1B2.ca.domain.app"; + mobile_platform_application.platform = "ios"; + mobile_platform_application.created_at = "2022-02-03T16:41:55-05:00"; + mobile_platform_application.updated_at = "2022-02-03T16:41:55-05:00"; + mobile_platform_application.sha256_cert_fingerprints = []; + mobile_platform_application.enabled_universal_or_app_links = true; + mobile_platform_application.enabled_shared_webcredentials = true; + await mobile_platform_application.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/mobile_platform_applications/1066176009.json', + query: '', + headers, + data: { "mobile_platform_application": {id: 1066176009, application_id: "A1B2.ca.domain.app", platform: "ios", created_at: "2022-02-03T16:41:55-05:00", updated_at: "2022-02-03T16:41:55-05:00", sha256_cert_fingerprints: [], enabled_universal_or_app_links: true, enabled_shared_webcredentials: true} } + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const mobile_platform_application = new MobilePlatformApplication({session: test_session}); + mobile_platform_application.id = 1066176010; + mobile_platform_application.application_id = "com.example.news.app"; + mobile_platform_application.platform = "android"; + mobile_platform_application.created_at = "2022-02-03T16:41:57-05:00"; + mobile_platform_application.updated_at = "2022-02-03T16:41:57-05:00"; + mobile_platform_application.sha256_cert_fingerprints = [ + "14:6D:E9:83:C5:73:06:50:D8:EE:B9:95:2F:34:FC:64:16:A0:83:42:E6:1D:BE:A8:8A:04:96:B2:3F:CF:44:E5" + ]; + mobile_platform_application.enabled_universal_or_app_links = true; + mobile_platform_application.enabled_shared_webcredentials = false; + await mobile_platform_application.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/mobile_platform_applications/1066176010.json', + query: '', + headers, + data: { "mobile_platform_application": {id: 1066176010, application_id: "com.example.news.app", platform: "android", created_at: "2022-02-03T16:41:57-05:00", updated_at: "2022-02-03T16:41:57-05:00", sha256_cert_fingerprints: ["14:6D:E9:83:C5:73:06:50:D8:EE:B9:95:2F:34:FC:64:16:A0:83:42:E6:1D:BE:A8:8A:04:96:B2:3F:CF:44:E5"], enabled_universal_or_app_links: true, enabled_shared_webcredentials: false} } + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await MobilePlatformApplication.delete({ + session: test_session, + id: 1066176011, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-04/mobile_platform_applications/1066176011.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-04/order.test.ts b/src/rest-resources/__tests__/2021-04/order.test.ts new file mode 100644 index 000000000..7df35a55c --- /dev/null +++ b/src/rest-resources/__tests__/2021-04/order.test.ts @@ -0,0 +1,814 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Order} from '../../2021-04'; + +describe('Order resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.April21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Order.all({ + session: test_session, + status: "any", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/orders.json', + query: 'status=any', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Order.all({ + session: test_session, + ids: "1073459980", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/orders.json', + query: 'ids=1073459980', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Order.all({ + session: test_session, + financial_status: "authorized", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/orders.json', + query: 'financial_status=authorized', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Order.all({ + session: test_session, + updated_at_min: "2005-07-31T15:57:11-04:00", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/orders.json', + query: 'updated_at_min=2005-07-31T15%3A57%3A11-04%3A00', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Order.all({ + session: test_session, + fields: "created_at,id,name,total-price", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/orders.json', + query: 'fields=created_at%2Cid%2Cname%2Ctotal-price', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Order.all({ + session: test_session, + since_id: "123", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/orders.json', + query: 'since_id=123', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Order.find({ + session: test_session, + id: 450789469, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/orders/450789469.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Order.find({ + session: test_session, + id: 450789469, + fields: "id,line_items,name,total_price", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/orders/450789469.json', + query: 'fields=id%2Cline_items%2Cname%2Ctotal_price', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order = new Order({session: test_session}); + order.id = 450789469; + order.note = "Customer contacted us about a custom engraving on this iPod"; + await order.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/orders/450789469.json', + query: '', + headers, + data: { "order": {id: 450789469, note: "Customer contacted us about a custom engraving on this iPod"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_10', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order = new Order({session: test_session}); + order.id = 450789469; + order.note_attributes = [ + { + name: "colour", + value: "red" + } + ]; + await order.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/orders/450789469.json', + query: '', + headers, + data: { "order": {id: 450789469, note_attributes: [{name: "colour", value: "red"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_11', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order = new Order({session: test_session}); + order.id = 450789469; + order.email = "a-different@email.com"; + await order.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/orders/450789469.json', + query: '', + headers, + data: { "order": {id: 450789469, email: "a-different@email.com"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_12', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order = new Order({session: test_session}); + order.id = 450789469; + order.phone = " 15145556677"; + await order.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/orders/450789469.json', + query: '', + headers, + data: { "order": {id: 450789469, phone: " 15145556677"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_13', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order = new Order({session: test_session}); + order.id = 450789469; + order.buyer_accepts_marketing = true; + await order.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/orders/450789469.json', + query: '', + headers, + data: { "order": {id: 450789469, buyer_accepts_marketing: true} } + }).toMatchMadeHttpRequest(); + }); + + it('test_14', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order = new Order({session: test_session}); + order.id = 450789469; + order.shipping_address = { + address1: "123 Ship Street", + city: "Shipsville" + }; + await order.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/orders/450789469.json', + query: '', + headers, + data: { "order": {id: 450789469, shipping_address: {address1: "123 Ship Street", city: "Shipsville"}} } + }).toMatchMadeHttpRequest(); + }); + + it('test_15', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order = new Order({session: test_session}); + order.id = 450789469; + order.customer = null; + await order.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/orders/450789469.json', + query: '', + headers, + data: { "order": {id: 450789469, customer: null} } + }).toMatchMadeHttpRequest(); + }); + + it('test_16', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order = new Order({session: test_session}); + order.id = 450789469; + order.tags = "External, Inbound, Outbound"; + await order.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/orders/450789469.json', + query: '', + headers, + data: { "order": {id: 450789469, tags: "External, Inbound, Outbound"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_17', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order = new Order({session: test_session}); + order.id = 450789469; + order.metafields = [ + { + key: "new", + value: "newvalue", + value_type: "string", + namespace: "global" + } + ]; + await order.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/orders/450789469.json', + query: '', + headers, + data: { "order": {id: 450789469, metafields: [{key: "new", value: "newvalue", value_type: "string", namespace: "global"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_18', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Order.delete({ + session: test_session, + id: 450789469, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-04/orders/450789469.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_19', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Order.count({ + session: test_session, + status: "any", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/orders/count.json', + query: 'status=any', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_20', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Order.count({ + session: test_session, + financial_status: "authorized", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/orders/count.json', + query: 'financial_status=authorized', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_21', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order = new Order({session: test_session}); + order.id = 450789469; + await order.close({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/orders/450789469/close.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_22', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order = new Order({session: test_session}); + order.id = 450789469; + await order.open({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/orders/450789469/open.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_23', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order = new Order({session: test_session}); + order.id = 450789469; + await order.cancel({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/orders/450789469/cancel.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_24', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order = new Order({session: test_session}); + order.id = 450789469; + await order.cancel({ + body: {amount: "10.00", currency: "USD"}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/orders/450789469/cancel.json', + query: '', + headers, + data: {amount: "10.00", currency: "USD"} + }).toMatchMadeHttpRequest(); + }); + + it('test_25', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order = new Order({session: test_session}); + order.id = 450789469; + await order.cancel({ + body: {refund: {note: "Customer made a mistake", shipping: {full_refund: true}, refund_line_items: [{line_item_id: 466157049, quantity: 1, restock_type: "cancel", location_id: 24826418}], transactions: [{parent_id: 1068278509, amount: "10.00", kind: "refund", gateway: "bogus"}, {parent_id: 1068278510, amount: "100.00", kind: "refund", gateway: "gift_card"}]}}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/orders/450789469/cancel.json', + query: '', + headers, + data: {refund: {note: "Customer made a mistake", shipping: {full_refund: true}, refund_line_items: [{line_item_id: 466157049, quantity: 1, restock_type: "cancel", location_id: 24826418}], transactions: [{parent_id: 1068278509, amount: "10.00", kind: "refund", gateway: "bogus"}, {parent_id: 1068278510, amount: "100.00", kind: "refund", gateway: "gift_card"}]}} + }).toMatchMadeHttpRequest(); + }); + + it('test_26', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order = new Order({session: test_session}); + order.line_items = [ + { + variant_id: 447654529, + quantity: 1 + } + ]; + await order.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/orders.json', + query: '', + headers, + data: { "order": {line_items: [{variant_id: 447654529, quantity: 1}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_27', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order = new Order({session: test_session}); + order.email = "foo@example.com"; + order.fulfillment_status = "fulfilled"; + order.send_receipt = true; + order.send_fulfillment_receipt = true; + order.line_items = [ + { + variant_id: 457924702, + quantity: 1 + } + ]; + await order.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/orders.json', + query: '', + headers, + data: { "order": {email: "foo@example.com", fulfillment_status: "fulfilled", send_receipt: true, send_fulfillment_receipt: true, line_items: [{variant_id: 457924702, quantity: 1}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_28', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order = new Order({session: test_session}); + order.email = "foo@example.com"; + order.fulfillment_status = "fulfilled"; + order.line_items = [ + { + variant_id: 447654529, + quantity: 1 + } + ]; + await order.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/orders.json', + query: '', + headers, + data: { "order": {email: "foo@example.com", fulfillment_status: "fulfilled", line_items: [{variant_id: 447654529, quantity: 1}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_29', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order = new Order({session: test_session}); + order.email = "foo@example.com"; + order.fulfillment_status = "fulfilled"; + order.fulfillments = [ + { + location_id: 24826418 + } + ]; + order.line_items = [ + { + variant_id: 447654529, + quantity: 1 + } + ]; + await order.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/orders.json', + query: '', + headers, + data: { "order": {email: "foo@example.com", fulfillment_status: "fulfilled", fulfillments: [{location_id: 24826418}], line_items: [{variant_id: 447654529, quantity: 1}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_30', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order = new Order({session: test_session}); + order.line_items = [ + { + title: "Big Brown Bear Boots", + price: 74.99, + grams: "1300", + quantity: 3, + tax_lines: [ + { + price: 13.5, + rate: 0.06, + title: "State tax" + } + ] + } + ]; + order.transactions = [ + { + kind: "sale", + status: "success", + amount: 238.47 + } + ]; + order.total_tax = 13.5; + order.currency = "EUR"; + await order.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/orders.json', + query: '', + headers, + data: { "order": {line_items: [{title: "Big Brown Bear Boots", price: 74.99, grams: "1300", quantity: 3, tax_lines: [{price: 13.5, rate: 0.06, title: "State tax"}]}], transactions: [{kind: "sale", status: "success", amount: 238.47}], total_tax: 13.5, currency: "EUR"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_31', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order = new Order({session: test_session}); + order.line_items = [ + { + title: "Red Leather Coat", + price: 129.99, + grams: "1700", + quantity: 1 + }, + { + title: "Blue Suede Shoes", + price: 85.95, + grams: "750", + quantity: 1, + taxable: false + }, + { + title: "Raspberry Beret", + price: 19.99, + grams: "320", + quantity: 2 + } + ]; + order.tax_lines = [ + { + price: 10.2, + rate: 0.06, + title: "State tax" + }, + { + price: 4.25, + rate: 0.025, + title: "County tax" + } + ]; + order.total_tax = 14.45; + await order.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/orders.json', + query: '', + headers, + data: { "order": {line_items: [{title: "Red Leather Coat", price: 129.99, grams: "1700", quantity: 1}, {title: "Blue Suede Shoes", price: 85.95, grams: "750", quantity: 1, taxable: false}, {title: "Raspberry Beret", price: 19.99, grams: "320", quantity: 2}], tax_lines: [{price: 10.2, rate: 0.06, title: "State tax"}, {price: 4.25, rate: 0.025, title: "County tax"}], total_tax: 14.45} } + }).toMatchMadeHttpRequest(); + }); + + it('test_32', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order = new Order({session: test_session}); + order.line_items = [ + { + variant_id: 447654529, + quantity: 1 + } + ]; + order.customer = { + id: 207119551 + }; + order.financial_status = "pending"; + await order.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/orders.json', + query: '', + headers, + data: { "order": {line_items: [{variant_id: 447654529, quantity: 1}], customer: {id: 207119551}, financial_status: "pending"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_33', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order = new Order({session: test_session}); + order.line_items = [ + { + variant_id: 447654529, + quantity: 1 + } + ]; + order.customer = { + first_name: "Paul", + last_name: "Norman", + email: "paul.norman@example.com" + }; + order.billing_address = { + first_name: "John", + last_name: "Smith", + address1: "123 Fake Street", + phone: "555-555-5555", + city: "Fakecity", + province: "Ontario", + country: "Canada", + zip: "K2P 1L4" + }; + order.shipping_address = { + first_name: "Jane", + last_name: "Smith", + address1: "123 Fake Street", + phone: "777-777-7777", + city: "Fakecity", + province: "Ontario", + country: "Canada", + zip: "K2P 1L4" + }; + order.email = "jane@example.com"; + order.transactions = [ + { + kind: "authorization", + status: "success", + amount: 50.0 + } + ]; + order.financial_status = "partially_paid"; + await order.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/orders.json', + query: '', + headers, + data: { "order": {line_items: [{variant_id: 447654529, quantity: 1}], customer: {first_name: "Paul", last_name: "Norman", email: "paul.norman@example.com"}, billing_address: {first_name: "John", last_name: "Smith", address1: "123 Fake Street", phone: "555-555-5555", city: "Fakecity", province: "Ontario", country: "Canada", zip: "K2P 1L4"}, shipping_address: {first_name: "Jane", last_name: "Smith", address1: "123 Fake Street", phone: "777-777-7777", city: "Fakecity", province: "Ontario", country: "Canada", zip: "K2P 1L4"}, email: "jane@example.com", transactions: [{kind: "authorization", status: "success", amount: 50.0}], financial_status: "partially_paid"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_34', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order = new Order({session: test_session}); + order.line_items = [ + { + variant_id: 447654529, + quantity: 1 + } + ]; + order.email = "jane@example.com"; + order.phone = "18885551234"; + order.billing_address = { + first_name: "John", + last_name: "Smith", + address1: "123 Fake Street", + phone: "555-555-5555", + city: "Fakecity", + province: "Ontario", + country: "Canada", + zip: "K2P 1L4" + }; + order.shipping_address = { + first_name: "Jane", + last_name: "Smith", + address1: "123 Fake Street", + phone: "777-777-7777", + city: "Fakecity", + province: "Ontario", + country: "Canada", + zip: "K2P 1L4" + }; + order.transactions = [ + { + kind: "sale", + status: "success", + amount: 50.0 + } + ]; + order.financial_status = "paid"; + order.discount_codes = [ + { + code: "FAKE30", + amount: "9.00", + type: "percentage" + } + ]; + await order.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/orders.json', + query: '', + headers, + data: { "order": {line_items: [{variant_id: 447654529, quantity: 1}], email: "jane@example.com", phone: "18885551234", billing_address: {first_name: "John", last_name: "Smith", address1: "123 Fake Street", phone: "555-555-5555", city: "Fakecity", province: "Ontario", country: "Canada", zip: "K2P 1L4"}, shipping_address: {first_name: "Jane", last_name: "Smith", address1: "123 Fake Street", phone: "777-777-7777", city: "Fakecity", province: "Ontario", country: "Canada", zip: "K2P 1L4"}, transactions: [{kind: "sale", status: "success", amount: 50.0}], financial_status: "paid", discount_codes: [{code: "FAKE30", amount: "9.00", type: "percentage"}]} } + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-04/order_risk.test.ts b/src/rest-resources/__tests__/2021-04/order_risk.test.ts new file mode 100644 index 000000000..828ddc16e --- /dev/null +++ b/src/rest-resources/__tests__/2021-04/order_risk.test.ts @@ -0,0 +1,119 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {OrderRisk} from '../../2021-04'; + +describe('OrderRisk resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.April21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order_risk = new OrderRisk({session: test_session}); + order_risk.order_id = 450789469; + order_risk.message = "This order came from an anonymous proxy"; + order_risk.recommendation = "cancel"; + order_risk.score = 1.0; + order_risk.source = "External"; + order_risk.cause_cancel = true; + order_risk.display = true; + await order_risk.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/orders/450789469/risks.json', + query: '', + headers, + data: { "risk": {message: "This order came from an anonymous proxy", recommendation: "cancel", score: 1.0, source: "External", cause_cancel: true, display: true} } + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await OrderRisk.all({ + session: test_session, + order_id: 450789469, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/orders/450789469/risks.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await OrderRisk.find({ + session: test_session, + order_id: 450789469, + id: 284138680, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/orders/450789469/risks/284138680.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order_risk = new OrderRisk({session: test_session}); + order_risk.order_id = 450789469; + order_risk.id = 284138680; + order_risk.message = "After further review, this is a legitimate order"; + order_risk.recommendation = "accept"; + order_risk.source = "External"; + order_risk.cause_cancel = false; + order_risk.score = 0.0; + await order_risk.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/orders/450789469/risks/284138680.json', + query: '', + headers, + data: { "risk": {id: 284138680, message: "After further review, this is a legitimate order", recommendation: "accept", source: "External", cause_cancel: false, score: 0.0} } + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await OrderRisk.delete({ + session: test_session, + order_id: 450789469, + id: 284138680, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-04/orders/450789469/risks/284138680.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-04/page.test.ts b/src/rest-resources/__tests__/2021-04/page.test.ts new file mode 100644 index 000000000..48b5416d5 --- /dev/null +++ b/src/rest-resources/__tests__/2021-04/page.test.ts @@ -0,0 +1,268 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Page} from '../../2021-04'; + +describe('Page resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.April21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Page.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/pages.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Page.all({ + session: test_session, + since_id: "108828309", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/pages.json', + query: 'since_id=108828309', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const page = new Page({session: test_session}); + page.title = "Warranty information"; + page.body_html = "

Warranty

\n

Returns accepted if we receive items 30 days after purchase.

"; + await page.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/pages.json', + query: '', + headers, + data: { "page": {title: "Warranty information", body_html: "

Warranty

\n

Returns accepted if we receive items 30 days after purchase.

"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const page = new Page({session: test_session}); + page.title = "Warranty information"; + page.body_html = "

Warranty

\n

Returns accepted if we receive items 30 days after purchase.

"; + page.published = false; + await page.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/pages.json', + query: '', + headers, + data: { "page": {title: "Warranty information", body_html: "

Warranty

\n

Returns accepted if we receive items 30 days after purchase.

", published: false} } + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const page = new Page({session: test_session}); + page.title = "Warranty information"; + page.body_html = "

Warranty

\n

Returns accepted if we receive items 30 days after purchase.

"; + page.metafields = [ + { + key: "new", + value: "new value", + value_type: "string", + namespace: "global" + } + ]; + await page.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/pages.json', + query: '', + headers, + data: { "page": {title: "Warranty information", body_html: "

Warranty

\n

Returns accepted if we receive items 30 days after purchase.

", metafields: [{key: "new", value: "new value", value_type: "string", namespace: "global"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Page.count({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/pages/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Page.find({ + session: test_session, + id: 131092082, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/pages/131092082.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const page = new Page({session: test_session}); + page.id = 131092082; + page.body_html = "

Returns accepted if we receive the items 14 days after purchase.

"; + await page.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/pages/131092082.json', + query: '', + headers, + data: { "page": {id: 131092082, body_html: "

Returns accepted if we receive the items 14 days after purchase.

"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const page = new Page({session: test_session}); + page.id = 131092082; + page.body_html = "

Returns accepted if we receive the items 14 days after purchase.

"; + page.author = "Christopher Gorski"; + page.title = "New warranty"; + page.handle = "new-warranty"; + await page.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/pages/131092082.json', + query: '', + headers, + data: { "page": {id: 131092082, body_html: "

Returns accepted if we receive the items 14 days after purchase.

", author: "Christopher Gorski", title: "New warranty", handle: "new-warranty"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_10', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const page = new Page({session: test_session}); + page.id = 131092082; + page.published = true; + await page.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/pages/131092082.json', + query: '', + headers, + data: { "page": {id: 131092082, published: true} } + }).toMatchMadeHttpRequest(); + }); + + it('test_11', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const page = new Page({session: test_session}); + page.id = 131092082; + page.published = false; + await page.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/pages/131092082.json', + query: '', + headers, + data: { "page": {id: 131092082, published: false} } + }).toMatchMadeHttpRequest(); + }); + + it('test_12', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const page = new Page({session: test_session}); + page.id = 131092082; + page.metafields = [ + { + key: "new", + value: "new value", + value_type: "string", + namespace: "global" + } + ]; + await page.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/pages/131092082.json', + query: '', + headers, + data: { "page": {id: 131092082, metafields: [{key: "new", value: "new value", value_type: "string", namespace: "global"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_13', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Page.delete({ + session: test_session, + id: 131092082, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-04/pages/131092082.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-04/payment.test.ts b/src/rest-resources/__tests__/2021-04/payment.test.ts new file mode 100644 index 000000000..2440f0e55 --- /dev/null +++ b/src/rest-resources/__tests__/2021-04/payment.test.ts @@ -0,0 +1,116 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Payment} from '../../2021-04'; + +describe('Payment resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.April21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const payment = new Payment({session: test_session}); + payment.checkout_id = "7yjf4v2we7gamku6a6h7tvm8h3mmvs4x"; + payment.request_details = { + ip_address: "123.1.1.1", + accept_language: "en-US,en;q=0.8,fr;q=0.6", + user_agent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.98 Safari/537.36" + }; + payment.amount = "398.00"; + payment.session_id = "global-4f10a3a42a3b4d41"; + payment.unique_token = "client-side-idempotency-token"; + await payment.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/checkouts/7yjf4v2we7gamku6a6h7tvm8h3mmvs4x/payments.json', + query: '', + headers, + data: { "payment": {request_details: {ip_address: "123.1.1.1", accept_language: "en-US,en;q=0.8,fr;q=0.6", user_agent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.98 Safari/537.36"}, amount: "398.00", session_id: "global-4f10a3a42a3b4d41", unique_token: "client-side-idempotency-token"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Payment.all({ + session: test_session, + checkout_id: "7yjf4v2we7gamku6a6h7tvm8h3mmvs4x", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/checkouts/7yjf4v2we7gamku6a6h7tvm8h3mmvs4x/payments.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Payment.find({ + session: test_session, + checkout_id: "7yjf4v2we7gamku6a6h7tvm8h3mmvs4x", + id: 25428999, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/checkouts/7yjf4v2we7gamku6a6h7tvm8h3mmvs4x/payments/25428999.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Payment.find({ + session: test_session, + checkout_id: "7yjf4v2we7gamku6a6h7tvm8h3mmvs4x", + id: 25428999, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/checkouts/7yjf4v2we7gamku6a6h7tvm8h3mmvs4x/payments/25428999.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Payment.count({ + session: test_session, + checkout_id: "7yjf4v2we7gamku6a6h7tvm8h3mmvs4x", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/checkouts/7yjf4v2we7gamku6a6h7tvm8h3mmvs4x/payments/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-04/payment_gateway.test.ts b/src/rest-resources/__tests__/2021-04/payment_gateway.test.ts new file mode 100644 index 000000000..cc99408f6 --- /dev/null +++ b/src/rest-resources/__tests__/2021-04/payment_gateway.test.ts @@ -0,0 +1,124 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {PaymentGateway} from '../../2021-04'; + +describe('PaymentGateway resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.April21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await PaymentGateway.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/payment_gateways.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await PaymentGateway.all({ + session: test_session, + disabled: "false", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/payment_gateways.json', + query: 'disabled=false', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const payment_gateway = new PaymentGateway({session: test_session}); + payment_gateway.credential1 = "someone@example.com"; + payment_gateway.provider_id = 7; + await payment_gateway.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/payment_gateways.json', + query: '', + headers, + data: { "payment_gateway": {credential1: "someone@example.com", provider_id: 7} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await PaymentGateway.find({ + session: test_session, + id: 431363653, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/payment_gateways/431363653.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const payment_gateway = new PaymentGateway({session: test_session}); + payment_gateway.id = 170508070; + payment_gateway.sandbox = true; + await payment_gateway.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/payment_gateways/170508070.json', + query: '', + headers, + data: { "payment_gateway": {id: 170508070, sandbox: true} } + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await PaymentGateway.delete({ + session: test_session, + id: 170508070, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-04/payment_gateways/170508070.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-04/payment_transaction.test.ts b/src/rest-resources/__tests__/2021-04/payment_transaction.test.ts new file mode 100644 index 000000000..f76efbf67 --- /dev/null +++ b/src/rest-resources/__tests__/2021-04/payment_transaction.test.ts @@ -0,0 +1,35 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {PaymentTransaction} from '../../2021-04'; + +describe('PaymentTransaction resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.April21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await PaymentTransaction.transactions({ + session: test_session, + payout_id: "623721858", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/shopify_payments/balance/transactions.json', + query: 'payout_id=623721858', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-04/payout.test.ts b/src/rest-resources/__tests__/2021-04/payout.test.ts new file mode 100644 index 000000000..d6df579ef --- /dev/null +++ b/src/rest-resources/__tests__/2021-04/payout.test.ts @@ -0,0 +1,70 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Payout} from '../../2021-04'; + +describe('Payout resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.April21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Payout.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/shopify_payments/payouts.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Payout.all({ + session: test_session, + date_max: "2012-11-12", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/shopify_payments/payouts.json', + query: 'date_max=2012-11-12', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Payout.find({ + session: test_session, + id: 623721858, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/shopify_payments/payouts/623721858.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-04/policy.test.ts b/src/rest-resources/__tests__/2021-04/policy.test.ts new file mode 100644 index 000000000..aa3b85d94 --- /dev/null +++ b/src/rest-resources/__tests__/2021-04/policy.test.ts @@ -0,0 +1,34 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Policy} from '../../2021-04'; + +describe('Policy resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.April21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Policy.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/policies.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-04/price_rule.test.ts b/src/rest-resources/__tests__/2021-04/price_rule.test.ts new file mode 100644 index 000000000..9f5c1366b --- /dev/null +++ b/src/rest-resources/__tests__/2021-04/price_rule.test.ts @@ -0,0 +1,246 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {PriceRule} from '../../2021-04'; + +describe('PriceRule resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.April21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const price_rule = new PriceRule({session: test_session}); + price_rule.title = "SUMMERSALE10OFF"; + price_rule.target_type = "line_item"; + price_rule.target_selection = "all"; + price_rule.allocation_method = "across"; + price_rule.value_type = "fixed_amount"; + price_rule.value = "-10.0"; + price_rule.customer_selection = "all"; + price_rule.starts_at = "2017-01-19T17:59:10Z"; + await price_rule.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/price_rules.json', + query: '', + headers, + data: { "price_rule": {title: "SUMMERSALE10OFF", target_type: "line_item", target_selection: "all", allocation_method: "across", value_type: "fixed_amount", value: "-10.0", customer_selection: "all", starts_at: "2017-01-19T17:59:10Z"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const price_rule = new PriceRule({session: test_session}); + price_rule.title = "15OFFCOLLECTION"; + price_rule.target_type = "line_item"; + price_rule.target_selection = "entitled"; + price_rule.allocation_method = "across"; + price_rule.value_type = "percentage"; + price_rule.value = "-15.0"; + price_rule.customer_selection = "all"; + price_rule.entitled_collection_ids = [ + 841564295 + ]; + price_rule.starts_at = "2017-01-19T17:59:10Z"; + await price_rule.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/price_rules.json', + query: '', + headers, + data: { "price_rule": {title: "15OFFCOLLECTION", target_type: "line_item", target_selection: "entitled", allocation_method: "across", value_type: "percentage", value: "-15.0", customer_selection: "all", entitled_collection_ids: [841564295], starts_at: "2017-01-19T17:59:10Z"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const price_rule = new PriceRule({session: test_session}); + price_rule.title = "FREESHIPPING"; + price_rule.target_type = "shipping_line"; + price_rule.target_selection = "all"; + price_rule.allocation_method = "each"; + price_rule.value_type = "percentage"; + price_rule.value = "-100.0"; + price_rule.usage_limit = 20; + price_rule.customer_selection = "all"; + price_rule.prerequisite_subtotal_range = { + greater_than_or_equal_to: "50.0" + }; + price_rule.starts_at = "2017-01-19T17:59:10Z"; + await price_rule.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/price_rules.json', + query: '', + headers, + data: { "price_rule": {title: "FREESHIPPING", target_type: "shipping_line", target_selection: "all", allocation_method: "each", value_type: "percentage", value: "-100.0", usage_limit: 20, customer_selection: "all", prerequisite_subtotal_range: {greater_than_or_equal_to: "50.0"}, starts_at: "2017-01-19T17:59:10Z"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const price_rule = new PriceRule({session: test_session}); + price_rule.title = "5OFFCUSTOMERGROUP"; + price_rule.target_type = "line_item"; + price_rule.target_selection = "all"; + price_rule.allocation_method = "across"; + price_rule.value_type = "fixed_amount"; + price_rule.value = "-5.0"; + price_rule.customer_selection = "prerequisite"; + price_rule.prerequisite_saved_search_ids = [ + 789629109 + ]; + price_rule.starts_at = "2017-01-19T17:59:10Z"; + await price_rule.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/price_rules.json', + query: '', + headers, + data: { "price_rule": {title: "5OFFCUSTOMERGROUP", target_type: "line_item", target_selection: "all", allocation_method: "across", value_type: "fixed_amount", value: "-5.0", customer_selection: "prerequisite", prerequisite_saved_search_ids: [789629109], starts_at: "2017-01-19T17:59:10Z"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const price_rule = new PriceRule({session: test_session}); + price_rule.title = "Buy2iPodsGetiPodTouchForFree"; + price_rule.value_type = "percentage"; + price_rule.value = "-100.0"; + price_rule.customer_selection = "all"; + price_rule.target_type = "line_item"; + price_rule.target_selection = "entitled"; + price_rule.allocation_method = "each"; + price_rule.starts_at = "2018-03-22T00:00:00-00:00"; + price_rule.prerequisite_collection_ids = [ + 841564295 + ]; + price_rule.entitled_product_ids = [ + 921728736 + ]; + price_rule.prerequisite_to_entitlement_quantity_ratio = { + prerequisite_quantity: 2, + entitled_quantity: 1 + }; + price_rule.allocation_limit = 3; + await price_rule.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/price_rules.json', + query: '', + headers, + data: { "price_rule": {title: "Buy2iPodsGetiPodTouchForFree", value_type: "percentage", value: "-100.0", customer_selection: "all", target_type: "line_item", target_selection: "entitled", allocation_method: "each", starts_at: "2018-03-22T00:00:00-00:00", prerequisite_collection_ids: [841564295], entitled_product_ids: [921728736], prerequisite_to_entitlement_quantity_ratio: {prerequisite_quantity: 2, entitled_quantity: 1}, allocation_limit: 3} } + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await PriceRule.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/price_rules.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const price_rule = new PriceRule({session: test_session}); + price_rule.id = 507328175; + price_rule.title = "WINTER SALE"; + await price_rule.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/price_rules/507328175.json', + query: '', + headers, + data: { "price_rule": {id: 507328175, title: "WINTER SALE"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await PriceRule.find({ + session: test_session, + id: 507328175, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/price_rules/507328175.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await PriceRule.delete({ + session: test_session, + id: 507328175, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-04/price_rules/507328175.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_10', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await PriceRule.count({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/price_rules/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-04/product.test.ts b/src/rest-resources/__tests__/2021-04/product.test.ts new file mode 100644 index 000000000..cebc3b985 --- /dev/null +++ b/src/rest-resources/__tests__/2021-04/product.test.ts @@ -0,0 +1,738 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Product} from '../../2021-04'; + +describe('Product resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.April21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Product.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/products.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Product.all({ + session: test_session, + ids: "632910392,921728736", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/products.json', + query: 'ids=632910392%2C921728736', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Product.all({ + session: test_session, + fields: "id,images,title", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/products.json', + query: 'fields=id%2Cimages%2Ctitle', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Product.all({ + session: test_session, + collection_id: "841564295", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/products.json', + query: 'collection_id=841564295', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Product.all({ + session: test_session, + since_id: "632910392", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/products.json', + query: 'since_id=632910392', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Product.all({ + session: test_session, + presentment_currencies: "USD", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/products.json', + query: 'presentment_currencies=USD', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product = new Product({session: test_session}); + product.title = "Burton Custom Freestyle 151"; + product.body_html = "Good snowboard!"; + product.vendor = "Burton"; + product.product_type = "Snowboard"; + product.tags = [ + "Barnes & Noble", + "Big Air", + "John's Fav" + ]; + await product.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/products.json', + query: '', + headers, + data: { "product": {title: "Burton Custom Freestyle 151", body_html: "Good snowboard!", vendor: "Burton", product_type: "Snowboard", tags: ["Barnes & Noble", "Big Air", "John's Fav"]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product = new Product({session: test_session}); + product.title = "Burton Custom Freestyle 151"; + product.body_html = "Good snowboard!"; + product.vendor = "Burton"; + product.product_type = "Snowboard"; + product.published = false; + await product.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/products.json', + query: '', + headers, + data: { "product": {title: "Burton Custom Freestyle 151", body_html: "Good snowboard!", vendor: "Burton", product_type: "Snowboard", published: false} } + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product = new Product({session: test_session}); + product.title = "Burton Custom Freestyle 151"; + product.body_html = "Good snowboard!"; + product.vendor = "Burton"; + product.product_type = "Snowboard"; + product.status = "draft"; + await product.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/products.json', + query: '', + headers, + data: { "product": {title: "Burton Custom Freestyle 151", body_html: "Good snowboard!", vendor: "Burton", product_type: "Snowboard", status: "draft"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_10', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product = new Product({session: test_session}); + product.title = "Burton Custom Freestyle 151"; + product.body_html = "Good snowboard!"; + product.vendor = "Burton"; + product.product_type = "Snowboard"; + product.variants = [ + { + option1: "First", + price: "10.00", + sku: "123" + }, + { + option1: "Second", + price: "20.00", + sku: "123" + } + ]; + await product.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/products.json', + query: '', + headers, + data: { "product": {title: "Burton Custom Freestyle 151", body_html: "Good snowboard!", vendor: "Burton", product_type: "Snowboard", variants: [{option1: "First", price: "10.00", sku: "123"}, {option1: "Second", price: "20.00", sku: "123"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_11', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product = new Product({session: test_session}); + product.title = "Burton Custom Freestyle 151"; + product.body_html = "Good snowboard!"; + product.vendor = "Burton"; + product.product_type = "Snowboard"; + product.variants = [ + { + option1: "Blue", + option2: "155" + }, + { + option1: "Black", + option2: "159" + } + ]; + product.options = [ + { + name: "Color", + values: [ + "Blue", + "Black" + ] + }, + { + name: "Size", + values: [ + "155", + "159" + ] + } + ]; + await product.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/products.json', + query: '', + headers, + data: { "product": {title: "Burton Custom Freestyle 151", body_html: "Good snowboard!", vendor: "Burton", product_type: "Snowboard", variants: [{option1: "Blue", option2: "155"}, {option1: "Black", option2: "159"}], options: [{name: "Color", values: ["Blue", "Black"]}, {name: "Size", values: ["155", "159"]}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_12', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product = new Product({session: test_session}); + product.title = "Burton Custom Freestyle 151"; + product.body_html = "Good snowboard!"; + product.vendor = "Burton"; + product.product_type = "Snowboard"; + product.images = [ + { + attachment: "R0lGODlhAQABAIAAAAAAAAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==\n" + } + ]; + await product.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/products.json', + query: '', + headers, + data: { "product": {title: "Burton Custom Freestyle 151", body_html: "Good snowboard!", vendor: "Burton", product_type: "Snowboard", images: [{attachment: "R0lGODlhAQABAIAAAAAAAAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==\n"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_13', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product = new Product({session: test_session}); + product.title = "Burton Custom Freestyle 151"; + product.body_html = "Good snowboard!"; + product.vendor = "Burton"; + product.product_type = "Snowboard"; + product.images = [ + { + src: "http://example.com/rails_logo.gif" + } + ]; + await product.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/products.json', + query: '', + headers, + data: { "product": {title: "Burton Custom Freestyle 151", body_html: "Good snowboard!", vendor: "Burton", product_type: "Snowboard", images: [{src: "http://example.com/rails_logo.gif"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_14', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product = new Product({session: test_session}); + product.title = "Burton Custom Freestyle 151"; + product.body_html = "Good snowboard!"; + product.vendor = "Burton"; + product.product_type = "Snowboard"; + product.metafields_global_title_tag = "Product SEO Title"; + product.metafields_global_description_tag = "Product SEO Description"; + await product.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/products.json', + query: '', + headers, + data: { "product": {title: "Burton Custom Freestyle 151", body_html: "Good snowboard!", vendor: "Burton", product_type: "Snowboard", metafields_global_title_tag: "Product SEO Title", metafields_global_description_tag: "Product SEO Description"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_15', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product = new Product({session: test_session}); + product.title = "Burton Custom Freestyle 151"; + product.body_html = "Good snowboard!"; + product.vendor = "Burton"; + product.product_type = "Snowboard"; + product.metafields = [ + { + key: "new", + value: "newvalue", + value_type: "string", + namespace: "global" + } + ]; + await product.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/products.json', + query: '', + headers, + data: { "product": {title: "Burton Custom Freestyle 151", body_html: "Good snowboard!", vendor: "Burton", product_type: "Snowboard", metafields: [{key: "new", value: "newvalue", value_type: "string", namespace: "global"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_16', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Product.count({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/products/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_17', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Product.count({ + session: test_session, + collection_id: "841564295", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/products/count.json', + query: 'collection_id=841564295', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_18', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Product.find({ + session: test_session, + id: 632910392, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/products/632910392.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_19', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Product.find({ + session: test_session, + id: 632910392, + fields: "id,images,title", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/products/632910392.json', + query: 'fields=id%2Cimages%2Ctitle', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_20', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product = new Product({session: test_session}); + product.id = 632910392; + product.title = "New product title"; + await product.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/products/632910392.json', + query: '', + headers, + data: { "product": {id: 632910392, title: "New product title"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_21', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product = new Product({session: test_session}); + product.id = 632910392; + product.status = "draft"; + await product.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/products/632910392.json', + query: '', + headers, + data: { "product": {id: 632910392, status: "draft"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_22', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product = new Product({session: test_session}); + product.id = 632910392; + product.tags = "Barnes & Noble, John's Fav"; + await product.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/products/632910392.json', + query: '', + headers, + data: { "product": {id: 632910392, tags: "Barnes & Noble, John's Fav"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_23', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product = new Product({session: test_session}); + product.id = 632910392; + product.images = []; + await product.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/products/632910392.json', + query: '', + headers, + data: { "product": {id: 632910392, images: []} } + }).toMatchMadeHttpRequest(); + }); + + it('test_24', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product = new Product({session: test_session}); + product.id = 632910392; + product.images = [ + { + id: 850703190 + }, + { + id: 562641783 + }, + { + id: 378407906 + }, + { + src: "http://example.com/rails_logo.gif" + } + ]; + await product.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/products/632910392.json', + query: '', + headers, + data: { "product": {id: 632910392, images: [{id: 850703190}, {id: 562641783}, {id: 378407906}, {src: "http://example.com/rails_logo.gif"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_25', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product = new Product({session: test_session}); + product.id = 632910392; + product.images = [ + { + id: 850703190, + position: 3 + }, + { + id: 562641783, + position: 2 + }, + { + id: 378407906, + position: 1 + } + ]; + await product.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/products/632910392.json', + query: '', + headers, + data: { "product": {id: 632910392, images: [{id: 850703190, position: 3}, {id: 562641783, position: 2}, {id: 378407906, position: 1}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_26', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product = new Product({session: test_session}); + product.id = 632910392; + product.variants = [ + { + id: 457924702 + }, + { + id: 39072856 + }, + { + id: 49148385 + }, + { + id: 808950810 + } + ]; + await product.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/products/632910392.json', + query: '', + headers, + data: { "product": {id: 632910392, variants: [{id: 457924702}, {id: 39072856}, {id: 49148385}, {id: 808950810}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_27', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product = new Product({session: test_session}); + product.id = 632910392; + product.title = "Updated Product Title"; + product.variants = [ + { + id: 808950810, + price: "2000.00", + sku: "Updating the Product SKU" + }, + { + id: 49148385 + }, + { + id: 39072856 + }, + { + id: 457924702 + } + ]; + await product.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/products/632910392.json', + query: '', + headers, + data: { "product": {id: 632910392, title: "Updated Product Title", variants: [{id: 808950810, price: "2000.00", sku: "Updating the Product SKU"}, {id: 49148385}, {id: 39072856}, {id: 457924702}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_28', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product = new Product({session: test_session}); + product.id = 632910392; + product.metafields_global_title_tag = "Brand new title"; + product.metafields_global_description_tag = "Brand new description"; + await product.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/products/632910392.json', + query: '', + headers, + data: { "product": {id: 632910392, metafields_global_title_tag: "Brand new title", metafields_global_description_tag: "Brand new description"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_29', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product = new Product({session: test_session}); + product.id = 632910392; + product.published = true; + await product.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/products/632910392.json', + query: '', + headers, + data: { "product": {id: 632910392, published: true} } + }).toMatchMadeHttpRequest(); + }); + + it('test_30', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product = new Product({session: test_session}); + product.id = 632910392; + product.published = false; + await product.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/products/632910392.json', + query: '', + headers, + data: { "product": {id: 632910392, published: false} } + }).toMatchMadeHttpRequest(); + }); + + it('test_31', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product = new Product({session: test_session}); + product.id = 632910392; + product.metafields = [ + { + key: "new", + value: "newvalue", + value_type: "string", + namespace: "global" + } + ]; + await product.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/products/632910392.json', + query: '', + headers, + data: { "product": {id: 632910392, metafields: [{key: "new", value: "newvalue", value_type: "string", namespace: "global"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_32', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Product.delete({ + session: test_session, + id: 632910392, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-04/products/632910392.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-04/product_listing.test.ts b/src/rest-resources/__tests__/2021-04/product_listing.test.ts new file mode 100644 index 000000000..91ae50b5a --- /dev/null +++ b/src/rest-resources/__tests__/2021-04/product_listing.test.ts @@ -0,0 +1,121 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {ProductListing} from '../../2021-04'; + +describe('ProductListing resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.April21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await ProductListing.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/product_listings.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await ProductListing.product_ids({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/product_listings/product_ids.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await ProductListing.count({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/product_listings/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await ProductListing.find({ + session: test_session, + product_id: 921728736, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/product_listings/921728736.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product_listing = new ProductListing({session: test_session}); + product_listing.product_id = 921728736; + await product_listing.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/product_listings/921728736.json', + query: '', + headers, + data: { "product_listing": {product_id: 921728736} } + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await ProductListing.delete({ + session: test_session, + product_id: 921728736, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-04/product_listings/921728736.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-04/product_resource_feedback.test.ts b/src/rest-resources/__tests__/2021-04/product_resource_feedback.test.ts new file mode 100644 index 000000000..55d6da01f --- /dev/null +++ b/src/rest-resources/__tests__/2021-04/product_resource_feedback.test.ts @@ -0,0 +1,78 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {ProductResourceFeedback} from '../../2021-04'; + +describe('ProductResourceFeedback resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.April21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product_resource_feedback = new ProductResourceFeedback({session: test_session}); + product_resource_feedback.product_id = 632910392; + product_resource_feedback.state = "requires_action"; + product_resource_feedback.messages = [ + "Needs at least one image." + ]; + product_resource_feedback.resource_updated_at = "2022-02-03T16:53:36-05:00"; + product_resource_feedback.feedback_generated_at = "2022-02-03T22:11:14.477009Z"; + await product_resource_feedback.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/products/632910392/resource_feedback.json', + query: '', + headers, + data: { "resource_feedback": {state: "requires_action", messages: ["Needs at least one image."], resource_updated_at: "2022-02-03T16:53:36-05:00", feedback_generated_at: "2022-02-03T22:11:14.477009Z"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product_resource_feedback = new ProductResourceFeedback({session: test_session}); + product_resource_feedback.product_id = 632910392; + product_resource_feedback.state = "success"; + product_resource_feedback.resource_updated_at = "2022-02-03T16:53:36-05:00"; + product_resource_feedback.feedback_generated_at = "2022-02-03T22:11:15.898793Z"; + await product_resource_feedback.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/products/632910392/resource_feedback.json', + query: '', + headers, + data: { "resource_feedback": {state: "success", resource_updated_at: "2022-02-03T16:53:36-05:00", feedback_generated_at: "2022-02-03T22:11:15.898793Z"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await ProductResourceFeedback.all({ + session: test_session, + product_id: 632910392, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/products/632910392/resource_feedback.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-04/province.test.ts b/src/rest-resources/__tests__/2021-04/province.test.ts new file mode 100644 index 000000000..25edf727a --- /dev/null +++ b/src/rest-resources/__tests__/2021-04/province.test.ts @@ -0,0 +1,110 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Province} from '../../2021-04'; + +describe('Province resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.April21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Province.all({ + session: test_session, + country_id: 879921427, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/countries/879921427/provinces.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Province.all({ + session: test_session, + country_id: 879921427, + since_id: "536137098", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/countries/879921427/provinces.json', + query: 'since_id=536137098', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Province.count({ + session: test_session, + country_id: 879921427, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/countries/879921427/provinces/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Province.find({ + session: test_session, + country_id: 879921427, + id: 224293623, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/countries/879921427/provinces/224293623.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const province = new Province({session: test_session}); + province.country_id = 879921427; + province.id = 224293623; + province.tax = 0.09; + await province.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/countries/879921427/provinces/224293623.json', + query: '', + headers, + data: { "province": {id: 224293623, tax: 0.09} } + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-04/recurring_application_charge.test.ts b/src/rest-resources/__tests__/2021-04/recurring_application_charge.test.ts new file mode 100644 index 000000000..4a67172f1 --- /dev/null +++ b/src/rest-resources/__tests__/2021-04/recurring_application_charge.test.ts @@ -0,0 +1,187 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {RecurringApplicationCharge} from '../../2021-04'; + +describe('RecurringApplicationCharge resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.April21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const recurring_application_charge = new RecurringApplicationCharge({session: test_session}); + recurring_application_charge.name = "Super Duper Plan"; + recurring_application_charge.price = 10.0; + recurring_application_charge.return_url = "http://super-duper.shopifyapps.com"; + await recurring_application_charge.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/recurring_application_charges.json', + query: '', + headers, + data: { "recurring_application_charge": {name: "Super Duper Plan", price: 10.0, return_url: "http://super-duper.shopifyapps.com"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const recurring_application_charge = new RecurringApplicationCharge({session: test_session}); + recurring_application_charge.name = "Super Duper Plan"; + recurring_application_charge.price = 10.0; + recurring_application_charge.return_url = "http://super-duper.shopifyapps.com"; + recurring_application_charge.capped_amount = 100; + recurring_application_charge.terms = "$1 for 1000 emails"; + await recurring_application_charge.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/recurring_application_charges.json', + query: '', + headers, + data: { "recurring_application_charge": {name: "Super Duper Plan", price: 10.0, return_url: "http://super-duper.shopifyapps.com", capped_amount: 100, terms: "$1 for 1000 emails"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const recurring_application_charge = new RecurringApplicationCharge({session: test_session}); + recurring_application_charge.name = "Super Duper Plan"; + recurring_application_charge.price = 10.0; + recurring_application_charge.return_url = "http://super-duper.shopifyapps.com"; + recurring_application_charge.trial_days = 5; + await recurring_application_charge.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/recurring_application_charges.json', + query: '', + headers, + data: { "recurring_application_charge": {name: "Super Duper Plan", price: 10.0, return_url: "http://super-duper.shopifyapps.com", trial_days: 5} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const recurring_application_charge = new RecurringApplicationCharge({session: test_session}); + recurring_application_charge.name = "Super Duper Plan"; + recurring_application_charge.price = 10.0; + recurring_application_charge.return_url = "http://super-duper.shopifyapps.com"; + recurring_application_charge.test = true; + await recurring_application_charge.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/recurring_application_charges.json', + query: '', + headers, + data: { "recurring_application_charge": {name: "Super Duper Plan", price: 10.0, return_url: "http://super-duper.shopifyapps.com", test: true} } + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await RecurringApplicationCharge.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/recurring_application_charges.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await RecurringApplicationCharge.all({ + session: test_session, + since_id: "455696195", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/recurring_application_charges.json', + query: 'since_id=455696195', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await RecurringApplicationCharge.find({ + session: test_session, + id: 455696195, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/recurring_application_charges/455696195.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await RecurringApplicationCharge.delete({ + session: test_session, + id: 455696195, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-04/recurring_application_charges/455696195.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const recurring_application_charge = new RecurringApplicationCharge({session: test_session}); + recurring_application_charge.id = 455696195; + await recurring_application_charge.customize({ + recurring_application_charge: {capped_amount: "200"}, + }); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/recurring_application_charges/455696195/customize.json', + query: 'recurring_application_charge%5Bcapped_amount%5D=200', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-04/redirect.test.ts b/src/rest-resources/__tests__/2021-04/redirect.test.ts new file mode 100644 index 000000000..e51610a41 --- /dev/null +++ b/src/rest-resources/__tests__/2021-04/redirect.test.ts @@ -0,0 +1,196 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Redirect} from '../../2021-04'; + +describe('Redirect resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.April21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Redirect.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/redirects.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Redirect.all({ + session: test_session, + since_id: "668809255", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/redirects.json', + query: 'since_id=668809255', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const redirect = new Redirect({session: test_session}); + redirect.path = "/ipod"; + redirect.target = "/pages/itunes"; + await redirect.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/redirects.json', + query: '', + headers, + data: { "redirect": {path: "/ipod", target: "/pages/itunes"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const redirect = new Redirect({session: test_session}); + redirect.path = "http://www.apple.com/forums"; + redirect.target = "http://forums.apple.com"; + await redirect.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/redirects.json', + query: '', + headers, + data: { "redirect": {path: "http://www.apple.com/forums", target: "http://forums.apple.com"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Redirect.count({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/redirects/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Redirect.find({ + session: test_session, + id: 668809255, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/redirects/668809255.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const redirect = new Redirect({session: test_session}); + redirect.id = 668809255; + redirect.path = "/tiger"; + await redirect.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/redirects/668809255.json', + query: '', + headers, + data: { "redirect": {id: 668809255, path: "/tiger"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const redirect = new Redirect({session: test_session}); + redirect.id = 668809255; + redirect.target = "/pages/macpro"; + await redirect.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/redirects/668809255.json', + query: '', + headers, + data: { "redirect": {id: 668809255, target: "/pages/macpro"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const redirect = new Redirect({session: test_session}); + redirect.id = 950115854; + redirect.path = "/powermac"; + redirect.target = "/pages/macpro"; + await redirect.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/redirects/950115854.json', + query: '', + headers, + data: { "redirect": {id: 950115854, path: "/powermac", target: "/pages/macpro"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_10', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Redirect.delete({ + session: test_session, + id: 668809255, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-04/redirects/668809255.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-04/refund.test.ts b/src/rest-resources/__tests__/2021-04/refund.test.ts new file mode 100644 index 000000000..4d56fe2f3 --- /dev/null +++ b/src/rest-resources/__tests__/2021-04/refund.test.ts @@ -0,0 +1,179 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Refund} from '../../2021-04'; + +describe('Refund resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.April21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Refund.all({ + session: test_session, + order_id: 450789469, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/orders/450789469/refunds.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const refund = new Refund({session: test_session}); + refund.order_id = 450789469; + refund.currency = "USD"; + refund.notify = true; + refund.note = "wrong size"; + refund.shipping = { + full_refund: true + }; + refund.refund_line_items = [ + { + line_item_id: 518995019, + quantity: 1, + restock_type: "return", + location_id: 487838322 + } + ]; + refund.transactions = [ + { + parent_id: 801038806, + amount: 41.94, + kind: "refund", + gateway: "bogus" + } + ]; + await refund.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/orders/450789469/refunds.json', + query: '', + headers, + data: { "refund": {currency: "USD", notify: true, note: "wrong size", shipping: {full_refund: true}, refund_line_items: [{line_item_id: 518995019, quantity: 1, restock_type: "return", location_id: 487838322}], transactions: [{parent_id: 801038806, amount: 41.94, kind: "refund", gateway: "bogus"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const refund = new Refund({session: test_session}); + refund.order_id = 450789469; + refund.currency = "USD"; + refund.shipping = { + amount: 5.0 + }; + refund.transactions = [ + { + parent_id: 801038806, + amount: 5.0, + kind: "refund", + gateway: "bogus" + } + ]; + await refund.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/orders/450789469/refunds.json', + query: '', + headers, + data: { "refund": {currency: "USD", shipping: {amount: 5.0}, transactions: [{parent_id: 801038806, amount: 5.0, kind: "refund", gateway: "bogus"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Refund.find({ + session: test_session, + order_id: 450789469, + id: 509562969, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/orders/450789469/refunds/509562969.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const refund = new Refund({session: test_session}); + refund.order_id = 450789469; + await refund.calculate({ + body: {refund: {shipping: {full_refund: true}, refund_line_items: [{line_item_id: 518995019, quantity: 1, restock_type: "no_restock"}]}}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/orders/450789469/refunds/calculate.json', + query: '', + headers, + data: { "refund": {shipping: {full_refund: true}, refund_line_items: [{line_item_id: 518995019, quantity: 1, restock_type: "no_restock"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const refund = new Refund({session: test_session}); + refund.order_id = 450789469; + await refund.calculate({ + body: {refund: {currency: "USD", shipping: {full_refund: true}, refund_line_items: [{line_item_id: 518995019, quantity: 1, restock_type: "no_restock"}]}}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/orders/450789469/refunds/calculate.json', + query: '', + headers, + data: { "refund": {currency: "USD", shipping: {full_refund: true}, refund_line_items: [{line_item_id: 518995019, quantity: 1, restock_type: "no_restock"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const refund = new Refund({session: test_session}); + refund.order_id = 450789469; + await refund.calculate({ + body: {refund: {currency: "USD", shipping: {amount: 2.0}}}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/orders/450789469/refunds/calculate.json', + query: '', + headers, + data: { "refund": {currency: "USD", shipping: {amount: 2.0}} } + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-04/report.test.ts b/src/rest-resources/__tests__/2021-04/report.test.ts new file mode 100644 index 000000000..a10015b9c --- /dev/null +++ b/src/rest-resources/__tests__/2021-04/report.test.ts @@ -0,0 +1,198 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Report} from '../../2021-04'; + +describe('Report resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.April21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Report.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/reports.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Report.all({ + session: test_session, + ids: "517154478", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/reports.json', + query: 'ids=517154478', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Report.all({ + session: test_session, + updated_at_min: "2005-07-31 15:57:11 EDT -04:00", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/reports.json', + query: 'updated_at_min=2005-07-31+15%3A57%3A11+EDT+-04%3A00', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Report.all({ + session: test_session, + fields: "id,shopify_ql", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/reports.json', + query: 'fields=id%2Cshopify_ql', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Report.all({ + session: test_session, + since_id: "123", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/reports.json', + query: 'since_id=123', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const report = new Report({session: test_session}); + report.name = "A new app report"; + report.shopify_ql = "SHOW total_sales BY order_id FROM sales SINCE -1m UNTIL today ORDER BY total_sales"; + await report.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/reports.json', + query: '', + headers, + data: { "report": {name: "A new app report", shopify_ql: "SHOW total_sales BY order_id FROM sales SINCE -1m UNTIL today ORDER BY total_sales"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Report.find({ + session: test_session, + id: 517154478, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/reports/517154478.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Report.find({ + session: test_session, + id: 517154478, + fields: "id,shopify_ql", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/reports/517154478.json', + query: 'fields=id%2Cshopify_ql', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const report = new Report({session: test_session}); + report.id = 517154478; + report.name = "Changed Report Name"; + report.shopify_ql = "SHOW total_sales BY order_id FROM sales SINCE -12m UNTIL today ORDER BY total_sales"; + await report.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/reports/517154478.json', + query: '', + headers, + data: { "report": {id: 517154478, name: "Changed Report Name", shopify_ql: "SHOW total_sales BY order_id FROM sales SINCE -12m UNTIL today ORDER BY total_sales"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_10', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Report.delete({ + session: test_session, + id: 517154478, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-04/reports/517154478.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-04/resource_feedback.test.ts b/src/rest-resources/__tests__/2021-04/resource_feedback.test.ts new file mode 100644 index 000000000..71e9fa347 --- /dev/null +++ b/src/rest-resources/__tests__/2021-04/resource_feedback.test.ts @@ -0,0 +1,73 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {ResourceFeedback} from '../../2021-04'; + +describe('ResourceFeedback resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.April21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const resource_feedback = new ResourceFeedback({session: test_session}); + resource_feedback.state = "requires_action"; + resource_feedback.messages = [ + "is not connected. Connect your account to use this sales channel." + ]; + resource_feedback.feedback_generated_at = "2022-02-03T22:00:23.179942Z"; + await resource_feedback.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/resource_feedback.json', + query: '', + headers, + data: { "resource_feedback": {state: "requires_action", messages: ["is not connected. Connect your account to use this sales channel."], feedback_generated_at: "2022-02-03T22:00:23.179942Z"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const resource_feedback = new ResourceFeedback({session: test_session}); + resource_feedback.state = "success"; + resource_feedback.feedback_generated_at = "2022-02-03T22:00:24.490026Z"; + await resource_feedback.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/resource_feedback.json', + query: '', + headers, + data: { "resource_feedback": {state: "success", feedback_generated_at: "2022-02-03T22:00:24.490026Z"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await ResourceFeedback.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/resource_feedback.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-04/script_tag.test.ts b/src/rest-resources/__tests__/2021-04/script_tag.test.ts new file mode 100644 index 000000000..7b3406a32 --- /dev/null +++ b/src/rest-resources/__tests__/2021-04/script_tag.test.ts @@ -0,0 +1,159 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {ScriptTag} from '../../2021-04'; + +describe('ScriptTag resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.April21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await ScriptTag.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/script_tags.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await ScriptTag.all({ + session: test_session, + src: "https://js-aplenty.com/foo.js", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/script_tags.json', + query: 'src=https%3A%2F%2Fjs-aplenty.com%2Ffoo.js', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await ScriptTag.all({ + session: test_session, + since_id: "421379493", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/script_tags.json', + query: 'since_id=421379493', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const script_tag = new ScriptTag({session: test_session}); + script_tag.event = "onload"; + script_tag.src = "https://djavaskripped.org/fancy.js"; + await script_tag.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/script_tags.json', + query: '', + headers, + data: { "script_tag": {event: "onload", src: "https://djavaskripped.org/fancy.js"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await ScriptTag.count({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/script_tags/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await ScriptTag.find({ + session: test_session, + id: 596726825, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/script_tags/596726825.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const script_tag = new ScriptTag({session: test_session}); + script_tag.id = 596726825; + script_tag.src = "https://somewhere-else.com/another.js"; + await script_tag.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/script_tags/596726825.json', + query: '', + headers, + data: { "script_tag": {id: 596726825, src: "https://somewhere-else.com/another.js"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await ScriptTag.delete({ + session: test_session, + id: 596726825, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-04/script_tags/596726825.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-04/shipping_zone.test.ts b/src/rest-resources/__tests__/2021-04/shipping_zone.test.ts new file mode 100644 index 000000000..da4f8c0e8 --- /dev/null +++ b/src/rest-resources/__tests__/2021-04/shipping_zone.test.ts @@ -0,0 +1,34 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {ShippingZone} from '../../2021-04'; + +describe('ShippingZone resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.April21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await ShippingZone.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/shipping_zones.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-04/shop.test.ts b/src/rest-resources/__tests__/2021-04/shop.test.ts new file mode 100644 index 000000000..13c1268cd --- /dev/null +++ b/src/rest-resources/__tests__/2021-04/shop.test.ts @@ -0,0 +1,52 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Shop} from '../../2021-04'; + +describe('Shop resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.April21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Shop.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/shop.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Shop.all({ + session: test_session, + fields: "address1,address2,city,province,country", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/shop.json', + query: 'fields=address1%2Caddress2%2Ccity%2Cprovince%2Ccountry', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-04/smart_collection.test.ts b/src/rest-resources/__tests__/2021-04/smart_collection.test.ts new file mode 100644 index 000000000..c2cf30e84 --- /dev/null +++ b/src/rest-resources/__tests__/2021-04/smart_collection.test.ts @@ -0,0 +1,456 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {SmartCollection} from '../../2021-04'; + +describe('SmartCollection resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.April21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await SmartCollection.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/smart_collections.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await SmartCollection.all({ + session: test_session, + since_id: "482865238", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/smart_collections.json', + query: 'since_id=482865238', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await SmartCollection.all({ + session: test_session, + product_id: "632910392", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/smart_collections.json', + query: 'product_id=632910392', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await SmartCollection.all({ + session: test_session, + ids: "482865238,1063001375", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/smart_collections.json', + query: 'ids=482865238%2C1063001375', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const smart_collection = new SmartCollection({session: test_session}); + smart_collection.title = "IPods"; + smart_collection.rules = [ + { + column: "title", + relation: "starts_with", + condition: "iPod" + } + ]; + await smart_collection.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/smart_collections.json', + query: '', + headers, + data: { "smart_collection": {title: "IPods", rules: [{column: "title", relation: "starts_with", condition: "iPod"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const smart_collection = new SmartCollection({session: test_session}); + smart_collection.title = "Macbooks"; + smart_collection.rules = [ + { + column: "vendor", + relation: "equals", + condition: "Apple" + } + ]; + await smart_collection.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/smart_collections.json', + query: '', + headers, + data: { "smart_collection": {title: "Macbooks", rules: [{column: "vendor", relation: "equals", condition: "Apple"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const smart_collection = new SmartCollection({session: test_session}); + smart_collection.title = "Macbooks"; + smart_collection.rules = [ + { + column: "vendor", + relation: "equals", + condition: "Apple" + } + ]; + smart_collection.published = false; + await smart_collection.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/smart_collections.json', + query: '', + headers, + data: { "smart_collection": {title: "Macbooks", rules: [{column: "vendor", relation: "equals", condition: "Apple"}], published: false} } + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const smart_collection = new SmartCollection({session: test_session}); + smart_collection.title = "Macbooks"; + smart_collection.rules = [ + { + column: "vendor", + relation: "equals", + condition: "Apple" + } + ]; + smart_collection.image = { + attachment: "R0lGODlhAQABAIAAAAAAAAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==\n", + alt: "iPod" + }; + await smart_collection.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/smart_collections.json', + query: '', + headers, + data: { "smart_collection": {title: "Macbooks", rules: [{column: "vendor", relation: "equals", condition: "Apple"}], image: {attachment: "R0lGODlhAQABAIAAAAAAAAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==\n", alt: "iPod"}} } + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const smart_collection = new SmartCollection({session: test_session}); + smart_collection.title = "Macbooks"; + smart_collection.rules = [ + { + column: "vendor", + relation: "equals", + condition: "Apple" + } + ]; + smart_collection.image = { + src: "http://example.com/rails_logo.gif", + alt: "Rails Logo" + }; + await smart_collection.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/smart_collections.json', + query: '', + headers, + data: { "smart_collection": {title: "Macbooks", rules: [{column: "vendor", relation: "equals", condition: "Apple"}], image: {src: "http://example.com/rails_logo.gif", alt: "Rails Logo"}} } + }).toMatchMadeHttpRequest(); + }); + + it('test_10', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await SmartCollection.count({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/smart_collections/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_11', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await SmartCollection.count({ + session: test_session, + product_id: "632910392", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/smart_collections/count.json', + query: 'product_id=632910392', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_12', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await SmartCollection.find({ + session: test_session, + id: 482865238, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/smart_collections/482865238.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_13', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const smart_collection = new SmartCollection({session: test_session}); + smart_collection.id = 482865238; + smart_collection.body_html = "

5000 songs in your pocket

"; + await smart_collection.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/smart_collections/482865238.json', + query: '', + headers, + data: { "smart_collection": {id: 482865238, body_html: "

5000 songs in your pocket

"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_14', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const smart_collection = new SmartCollection({session: test_session}); + smart_collection.id = 482865238; + smart_collection.published = true; + await smart_collection.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/smart_collections/482865238.json', + query: '', + headers, + data: { "smart_collection": {id: 482865238, published: true} } + }).toMatchMadeHttpRequest(); + }); + + it('test_15', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const smart_collection = new SmartCollection({session: test_session}); + smart_collection.id = 482865238; + smart_collection.published = false; + await smart_collection.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/smart_collections/482865238.json', + query: '', + headers, + data: { "smart_collection": {id: 482865238, published: false} } + }).toMatchMadeHttpRequest(); + }); + + it('test_16', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const smart_collection = new SmartCollection({session: test_session}); + smart_collection.id = 482865238; + smart_collection.image = { + attachment: "R0lGODlhbgCMAPf/APbr48VySrxTO7IgKt2qmKQdJeK8lsFjROG5p/nz7Zg3\nMNmnd7Q1MLNVS9GId71hSJMZIuzTu4UtKbeEeakhKMl8U8WYjfr18YQaIbAf\nKKwhKdKzqpQtLebFortOOejKrOjZ1Mt7aMNpVbAqLLV7bsNqR 3WwMqEWenN\nsZYxL/Ddy/Pm2e7ZxLlUQrIjNPXp3bU5MbhENbEtLtqhj5ZQTfHh0bMxL7Ip\nNsNyUYkZIrZJPcqGdYIUHb5aPKkeJnoUHd2yiJkiLKYiKLRFOsyJXKVDO8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YawDzP8Q ZwAICLckbgd08i290eh9V\nCIadQw3qO5Oa1H1GNRlSjeorO2HLruZ2rLudAm Dm9Gxcx/GXmSIMbnjH5W2\nzy2RbOzM cENBRAWs0N9b3zXWdp8pra1r61tbXdb4N/2Nv8i5gzeIJd5Gjui\nwT AzQ9YVGrYnNO0Agm27GBkvNnNzje 921qf/ b1QEfuMDFPe5lk/lspUG3\nWKbQCofLBBBuwNEs3C3aikcrB2TTeM81HgmOd3zf/PZ3yFPNaqSXfODF0EDK\nE9e6liZmCvJwOLD7AQhU2efSbG6zm7VgiG1ofBc //nGgZ7vbYw67aVux4v/\nfXSSK53by/HVrzIwDZTBBANUrzpMeAAIWASeB4P/AQ9 cHjEJx7xWgDE5nLQ\neMdHXvKbg/zkMZ23H/1oFRjYPOc9v3nQ58Aw0xn9LACvO7HQAOZVf/jl0ii1\nHcXe9bPX3euftaPL5R71tIf97nsy7/o0WlP2r4/JOU7B r5nqva7jz1EdZ97\n4qNe bonfvCfVXvly1762beOOdLBd Q7PCAAOw==\n", + alt: "Rails logo" + }; + await smart_collection.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/smart_collections/482865238.json', + query: '', + headers, + data: { "smart_collection": {id: 482865238, image: {attachment: "R0lGODlhbgCMAPf/APbr48VySrxTO7IgKt2qmKQdJeK8lsFjROG5p/nz7Zg3\nMNmnd7Q1MLNVS9GId71hSJMZIuzTu4UtKbeEeakhKMl8U8WYjfr18YQaIbAf\nKKwhKdKzqpQtLebFortOOejKrOjZ1Mt7aMNpVbAqLLV7bsNqR 3WwMqEWenN\nsZYxL/Ddy/Pm2e7ZxLlUQrIjNPXp3bU5MbhENbEtLtqhj5ZQTfHh0bMxL7Ip\nNsNyUYkZIrZJPcqGdYIUHb5aPKkeJnoUHd2yiJkiLKYiKLRFOsyJXKVDO8up\nosFaS TBnK4kKti5sNaYg/z49aqYl5kqLrljUtORfMOlo/36 H4ZH8yDYq0f\nKKFYTaU9MrY8MrZBNXwXHpga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5W2\nzy2RbOzM cENBRAWs0N9b3zXWdp8pra1r61tbXdb4N/2Nv8i5gzeIJd5Gjui\nwT AzQ9YVGrYnNO0Agm27GBkvNnNzje 921qf/ b1QEfuMDFPe5lk/lspUG3\nWKbQCofLBBBuwNEs3C3aikcrB2TTeM81HgmOd3zf/PZ3yFPNaqSXfODF0EDK\nE9e6liZmCvJwOLD7AQhU2efSbG6zm7VgiG1ofBc //nGgZ7vbYw67aVux4v/\nfXSSK53by/HVrzIwDZTBBANUrzpMeAAIWASeB4P/AQ9 cHjEJx7xWgDE5nLQ\neMdHXvKbg/zkMZ23H/1oFRjYPOc9v3nQ58Aw0xn9LACvO7HQAOZVf/jl0ii1\nHcXe9bPX3euftaPL5R71tIf97nsy7/o0WlP2r4/JOU7B r5nqva7jz1EdZ97\n4qNe bonfvCfVXvly1762beOOdLBd Q7PCAAOw==\n", alt: "Rails logo"}} } + }).toMatchMadeHttpRequest(); + }); + + it('test_17', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const smart_collection = new SmartCollection({session: test_session}); + smart_collection.id = 482865238; + smart_collection.image = { + alt: "Rails logo" + }; + await smart_collection.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/smart_collections/482865238.json', + query: '', + headers, + data: { "smart_collection": {id: 482865238, image: {alt: "Rails logo"}} } + }).toMatchMadeHttpRequest(); + }); + + it('test_18', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const smart_collection = new SmartCollection({session: test_session}); + smart_collection.id = 482865238; + smart_collection.image = ""; + smart_collection.updated_at = "2022-02-03T17:04:39-05:00"; + smart_collection.title = "Smart iPods"; + smart_collection.handle = "smart-ipods"; + smart_collection.body_html = "

The best selling ipod ever

"; + smart_collection.published_at = "2008-02-01T19:00:00-05:00"; + smart_collection.sort_order = "manual"; + smart_collection.template_suffix = null; + smart_collection.disjunctive = false; + smart_collection.rules = [ + { + column: "type", + relation: "equals", + condition: "Cult Products" + } + ]; + smart_collection.published_scope = "web"; + smart_collection.admin_graphql_api_id = "gid://shopify/Collection/482865238"; + await smart_collection.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/smart_collections/482865238.json', + query: '', + headers, + data: { "smart_collection": {id: 482865238, image: "", updated_at: "2022-02-03T17:04:39-05:00", title: "Smart iPods", handle: "smart-ipods", body_html: "

The best selling ipod ever

", published_at: "2008-02-01T19:00:00-05:00", sort_order: "manual", template_suffix: null, disjunctive: false, rules: [{column: "type", relation: "equals", condition: "Cult Products"}], published_scope: "web", admin_graphql_api_id: "gid://shopify/Collection/482865238"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_19', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await SmartCollection.delete({ + session: test_session, + id: 482865238, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-04/smart_collections/482865238.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_20', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const smart_collection = new SmartCollection({session: test_session}); + smart_collection.id = 482865238; + await smart_collection.order({ + products: ["921728736", "632910392"], + }); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/smart_collections/482865238/order.json', + query: 'products%5B%5D=921728736&products%5B%5D=632910392', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_21', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const smart_collection = new SmartCollection({session: test_session}); + smart_collection.id = 482865238; + await smart_collection.order({ + sort_order: "alpha-desc", + }); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/smart_collections/482865238/order.json', + query: 'sort_order=alpha-desc', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-04/storefront_access_token.test.ts b/src/rest-resources/__tests__/2021-04/storefront_access_token.test.ts new file mode 100644 index 000000000..50a68e9e8 --- /dev/null +++ b/src/rest-resources/__tests__/2021-04/storefront_access_token.test.ts @@ -0,0 +1,69 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {StorefrontAccessToken} from '../../2021-04'; + +describe('StorefrontAccessToken resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.April21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const storefront_access_token = new StorefrontAccessToken({session: test_session}); + storefront_access_token.title = "Test"; + await storefront_access_token.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/storefront_access_tokens.json', + query: '', + headers, + data: { "storefront_access_token": {title: "Test"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await StorefrontAccessToken.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/storefront_access_tokens.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await StorefrontAccessToken.delete({ + session: test_session, + id: 755357713, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-04/storefront_access_tokens/755357713.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-04/tender_transaction.test.ts b/src/rest-resources/__tests__/2021-04/tender_transaction.test.ts new file mode 100644 index 000000000..3083ec85e --- /dev/null +++ b/src/rest-resources/__tests__/2021-04/tender_transaction.test.ts @@ -0,0 +1,124 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {TenderTransaction} from '../../2021-04'; + +describe('TenderTransaction resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.April21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await TenderTransaction.all({ + session: test_session, + processed_at_max: "2005-08-05 10:22:51 -0400", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/tender_transactions.json', + query: 'processed_at_max=2005-08-05+10%3A22%3A51+-0400', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await TenderTransaction.all({ + session: test_session, + order: "processed_at ASC", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/tender_transactions.json', + query: 'order=processed_at+ASC', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await TenderTransaction.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/tender_transactions.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await TenderTransaction.all({ + session: test_session, + since_id: "1011222896", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/tender_transactions.json', + query: 'since_id=1011222896', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await TenderTransaction.all({ + session: test_session, + processed_at_min: "2005-08-06 10:22:51 -0400", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/tender_transactions.json', + query: 'processed_at_min=2005-08-06+10%3A22%3A51+-0400', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await TenderTransaction.all({ + session: test_session, + processed_at_max: "2005-08-06 10:22:51 -0400", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/tender_transactions.json', + query: 'processed_at_max=2005-08-06+10%3A22%3A51+-0400', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-04/theme.test.ts b/src/rest-resources/__tests__/2021-04/theme.test.ts new file mode 100644 index 000000000..a456b6447 --- /dev/null +++ b/src/rest-resources/__tests__/2021-04/theme.test.ts @@ -0,0 +1,125 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Theme} from '../../2021-04'; + +describe('Theme resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.April21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Theme.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/themes.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const theme = new Theme({session: test_session}); + theme.name = "Lemongrass"; + theme.src = "http://themes.shopify.com/theme.zip"; + theme.role = "main"; + await theme.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/themes.json', + query: '', + headers, + data: { "theme": {name: "Lemongrass", src: "http://themes.shopify.com/theme.zip", role: "main"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Theme.find({ + session: test_session, + id: 828155753, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/themes/828155753.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const theme = new Theme({session: test_session}); + theme.id = 752253240; + theme.name = "Experimental"; + await theme.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/themes/752253240.json', + query: '', + headers, + data: { "theme": {id: 752253240, name: "Experimental"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const theme = new Theme({session: test_session}); + theme.id = 752253240; + theme.role = "main"; + await theme.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/themes/752253240.json', + query: '', + headers, + data: { "theme": {id: 752253240, role: "main"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Theme.delete({ + session: test_session, + id: 752253240, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-04/themes/752253240.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-04/transaction.test.ts b/src/rest-resources/__tests__/2021-04/transaction.test.ts new file mode 100644 index 000000000..13a775e07 --- /dev/null +++ b/src/rest-resources/__tests__/2021-04/transaction.test.ts @@ -0,0 +1,174 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Transaction} from '../../2021-04'; + +describe('Transaction resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.April21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Transaction.all({ + session: test_session, + order_id: 450789469, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/orders/450789469/transactions.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Transaction.all({ + session: test_session, + order_id: 450789469, + since_id: "801038806", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/orders/450789469/transactions.json', + query: 'since_id=801038806', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const transaction = new Transaction({session: test_session}); + transaction.order_id = 450789469; + transaction.currency = "USD"; + transaction.amount = "10.00"; + transaction.kind = "capture"; + transaction.parent_id = 389404469; + await transaction.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/orders/450789469/transactions.json', + query: '', + headers, + data: { "transaction": {currency: "USD", amount: "10.00", kind: "capture", parent_id: 389404469} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const transaction = new Transaction({session: test_session}); + transaction.order_id = 450789469; + transaction.currency = "USD"; + transaction.amount = "10.00"; + transaction.kind = "void"; + transaction.parent_id = 389404469; + await transaction.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/orders/450789469/transactions.json', + query: '', + headers, + data: { "transaction": {currency: "USD", amount: "10.00", kind: "void", parent_id: 389404469} } + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const transaction = new Transaction({session: test_session}); + transaction.order_id = 450789469; + transaction.currency = "USD"; + transaction.amount = "10.00"; + transaction.kind = "capture"; + transaction.parent_id = 389404469; + transaction.test = true; + await transaction.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/orders/450789469/transactions.json', + query: '', + headers, + data: { "transaction": {currency: "USD", amount: "10.00", kind: "capture", parent_id: 389404469, test: true} } + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const transaction = new Transaction({session: test_session}); + transaction.order_id = 450789469; + transaction.kind = "capture"; + transaction.authorization = "authorization-key"; + await transaction.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/orders/450789469/transactions.json', + query: '', + headers, + data: { "transaction": {kind: "capture", authorization: "authorization-key"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Transaction.count({ + session: test_session, + order_id: 450789469, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/orders/450789469/transactions/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Transaction.find({ + session: test_session, + order_id: 450789469, + id: 389404469, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/orders/450789469/transactions/389404469.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-04/usage_charge.test.ts b/src/rest-resources/__tests__/2021-04/usage_charge.test.ts new file mode 100644 index 000000000..33f8fb452 --- /dev/null +++ b/src/rest-resources/__tests__/2021-04/usage_charge.test.ts @@ -0,0 +1,73 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {UsageCharge} from '../../2021-04'; + +describe('UsageCharge resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.April21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const usage_charge = new UsageCharge({session: test_session}); + usage_charge.recurring_application_charge_id = 455696195; + usage_charge.description = "Super Mega Plan 1000 emails"; + usage_charge.price = 1.0; + await usage_charge.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/recurring_application_charges/455696195/usage_charges.json', + query: '', + headers, + data: { "usage_charge": {description: "Super Mega Plan 1000 emails", price: 1.0} } + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await UsageCharge.all({ + session: test_session, + recurring_application_charge_id: 455696195, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/recurring_application_charges/455696195/usage_charges.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await UsageCharge.find({ + session: test_session, + recurring_application_charge_id: 455696195, + id: 1034618217, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/recurring_application_charges/455696195/usage_charges/1034618217.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-04/user.test.ts b/src/rest-resources/__tests__/2021-04/user.test.ts new file mode 100644 index 000000000..b081c195d --- /dev/null +++ b/src/rest-resources/__tests__/2021-04/user.test.ts @@ -0,0 +1,69 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {User} from '../../2021-04'; + +describe('User resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.April21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await User.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/users.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await User.find({ + session: test_session, + id: 548380009, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/users/548380009.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await User.current({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/users/current.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-04/variant.test.ts b/src/rest-resources/__tests__/2021-04/variant.test.ts new file mode 100644 index 000000000..437182f65 --- /dev/null +++ b/src/rest-resources/__tests__/2021-04/variant.test.ts @@ -0,0 +1,254 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Variant} from '../../2021-04'; + +describe('Variant resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.April21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Variant.all({ + session: test_session, + product_id: 632910392, + since_id: "49148385", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/products/632910392/variants.json', + query: 'since_id=49148385', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Variant.all({ + session: test_session, + product_id: 632910392, + presentment_currencies: "USD,CAD", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/products/632910392/variants.json', + query: 'presentment_currencies=USD%2CCAD', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Variant.all({ + session: test_session, + product_id: 632910392, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/products/632910392/variants.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Variant.count({ + session: test_session, + product_id: 632910392, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/products/632910392/variants/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Variant.find({ + session: test_session, + id: 808950810, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/variants/808950810.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const variant = new Variant({session: test_session}); + variant.id = 808950810; + variant.option1 = "Not Pink"; + variant.price = "99.00"; + await variant.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/variants/808950810.json', + query: '', + headers, + data: { "variant": {id: 808950810, option1: "Not Pink", price: "99.00"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const variant = new Variant({session: test_session}); + variant.id = 808950810; + variant.image_id = 562641783; + await variant.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/variants/808950810.json', + query: '', + headers, + data: { "variant": {id: 808950810, image_id: 562641783} } + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const variant = new Variant({session: test_session}); + variant.id = 808950810; + variant.metafields = [ + { + key: "new", + value: "newvalue", + value_type: "string", + namespace: "global" + } + ]; + await variant.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/variants/808950810.json', + query: '', + headers, + data: { "variant": {id: 808950810, metafields: [{key: "new", value: "newvalue", value_type: "string", namespace: "global"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const variant = new Variant({session: test_session}); + variant.product_id = 632910392; + variant.option1 = "Yellow"; + variant.price = "1.00"; + await variant.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/products/632910392/variants.json', + query: '', + headers, + data: { "variant": {option1: "Yellow", price: "1.00"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_10', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const variant = new Variant({session: test_session}); + variant.product_id = 632910392; + variant.image_id = 850703190; + variant.option1 = "Purple"; + await variant.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/products/632910392/variants.json', + query: '', + headers, + data: { "variant": {image_id: 850703190, option1: "Purple"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_11', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const variant = new Variant({session: test_session}); + variant.product_id = 632910392; + variant.option1 = "Blue"; + variant.metafields = [ + { + key: "new", + value: "newvalue", + value_type: "string", + namespace: "global" + } + ]; + await variant.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/products/632910392/variants.json', + query: '', + headers, + data: { "variant": {option1: "Blue", metafields: [{key: "new", value: "newvalue", value_type: "string", namespace: "global"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_12', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Variant.delete({ + session: test_session, + product_id: 632910392, + id: 808950810, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-04/products/632910392/variants/808950810.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-04/webhook.test.ts b/src/rest-resources/__tests__/2021-04/webhook.test.ts new file mode 100644 index 000000000..00f7efdc0 --- /dev/null +++ b/src/rest-resources/__tests__/2021-04/webhook.test.ts @@ -0,0 +1,202 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Webhook} from '../../2021-04'; + +describe('Webhook resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.April21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Webhook.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/webhooks.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Webhook.all({ + session: test_session, + since_id: "901431826", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/webhooks.json', + query: 'since_id=901431826', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const webhook = new Webhook({session: test_session}); + webhook.topic = "orders/create"; + webhook.address = "https://example.hostname.com/"; + webhook.format = "json"; + webhook.fields = [ + "id", + "note" + ]; + await webhook.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/webhooks.json', + query: '', + headers, + data: { "webhook": {topic: "orders/create", address: "https://example.hostname.com/", format: "json", fields: ["id", "note"]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const webhook = new Webhook({session: test_session}); + webhook.address = "arn:aws:events:us-east-1::event-source/aws.partner/shopify.com/755357713/example-event-source"; + webhook.topic = "customers/update"; + webhook.format = "json"; + await webhook.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/webhooks.json', + query: '', + headers, + data: { "webhook": {address: "arn:aws:events:us-east-1::event-source/aws.partner/shopify.com/755357713/example-event-source", topic: "customers/update", format: "json"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const webhook = new Webhook({session: test_session}); + webhook.address = "pubsub://projectName:topicName"; + webhook.topic = "customers/update"; + webhook.format = "json"; + await webhook.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-04/webhooks.json', + query: '', + headers, + data: { "webhook": {address: "pubsub://projectName:topicName", topic: "customers/update", format: "json"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Webhook.count({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/webhooks/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Webhook.count({ + session: test_session, + topic: "orders/create", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/webhooks/count.json', + query: 'topic=orders%2Fcreate', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Webhook.find({ + session: test_session, + id: 4759306, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-04/webhooks/4759306.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const webhook = new Webhook({session: test_session}); + webhook.id = 4759306; + webhook.address = "https://somewhere-else.com/"; + await webhook.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-04/webhooks/4759306.json', + query: '', + headers, + data: { "webhook": {id: 4759306, address: "https://somewhere-else.com/"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_10', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Webhook.delete({ + session: test_session, + id: 4759306, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-04/webhooks/4759306.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-07/abandoned_checkout.test.ts b/src/rest-resources/__tests__/2021-07/abandoned_checkout.test.ts new file mode 100644 index 000000000..3065abecb --- /dev/null +++ b/src/rest-resources/__tests__/2021-07/abandoned_checkout.test.ts @@ -0,0 +1,141 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {AbandonedCheckout} from '../../2021-07'; + +describe('AbandonedCheckout resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.July21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await AbandonedCheckout.checkouts({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/checkouts.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await AbandonedCheckout.checkouts({ + session: test_session, + status: "closed", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/checkouts.json', + query: 'status=closed', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await AbandonedCheckout.checkouts({ + session: test_session, + created_at_max: "2013-10-12T07:05:27-02:00", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/checkouts.json', + query: 'created_at_max=2013-10-12T07%3A05%3A27-02%3A00', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await AbandonedCheckout.checkouts({ + session: test_session, + limit: "1", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/checkouts.json', + query: 'limit=1', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await AbandonedCheckout.checkouts({ + session: test_session, + status: "closed", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/checkouts.json', + query: 'status=closed', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await AbandonedCheckout.checkouts({ + session: test_session, + created_at_max: "2013-10-12T07:05:27-02:00", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/checkouts.json', + query: 'created_at_max=2013-10-12T07%3A05%3A27-02%3A00', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await AbandonedCheckout.checkouts({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/checkouts.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-07/access_scope.test.ts b/src/rest-resources/__tests__/2021-07/access_scope.test.ts new file mode 100644 index 000000000..49eb590fb --- /dev/null +++ b/src/rest-resources/__tests__/2021-07/access_scope.test.ts @@ -0,0 +1,34 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {AccessScope} from '../../2021-07'; + +describe('AccessScope resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.July21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await AccessScope.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/oauth/access_scopes.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-07/android_pay_key.test.ts b/src/rest-resources/__tests__/2021-07/android_pay_key.test.ts new file mode 100644 index 000000000..d24dd1061 --- /dev/null +++ b/src/rest-resources/__tests__/2021-07/android_pay_key.test.ts @@ -0,0 +1,70 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {AndroidPayKey} from '../../2021-07'; + +describe('AndroidPayKey resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.July21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const android_pay_key = new AndroidPayKey({session: test_session}); + + await android_pay_key.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/android_pay_keys.json', + query: '', + headers, + data: { "android_pay_key": {} } + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await AndroidPayKey.find({ + session: test_session, + id: 964811897, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/android_pay_keys/964811897.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await AndroidPayKey.delete({ + session: test_session, + id: 964811898, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-07/android_pay_keys/964811898.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-07/apple_pay_certificate.test.ts b/src/rest-resources/__tests__/2021-07/apple_pay_certificate.test.ts new file mode 100644 index 000000000..447406614 --- /dev/null +++ b/src/rest-resources/__tests__/2021-07/apple_pay_certificate.test.ts @@ -0,0 +1,108 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {ApplePayCertificate} from '../../2021-07'; + +describe('ApplePayCertificate resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.July21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const apple_pay_certificate = new ApplePayCertificate({session: test_session}); + + await apple_pay_certificate.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/apple_pay_certificates.json', + query: '', + headers, + data: { "apple_pay_certificate": {} } + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await ApplePayCertificate.find({ + session: test_session, + id: 1068938280, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/apple_pay_certificates/1068938280.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const apple_pay_certificate = new ApplePayCertificate({session: test_session}); + apple_pay_certificate.id = 1068938282; + apple_pay_certificate.status = "completed"; + apple_pay_certificate.merchant_id = "merchant.something"; + apple_pay_certificate.encoded_signed_certificate = "MIIEZzCCBA6gAwIBAgIIWGMideLkDJAwCgYIKoZIzj0EAwIwgYAxNDAyBgNV\nBAMMK0FwcGxlIFdvcmxkd2lkZSBEZXZlbG9wZXIgUmVsYXRpb25zIENBIC0g\nRzIxJjAkBgNVBAsMHUFwcGxlIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MRMw\nEQYDVQQKDApBcHBsZSBJbmMuMQswCQYDVQQGEwJVUzAeFw0xNDEyMDgyMTMy\nMDBaFw0xNzAxMDYyMTMyMDBaMIGZMSowKAYKCZImiZPyLGQBAQwabWVyY2hh\nbnQuY29tLm5vcm1vcmUuamFzb24xMDAuBgNVBAMMJ01lcmNoYW50IElEOiBt\nZXJjaGFudC5jb20ubm9ybW9yZS5qYXNvbjETMBEGA1UECwwKNVVZMzJOTE5O\nOTEXMBUGA1UECgwOSm9zaHVhIFRlc3NpZXIxCzAJBgNVBAYTAkNBMFkwEwYH\nKoZIzj0CAQYIKoZIzj0DAQcDQgAEAxDDCvzG6MnsZSJOtbr0hr3MRq 4HzTZ\nx8J4FD34E3kU5CallEnZLBmnzfqmjP8644SO28LLJxvWBnrg7lHFtaOCAlUw\nggJRMEcGCCsGAQUFBwEBBDswOTA3BggrBgEFBQcwAYYraHR0cDovL29jc3Au\nYXBwbGUuY29tL29jc3AwNC1hcHBsZXd3ZHJjYTIwMTAdBgNVHQ4EFgQUkPsO\nKEKvhL/takKomy5GWXtCd8wwDAYDVR0TAQH/BAIwADAfBgNVHSMEGDAWgBSE\ntoTMOoZichZZlOgao71I3zrfCzCCAR0GA1UdIASCARQwggEQMIIBDAYJKoZI\nhvdjZAUBMIH MIHDBggrBgEFBQcCAjCBtgyBs1JlbGlhbmNlIG9uIHRoaXMg\nY2VydGlmaWNhdGUgYnkgYW55IHBhcnR5IGFzc3VtZXMgYWNjZXB0YW5jZSBv\nZiB0aGUgdGhlbiBhcHBsaWNhYmxlIHN0YW5kYXJkIHRlcm1zIGFuZCBjb25k\naXRpb25zIG9mIHVzZSwgY2VydGlmaWNhdGUgcG9saWN5IGFuZCBjZXJ0aWZp\nY2F0aW9uIHByYWN0aWNlIHN0YXRlbWVudHMuMDYGCCsGAQUFBwIBFipodHRw\nOi8vd3d3LmFwcGxlLmNvbS9jZXJ0aWZpY2F0ZWF1dGhvcml0eS8wNgYDVR0f\nBC8wLTAroCmgJ4YlaHR0cDovL2NybC5hcHBsZS5jb20vYXBwbGV3d2RyY2Ey\nLmNybDAOBgNVHQ8BAf8EBAMCAygwTwYJKoZIhvdjZAYgBEIMQDM0NTBBMjhB\nOTlGRjIyRkI5OTdDRERFODU1REREOTI5NTE4RjVGMDdBQUM4NzdDMzRCQjM3\nODFCQTg2MzkyNjIwCgYIKoZIzj0EAwIDRwAwRAIgZ/oNx0gCc/PM4pYhOWL2\nCecFQrIgzHr/fZd8qcy3Be8CIEQCaAPpmvQrXEX0hFexoYMHtOHY9dgN2D8L\nNKpVyn3t\n"; + await apple_pay_certificate.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/apple_pay_certificates/1068938282.json', + query: '', + headers, + data: { "apple_pay_certificate": {id: 1068938282, status: "completed", merchant_id: "merchant.something", encoded_signed_certificate: "MIIEZzCCBA6gAw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cG9saWN5IGFuZCBjZXJ0aWZp\nY2F0aW9uIHByYWN0aWNlIHN0YXRlbWVudHMuMDYGCCsGAQUFBwIBFipodHRw\nOi8vd3d3LmFwcGxlLmNvbS9jZXJ0aWZpY2F0ZWF1dGhvcml0eS8wNgYDVR0f\nBC8wLTAroCmgJ4YlaHR0cDovL2NybC5hcHBsZS5jb20vYXBwbGV3d2RyY2Ey\nLmNybDAOBgNVHQ8BAf8EBAMCAygwTwYJKoZIhvdjZAYgBEIMQDM0NTBBMjhB\nOTlGRjIyRkI5OTdDRERFODU1REREOTI5NTE4RjVGMDdBQUM4NzdDMzRCQjM3\nODFCQTg2MzkyNjIwCgYIKoZIzj0EAwIDRwAwRAIgZ/oNx0gCc/PM4pYhOWL2\nCecFQrIgzHr/fZd8qcy3Be8CIEQCaAPpmvQrXEX0hFexoYMHtOHY9dgN2D8L\nNKpVyn3t\n"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await ApplePayCertificate.delete({ + session: test_session, + id: 1068938283, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-07/apple_pay_certificates/1068938283.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await ApplePayCertificate.csr({ + session: test_session, + id: 1068938281, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/apple_pay_certificates/1068938281/csr.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-07/application_charge.test.ts b/src/rest-resources/__tests__/2021-07/application_charge.test.ts new file mode 100644 index 000000000..c2a59f21d --- /dev/null +++ b/src/rest-resources/__tests__/2021-07/application_charge.test.ts @@ -0,0 +1,109 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {ApplicationCharge} from '../../2021-07'; + +describe('ApplicationCharge resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.July21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const application_charge = new ApplicationCharge({session: test_session}); + application_charge.name = "Super Duper Expensive action"; + application_charge.price = 100.0; + application_charge.return_url = "http://super-duper.shopifyapps.com"; + await application_charge.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/application_charges.json', + query: '', + headers, + data: { "application_charge": {name: "Super Duper Expensive action", price: 100.0, return_url: "http://super-duper.shopifyapps.com"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const application_charge = new ApplicationCharge({session: test_session}); + application_charge.name = "Super Duper Expensive action"; + application_charge.price = 100.0; + application_charge.return_url = "http://super-duper.shopifyapps.com"; + application_charge.test = true; + await application_charge.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/application_charges.json', + query: '', + headers, + data: { "application_charge": {name: "Super Duper Expensive action", price: 100.0, return_url: "http://super-duper.shopifyapps.com", test: true} } + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await ApplicationCharge.find({ + session: test_session, + id: 675931192, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/application_charges/675931192.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await ApplicationCharge.all({ + session: test_session, + since_id: "556467234", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/application_charges.json', + query: 'since_id=556467234', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await ApplicationCharge.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/application_charges.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-07/application_credit.test.ts b/src/rest-resources/__tests__/2021-07/application_credit.test.ts new file mode 100644 index 000000000..d40f06054 --- /dev/null +++ b/src/rest-resources/__tests__/2021-07/application_credit.test.ts @@ -0,0 +1,89 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {ApplicationCredit} from '../../2021-07'; + +describe('ApplicationCredit resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.July21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const application_credit = new ApplicationCredit({session: test_session}); + application_credit.description = "application credit for refund"; + application_credit.amount = 5.0; + await application_credit.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/application_credits.json', + query: '', + headers, + data: { "application_credit": {description: "application credit for refund", amount: 5.0} } + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const application_credit = new ApplicationCredit({session: test_session}); + application_credit.description = "application credit for refund"; + application_credit.amount = 5.0; + application_credit.test = true; + await application_credit.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/application_credits.json', + query: '', + headers, + data: { "application_credit": {description: "application credit for refund", amount: 5.0, test: true} } + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await ApplicationCredit.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/application_credits.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await ApplicationCredit.find({ + session: test_session, + id: 140583599, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/application_credits/140583599.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-07/article.test.ts b/src/rest-resources/__tests__/2021-07/article.test.ts new file mode 100644 index 000000000..45b565752 --- /dev/null +++ b/src/rest-resources/__tests__/2021-07/article.test.ts @@ -0,0 +1,484 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Article} from '../../2021-07'; + +describe('Article resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.July21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Article.all({ + session: test_session, + blog_id: 241253187, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/blogs/241253187/articles.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Article.all({ + session: test_session, + blog_id: 241253187, + since_id: "134645308", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/blogs/241253187/articles.json', + query: 'since_id=134645308', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const article = new Article({session: test_session}); + article.blog_id = 241253187; + article.title = "My new Article title"; + article.author = "John Smith"; + article.tags = "This Post, Has Been Tagged"; + article.body_html = "

I like articles

\n

Yea, I like posting them through REST.

"; + article.published_at = "Thu Mar 24 15:45:47 UTC 2011"; + await article.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/blogs/241253187/articles.json', + query: '', + headers, + data: { "article": {title: "My new Article title", author: "John Smith", tags: "This Post, Has Been Tagged", body_html: "

I like articles

\n

Yea, I like posting them through REST.

", published_at: "Thu Mar 24 15:45:47 UTC 2011"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const article = new Article({session: test_session}); + article.blog_id = 241253187; + article.title = "My new Article title"; + article.author = "John Smith"; + article.tags = "This Post, Has Been Tagged"; + article.body_html = "

I like articles

\n

Yea, I like posting them through REST.

"; + article.published = false; + await article.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/blogs/241253187/articles.json', + query: '', + headers, + data: { "article": {title: "My new Article title", author: "John Smith", tags: "This Post, Has Been Tagged", body_html: "

I like articles

\n

Yea, I like posting them through REST.

", published: false} } + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const article = new Article({session: test_session}); + article.blog_id = 241253187; + article.title = "My new Article title"; + article.author = "John Smith"; + article.tags = "This Post, Has Been Tagged"; + article.body_html = "

I like articles

\n

Yea, I like posting them through REST.

"; + article.published_at = "Thu Mar 24 15:45:47 UTC 2011"; + article.image = { + attachment: "R0lGODlhAQABAIAAAAAAAAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==\n" + }; + await article.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/blogs/241253187/articles.json', + query: '', + headers, + data: { "article": {title: "My new Article title", author: "John Smith", tags: "This Post, Has Been Tagged", body_html: "

I like articles

\n

Yea, I like posting them through REST.

", published_at: "Thu Mar 24 15:45:47 UTC 2011", image: {attachment: "R0lGODlhAQABAIAAAAAAAAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==\n"}} } + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const article = new Article({session: test_session}); + article.blog_id = 241253187; + article.title = "My new Article title"; + article.author = "John Smith"; + article.tags = "This Post, Has Been Tagged"; + article.body_html = "

I like articles

\n

Yea, I like posting them through REST.

"; + article.published_at = "Thu Mar 24 15:45:47 UTC 2011"; + article.image = { + src: "http://example.com/rails_logo.gif", + alt: "Rails logo" + }; + await article.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/blogs/241253187/articles.json', + query: '', + headers, + data: { "article": {title: "My new Article title", author: "John Smith", tags: "This Post, Has Been Tagged", body_html: "

I like articles

\n

Yea, I like posting them through REST.

", published_at: "Thu Mar 24 15:45:47 UTC 2011", image: {src: "http://example.com/rails_logo.gif", alt: "Rails logo"}} } + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const article = new Article({session: test_session}); + article.blog_id = 241253187; + article.title = "My new Article title"; + article.author = "John Smith"; + article.tags = "This Post, Has Been Tagged"; + article.body_html = "

I like articles

\n

Yea, I like posting them through REST.

"; + article.published_at = "Thu Mar 24 15:45:47 UTC 2011"; + article.metafields = [ + { + key: "new", + value: "newvalue", + type: "single_line_text_field", + namespace: "global" + } + ]; + await article.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/blogs/241253187/articles.json', + query: '', + headers, + data: { "article": {title: "My new Article title", author: "John Smith", tags: "This Post, Has Been Tagged", body_html: "

I like articles

\n

Yea, I like posting them through REST.

", published_at: "Thu Mar 24 15:45:47 UTC 2011", metafields: [{key: "new", value: "newvalue", type: "single_line_text_field", namespace: "global"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Article.count({ + session: test_session, + blog_id: 241253187, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/blogs/241253187/articles/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Article.find({ + session: test_session, + blog_id: 241253187, + id: 134645308, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/blogs/241253187/articles/134645308.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_10', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const article = new Article({session: test_session}); + article.blog_id = 241253187; + article.id = 134645308; + article.title = "My new Title"; + article.author = "Your name"; + article.tags = "Tags, Will Be, Updated"; + article.body_html = "

Look, I can even update through a web service.

"; + article.published_at = "Thu Mar 24 15:45:47 UTC 2011"; + await article.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/blogs/241253187/articles/134645308.json', + query: '', + headers, + data: { "article": {id: 134645308, title: "My new Title", author: "Your name", tags: "Tags, Will Be, Updated", body_html: "

Look, I can even update through a web service.

", published_at: "Thu Mar 24 15:45:47 UTC 2011"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_11', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const article = new Article({session: test_session}); + article.blog_id = 241253187; + article.id = 134645308; + article.published = true; + await article.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/blogs/241253187/articles/134645308.json', + query: '', + headers, + data: { "article": {id: 134645308, published: true} } + }).toMatchMadeHttpRequest(); + }); + + it('test_12', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const article = new Article({session: test_session}); + article.blog_id = 241253187; + article.id = 134645308; + article.published = false; + await article.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/blogs/241253187/articles/134645308.json', + query: '', + headers, + data: { "article": {id: 134645308, published: false} } + }).toMatchMadeHttpRequest(); + }); + + it('test_13', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const article = new Article({session: test_session}); + article.blog_id = 241253187; + article.id = 134645308; + article.title = "My new Title"; + article.author = "Your name"; + article.tags = "Tags, Will Be, Updated"; + article.body_html = "

Look, I can even update through a web service.

"; + article.published_at = "Thu Mar 24 15:45:47 UT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qQcyxHe 9eXAfVOQAg7k16v7jQsAHGi2Bv0gUzyQQ05Ga Cy\n0MBEDsZgN8gQ4QnXt7oJ0QOGOZACDTeEu0aTCwC80EKhDcAHMDGHWATMsuMC\nFsVl/9GnP0Jg0kw24MUv/qUTOGDlCj8WETfGsVx2vI UzsATIFZUaTIRk3QY\n ZYlFq0Ce5QJHBXgdU MRCSwEYlVBCHPQZhyn7vhhD9fWdAc2DKhKXxhRCc6\n0Yi4LOPcl6hGVUFqc4gJLGaxufKO1s2VkrOj63znOkciCKMedZ n7ARUp1rQ\niLAyIlyNYURcONaInrWs9ci4JyJOaFYawDzP8Q ZwAICLckbgd08i290eh9V\nCIadQw3qO5Oa1H1GNRlSjeorO2HLruZ2rLudAm Dm9Gxcx/GXmSIMbnjH5W2\nzy2RbOzM cENBRAWs0N9b3zXWdp8pra1r61tbXdb4N/2Nv8i5gzeIJd5Gjui\nwT AzQ9YVGrYnNO0Agm27GBkvNnNzje 921qf/ b1QEfuMDFPe5lk/lspUG3\nWKbQCofLBBBuwNEs3C3aikcrB2TTeM81HgmOd3zf/PZ3yFPNaqSXfODF0EDK\nE9e6liZmCvJwOLD7AQhU2efSbG6zm7VgiG1ofBc //nGgZ7vbYw67aVux4v/\nfXSSK53by/HVrzIwDZTBBANUrzpMeAAIWASeB4P/AQ9 cHjEJx7xWgDE5nLQ\neMdHXvKbg/zkMZ23H/1oFRjYPOc9v3nQ58Aw0xn9LACvO7HQAOZVf/jl0ii1\nHcXe9bPX3euftaPL5R71tIf97nsy7/o0WlP2r4/JOU7B r5nqva7jz1EdZ97\n4qNe bonfvCfVXvly1762beOOdLBd Q7PCAAOw==\n" + }; + await article.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/blogs/241253187/articles/134645308.json', + query: '', + headers, + data: { "article": {id: 134645308, title: "My new Title", author: "Your name", tags: "Tags, Will Be, Updated", body_html: "

Look, I can even update through a web service.

", published_at: "Thu Mar 24 15:45:47 UTC 2011", image: {attachment: "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7k16v7jQsAHGi2Bv0gUzyQQ05Ga Cy\n0MBEDsZgN8gQ4QnXt7oJ0QOGOZACDTeEu0aTCwC80EKhDcAHMDGHWATMsuMC\nFsVl/9GnP0Jg0kw24MUv/qUTOGDlCj8WETfGsVx2vI UzsATIFZUaTIRk3QY\n ZYlFq0Ce5QJHBXgdU MRCSwEYlVBCHPQZhyn7vhhD9fWdAc2DKhKXxhRCc6\n0Yi4LOPcl6hGVUFqc4gJLGaxufKO1s2VkrOj63znOkciCKMedZ n7ARUp1rQ\niLAyIlyNYURcONaInrWs9ci4JyJOaFYawDzP8Q ZwAICLckbgd08i290eh9V\nCIadQw3qO5Oa1H1GNRlSjeorO2HLruZ2rLudAm Dm9Gxcx/GXmSIMbnjH5W2\nzy2RbOzM cENBRAWs0N9b3zXWdp8pra1r61tbXdb4N/2Nv8i5gzeIJd5Gjui\nwT AzQ9YVGrYnNO0Agm27GBkvNnNzje 921qf/ b1QEfuMDFPe5lk/lspUG3\nWKbQCofLBBBuwNEs3C3aikcrB2TTeM81HgmOd3zf/PZ3yFPNaqSXfODF0EDK\nE9e6liZmCvJwOLD7AQhU2efSbG6zm7VgiG1ofBc //nGgZ7vbYw67aVux4v/\nfXSSK53by/HVrzIwDZTBBANUrzpMeAAIWASeB4P/AQ9 cHjEJx7xWgDE5nLQ\neMdHXvKbg/zkMZ23H/1oFRjYPOc9v3nQ58Aw0xn9LACvO7HQAOZVf/jl0ii1\nHcXe9bPX3euftaPL5R71tIf97nsy7/o0WlP2r4/JOU7B r5nqva7jz1EdZ97\n4qNe bonfvCfVXvly1762beOOdLBd Q7PCAAOw==\n"}} } + }).toMatchMadeHttpRequest(); + }); + + it('test_14', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const article = new Article({session: test_session}); + article.blog_id = 241253187; + article.id = 134645308; + article.title = "My new Title"; + article.author = "Your name"; + article.tags = "Tags, Will Be, Updated"; + article.body_html = "

Look, I can even update through a web service.

"; + article.published_at = "Thu Mar 24 15:45:47 UTC 2011"; + article.image = { + alt: "Rails logo" + }; + await article.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/blogs/241253187/articles/134645308.json', + query: '', + headers, + data: { "article": {id: 134645308, title: "My new Title", author: "Your name", tags: "Tags, Will Be, Updated", body_html: "

Look, I can even update through a web service.

", published_at: "Thu Mar 24 15:45:47 UTC 2011", image: {alt: "Rails logo"}} } + }).toMatchMadeHttpRequest(); + }); + + it('test_15', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const article = new Article({session: test_session}); + article.blog_id = 241253187; + article.id = 134645308; + article.image = ""; + await article.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/blogs/241253187/articles/134645308.json', + query: '', + headers, + data: { "article": {id: 134645308, image: ""} } + }).toMatchMadeHttpRequest(); + }); + + it('test_16', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const article = new Article({session: test_session}); + article.blog_id = 241253187; + article.id = 134645308; + article.metafields = [ + { + key: "new", + value: "newvalue", + type: "single_line_text_field", + namespace: "global" + } + ]; + await article.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/blogs/241253187/articles/134645308.json', + query: '', + headers, + data: { "article": {id: 134645308, metafields: [{key: "new", value: "newvalue", type: "single_line_text_field", namespace: "global"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_17', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Article.delete({ + session: test_session, + blog_id: 241253187, + id: 134645308, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-07/blogs/241253187/articles/134645308.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_18', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Article.authors({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/articles/authors.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_19', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Article.tags({ + session: test_session, + blog_id: 241253187, + limit: "1", + popular: "1", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/blogs/241253187/articles/tags.json', + query: 'limit=1&popular=1', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_20', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Article.tags({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/articles/tags.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_21', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Article.tags({ + session: test_session, + blog_id: 241253187, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/blogs/241253187/articles/tags.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_22', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Article.tags({ + session: test_session, + limit: "1", + popular: "1", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/articles/tags.json', + query: 'limit=1&popular=1', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-07/asset.test.ts b/src/rest-resources/__tests__/2021-07/asset.test.ts new file mode 100644 index 000000000..114f2d7dd --- /dev/null +++ b/src/rest-resources/__tests__/2021-07/asset.test.ts @@ -0,0 +1,149 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Asset} from '../../2021-07'; + +describe('Asset resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.July21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Asset.all({ + session: test_session, + theme_id: 828155753, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/themes/828155753/assets.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const asset = new Asset({session: test_session}); + asset.theme_id = 828155753; + asset.key = "templates/index.liquid"; + asset.value = "

We are busy updating the store for you and will be back within the hour.

"; + await asset.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/themes/828155753/assets.json', + query: '', + headers, + data: { "asset": {key: "templates/index.liquid", value: "

We are busy updating the store for you and will be back within the hour.

"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const asset = new Asset({session: test_session}); + asset.theme_id = 828155753; + asset.key = "assets/empty.gif"; + asset.attachment = "R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw==\n"; + await asset.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/themes/828155753/assets.json', + query: '', + headers, + data: { "asset": {key: "assets/empty.gif", attachment: "R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw==\n"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const asset = new Asset({session: test_session}); + asset.theme_id = 828155753; + asset.key = "assets/bg-body.gif"; + asset.src = "http://apple.com/new_bg.gif"; + await asset.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/themes/828155753/assets.json', + query: '', + headers, + data: { "asset": {key: "assets/bg-body.gif", src: "http://apple.com/new_bg.gif"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const asset = new Asset({session: test_session}); + asset.theme_id = 828155753; + asset.key = "layout/alternate.liquid"; + asset.source_key = "layout/theme.liquid"; + await asset.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/themes/828155753/assets.json', + query: '', + headers, + data: { "asset": {key: "layout/alternate.liquid", source_key: "layout/theme.liquid"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Asset.all({ + session: test_session, + theme_id: 828155753, + asset: {key: "templates/index.liquid"}, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/themes/828155753/assets.json', + query: 'asset%5Bkey%5D=templates%2Findex.liquid', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Asset.delete({ + session: test_session, + theme_id: 828155753, + asset: {key: "assets/bg-body.gif"}, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-07/themes/828155753/assets.json', + query: 'asset%5Bkey%5D=assets%2Fbg-body.gif', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-07/assigned_fulfillment_order.test.ts b/src/rest-resources/__tests__/2021-07/assigned_fulfillment_order.test.ts new file mode 100644 index 000000000..4b7925e1e --- /dev/null +++ b/src/rest-resources/__tests__/2021-07/assigned_fulfillment_order.test.ts @@ -0,0 +1,36 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {AssignedFulfillmentOrder} from '../../2021-07'; + +describe('AssignedFulfillmentOrder resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.July21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await AssignedFulfillmentOrder.all({ + session: test_session, + assignment_status: "cancellation_requested", + location_ids: ["24826418"], + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/assigned_fulfillment_orders.json', + query: 'assignment_status=cancellation_requested&location_ids%5B%5D=24826418', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-07/balance.test.ts b/src/rest-resources/__tests__/2021-07/balance.test.ts new file mode 100644 index 000000000..dd1b596a7 --- /dev/null +++ b/src/rest-resources/__tests__/2021-07/balance.test.ts @@ -0,0 +1,34 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Balance} from '../../2021-07'; + +describe('Balance resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.July21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Balance.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/shopify_payments/balance.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-07/blog.test.ts b/src/rest-resources/__tests__/2021-07/blog.test.ts new file mode 100644 index 000000000..48ea1b6b0 --- /dev/null +++ b/src/rest-resources/__tests__/2021-07/blog.test.ts @@ -0,0 +1,229 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Blog} from '../../2021-07'; + +describe('Blog resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.July21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Blog.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/blogs.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Blog.all({ + session: test_session, + since_id: "241253187", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/blogs.json', + query: 'since_id=241253187', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const blog = new Blog({session: test_session}); + blog.title = "Apple main blog"; + await blog.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/blogs.json', + query: '', + headers, + data: { "blog": {title: "Apple main blog"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const blog = new Blog({session: test_session}); + blog.title = "Apple main blog"; + blog.metafields = [ + { + key: "sponsor", + value: "Shopify", + type: "single_line_text_field", + namespace: "global" + } + ]; + await blog.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/blogs.json', + query: '', + headers, + data: { "blog": {title: "Apple main blog", metafields: [{key: "sponsor", value: "Shopify", type: "single_line_text_field", namespace: "global"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Blog.count({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/blogs/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Blog.find({ + session: test_session, + id: 241253187, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/blogs/241253187.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Blog.find({ + session: test_session, + id: 241253187, + fields: "id,title", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/blogs/241253187.json', + query: 'fields=id%2Ctitle', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const blog = new Blog({session: test_session}); + blog.id = 241253187; + blog.title = "IPod Updates"; + await blog.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/blogs/241253187.json', + query: '', + headers, + data: { "blog": {id: 241253187, title: "IPod Updates"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const blog = new Blog({session: test_session}); + blog.id = 241253187; + blog.title = "IPod Updates"; + blog.handle = "ipod-updates"; + blog.commentable = "moderate"; + await blog.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/blogs/241253187.json', + query: '', + headers, + data: { "blog": {id: 241253187, title: "IPod Updates", handle: "ipod-updates", commentable: "moderate"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_10', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const blog = new Blog({session: test_session}); + blog.id = 241253187; + blog.metafields = [ + { + key: "sponsor", + value: "Shopify", + type: "single_line_text_field", + namespace: "global" + } + ]; + await blog.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/blogs/241253187.json', + query: '', + headers, + data: { "blog": {id: 241253187, metafields: [{key: "sponsor", value: "Shopify", type: "single_line_text_field", namespace: "global"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_11', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Blog.delete({ + session: test_session, + id: 241253187, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-07/blogs/241253187.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-07/cancellation_request.test.ts b/src/rest-resources/__tests__/2021-07/cancellation_request.test.ts new file mode 100644 index 000000000..f2b89d25a --- /dev/null +++ b/src/rest-resources/__tests__/2021-07/cancellation_request.test.ts @@ -0,0 +1,73 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {CancellationRequest} from '../../2021-07'; + +describe('CancellationRequest resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.July21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const cancellation_request = new CancellationRequest({session: test_session}); + cancellation_request.fulfillment_order_id = 1046000837; + cancellation_request.message = "The customer changed his mind."; + await cancellation_request.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/fulfillment_orders/1046000837/cancellation_request.json', + query: '', + headers, + data: { "cancellation_request": {message: "The customer changed his mind."} } + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const cancellation_request = new CancellationRequest({session: test_session}); + cancellation_request.fulfillment_order_id = 1046000838; + await cancellation_request.accept({ + body: {cancellation_request: {message: "We had not started any processing yet."}}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/fulfillment_orders/1046000838/cancellation_request/accept.json', + query: '', + headers, + data: { "cancellation_request": {message: "We had not started any processing yet."} } + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const cancellation_request = new CancellationRequest({session: test_session}); + cancellation_request.fulfillment_order_id = 1046000839; + await cancellation_request.reject({ + body: {cancellation_request: {message: "We have already send the shipment out."}}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/fulfillment_orders/1046000839/cancellation_request/reject.json', + query: '', + headers, + data: { "cancellation_request": {message: "We have already send the shipment out."} } + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-07/carrier_service.test.ts b/src/rest-resources/__tests__/2021-07/carrier_service.test.ts new file mode 100644 index 000000000..386af61c7 --- /dev/null +++ b/src/rest-resources/__tests__/2021-07/carrier_service.test.ts @@ -0,0 +1,108 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {CarrierService} from '../../2021-07'; + +describe('CarrierService resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.July21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const carrier_service = new CarrierService({session: test_session}); + carrier_service.name = "Shipping Rate Provider"; + carrier_service.callback_url = "http://shippingrateprovider.com"; + carrier_service.service_discovery = true; + await carrier_service.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/carrier_services.json', + query: '', + headers, + data: { "carrier_service": {name: "Shipping Rate Provider", callback_url: "http://shippingrateprovider.com", service_discovery: true} } + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CarrierService.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/carrier_services.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const carrier_service = new CarrierService({session: test_session}); + carrier_service.id = 1036894964; + carrier_service.name = "Some new name"; + carrier_service.active = false; + await carrier_service.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/carrier_services/1036894964.json', + query: '', + headers, + data: { "carrier_service": {id: 1036894964, name: "Some new name", active: false} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CarrierService.find({ + session: test_session, + id: 1036894966, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/carrier_services/1036894966.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CarrierService.delete({ + session: test_session, + id: 1036894967, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-07/carrier_services/1036894967.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-07/checkout.test.ts b/src/rest-resources/__tests__/2021-07/checkout.test.ts new file mode 100644 index 000000000..061b6c195 --- /dev/null +++ b/src/rest-resources/__tests__/2021-07/checkout.test.ts @@ -0,0 +1,229 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Checkout} from '../../2021-07'; + +describe('Checkout resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.July21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const checkout = new Checkout({session: test_session}); + checkout.line_items = [ + { + variant_id: 39072856, + quantity: 5 + } + ]; + await checkout.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/checkouts.json', + query: '', + headers, + data: { "checkout": {line_items: [{variant_id: 39072856, quantity: 5}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const checkout = new Checkout({session: test_session}); + checkout.email = "me@example.com"; + await checkout.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/checkouts.json', + query: '', + headers, + data: { "checkout": {email: "me@example.com"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const checkout = new Checkout({session: test_session}); + checkout.token = "b490a9220cd14d7344024f4874f640a6"; + await checkout.complete({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/checkouts/b490a9220cd14d7344024f4874f640a6/complete.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Checkout.find({ + session: test_session, + token: "bd5a8aa1ecd019dd3520ff791ee3a24c", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/checkouts/bd5a8aa1ecd019dd3520ff791ee3a24c.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Checkout.find({ + session: test_session, + token: "7yjf4v2we7gamku6a6h7tvm8h3mmvs4x", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/checkouts/7yjf4v2we7gamku6a6h7tvm8h3mmvs4x.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Checkout.find({ + session: test_session, + token: "exuw7apwoycchjuwtiqg8nytfhphr62a", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/checkouts/exuw7apwoycchjuwtiqg8nytfhphr62a.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const checkout = new Checkout({session: test_session}); + checkout.token = "exuw7apwoycchjuwtiqg8nytfhphr62a"; + checkout.email = "john.smith@example.com"; + checkout.shipping_address = { + first_name: "John", + last_name: "Smith", + address1: "126 York St.", + city: "Los Angeles", + province_code: "CA", + country_code: "US", + phone: "(123)456-7890", + zip: "90002" + }; + await checkout.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/checkouts/exuw7apwoycchjuwtiqg8nytfhphr62a.json', + query: '', + headers, + data: { "checkout": {token: "exuw7apwoycchjuwtiqg8nytfhphr62a", email: "john.smith@example.com", shipping_address: {first_name: "John", last_name: "Smith", address1: "126 York St.", city: "Los Angeles", province_code: "CA", country_code: "US", phone: "(123)456-7890", zip: "90002"}} } + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const checkout = new Checkout({session: test_session}); + checkout.token = "exuw7apwoycchjuwtiqg8nytfhphr62a"; + checkout.shipping_line = { + handle: "shopify-Free Shipping-0.00" + }; + await checkout.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/checkouts/exuw7apwoycchjuwtiqg8nytfhphr62a.json', + query: '', + headers, + data: { "checkout": {token: "exuw7apwoycchjuwtiqg8nytfhphr62a", shipping_line: {handle: "shopify-Free Shipping-0.00"}} } + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Checkout.shipping_rates({ + session: test_session, + token: "exuw7apwoycchjuwtiqg8nytfhphr62a", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/checkouts/exuw7apwoycchjuwtiqg8nytfhphr62a/shipping_rates.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_10', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Checkout.shipping_rates({ + session: test_session, + token: "exuw7apwoycchjuwtiqg8nytfhphr62a", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/checkouts/exuw7apwoycchjuwtiqg8nytfhphr62a/shipping_rates.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_11', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Checkout.shipping_rates({ + session: test_session, + token: "zs9ru89kuqcdagk8bz4r9hnxt22wwd42", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/checkouts/zs9ru89kuqcdagk8bz4r9hnxt22wwd42/shipping_rates.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-07/collect.test.ts b/src/rest-resources/__tests__/2021-07/collect.test.ts new file mode 100644 index 000000000..f8a434da4 --- /dev/null +++ b/src/rest-resources/__tests__/2021-07/collect.test.ts @@ -0,0 +1,177 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Collect} from '../../2021-07'; + +describe('Collect resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.July21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const collect = new Collect({session: test_session}); + collect.product_id = 921728736; + collect.collection_id = 841564295; + await collect.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/collects.json', + query: '', + headers, + data: { "collect": {product_id: 921728736, collection_id: 841564295} } + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Collect.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/collects.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Collect.all({ + session: test_session, + product_id: "632910392", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/collects.json', + query: 'product_id=632910392', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Collect.all({ + session: test_session, + collection_id: "841564295", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/collects.json', + query: 'collection_id=841564295', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Collect.delete({ + session: test_session, + id: 455204334, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-07/collects/455204334.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Collect.find({ + session: test_session, + id: 455204334, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/collects/455204334.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Collect.count({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/collects/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Collect.count({ + session: test_session, + product_id: "632910392", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/collects/count.json', + query: 'product_id=632910392', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Collect.count({ + session: test_session, + collection_id: "841564295", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/collects/count.json', + query: 'collection_id=841564295', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-07/collection.test.ts b/src/rest-resources/__tests__/2021-07/collection.test.ts new file mode 100644 index 000000000..628694319 --- /dev/null +++ b/src/rest-resources/__tests__/2021-07/collection.test.ts @@ -0,0 +1,53 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Collection} from '../../2021-07'; + +describe('Collection resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.July21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Collection.find({ + session: test_session, + id: 841564295, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/collections/841564295.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Collection.products({ + session: test_session, + id: 841564295, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/collections/841564295/products.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-07/collection_listing.test.ts b/src/rest-resources/__tests__/2021-07/collection_listing.test.ts new file mode 100644 index 000000000..905fdedb0 --- /dev/null +++ b/src/rest-resources/__tests__/2021-07/collection_listing.test.ts @@ -0,0 +1,105 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {CollectionListing} from '../../2021-07'; + +describe('CollectionListing resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.July21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CollectionListing.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/collection_listings.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CollectionListing.product_ids({ + session: test_session, + collection_id: 841564295, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/collection_listings/841564295/product_ids.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CollectionListing.find({ + session: test_session, + collection_id: 482865238, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/collection_listings/482865238.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const collection_listing = new CollectionListing({session: test_session}); + collection_listing.collection_id = 482865238; + await collection_listing.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/collection_listings/482865238.json', + query: '', + headers, + data: { "collection_listing": {collection_id: 482865238} } + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CollectionListing.delete({ + session: test_session, + collection_id: 482865238, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-07/collection_listings/482865238.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-07/comment.test.ts b/src/rest-resources/__tests__/2021-07/comment.test.ts new file mode 100644 index 000000000..a67d23801 --- /dev/null +++ b/src/rest-resources/__tests__/2021-07/comment.test.ts @@ -0,0 +1,289 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Comment} from '../../2021-07'; + +describe('Comment resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.July21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Comment.all({ + session: test_session, + article_id: "134645308", + blog_id: "241253187", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/comments.json', + query: 'article_id=134645308&blog_id=241253187', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Comment.all({ + session: test_session, + blog_id: "241253187", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/comments.json', + query: 'blog_id=241253187', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Comment.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/comments.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Comment.all({ + session: test_session, + since_id: "118373535", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/comments.json', + query: 'since_id=118373535', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Comment.count({ + session: test_session, + article_id: "134645308", + blog_id: "241253187", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/comments/count.json', + query: 'article_id=134645308&blog_id=241253187', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Comment.count({ + session: test_session, + blog_id: "241253187", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/comments/count.json', + query: 'blog_id=241253187', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Comment.count({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/comments/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Comment.find({ + session: test_session, + id: 118373535, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/comments/118373535.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const comment = new Comment({session: test_session}); + comment.id = 118373535; + comment.body = "You can even update through a web service."; + comment.author = "Your new name"; + comment.email = "your@updated-email.com"; + comment.published_at = "2022-02-03T22:13:53.233Z"; + await comment.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/comments/118373535.json', + query: '', + headers, + data: { "comment": {id: 118373535, body: "You can even update through a web service.", author: "Your new name", email: "your@updated-email.com", published_at: "2022-02-03T22:13:53.233Z"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_10', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const comment = new Comment({session: test_session}); + comment.body = "I like comments\nAnd I like posting them *RESTfully*."; + comment.author = "Your name"; + comment.email = "your@email.com"; + comment.ip = "107.20.160.121"; + comment.blog_id = 241253187; + comment.article_id = 134645308; + await comment.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/comments.json', + query: '', + headers, + data: { "comment": {body: "I like comments\nAnd I like posting them *RESTfully*.", author: "Your name", email: "your@email.com", ip: "107.20.160.121", blog_id: 241253187, article_id: 134645308} } + }).toMatchMadeHttpRequest(); + }); + + it('test_11', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const comment = new Comment({session: test_session}); + comment.id = 653537639; + await comment.spam({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/comments/653537639/spam.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_12', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const comment = new Comment({session: test_session}); + comment.id = 653537639; + await comment.not_spam({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/comments/653537639/not_spam.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_13', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const comment = new Comment({session: test_session}); + comment.id = 653537639; + await comment.approve({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/comments/653537639/approve.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_14', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const comment = new Comment({session: test_session}); + comment.id = 653537639; + await comment.remove({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/comments/653537639/remove.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_15', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const comment = new Comment({session: test_session}); + comment.id = 653537639; + await comment.restore({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/comments/653537639/restore.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-07/country.test.ts b/src/rest-resources/__tests__/2021-07/country.test.ts new file mode 100644 index 000000000..17437678e --- /dev/null +++ b/src/rest-resources/__tests__/2021-07/country.test.ts @@ -0,0 +1,158 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Country} from '../../2021-07'; + +describe('Country resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.July21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Country.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/countries.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Country.all({ + session: test_session, + since_id: "359115488", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/countries.json', + query: 'since_id=359115488', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const country = new Country({session: test_session}); + country.code = "FR"; + await country.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/countries.json', + query: '', + headers, + data: { "country": {code: "FR"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const country = new Country({session: test_session}); + country.code = "FR"; + country.tax = 0.2; + await country.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/countries.json', + query: '', + headers, + data: { "country": {code: "FR", tax: 0.2} } + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Country.count({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/countries/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Country.find({ + session: test_session, + id: 879921427, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/countries/879921427.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const country = new Country({session: test_session}); + country.id = 879921427; + country.tax = 0.05; + await country.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/countries/879921427.json', + query: '', + headers, + data: { "country": {id: 879921427, tax: 0.05} } + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Country.delete({ + session: test_session, + id: 879921427, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-07/countries/879921427.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-07/currency.test.ts b/src/rest-resources/__tests__/2021-07/currency.test.ts new file mode 100644 index 000000000..2c1e7b61c --- /dev/null +++ b/src/rest-resources/__tests__/2021-07/currency.test.ts @@ -0,0 +1,34 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Currency} from '../../2021-07'; + +describe('Currency resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.July21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Currency.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/currencies.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-07/custom_collection.test.ts b/src/rest-resources/__tests__/2021-07/custom_collection.test.ts new file mode 100644 index 000000000..b4b019989 --- /dev/null +++ b/src/rest-resources/__tests__/2021-07/custom_collection.test.ts @@ -0,0 +1,436 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {CustomCollection} from '../../2021-07'; + +describe('CustomCollection resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.July21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CustomCollection.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/custom_collections.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CustomCollection.all({ + session: test_session, + since_id: "841564295", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/custom_collections.json', + query: 'since_id=841564295', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CustomCollection.all({ + session: test_session, + product_id: "632910392", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/custom_collections.json', + query: 'product_id=632910392', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CustomCollection.all({ + session: test_session, + ids: "395646240,691652237,841564295", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/custom_collections.json', + query: 'ids=395646240%2C691652237%2C841564295', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const custom_collection = new CustomCollection({session: test_session}); + custom_collection.title = "Macbooks"; + await custom_collection.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/custom_collections.json', + query: '', + headers, + data: { "custom_collection": {title: "Macbooks"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const custom_collection = new CustomCollection({session: test_session}); + custom_collection.title = "Macbooks"; + custom_collection.published = false; + await custom_collection.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/custom_collections.json', + query: '', + headers, + data: { "custom_collection": {title: "Macbooks", published: false} } + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const custom_collection = new CustomCollection({session: test_session}); + custom_collection.title = "Macbooks"; + custom_collection.image = { + src: "http://example.com/rails_logo.gif", + alt: "Rails Logo" + }; + await custom_collection.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/custom_collections.json', + query: '', + headers, + data: { "custom_collection": {title: "Macbooks", image: {src: "http://example.com/rails_logo.gif", alt: "Rails Logo"}} } + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const custom_collection = new CustomCollection({session: test_session}); + custom_collection.title = "IPods"; + custom_collection.collects = [ + { + product_id: 921728736 + } + ]; + await custom_collection.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/custom_collections.json', + query: '', + headers, + data: { "custom_collection": {title: "IPods", collects: [{product_id: 921728736}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const custom_collection = new CustomCollection({session: test_session}); + custom_collection.title = "Macbooks"; + custom_collection.metafields = [ + { + key: "new", + value: "newvalue", + type: "single_line_text_field", + namespace: "global" + } + ]; + await custom_collection.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/custom_collections.json', + query: '', + headers, + data: { "custom_collection": {title: "Macbooks", metafields: [{key: "new", value: "newvalue", type: "single_line_text_field", namespace: "global"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_10', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CustomCollection.count({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/custom_collections/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_11', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CustomCollection.count({ + session: test_session, + product_id: "632910392", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/custom_collections/count.json', + query: 'product_id=632910392', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_12', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CustomCollection.find({ + session: test_session, + id: 841564295, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/custom_collections/841564295.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_13', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const custom_collection = new CustomCollection({session: test_session}); + custom_collection.id = 841564295; + custom_collection.image = ""; + custom_collection.updated_at = "2022-02-03T17:11:24-05:00"; + custom_collection.title = "IPods"; + custom_collection.handle = "ipods"; + custom_collection.body_html = "

The best selling ipod ever

"; + custom_collection.published_at = "2008-02-01T19:00:00-05:00"; + custom_collection.sort_order = "manual"; + custom_collection.template_suffix = null; + custom_collection.published_scope = "web"; + custom_collection.admin_graphql_api_id = "gid://shopify/Collection/841564295"; + await custom_collection.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/custom_collections/841564295.json', + query: '', + headers, + data: { "custom_collection": {id: 841564295, image: "", updated_at: "2022-02-03T17:11:24-05:00", title: "IPods", handle: "ipods", body_html: "

The best selling ipod ever

", published_at: "2008-02-01T19:00:00-05:00", sort_order: "manual", template_suffix: null, published_scope: "web", admin_graphql_api_id: "gid://shopify/Collection/841564295"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_14', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const custom_collection = new CustomCollection({session: test_session}); + custom_collection.id = 841564295; + custom_collection.metafields = [ + { + key: "new", + value: "newvalue", + type: "single_line_text_field", + namespace: "global" + } + ]; + await custom_collection.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/custom_collections/841564295.json', + query: '', + headers, + data: { "custom_collection": {id: 841564295, metafields: [{key: "new", value: "newvalue", type: "single_line_text_field", namespace: "global"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_15', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const custom_collection = new CustomCollection({session: test_session}); + custom_collection.id = 841564295; + custom_collection.body_html = "

5000 songs in your pocket

"; + await custom_collection.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/custom_collections/841564295.json', + query: '', + headers, + data: { "custom_collection": {id: 841564295, body_html: "

5000 songs in your pocket

"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_16', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const custom_collection = new CustomCollection({session: test_session}); + custom_collection.id = 841564295; + custom_collection.collects = [ + { + product_id: 921728736, + position: 1 + }, + { + id: 455204334, + position: 2 + } + ]; + await custom_collection.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/custom_collections/841564295.json', + query: '', + headers, + data: { "custom_collection": {id: 841564295, collects: [{product_id: 921728736, position: 1}, {id: 455204334, position: 2}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_17', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const custom_collection = new CustomCollection({session: test_session}); + custom_collection.id = 841564295; + custom_collection.published = true; + await custom_collection.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/custom_collections/841564295.json', + query: '', + headers, + data: { "custom_collection": {id: 841564295, published: true} } + }).toMatchMadeHttpRequest(); + }); + + it('test_18', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const custom_collection = new CustomCollection({session: test_session}); + custom_collection.id = 841564295; + custom_collection.published = false; + await custom_collection.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/custom_collections/841564295.json', + query: '', + headers, + data: { "custom_collection": {id: 841564295, published: false} } + }).toMatchMadeHttpRequest(); + }); + + it('test_19', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const custom_collection = new CustomCollection({session: test_session}); + custom_collection.id = 841564295; + custom_collection.image = { + attachment: "R0lGODlhbgCMAPf/APbr48VySrxTO7IgKt2qmKQdJeK8lsFjROG5p/nz7Zg3\nMNmnd7Q1MLNVS9GId71hSJMZIuzTu4UtKbeEeakhKMl8U8WYjfr18YQaIbAf\nKKwhKdKzqpQtLebFortOOejKrOjZ1Mt7aMNpVbAqLLV7bsNqR 3WwMqEWenN\nsZYxL/Ddy/Pm2e7ZxLlUQrIjNPXp3bU5MbhENbEtLtqhj5ZQTfHh0bMxL7Ip\nNsNyUYkZIrZJPcqGdYIUHb5aPKkeJnoUHd2yiJkiLKYiKLRFOsyJXKVDO8up\nosFaS TBnK4kKti5sNaYg/z49aqYl5kqLrljUtORfMOlo/36 H4ZH8yDYq0f\nKKFYTaU9MrY8MrZBNXwXHpgaIdGVYu/byLZNP9SaZLIyOuXCtHkpJst Wpcm\nLMyCa8BfP9GMb9KQdPDd1PPk1sd5VP79/L5dQZ0bI9 ymqssK9WcfIoXHdzG\nxdWWfteib79lSr1YP86MYurQxK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3\nWKbQCofLBBBuwNEs3C3aikcrB2TTeM81HgmOd3zf/PZ3yFPNaqSXfODF0EDK\nE9e6liZmCvJwOLD7AQhU2efSbG6zm7VgiG1ofBc //nGgZ7vbYw67aVux4v/\nfXSSK53by/HVrzIwDZTBBANUrzpMeAAIWASeB4P/AQ9 cHjEJx7xWgDE5nLQ\neMdHXvKbg/zkMZ23H/1oFRjYPOc9v3nQ58Aw0xn9LACvO7HQAOZVf/jl0ii1\nHcXe9bPX3euftaPL5R71tIf97nsy7/o0WlP2r4/JOU7B r5nqva7jz1EdZ97\n4qNe bonfvCfVXvly1762beOOdLBd Q7PCAAOw==\n", + alt: "Rails logo" + }; + await custom_collection.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/custom_collections/841564295.json', + query: '', + headers, + data: { "custom_collection": {id: 841564295, image: {attachment: "R0lGODlhbgCMAPf/APbr48VySrxTO7IgKt2qmKQdJeK8lsFjROG5p/nz7Zg3\nMNmnd7Q1MLNVS9GId71hSJMZIuzTu4UtKbeEeakhKMl8U8WYjfr18YQaIbAf\nKKwhKdKzqpQtLebFortOOejKrOjZ1Mt7aMNpVbAqLLV7bsNqR 3WwMqEWenN\nsZYxL/Ddy/Pm2e7ZxLlUQrIjNPXp3bU5MbhENbEtLtqhj5ZQTfHh0bMxL7Ip\nNsNyUYkZIrZJPcqGdYIUHb5aPKkeJnoUHd2yiJkiLKYiKLRFOsyJXKVDO8up\nosFaS TBnK4kKti5sNaYg/z49aqYl5kqLrljUtORfMOlo/36 H4ZH8yDYq0f\nKKFYTaU9MrY8MrZBNXwXHpgaIdGVYu/byLZNP9SaZLIyOuXCtHkpJst Wpcm\nLMyCa8BfP9GMb9KQdPDd1PPk1sd5VP79/L5dQZ0bI9 ymqssK9WcfIoXHdzG\nxdWWfteib79lSr1YP86MYurQxKdcUKdMQr5ZSfPs6YEZH8uhl4oWIenMuurQ\nttmejaqoqsqBVaAcJLlJN5kvMLlZRMNsSL5fRak0LbdQQMVvSP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SbG6zm7VgiG1ofBc //nGgZ7vbYw67aVux4v/\nfXSSK53by/HVrzIwDZTBBANUrzpMeAAIWASeB4P/AQ9 cHjEJx7xWgDE5nLQ\neMdHXvKbg/zkMZ23H/1oFRjYPOc9v3nQ58Aw0xn9LACvO7HQAOZVf/jl0ii1\nHcXe9bPX3euftaPL5R71tIf97nsy7/o0WlP2r4/JOU7B r5nqva7jz1EdZ97\n4qNe bonfvCfVXvly1762beOOdLBd Q7PCAAOw==\n", alt: "Rails logo"}} } + }).toMatchMadeHttpRequest(); + }); + + it('test_20', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const custom_collection = new CustomCollection({session: test_session}); + custom_collection.id = 841564295; + custom_collection.image = { + alt: "Rails logo" + }; + await custom_collection.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/custom_collections/841564295.json', + query: '', + headers, + data: { "custom_collection": {id: 841564295, image: {alt: "Rails logo"}} } + }).toMatchMadeHttpRequest(); + }); + + it('test_21', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CustomCollection.delete({ + session: test_session, + id: 841564295, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-07/custom_collections/841564295.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-07/customer.test.ts b/src/rest-resources/__tests__/2021-07/customer.test.ts new file mode 100644 index 000000000..1bc663da5 --- /dev/null +++ b/src/rest-resources/__tests__/2021-07/customer.test.ts @@ -0,0 +1,440 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Customer} from '../../2021-07'; + +describe('Customer resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.July21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Customer.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/customers.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Customer.all({ + session: test_session, + since_id: "207119551", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/customers.json', + query: 'since_id=207119551', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Customer.all({ + session: test_session, + updated_at_min: "2022-02-02 21:51:21", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/customers.json', + query: 'updated_at_min=2022-02-02+21%3A51%3A21', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Customer.all({ + session: test_session, + ids: "207119551,1073339489", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/customers.json', + query: 'ids=207119551%2C1073339489', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const customer = new Customer({session: test_session}); + customer.first_name = "Steve"; + customer.last_name = "Lastnameson"; + customer.email = "steve.lastnameson@example.com"; + customer.phone = " 15142546011"; + customer.verified_email = true; + customer.addresses = [ + { + address1: "123 Oak St", + city: "Ottawa", + province: "ON", + phone: "555-1212", + zip: "123 ABC", + last_name: "Lastnameson", + first_name: "Mother", + country: "CA" + } + ]; + customer.password = "newpass"; + customer.password_confirmation = "newpass"; + customer.send_email_welcome = false; + await customer.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/customers.json', + query: '', + headers, + data: { "customer": {first_name: "Steve", last_name: "Lastnameson", email: "steve.lastnameson@example.com", phone: " 15142546011", verified_email: true, addresses: [{address1: "123 Oak St", city: "Ottawa", province: "ON", phone: "555-1212", zip: "123 ABC", last_name: "Lastnameson", first_name: "Mother", country: "CA"}], password: "newpass", password_confirmation: "newpass", send_email_welcome: false} } + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const customer = new Customer({session: test_session}); + customer.first_name = "Steve"; + customer.last_name = "Lastnameson"; + customer.email = "steve.lastnameson@example.com"; + customer.phone = " 15142546011"; + customer.verified_email = true; + customer.addresses = [ + { + address1: "123 Oak St", + city: "Ottawa", + province: "ON", + phone: "555-1212", + zip: "123 ABC", + last_name: "Lastnameson", + first_name: "Mother", + country: "CA" + } + ]; + await customer.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/customers.json', + query: '', + headers, + data: { "customer": {first_name: "Steve", last_name: "Lastnameson", email: "steve.lastnameson@example.com", phone: " 15142546011", verified_email: true, addresses: [{address1: "123 Oak St", city: "Ottawa", province: "ON", phone: "555-1212", zip: "123 ABC", last_name: "Lastnameson", first_name: "Mother", country: "CA"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const customer = new Customer({session: test_session}); + customer.first_name = "Steve"; + customer.last_name = "Lastnameson"; + customer.email = "steve.lastnameson@example.com"; + customer.phone = " 15142546011"; + customer.verified_email = true; + customer.addresses = [ + { + address1: "123 Oak St", + city: "Ottawa", + province: "ON", + phone: "555-1212", + zip: "123 ABC", + last_name: "Lastnameson", + first_name: "Mother", + country: "CA" + } + ]; + customer.metafields = [ + { + key: "new", + value: "newvalue", + value_type: "string", + namespace: "global" + } + ]; + await customer.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/customers.json', + query: '', + headers, + data: { "customer": {first_name: "Steve", last_name: "Lastnameson", email: "steve.lastnameson@example.com", phone: " 15142546011", verified_email: true, addresses: [{address1: "123 Oak St", city: "Ottawa", province: "ON", phone: "555-1212", zip: "123 ABC", last_name: "Lastnameson", first_name: "Mother", country: "CA"}], metafields: [{key: "new", value: "newvalue", value_type: "string", namespace: "global"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const customer = new Customer({session: test_session}); + customer.first_name = "Steve"; + customer.last_name = "Lastnameson"; + customer.email = "steve.lastnameson@example.com"; + customer.phone = " 15142546011"; + customer.verified_email = true; + customer.addresses = [ + { + address1: "123 Oak St", + city: "Ottawa", + province: "ON", + phone: "555-1212", + zip: "123 ABC", + last_name: "Lastnameson", + first_name: "Mother", + country: "CA" + } + ]; + customer.send_email_invite = true; + await customer.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/customers.json', + query: '', + headers, + data: { "customer": {first_name: "Steve", last_name: "Lastnameson", email: "steve.lastnameson@example.com", phone: " 15142546011", verified_email: true, addresses: [{address1: "123 Oak St", city: "Ottawa", province: "ON", phone: "555-1212", zip: "123 ABC", last_name: "Lastnameson", first_name: "Mother", country: "CA"}], send_email_invite: true} } + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Customer.search({ + session: test_session, + query: "Bob country:United States", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/customers/search.json', + query: 'query=Bob+country%3AUnited+States', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_10', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Customer.find({ + session: test_session, + id: 207119551, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/customers/207119551.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_11', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const customer = new Customer({session: test_session}); + customer.id = 207119551; + customer.email = "changed@email.address.com"; + customer.note = "Customer is a great guy"; + await customer.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/customers/207119551.json', + query: '', + headers, + data: { "customer": {id: 207119551, email: "changed@email.address.com", note: "Customer is a great guy"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_12', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const customer = new Customer({session: test_session}); + customer.id = 207119551; + customer.metafields = [ + { + key: "new", + value: "newvalue", + value_type: "string", + namespace: "global" + } + ]; + await customer.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/customers/207119551.json', + query: '', + headers, + data: { "customer": {id: 207119551, metafields: [{key: "new", value: "newvalue", value_type: "string", namespace: "global"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_13', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const customer = new Customer({session: test_session}); + customer.id = 207119551; + customer.tags = "New Customer, Repeat Customer"; + await customer.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/customers/207119551.json', + query: '', + headers, + data: { "customer": {id: 207119551, tags: "New Customer, Repeat Customer"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_14', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const customer = new Customer({session: test_session}); + customer.id = 207119551; + customer.accepts_marketing = true; + customer.accepts_marketing_updated_at = "2022-01-31T16:45:55-05:00"; + customer.marketing_opt_in_level = "confirmed_opt_in"; + await customer.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/customers/207119551.json', + query: '', + headers, + data: { "customer": {id: 207119551, accepts_marketing: true, accepts_marketing_updated_at: "2022-01-31T16:45:55-05:00", marketing_opt_in_level: "confirmed_opt_in"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_15', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const customer = new Customer({session: test_session}); + customer.id = 207119551; + await customer.account_activation_url({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/customers/207119551/account_activation_url.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_16', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const customer = new Customer({session: test_session}); + customer.id = 207119551; + await customer.send_invite({ + body: {customer_invite: {}}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/customers/207119551/send_invite.json', + query: '', + headers, + data: {customer_invite: {}} + }).toMatchMadeHttpRequest(); + }); + + it('test_17', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const customer = new Customer({session: test_session}); + customer.id = 207119551; + await customer.send_invite({ + body: {customer_invite: {to: "new_test_email@shopify.com", from: "j.limited@example.com", bcc: ["j.limited@example.com"], subject: "Welcome to my new shop", custom_message: "My awesome new store"}}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/customers/207119551/send_invite.json', + query: '', + headers, + data: {customer_invite: {to: "new_test_email@shopify.com", from: "j.limited@example.com", bcc: ["j.limited@example.com"], subject: "Welcome to my new shop", custom_message: "My awesome new store"}} + }).toMatchMadeHttpRequest(); + }); + + it('test_18', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Customer.count({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/customers/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_19', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Customer.orders({ + session: test_session, + id: 207119551, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/customers/207119551/orders.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-07/customer_address.test.ts b/src/rest-resources/__tests__/2021-07/customer_address.test.ts new file mode 100644 index 000000000..56e712611 --- /dev/null +++ b/src/rest-resources/__tests__/2021-07/customer_address.test.ts @@ -0,0 +1,180 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {CustomerAddress} from '../../2021-07'; + +describe('CustomerAddress resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.July21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CustomerAddress.all({ + session: test_session, + customer_id: 207119551, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/customers/207119551/addresses.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CustomerAddress.all({ + session: test_session, + customer_id: 207119551, + limit: "1", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/customers/207119551/addresses.json', + query: 'limit=1', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const customer_address = new CustomerAddress({session: test_session}); + customer_address.customer_id = 207119551; + customer_address.address1 = "1 Rue des Carrieres"; + customer_address.address2 = "Suite 1234"; + customer_address.city = "Montreal"; + customer_address.company = "Fancy Co."; + customer_address.first_name = "Samuel"; + customer_address.last_name = "de Champlain"; + customer_address.phone = "819-555-5555"; + customer_address.province = "Quebec"; + customer_address.country = "Canada"; + customer_address.zip = "G1R 4P5"; + customer_address.name = "Samuel de Champlain"; + customer_address.province_code = "QC"; + customer_address.country_code = "CA"; + customer_address.country_name = "Canada"; + await customer_address.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/customers/207119551/addresses.json', + query: '', + headers, + data: { "address": {address1: "1 Rue des Carrieres", address2: "Suite 1234", city: "Montreal", company: "Fancy Co.", first_name: "Samuel", last_name: "de Champlain", phone: "819-555-5555", province: "Quebec", country: "Canada", zip: "G1R 4P5", name: "Samuel de Champlain", province_code: "QC", country_code: "CA", country_name: "Canada"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CustomerAddress.find({ + session: test_session, + customer_id: 207119551, + id: 207119551, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/customers/207119551/addresses/207119551.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const customer_address = new CustomerAddress({session: test_session}); + customer_address.customer_id = 207119551; + customer_address.id = 207119551; + customer_address.zip = "90210"; + await customer_address.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/customers/207119551/addresses/207119551.json', + query: '', + headers, + data: { "address": {id: 207119551, zip: "90210"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CustomerAddress.delete({ + session: test_session, + customer_id: 207119551, + id: 1053317335, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-07/customers/207119551/addresses/1053317335.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const customer_address = new CustomerAddress({session: test_session}); + customer_address.customer_id = 207119551; + await customer_address.set({ + address_ids: ["1053317336"], + operation: "destroy", + }); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/customers/207119551/addresses/set.json', + query: 'address_ids%5B%5D=1053317336&operation=destroy', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const customer_address = new CustomerAddress({session: test_session}); + customer_address.customer_id = 207119551; + customer_address.id = 1053317337; + await customer_address.default({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/customers/207119551/addresses/1053317337/default.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-07/customer_saved_search.test.ts b/src/rest-resources/__tests__/2021-07/customer_saved_search.test.ts new file mode 100644 index 000000000..a379dbaea --- /dev/null +++ b/src/rest-resources/__tests__/2021-07/customer_saved_search.test.ts @@ -0,0 +1,195 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {CustomerSavedSearch} from '../../2021-07'; + +describe('CustomerSavedSearch resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.July21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CustomerSavedSearch.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/customer_saved_searches.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CustomerSavedSearch.all({ + session: test_session, + since_id: "20610973", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/customer_saved_searches.json', + query: 'since_id=20610973', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const customer_saved_search = new CustomerSavedSearch({session: test_session}); + customer_saved_search.name = "Spent more than $50"; + customer_saved_search.query = "total_spent:>50"; + await customer_saved_search.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/customer_saved_searches.json', + query: '', + headers, + data: { "customer_saved_search": {name: "Spent more than $50", query: "total_spent:>50"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const customer_saved_search = new CustomerSavedSearch({session: test_session}); + customer_saved_search.name = "Spent more than $50 and after 2013"; + customer_saved_search.query = "total_spent:>50 order_date:>=2013-01-01"; + await customer_saved_search.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/customer_saved_searches.json', + query: '', + headers, + data: { "customer_saved_search": {name: "Spent more than $50 and after 2013", query: "total_spent:>50 order_date:>=2013-01-01"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CustomerSavedSearch.count({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/customer_saved_searches/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CustomerSavedSearch.count({ + session: test_session, + since_id: "20610973", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/customer_saved_searches/count.json', + query: 'since_id=20610973', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CustomerSavedSearch.find({ + session: test_session, + id: 789629109, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/customer_saved_searches/789629109.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const customer_saved_search = new CustomerSavedSearch({session: test_session}); + customer_saved_search.id = 789629109; + customer_saved_search.name = "This Name Has Been Changed"; + await customer_saved_search.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/customer_saved_searches/789629109.json', + query: '', + headers, + data: { "customer_saved_search": {id: 789629109, name: "This Name Has Been Changed"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CustomerSavedSearch.delete({ + session: test_session, + id: 789629109, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-07/customer_saved_searches/789629109.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_10', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CustomerSavedSearch.customers({ + session: test_session, + id: 789629109, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/customer_saved_searches/789629109/customers.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-07/deprecated_api_call.test.ts b/src/rest-resources/__tests__/2021-07/deprecated_api_call.test.ts new file mode 100644 index 000000000..7452d0ad1 --- /dev/null +++ b/src/rest-resources/__tests__/2021-07/deprecated_api_call.test.ts @@ -0,0 +1,34 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {DeprecatedApiCall} from '../../2021-07'; + +describe('DeprecatedApiCall resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.July21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await DeprecatedApiCall.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/deprecated_api_calls.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-07/discount_code.test.ts b/src/rest-resources/__tests__/2021-07/discount_code.test.ts new file mode 100644 index 000000000..e4ad87b8f --- /dev/null +++ b/src/rest-resources/__tests__/2021-07/discount_code.test.ts @@ -0,0 +1,184 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {DiscountCode} from '../../2021-07'; + +describe('DiscountCode resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.July21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const discount_code = new DiscountCode({session: test_session}); + discount_code.price_rule_id = 507328175; + discount_code.code = "SUMMERSALE10OFF"; + await discount_code.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/price_rules/507328175/discount_codes.json', + query: '', + headers, + data: { "discount_code": {code: "SUMMERSALE10OFF"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await DiscountCode.all({ + session: test_session, + price_rule_id: 507328175, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/price_rules/507328175/discount_codes.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const discount_code = new DiscountCode({session: test_session}); + discount_code.price_rule_id = 507328175; + discount_code.id = 507328175; + discount_code.code = "WINTERSALE20OFF"; + await discount_code.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/price_rules/507328175/discount_codes/507328175.json', + query: '', + headers, + data: { "discount_code": {id: 507328175, code: "WINTERSALE20OFF"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await DiscountCode.find({ + session: test_session, + price_rule_id: 507328175, + id: 507328175, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/price_rules/507328175/discount_codes/507328175.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await DiscountCode.delete({ + session: test_session, + price_rule_id: 507328175, + id: 507328175, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-07/price_rules/507328175/discount_codes/507328175.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await DiscountCode.count({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/discount_codes/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const discount_code = new DiscountCode({session: test_session}); + discount_code.price_rule_id = 507328175; + await discount_code.batch({ + body: {discount_codes: [{code: "SUMMER1"}, {code: "SUMMER2"}, {code: "SUMMER3"}]}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/price_rules/507328175/batch.json', + query: '', + headers, + data: {discount_codes: [{code: "SUMMER1"}, {code: "SUMMER2"}, {code: "SUMMER3"}]} + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await DiscountCode.get_all({ + session: test_session, + price_rule_id: 507328175, + batch_id: 173232803, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/price_rules/507328175/batch/173232803.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await DiscountCode.all({ + session: test_session, + price_rule_id: 507328175, + batch_id: 173232803, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/price_rules/507328175/batch/173232803/discount_codes.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-07/dispute.test.ts b/src/rest-resources/__tests__/2021-07/dispute.test.ts new file mode 100644 index 000000000..2f3f272c0 --- /dev/null +++ b/src/rest-resources/__tests__/2021-07/dispute.test.ts @@ -0,0 +1,88 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Dispute} from '../../2021-07'; + +describe('Dispute resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.July21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Dispute.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/shopify_payments/disputes.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Dispute.all({ + session: test_session, + status: "won", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/shopify_payments/disputes.json', + query: 'status=won', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Dispute.all({ + session: test_session, + initiated_at: "2013-05-03", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/shopify_payments/disputes.json', + query: 'initiated_at=2013-05-03', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Dispute.find({ + session: test_session, + id: 598735659, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/shopify_payments/disputes/598735659.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-07/draft_order.test.ts b/src/rest-resources/__tests__/2021-07/draft_order.test.ts new file mode 100644 index 000000000..25697cae4 --- /dev/null +++ b/src/rest-resources/__tests__/2021-07/draft_order.test.ts @@ -0,0 +1,346 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {DraftOrder} from '../../2021-07'; + +describe('DraftOrder resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.July21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const draft_order = new DraftOrder({session: test_session}); + draft_order.line_items = [ + { + variant_id: 447654529, + quantity: 1 + } + ]; + await draft_order.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/draft_orders.json', + query: '', + headers, + data: { "draft_order": {line_items: [{variant_id: 447654529, quantity: 1}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const draft_order = new DraftOrder({session: test_session}); + draft_order.line_items = [ + { + title: "Custom Tee", + price: "20.00", + quantity: 2 + } + ]; + draft_order.applied_discount = { + description: "Custom discount", + value_type: "fixed_amount", + value: "10.0", + amount: "10.00", + title: "Custom" + }; + draft_order.customer = { + id: 207119551 + }; + draft_order.use_customer_default_address = true; + await draft_order.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/draft_orders.json', + query: '', + headers, + data: { "draft_order": {line_items: [{title: "Custom Tee", price: "20.00", quantity: 2}], applied_discount: {description: "Custom discount", value_type: "fixed_amount", value: "10.0", amount: "10.00", title: "Custom"}, customer: {id: 207119551}, use_customer_default_address: true} } + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const draft_order = new DraftOrder({session: test_session}); + draft_order.line_items = [ + { + title: "Custom Tee", + price: "20.00", + quantity: 1, + applied_discount: { + description: "Custom discount", + value_type: "fixed_amount", + value: "10.0", + amount: "10.0", + title: "Custom" + } + } + ]; + await draft_order.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/draft_orders.json', + query: '', + headers, + data: { "draft_order": {line_items: [{title: "Custom Tee", price: "20.00", quantity: 1, applied_discount: {description: "Custom discount", value_type: "fixed_amount", value: "10.0", amount: "10.0", title: "Custom"}}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const draft_order = new DraftOrder({session: test_session}); + draft_order.line_items = [ + { + title: "Custom Tee", + price: "20.00", + quantity: 1, + applied_discount: { + description: "Custom discount", + value_type: "percentage", + value: "10.0", + amount: "2.0", + title: "Custom" + } + } + ]; + await draft_order.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/draft_orders.json', + query: '', + headers, + data: { "draft_order": {line_items: [{title: "Custom Tee", price: "20.00", quantity: 1, applied_discount: {description: "Custom discount", value_type: "percentage", value: "10.0", amount: "2.0", title: "Custom"}}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const draft_order = new DraftOrder({session: test_session}); + draft_order.line_items = [ + { + title: "Custom Tee", + price: "20.00", + quantity: 2 + } + ]; + draft_order.customer = { + id: 207119551 + }; + draft_order.use_customer_default_address = true; + await draft_order.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/draft_orders.json', + query: '', + headers, + data: { "draft_order": {line_items: [{title: "Custom Tee", price: "20.00", quantity: 2}], customer: {id: 207119551}, use_customer_default_address: true} } + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await DraftOrder.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/draft_orders.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const draft_order = new DraftOrder({session: test_session}); + draft_order.id = 994118539; + draft_order.note = "Customer contacted us about a custom engraving on this iPod"; + await draft_order.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/draft_orders/994118539.json', + query: '', + headers, + data: { "draft_order": {id: 994118539, note: "Customer contacted us about a custom engraving on this iPod"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const draft_order = new DraftOrder({session: test_session}); + draft_order.id = 994118539; + draft_order.applied_discount = { + description: "Custom discount", + value_type: "percentage", + value: "10.0", + amount: "19.90", + title: "Custom" + }; + await draft_order.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/draft_orders/994118539.json', + query: '', + headers, + data: { "draft_order": {id: 994118539, applied_discount: {description: "Custom discount", value_type: "percentage", value: "10.0", amount: "19.90", title: "Custom"}} } + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await DraftOrder.find({ + session: test_session, + id: 994118539, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/draft_orders/994118539.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_10', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await DraftOrder.delete({ + session: test_session, + id: 994118539, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-07/draft_orders/994118539.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_11', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await DraftOrder.count({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/draft_orders/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_12', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const draft_order = new DraftOrder({session: test_session}); + draft_order.id = 994118539; + await draft_order.send_invoice({ + body: {draft_order_invoice: {to: "first@example.com", from: "j.smith@example.com", bcc: ["j.smith@example.com"], subject: "Apple Computer Invoice", custom_message: "Thank you for ordering!"}}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/draft_orders/994118539/send_invoice.json', + query: '', + headers, + data: {draft_order_invoice: {to: "first@example.com", from: "j.smith@example.com", bcc: ["j.smith@example.com"], subject: "Apple Computer Invoice", custom_message: "Thank you for ordering!"}} + }).toMatchMadeHttpRequest(); + }); + + it('test_13', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const draft_order = new DraftOrder({session: test_session}); + draft_order.id = 994118539; + await draft_order.send_invoice({ + body: {draft_order_invoice: {}}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/draft_orders/994118539/send_invoice.json', + query: '', + headers, + data: {draft_order_invoice: {}} + }).toMatchMadeHttpRequest(); + }); + + it('test_14', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const draft_order = new DraftOrder({session: test_session}); + draft_order.id = 994118539; + await draft_order.complete({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/draft_orders/994118539/complete.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_15', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const draft_order = new DraftOrder({session: test_session}); + draft_order.id = 994118539; + await draft_order.complete({ + payment_pending: "true", + }); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/draft_orders/994118539/complete.json', + query: 'payment_pending=true', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-07/event.test.ts b/src/rest-resources/__tests__/2021-07/event.test.ts new file mode 100644 index 000000000..3790d0cd3 --- /dev/null +++ b/src/rest-resources/__tests__/2021-07/event.test.ts @@ -0,0 +1,216 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Event} from '../../2021-07'; + +describe('Event resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.July21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Event.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/events.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Event.all({ + session: test_session, + created_at_min: "2008-01-10 12:30:00+00:00", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/events.json', + query: 'created_at_min=2008-01-10+12%3A30%3A00%2B00%3A00', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Event.all({ + session: test_session, + order_id: 450789469, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/orders/450789469/events.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Event.all({ + session: test_session, + order_id: 450789469, + limit: "1", + since_id: "164748010", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/orders/450789469/events.json', + query: 'limit=1&since_id=164748010', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Event.all({ + session: test_session, + product_id: 921728736, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/products/921728736/events.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Event.all({ + session: test_session, + since_id: "164748010", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/events.json', + query: 'since_id=164748010', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Event.all({ + session: test_session, + filter: "Product,Order", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/events.json', + query: 'filter=Product%2COrder', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Event.all({ + session: test_session, + filter: "Product", + verb: "destroy", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/events.json', + query: 'filter=Product&verb=destroy', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Event.find({ + session: test_session, + id: 677313116, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/events/677313116.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_10', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Event.count({ + session: test_session, + created_at_min: "2008-01-10T13:00:00+00:00", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/events/count.json', + query: 'created_at_min=2008-01-10T13%3A00%3A00%2B00%3A00', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_11', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Event.count({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/events/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-07/fulfillment.test.ts b/src/rest-resources/__tests__/2021-07/fulfillment.test.ts new file mode 100644 index 000000000..0fb470bc8 --- /dev/null +++ b/src/rest-resources/__tests__/2021-07/fulfillment.test.ts @@ -0,0 +1,581 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Fulfillment} from '../../2021-07'; + +describe('Fulfillment resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.July21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Fulfillment.all({ + session: test_session, + order_id: 450789469, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/orders/450789469/fulfillments.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Fulfillment.all({ + session: test_session, + order_id: 450789469, + since_id: "255858046", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/orders/450789469/fulfillments.json', + query: 'since_id=255858046', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment = new Fulfillment({session: test_session}); + fulfillment.order_id = 450789469; + fulfillment.location_id = 487838322; + fulfillment.tracking_number = "123456789"; + fulfillment.tracking_urls = [ + "https://shipping.xyz/track.php?num=123456789", + "https://anothershipper.corp/track.php?code=abc" + ]; + fulfillment.notify_customer = true; + await fulfillment.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/orders/450789469/fulfillments.json', + query: '', + headers, + data: { "fulfillment": {location_id: 487838322, tracking_number: "123456789", tracking_urls: ["https://shipping.xyz/track.php?num=123456789", "https://anothershipper.corp/track.php?code=abc"], notify_customer: true} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment = new Fulfillment({session: test_session}); + fulfillment.order_id = 450789469; + fulfillment.location_id = 655441491; + fulfillment.tracking_number = null; + fulfillment.line_items = [ + { + id: 518995019 + } + ]; + await fulfillment.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/orders/450789469/fulfillments.json', + query: '', + headers, + data: { "fulfillment": {location_id: 655441491, tracking_number: null, line_items: [{id: 518995019}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment = new Fulfillment({session: test_session}); + fulfillment.order_id = 450789469; + fulfillment.location_id = 655441491; + fulfillment.tracking_numbers = [ + "88b451840563b72cc15d3fcb6179f302", + "aee587edbd98ad725d27974c808ec7d6", + "94e71192ecf091ea5c25b69c385c2b1b" + ]; + fulfillment.line_items = [ + { + id: 518995019 + } + ]; + await fulfillment.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/orders/450789469/fulfillments.json', + query: '', + headers, + data: { "fulfillment": {location_id: 655441491, tracking_numbers: ["88b451840563b72cc15d3fcb6179f302", "aee587edbd98ad725d27974c808ec7d6", "94e71192ecf091ea5c25b69c385c2b1b"], line_items: [{id: 518995019}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment = new Fulfillment({session: test_session}); + fulfillment.order_id = 450789469; + fulfillment.location_id = 655441491; + fulfillment.tracking_url = "http://www.packagetrackr.com/track/somecarrier/1234567"; + fulfillment.tracking_company = "Jack Black's Pack, Stack and Track"; + fulfillment.line_items = [ + { + id: 518995019 + } + ]; + await fulfillment.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/orders/450789469/fulfillments.json', + query: '', + headers, + data: { "fulfillment": {location_id: 655441491, tracking_url: "http://www.packagetrackr.com/track/somecarrier/1234567", tracking_company: "Jack Black's Pack, Stack and Track", line_items: [{id: 518995019}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment = new Fulfillment({session: test_session}); + fulfillment.order_id = 450789469; + fulfillment.location_id = 655441491; + fulfillment.tracking_number = "123456789"; + fulfillment.tracking_company = "4PX"; + fulfillment.line_items = [ + { + id: 518995019 + } + ]; + await fulfillment.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/orders/450789469/fulfillments.json', + query: '', + headers, + data: { "fulfillment": {location_id: 655441491, tracking_number: "123456789", tracking_company: "4PX", line_items: [{id: 518995019}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment = new Fulfillment({session: test_session}); + fulfillment.order_id = 450789469; + fulfillment.location_id = 655441491; + fulfillment.tracking_number = "123456789010"; + fulfillment.tracking_company = "fed ex"; + fulfillment.line_items = [ + { + id: 518995019 + } + ]; + await fulfillment.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/orders/450789469/fulfillments.json', + query: '', + headers, + data: { "fulfillment": {location_id: 655441491, tracking_number: "123456789010", tracking_company: "fed ex", line_items: [{id: 518995019}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment = new Fulfillment({session: test_session}); + fulfillment.order_id = 450789469; + fulfillment.location_id = 655441491; + fulfillment.tracking_number = "123456789010"; + fulfillment.tracking_company = "fed ex"; + fulfillment.tracking_url = "https://www.new-fedex-tracking.com/?number=123456789010"; + fulfillment.line_items = [ + { + id: 518995019 + } + ]; + await fulfillment.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/orders/450789469/fulfillments.json', + query: '', + headers, + data: { "fulfillment": {location_id: 655441491, tracking_number: "123456789010", tracking_company: "fed ex", tracking_url: "https://www.new-fedex-tracking.com/?number=123456789010", line_items: [{id: 518995019}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_10', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment = new Fulfillment({session: test_session}); + fulfillment.order_id = 450789469; + fulfillment.location_id = 655441491; + fulfillment.tracking_number = "RR123456789CN"; + fulfillment.tracking_company = "Chinese Post"; + fulfillment.line_items = [ + { + id: 518995019 + } + ]; + await fulfillment.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/orders/450789469/fulfillments.json', + query: '', + headers, + data: { "fulfillment": {location_id: 655441491, tracking_number: "RR123456789CN", tracking_company: "Chinese Post", line_items: [{id: 518995019}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_11', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment = new Fulfillment({session: test_session}); + fulfillment.order_id = 450789469; + fulfillment.location_id = 655441491; + fulfillment.tracking_number = "1234567"; + fulfillment.tracking_company = "Custom Tracking Company"; + fulfillment.line_items = [ + { + id: 518995019 + } + ]; + await fulfillment.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/orders/450789469/fulfillments.json', + query: '', + headers, + data: { "fulfillment": {location_id: 655441491, tracking_number: "1234567", tracking_company: "Custom Tracking Company", line_items: [{id: 518995019}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_12', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment = new Fulfillment({session: test_session}); + fulfillment.order_id = 450789469; + fulfillment.location_id = 655441491; + fulfillment.tracking_number = "CJ274101086US"; + fulfillment.tracking_url = "http://www.custom-tracking.com/?tracking_number=CJ274101086US"; + fulfillment.line_items = [ + { + id: 518995019 + } + ]; + await fulfillment.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/orders/450789469/fulfillments.json', + query: '', + headers, + data: { "fulfillment": {location_id: 655441491, tracking_number: "CJ274101086US", tracking_url: "http://www.custom-tracking.com/?tracking_number=CJ274101086US", line_items: [{id: 518995019}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_13', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment = new Fulfillment({session: test_session}); + fulfillment.order_id = 450789469; + fulfillment.location_id = 655441491; + fulfillment.tracking_number = null; + fulfillment.line_items = [ + { + id: 518995019 + } + ]; + await fulfillment.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/orders/450789469/fulfillments.json', + query: '', + headers, + data: { "fulfillment": {location_id: 655441491, tracking_number: null, line_items: [{id: 518995019}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_14', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment = new Fulfillment({session: test_session}); + fulfillment.order_id = 450789469; + fulfillment.location_id = 655441491; + fulfillment.tracking_number = null; + fulfillment.line_items = [ + { + id: 518995019, + quantity: 1 + } + ]; + await fulfillment.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/orders/450789469/fulfillments.json', + query: '', + headers, + data: { "fulfillment": {location_id: 655441491, tracking_number: null, line_items: [{id: 518995019, quantity: 1}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_15', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Fulfillment.all({ + session: test_session, + fulfillment_order_id: 1046000859, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/fulfillment_orders/1046000859/fulfillments.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_16', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Fulfillment.count({ + session: test_session, + order_id: 450789469, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/orders/450789469/fulfillments/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_17', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Fulfillment.find({ + session: test_session, + order_id: 450789469, + id: 255858046, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/orders/450789469/fulfillments/255858046.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_18', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment = new Fulfillment({session: test_session}); + fulfillment.order_id = 450789469; + fulfillment.id = 255858046; + fulfillment.tracking_number = "987654321"; + await fulfillment.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/orders/450789469/fulfillments/255858046.json', + query: '', + headers, + data: { "fulfillment": {tracking_number: "987654321", id: 255858046} } + }).toMatchMadeHttpRequest(); + }); + + it('test_19', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment = new Fulfillment({session: test_session}); + fulfillment.message = "The package was shipped this morning."; + fulfillment.notify_customer = false; + fulfillment.tracking_info = { + number: 1562678, + url: "https://www.my-shipping-company.com", + company: "my-shipping-company" + }; + fulfillment.line_items_by_fulfillment_order = [ + { + fulfillment_order_id: 1046000873, + fulfillment_order_line_items: [ + { + id: 1058737644, + quantity: 1 + } + ] + } + ]; + await fulfillment.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/fulfillments.json', + query: '', + headers, + data: { "fulfillment": {message: "The package was shipped this morning.", notify_customer: false, tracking_info: {number: 1562678, url: "https://www.my-shipping-company.com", company: "my-shipping-company"}, line_items_by_fulfillment_order: [{fulfillment_order_id: 1046000873, fulfillment_order_line_items: [{id: 1058737644, quantity: 1}]}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_20', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment = new Fulfillment({session: test_session}); + fulfillment.message = "The package was shipped this morning."; + fulfillment.notify_customer = false; + fulfillment.tracking_info = { + number: 1562678, + url: "https://www.my-shipping-company.com", + company: "my-shipping-company" + }; + fulfillment.line_items_by_fulfillment_order = [ + { + fulfillment_order_id: 1046000874 + } + ]; + await fulfillment.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/fulfillments.json', + query: '', + headers, + data: { "fulfillment": {message: "The package was shipped this morning.", notify_customer: false, tracking_info: {number: 1562678, url: "https://www.my-shipping-company.com", company: "my-shipping-company"}, line_items_by_fulfillment_order: [{fulfillment_order_id: 1046000874}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_21', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment = new Fulfillment({session: test_session}); + fulfillment.id = 1069019908; + await fulfillment.update_tracking({ + body: {fulfillment: {notify_customer: true, tracking_info: {number: "1111", url: "http://www.my-url.com", company: "my-company"}}}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/fulfillments/1069019908/update_tracking.json', + query: '', + headers, + data: { "fulfillment": {notify_customer: true, tracking_info: {number: "1111", url: "http://www.my-url.com", company: "my-company"}} } + }).toMatchMadeHttpRequest(); + }); + + it('test_22', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment = new Fulfillment({session: test_session}); + fulfillment.order_id = 450789469; + fulfillment.id = 255858046; + await fulfillment.complete({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/orders/450789469/fulfillments/255858046/complete.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_23', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment = new Fulfillment({session: test_session}); + fulfillment.order_id = 450789469; + fulfillment.id = 255858046; + await fulfillment.open({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/orders/450789469/fulfillments/255858046/open.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_24', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment = new Fulfillment({session: test_session}); + fulfillment.order_id = 450789469; + fulfillment.id = 255858046; + await fulfillment.cancel({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/orders/450789469/fulfillments/255858046/cancel.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_25', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment = new Fulfillment({session: test_session}); + fulfillment.id = 1069019909; + await fulfillment.cancel({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/fulfillments/1069019909/cancel.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-07/fulfillment_event.test.ts b/src/rest-resources/__tests__/2021-07/fulfillment_event.test.ts new file mode 100644 index 000000000..211447c1c --- /dev/null +++ b/src/rest-resources/__tests__/2021-07/fulfillment_event.test.ts @@ -0,0 +1,95 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {FulfillmentEvent} from '../../2021-07'; + +describe('FulfillmentEvent resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.July21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await FulfillmentEvent.all({ + session: test_session, + order_id: 450789469, + fulfillment_id: 255858046, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/orders/450789469/fulfillments/255858046/events.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment_event = new FulfillmentEvent({session: test_session}); + fulfillment_event.order_id = 450789469; + fulfillment_event.fulfillment_id = 255858046; + fulfillment_event.status = "in_transit"; + await fulfillment_event.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/orders/450789469/fulfillments/255858046/events.json', + query: '', + headers, + data: { "event": {status: "in_transit"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await FulfillmentEvent.find({ + session: test_session, + order_id: 450789469, + fulfillment_id: 255858046, + id: 944956395, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/orders/450789469/fulfillments/255858046/events/944956395.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await FulfillmentEvent.delete({ + session: test_session, + order_id: 450789469, + fulfillment_id: 255858046, + id: 944956397, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-07/orders/450789469/fulfillments/255858046/events/944956397.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-07/fulfillment_order.test.ts b/src/rest-resources/__tests__/2021-07/fulfillment_order.test.ts new file mode 100644 index 000000000..2d6e1ae44 --- /dev/null +++ b/src/rest-resources/__tests__/2021-07/fulfillment_order.test.ts @@ -0,0 +1,144 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {FulfillmentOrder} from '../../2021-07'; + +describe('FulfillmentOrder resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.July21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await FulfillmentOrder.all({ + session: test_session, + order_id: 450789469, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/orders/450789469/fulfillment_orders.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await FulfillmentOrder.find({ + session: test_session, + id: 1046000847, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/fulfillment_orders/1046000847.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment_order = new FulfillmentOrder({session: test_session}); + fulfillment_order.id = 1046000848; + await fulfillment_order.cancel({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/fulfillment_orders/1046000848/cancel.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment_order = new FulfillmentOrder({session: test_session}); + fulfillment_order.id = 1046000851; + await fulfillment_order.close({ + body: {fulfillment_order: {message: "Not enough inventory to complete this work."}}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/fulfillment_orders/1046000851/close.json', + query: '', + headers, + data: { "fulfillment_order": {message: "Not enough inventory to complete this work."} } + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment_order = new FulfillmentOrder({session: test_session}); + fulfillment_order.id = 1046000852; + await fulfillment_order.move({ + body: {fulfillment_order: {new_location_id: 655441491}}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/fulfillment_orders/1046000852/move.json', + query: '', + headers, + data: { "fulfillment_order": {new_location_id: 655441491} } + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment_order = new FulfillmentOrder({session: test_session}); + fulfillment_order.id = 1046000854; + await fulfillment_order.open({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/fulfillment_orders/1046000854/open.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment_order = new FulfillmentOrder({session: test_session}); + fulfillment_order.id = 1046000855; + await fulfillment_order.reschedule({ + body: {fulfillment_order: {new_fulfill_at: "2023-03-03"}}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/fulfillment_orders/1046000855/reschedule.json', + query: '', + headers, + data: { "fulfillment_order": {new_fulfill_at: "2023-03-03"} } + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-07/fulfillment_request.test.ts b/src/rest-resources/__tests__/2021-07/fulfillment_request.test.ts new file mode 100644 index 000000000..766b2cbba --- /dev/null +++ b/src/rest-resources/__tests__/2021-07/fulfillment_request.test.ts @@ -0,0 +1,101 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {FulfillmentRequest} from '../../2021-07'; + +describe('FulfillmentRequest resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.July21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment_request = new FulfillmentRequest({session: test_session}); + fulfillment_request.fulfillment_order_id = 1046000840; + fulfillment_request.message = "Fulfill this ASAP please."; + fulfillment_request.fulfillment_order_line_items = [ + { + id: 1058737578, + quantity: 1 + }, + { + id: 1058737579, + quantity: 1 + } + ]; + await fulfillment_request.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/fulfillment_orders/1046000840/fulfillment_request.json', + query: '', + headers, + data: { "fulfillment_request": {message: "Fulfill this ASAP please.", fulfillment_order_line_items: [{id: 1058737578, quantity: 1}, {id: 1058737579, quantity: 1}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment_request = new FulfillmentRequest({session: test_session}); + fulfillment_request.fulfillment_order_id = 1046000843; + fulfillment_request.message = "Fulfill this ASAP please."; + await fulfillment_request.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/fulfillment_orders/1046000843/fulfillment_request.json', + query: '', + headers, + data: { "fulfillment_request": {message: "Fulfill this ASAP please."} } + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment_request = new FulfillmentRequest({session: test_session}); + fulfillment_request.fulfillment_order_id = 1046000844; + await fulfillment_request.accept({ + body: {fulfillment_request: {message: "We will start processing your fulfillment on the next business day."}}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/fulfillment_orders/1046000844/fulfillment_request/accept.json', + query: '', + headers, + data: { "fulfillment_request": {message: "We will start processing your fulfillment on the next business day."} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment_request = new FulfillmentRequest({session: test_session}); + fulfillment_request.fulfillment_order_id = 1046000845; + await fulfillment_request.reject({ + body: {fulfillment_request: {message: "Not enough inventory on hand to complete the work."}}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/fulfillment_orders/1046000845/fulfillment_request/reject.json', + query: '', + headers, + data: { "fulfillment_request": {message: "Not enough inventory on hand to complete the work."} } + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-07/fulfillment_service.test.ts b/src/rest-resources/__tests__/2021-07/fulfillment_service.test.ts new file mode 100644 index 000000000..ec693496c --- /dev/null +++ b/src/rest-resources/__tests__/2021-07/fulfillment_service.test.ts @@ -0,0 +1,128 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {FulfillmentService} from '../../2021-07'; + +describe('FulfillmentService resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.July21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await FulfillmentService.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/fulfillment_services.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await FulfillmentService.all({ + session: test_session, + scope: "all", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/fulfillment_services.json', + query: 'scope=all', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment_service = new FulfillmentService({session: test_session}); + fulfillment_service.name = "Jupiter Fulfillment"; + fulfillment_service.callback_url = "http://google.com"; + fulfillment_service.inventory_management = true; + fulfillment_service.tracking_support = true; + fulfillment_service.requires_shipping_method = true; + fulfillment_service.format = "json"; + await fulfillment_service.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/fulfillment_services.json', + query: '', + headers, + data: { "fulfillment_service": {name: "Jupiter Fulfillment", callback_url: "http://google.com", inventory_management: true, tracking_support: true, requires_shipping_method: true, format: "json"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await FulfillmentService.find({ + session: test_session, + id: 755357713, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/fulfillment_services/755357713.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment_service = new FulfillmentService({session: test_session}); + fulfillment_service.id = 755357713; + fulfillment_service.name = "New Fulfillment Service Name"; + await fulfillment_service.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/fulfillment_services/755357713.json', + query: '', + headers, + data: { "fulfillment_service": {id: 755357713, name: "New Fulfillment Service Name"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await FulfillmentService.delete({ + session: test_session, + id: 755357713, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-07/fulfillment_services/755357713.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-07/gift_card.test.ts b/src/rest-resources/__tests__/2021-07/gift_card.test.ts new file mode 100644 index 000000000..8cc7af409 --- /dev/null +++ b/src/rest-resources/__tests__/2021-07/gift_card.test.ts @@ -0,0 +1,215 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {GiftCard} from '../../2021-07'; + +describe('GiftCard resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.July21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await GiftCard.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/gift_cards.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await GiftCard.all({ + session: test_session, + status: "enabled", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/gift_cards.json', + query: 'status=enabled', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const gift_card = new GiftCard({session: test_session}); + gift_card.note = "This is a note"; + gift_card.initial_value = 100.0; + gift_card.code = "ABCD EFGH IJKL MNOP"; + gift_card.template_suffix = "gift_cards.birthday.liquid"; + await gift_card.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/gift_cards.json', + query: '', + headers, + data: { "gift_card": {note: "This is a note", initial_value: 100.0, code: "ABCD EFGH IJKL MNOP", template_suffix: "gift_cards.birthday.liquid"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const gift_card = new GiftCard({session: test_session}); + gift_card.initial_value = 25.0; + await gift_card.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/gift_cards.json', + query: '', + headers, + data: { "gift_card": {initial_value: 25.0} } + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await GiftCard.find({ + session: test_session, + id: 1035197676, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/gift_cards/1035197676.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const gift_card = new GiftCard({session: test_session}); + gift_card.id = 1035197676; + gift_card.note = "Updating with a new note"; + await gift_card.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/gift_cards/1035197676.json', + query: '', + headers, + data: { "gift_card": {id: 1035197676, note: "Updating with a new note"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const gift_card = new GiftCard({session: test_session}); + gift_card.id = 1035197676; + gift_card.expires_on = "2020-01-01"; + await gift_card.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/gift_cards/1035197676.json', + query: '', + headers, + data: { "gift_card": {id: 1035197676, expires_on: "2020-01-01"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await GiftCard.count({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/gift_cards/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await GiftCard.count({ + session: test_session, + status: "enabled", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/gift_cards/count.json', + query: 'status=enabled', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_10', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const gift_card = new GiftCard({session: test_session}); + gift_card.id = 1035197676; + await gift_card.disable({ + body: {gift_card: {id: 1035197676}}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/gift_cards/1035197676/disable.json', + query: '', + headers, + data: { "gift_card": {id: 1035197676} } + }).toMatchMadeHttpRequest(); + }); + + it('test_11', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await GiftCard.search({ + session: test_session, + query: "last_characters:mnop", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/gift_cards/search.json', + query: 'query=last_characters%3Amnop', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-07/gift_card_adjustment.test.ts b/src/rest-resources/__tests__/2021-07/gift_card_adjustment.test.ts new file mode 100644 index 000000000..3fbbb4a98 --- /dev/null +++ b/src/rest-resources/__tests__/2021-07/gift_card_adjustment.test.ts @@ -0,0 +1,131 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {GiftCardAdjustment} from '../../2021-07'; + +describe('GiftCardAdjustment resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.July21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await GiftCardAdjustment.all({ + session: test_session, + gift_card_id: 1035197676, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/gift_cards/1035197676/adjustments.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const gift_card_adjustment = new GiftCardAdjustment({session: test_session}); + gift_card_adjustment.gift_card_id = 1035197676; + gift_card_adjustment.amount = 10.0; + gift_card_adjustment.note = "Customer refilled gift card by $10"; + await gift_card_adjustment.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/gift_cards/1035197676/adjustments.json', + query: '', + headers, + data: { "adjustment": {amount: 10.0, note: "Customer refilled gift card by $10"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const gift_card_adjustment = new GiftCardAdjustment({session: test_session}); + gift_card_adjustment.gift_card_id = 1035197676; + gift_card_adjustment.amount = -20.0; + gift_card_adjustment.note = "Customer spent $20 via external service"; + await gift_card_adjustment.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/gift_cards/1035197676/adjustments.json', + query: '', + headers, + data: { "adjustment": {amount: -20.0, note: "Customer spent $20 via external service"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const gift_card_adjustment = new GiftCardAdjustment({session: test_session}); + gift_card_adjustment.gift_card_id = 1035197676; + gift_card_adjustment.amount = 10.0; + gift_card_adjustment.remote_transaction_ref = "gift_card_app_transaction_193402"; + gift_card_adjustment.remote_transaction_url = "http://example.com/my-gift-card-app/gift_card_adjustments/193402"; + await gift_card_adjustment.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/gift_cards/1035197676/adjustments.json', + query: '', + headers, + data: { "adjustment": {amount: 10.0, remote_transaction_ref: "gift_card_app_transaction_193402", remote_transaction_url: "http://example.com/my-gift-card-app/gift_card_adjustments/193402"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const gift_card_adjustment = new GiftCardAdjustment({session: test_session}); + gift_card_adjustment.gift_card_id = 1035197676; + gift_card_adjustment.amount = 10.0; + gift_card_adjustment.processed_at = "2021-08-03T16:57:35-04:00"; + await gift_card_adjustment.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/gift_cards/1035197676/adjustments.json', + query: '', + headers, + data: { "adjustment": {amount: 10.0, processed_at: "2021-08-03T16:57:35-04:00"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await GiftCardAdjustment.find({ + session: test_session, + gift_card_id: 1035197676, + id: 9, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/gift_cards/1035197676/adjustments/9.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-07/image.test.ts b/src/rest-resources/__tests__/2021-07/image.test.ts new file mode 100644 index 000000000..f43ecd874 --- /dev/null +++ b/src/rest-resources/__tests__/2021-07/image.test.ts @@ -0,0 +1,305 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Image} from '../../2021-07'; + +describe('Image resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.July21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Image.all({ + session: test_session, + product_id: 632910392, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/products/632910392/images.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Image.all({ + session: test_session, + product_id: 632910392, + since_id: "850703190", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/products/632910392/images.json', + query: 'since_id=850703190', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const image = new Image({session: test_session}); + image.product_id = 632910392; + image.attachment = "R0lGODlhbgCMAPf/APbr48VySrxTO7IgKt2qmKQdJeK8lsFjROG5p/nz7Zg3\nMNmnd7Q1MLNVS9GId71hSJMZIuzTu4UtKbeEeakhKMl8U8WYjfr18YQaIbAf\nKKwhKdKzqpQtLebFortOOejKrOjZ1Mt7aMNpVbAqLLV7bsNqR 3WwMqEWenN\nsZYxL/Ddy/Pm2e7ZxLlUQrIjNPXp3bU5MbhENbEtLtqhj5ZQTfHh0bMxL7Ip\nNsNyUYkZIrZJPcqGdYIUHb5aPKkeJnoUHd2yiJkiLKYiKLRFOsyJXKVDO8up\nosFaS TBnK4kKti5sNaYg/z49aqYl5kqLrljUtORfMOlo/36 H4ZH8yDYq0f\nKKFYTaU9MrY8MrZBNXwXHpgaIdGVYu/byLZNP9SaZLIyOuXCtHkpJst Wpcm\nLMyCa8BfP9GMb9KQdPDd1PPk1sd5VP79/L5dQZ0bI9 ymqssK9WcfIoXHdzG\nxdWWfteib79lSr1YP86MYurQxKdcUKdMQr5ZSfPs6YEZH8uhl4oWIenMuurQ\nttmejaqoqsqBVaAcJLlJN5kvMLlZRMNsSL5fRak0LbdQQMVvSPjw6cJnRpkf\nKtm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c //nGgZ7vbYw67aVux4v/\nfXSSK53by/HVrzIwDZTBBANUrzpMeAAIWASeB4P/AQ9 cHjEJx7xWgDE5nLQ\neMdHXvKbg/zkMZ23H/1oFRjYPOc9v3nQ58Aw0xn9LACvO7HQAOZVf/jl0ii1\nHcXe9bPX3euftaPL5R71tIf97nsy7/o0WlP2r4/JOU7B r5nqva7jz1EdZ97\n4qNe bonfvCfVXvly1762beOOdLBd Q7PCAAOw==\n"; + image.filename = "rails_logo.gif"; + await image.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/products/632910392/images.json', + query: '', + headers, + data: { "image": {attachment: "R0lGODlhbgCMAPf/APbr48VySrxTO7IgKt2qmKQdJeK8lsFjROG5p/nz7Zg3\nMNmnd7Q1MLNVS9GId71hSJMZIuzTu4UtKbeEeakhKMl8U8WYjfr18YQaIbAf\nKKwhKdKzqpQtLebFortOOejKrOjZ1Mt7aMNpVbAqLLV7bsNqR 3WwMqEWenN\nsZYxL/Ddy/Pm2e7ZxLlUQrIjNPXp3bU5MbhENbEtLtqhj5ZQTfHh0bMxL7Ip\nNsNyUYkZIrZJPcqGdYIUHb5aPKkeJnoUHd2yiJkiLKYiKLRFOsyJXKVDO8up\nosFaS TBnK4kKti5sNaYg/z49aqYl5kqLrljUtORfMOlo/36 H4ZH8yDYq0f\nKKFYTaU9MrY8MrZBNXwXHpgaIdGVYu/byLZNP9SaZLIyOuXCtHkpJst Wpcm\nLMyCa8BfP9GMb9KQdPDd1PPk1sd5VP79/L5dQZ0bI9 ymqssK9WcfIoXHdzG\nxdWWfteib79lSr1YP86MYurQxKdcUKdMQr5ZSfPs6YEZH8uhl4oWIenMuurQ\nttmejaqoqsqBVaAcJLlJN5kvMLlZRMNsSL5fRak0LbdQQMVvSPjw6cJnRpkf\nKtmjhvfu5cJtT7IuOMVvWLY/M/37 o0YH9ibhtSYdObErc6HarM9NnYSGNGR\navLi09unje3WyeO8rsVrT7tdRtK3uffu6NWeaL9pTJIjJrM4NPb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FRjYPOc9v3nQ58Aw0xn9LACvO7HQAOZVf/jl0ii1\nHcXe9bPX3euftaPL5R71tIf97nsy7/o0WlP2r4/JOU7B r5nqva7jz1EdZ97\n4qNe bonfvCfVXvly1762beOOdLBd Q7PCAAOw==\n", filename: "rails_logo.gif"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const image = new Image({session: test_session}); + image.product_id = 632910392; + image.src = "http://example.com/rails_logo.gif"; + await image.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/products/632910392/images.json', + query: '', + headers, + data: { "image": {src: "http://example.com/rails_logo.gif"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const image = new Image({session: test_session}); + image.product_id = 632910392; + image.position = 1; + image.attachment = "R0lGODlhbgCMAPf/APbr48VySrxTO7IgKt2qmKQdJeK8lsFjROG5p/nz7Zg3\nMNmnd7Q1MLNVS9GId71hSJMZIuzTu4UtKbeEeakhKMl8U8WYjfr18YQaIbAf\nKKwhKdKzqpQtLebFortOOejKrOjZ1Mt7aMNpVbAqLLV7bsNqR 3WwMqEWenN\nsZYxL/Ddy/Pm2e7ZxLlUQrIjNPXp3bU5MbhENbEtLtqhj5ZQTfHh0bMxL7Ip\nNsNyUYkZIrZJPcqGdYIUHb5aPKkeJnoUHd2yiJkiLKYiKLRFOsyJXKVDO8up\nosFaS TBnK4kKti5sNaYg/z49aqYl5kqLrljUtORfMOlo/36 H4ZH8yDYq0f\nKKFYTaU9MrY8MrZBNXwXHpgaIdGVYu/byLZNP9SaZLIyOuXCtHkpJst Wpcm\nLMyCa8BfP9GMb9KQdPDd1PPk1sd5VP79/L5dQZ0bI9 ymqssK9WcfIoXHdzG\nxdWWfteib79lSr1YP86MYurQxKdcUKdMQr5ZSfPs6YEZH8uhl4oWIenMuurQ\nttmejaqoqsqBVaAcJLlJN5kvMLlZRMNsSL5fRak0L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LD7AQhU2efSbG6zm7VgiG1ofBc //nGgZ7vbYw67aVux4v/\nfXSSK53by/HVrzIwDZTBBANUrzpMeAAIWASeB4P/AQ9 cHjEJx7xWgDE5nLQ\neMdHXvKbg/zkMZ23H/1oFRjYPOc9v3nQ58Aw0xn9LACvO7HQAOZVf/jl0ii1\nHcXe9bPX3euftaPL5R71tIf97nsy7/o0WlP2r4/JOU7B r5nqva7jz1EdZ97\n4qNe bonfvCfVXvly1762beOOdLBd Q7PCAAOw==\n"; + image.filename = "rails_logo.gif"; + await image.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/products/632910392/images.json', + query: '', + headers, + data: { "image": {position: 1, attachment: "R0lGODlhbgCMAPf/APbr48VySrxTO7IgKt2qmKQdJeK8lsFjROG5p/nz7Zg3\nMNmnd7Q1MLNVS9GId71hSJMZIuzTu4UtKbeEeakhKMl8U8WYjfr18YQaIbAf\nKKwhKdKzqpQtLebFortOOejKrOjZ1Mt7aMNpVbAqLLV7bsNqR 3WwMqEWenN\nsZYxL/Ddy/Pm2e7ZxLlUQrIjNPXp3bU5MbhENbEtLtqhj5ZQTfHh0bMxL7Ip\nNsNyUYkZIrZJPcqGdYIUHb5aPKkeJnoUHd2yiJkiLKYiKLRFOsyJXKVDO8up\nosFaS TBnK4kKti5sNaYg/z49aqYl5kqLrljUtORfMOlo/36 H4ZH8yDYq0f\nKKFYTaU9MrY8MrZBNXwXHpgaIdGVYu/byLZNP9SaZLIyOuXCtHkpJst Wpcm\nLMyCa8BfP9GMb9KQdPDd1PPk1sd5VP79/L5dQZ0bI9 ymqssK9WcfIoXHdzG\nxdWWfteib79lSr1YP86MYurQxKdcUKdMQr5ZSfPs6YEZH8uhl4oWIenMuurQ\nttmejaqoqsqBVaAcJLlJN5kvMLlZRMNsSL5fRak0LbdQQMVvSPjw6cJnRpkf\nKtmjhvfu5cJtT7IuOMVvWLY/M/37 o0YH9ibhtSYdObErc6HarM9NnYSGNGR\navLi09unje3WyeO8rsVrT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gDE5nLQ\neMdHXvKbg/zkMZ23H/1oFRjYPOc9v3nQ58Aw0xn9LACvO7HQAOZVf/jl0ii1\nHcXe9bPX3euftaPL5R71tIf97nsy7/o0WlP2r4/JOU7B r5nqva7jz1EdZ97\n4qNe bonfvCfVXvly1762beOOdLBd Q7PCAAOw==\n", filename: "rails_logo.gif"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const image = new Image({session: test_session}); + image.product_id = 632910392; + image.variant_ids = [ + 808950810, + 457924702 + ]; + image.attachment = "R0lGODlhbgCMAPf/APbr48VySrxTO7IgKt2qmKQdJeK8lsFjROG5p/nz7Zg3\nMNmnd7Q1MLNVS9GId71hSJMZIuzTu4UtKbeEeakhKMl8U8WYjfr18YQaIbAf\nKKwhKdKzqpQtLebFortOOejKrOjZ1Mt7aMNpVbAqLLV7bsNqR 3WwMqEWenN\nsZYxL/Ddy/Pm2e7ZxLlUQrIjNPXp3bU5MbhENbEtLtqhj5ZQTfHh0bMxL7Ip\nNsNyUYkZIrZJPcqGdYIUHb5aPKkeJnoUHd2yiJkiLKYiKLRFOsyJXKVDO8up\nosFaS TBnK4kKti5sNaYg/z49aqYl5kqLrljUtORfMOlo/36 H4ZH8yDYq0f\nKKFYTaU9MrY8MrZBNXwXHpgaIdGVYu/byLZNP9SaZLIyOuXCtHkpJst Wpcm\nLMyCa8BfP9GMb9KQdPDd1PPk1sd5VP79/L5dQZ0bI9 ymqssK9WcfIoXHdzG\nxdWWfteib79lSr1YP86MYurQxKdcUKdMQr5ZSfPs6YEZH8uhl4oWIenMuurQ\nttmejaqoqsqBVaAcJLlJN5kvMLlZRMNsSL5fRak0LbdQQMVvSPjw6cJnRpkf\nKtmjhvfu5cJtT7IuOMVvWLY/M/37 o0YH9ibhtSYdObErc6HarM9NnYSGNGR\navLi09unje3WyeO8rsVrT7tdRtK3uffu6NWeaL9pTJIjJrM4NPbx8cdyX7M7\nPYYVHu7j4KgoNJ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7HQAOZVf/jl0ii1\nHcXe9bPX3euftaPL5R71tIf97nsy7/o0WlP2r4/JOU7B r5nqva7jz1EdZ97\n4qNe bonfvCfVXvly1762beOOdLBd Q7PCAAOw==\n"; + image.filename = "rails_logo.gif"; + await image.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/products/632910392/images.json', + query: '', + headers, + data: { "image": {variant_ids: [808950810, 457924702], attachment: "R0lGODlhbgCMAPf/APbr48VySrxTO7IgKt2qmKQdJeK8lsFjROG5p/nz7Zg3\nMNmnd7Q1MLNVS9GId71hSJMZIuzTu4UtKbeEeakhKMl8U8WYjfr18YQaIbAf\nKKwhKdKzqpQtLebFortOOejKrOjZ1Mt7aMNpVbAqLLV7bsNqR 3WwMqEWenN\nsZYxL/Ddy/Pm2e7ZxLlUQrIjNPXp3bU5MbhENbEtLtqhj5ZQTfHh0bMxL7Ip\nNsNyUYkZIrZJPcqGdYIUHb5aPKkeJnoUHd2yiJkiLKYiKLRFOsyJXKVDO8up\nosFaS TBnK4kKti5sNaYg/z49aqYl5kqLrljUtORfMOlo/36 H4ZH8yDYq0f\nKKFYTaU9MrY8MrZBNXwXHpgaIdGVYu/byLZNP9SaZLIyOuXCtHkpJst Wpcm\nLMyCa8BfP9GMb9KQdPDd1PPk1sd5VP79/L5dQZ0bI9 ymqssK9WcfIoXHdzG\nxdWWfteib79lSr1YP86MYurQxKdcUKdMQr5ZSfPs6YEZH8uhl4oWIenMuurQ\nttmejaqoqsqBVaAcJLlJN5kvMLlZRMNsSL5fRak0LbdQQMVvSPjw6cJnRpkf\nKtmjhvfu5cJtT7IuOMVvWLY/M/37 o0YH9ibhtSYdObErc6HarM9NnYSGNGR\navLi09unje3WyeO8rsVrT7tdRtK3uffu6NWeaL9pTJIjJrM4NPbx8cdyX7M7\nPYYVHu7j4KgoNJAYIKtkV5o9MsOcldicis RYNutfrhFOZ0hJbqinZ8bI8h5\nUObFuOfItJsfJrJfUOfIqc PXqQtK8RnSbA4Mcd3T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Xvly1762beOOdLBd Q7PCAAOw==\n", filename: "rails_logo.gif"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const image = new Image({session: test_session}); + image.product_id = 632910392; + image.position = 1; + image.metafields = [ + { + key: "new", + value: "newvalue", + type: "single_line_text_field", + namespace: "global" + } + ]; + image.attachment = "R0lGODlhbgCMAPf/APbr48VySrxTO7IgKt2qmKQdJeK8lsFjROG5p/nz7Zg3\nMNmnd7Q1MLNVS9GId71hSJMZIuzTu4UtKbeEeakhKMl8U8WYjfr18YQaIbAf\nKKwhKdKzqpQtLebFortOOejKrOjZ1Mt7aMNpVbAqLLV7bsNqR 3WwMqEWenN\nsZYxL/Ddy/Pm2e7ZxLlUQrIjNPXp3bU5MbhENbEtLtqhj5ZQTfHh0bMxL7Ip\nNsNyUYkZIrZJPcqGdYIUHb5aPKkeJnoUHd2yiJkiLKYiKLRFOsyJXKVDO8up\nosFaS TBnK4kKti5sNaYg/z49aqYl5kqLrljUtORfMOlo/36 H4ZH8yDYq0f\nKKFYTaU9MrY8MrZBNXwXHpgaIdGVYu/byLZNP9SaZLIyOuXCtHkpJst Wpcm\nLMyCa8BfP9GMb9KQdPDd1PPk1sd5VP79/L5dQZ0bI9 ymqssK9WcfIoXHdzG\nxdWWfteib79lSr1YP86MYurQxKdcUKdMQr5ZSfPs6YEZH8uhl4oWIenMuurQ\nttmejaqoqsqBVaAcJLlJN5kvMLlZRMNsSL5fRak0LbdQQMVvSPjw6cJnRpkf\nKtmjhvfu5cJtT7IuOMVvWLY/M/37 o0YH9ibhtSYdObErc6HarM9NnYSGNGR\navLi09unje3WyeO8rsVrT7tdRtK3uffu6NWeaL9pTJIjJrM4NPbx8cdyX7M7\nPYYVHu7j4KgoNJAYIKtkV5o9MsOcldicis RYNutfrhFOZ0hJbqinZ8bI8h5\nUObFuOfItJsfJrJfUOfIqc PXqQtK8RnSbA4Mcd3Tm0SGbpXQ8aqp7RLNs s\nov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==\n"; + image.filename = "rails_logo.gif"; + await image.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/products/632910392/images.json', + query: '', + headers, + data: { "image": {position: 1, metafields: [{key: "new", value: "newvalue", type: "single_line_text_field", namespace: "global"}], attachment: "R0lGODlhbgCMAPf/APbr48VySrxTO7IgKt2qmKQdJeK8lsFjROG5p/nz7Zg3\nMNmnd7Q1MLNVS9GId71hSJMZIuzTu4UtKbeEeakhKMl8U8WYjfr18YQaIbAf\nKKwhKdKzqpQtLebFortOOejKrOjZ1Mt7aMNpVbAqLLV7bsNqR 3WwMqEWenN\nsZYxL/Ddy/Pm2e7ZxLlUQrIjNPXp3bU5MbhENbEtLtqhj5ZQTfHh0bMxL7Ip\nNsNyUYkZIrZJPcqGdYIUHb5aPKkeJnoUHd2yiJkiLKYiKLRFOsyJXKVDO8up\nosFaS TBnK4kKti5sNaYg/z49aqYl5kqLrljUtORfMOlo/36 H4ZH8yDYq0f\nKKFYTaU9MrY8MrZBNXwXHpgaIdGVYu/byLZNP9SaZLIyOuXCtHkpJst Wpcm\nLMyCa8BfP9GMb9KQdPDd1PPk1sd5VP79/L5dQZ0bI9 ymqssK9WcfIoXHdzG\nxdWWfteib79lSr1YP86MYurQxKdcUKdMQr5ZSfPs6YEZH8uhl4oWIenMuurQ\nttmejaqoqsqBVaAcJLlJN5kvMLlZRMNsSL5fRak0LbdQQMVvSPjw6cJnRpkf\nKtmjhvfu5cJtT7IuOMVvWLY/M/37 o0YH9ibhtSYdObErc6HarM9NnYSGNGR\navLi09unje3WyeO8rsVrT7tdRtK3uffu6NWeaL9pTJIjJrM4NPbx8cdyX7M7\nPYYVHu7j4KgoNJAYIKtkV5o9MsOcldicis RYNutfrhFOZ0hJbqinZ8bI8h5\nUObFuOfItJsfJrJfUOfIqc PXqQtK8RnSbA4Mcd3Tm0SGbpXQ8aqp7RLNs s\novHfzpVhV9iggMd1TLtbRKUdKXEQFsd4XrZRPLIgMZUeJ jKvrAlK6AhJ65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DHvUHLQyhWsy01rXs2MFj2ZGC6862KKRgHGY6K9zlEPdyP8AJcteo\n3ClsQCHq0AF0QdkN HbjlxygL31hO13tMrW7lwkB0BiUoR3x4EfmrYlCNjAF\nCRAoIWmwQexQqQcyxHe 9eXAfVOQAg7k16v7jQsAHGi2Bv0gUzyQQ05Ga Cy\n0MBEDsZgN8gQ4QnXt7oJ0QOGOZACDTeEu0aTCwC80EKhDcAHMDGHWATMsuMC\nFsVl/9GnP0Jg0kw24MUv/qUTOGDlCj8WETfGsVx2vI UzsATIFZUaTIRk3QY\n ZYlFq0Ce5QJHBXgdU MRCSwEYlVBCHPQZhyn7vhhD9fWdAc2DKhKXxhRCc6\n0Yi4LOPcl6hGVUFqc4gJLGaxufKO1s2VkrOj63znOkciCKMedZ n7ARUp1rQ\niLAyIlyNYURcONaInrWs9ci4JyJOaFYawDzP8Q ZwAICLckbgd08i290eh9V\nCIadQw3qO5Oa1H1GNRlSjeorO2HLruZ2rLudAm Dm9Gxcx/GXmSIMbnjH5W2\nzy2RbOzM cENBRAWs0N9b3zXWdp8pra1r61tbXdb4N/2Nv8i5gzeIJd5Gjui\nwT AzQ9YVGrYnNO0Agm27GBkvNnNzje 921qf/ b1QEfuMDFPe5lk/lspUG3\nWKbQCofLBBBuwNEs3C3aikcrB2TTeM81HgmOd3zf/PZ3yFPNaqSXfODF0EDK\nE9e6liZmCvJwOLD7AQhU2efSbG6zm7VgiG1ofBc //nGgZ7vbYw67aVux4v/\nfXSSK53by/HVrzIwDZTBBANUrzpMeAAIWASeB4P/AQ9 cHjEJx7xWgDE5nLQ\neMdHXvKbg/zkMZ23H/1oFRjYPOc9v3nQ58Aw0xn9LACvO7HQAOZVf/jl0ii1\nHcXe9bPX3euftaPL5R71tIf97nsy7/o0WlP2r4/JOU7B r5nqva7jz1EdZ97\n4qNe bonfvCfVXvly1762beOOdLBd Q7PCAAOw==\n", filename: "rails_logo.gif"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Image.count({ + session: test_session, + product_id: 632910392, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/products/632910392/images/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Image.count({ + session: test_session, + product_id: 632910392, + since_id: "850703190", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/products/632910392/images/count.json', + query: 'since_id=850703190', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_10', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Image.find({ + session: test_session, + product_id: 632910392, + id: 850703190, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/products/632910392/images/850703190.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_11', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const image = new Image({session: test_session}); + image.product_id = 632910392; + image.id = 850703190; + image.position = 2; + image.alt = "new alt tag content"; + await image.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/products/632910392/images/850703190.json', + query: '', + headers, + data: { "image": {id: 850703190, position: 2, alt: "new alt tag content"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_12', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const image = new Image({session: test_session}); + image.product_id = 632910392; + image.id = 850703190; + image.variant_ids = [ + 808950810, + 457924702 + ]; + await image.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/products/632910392/images/850703190.json', + query: '', + headers, + data: { "image": {id: 850703190, variant_ids: [808950810, 457924702]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_13', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const image = new Image({session: test_session}); + image.product_id = 632910392; + image.id = 850703190; + image.metafields = [ + { + key: "my_new_metafield", + value: "my_new_value", + type: "single_line_text_field", + namespace: "tags" + } + ]; + await image.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/products/632910392/images/850703190.json', + query: '', + headers, + data: { "image": {id: 850703190, metafields: [{key: "my_new_metafield", value: "my_new_value", type: "single_line_text_field", namespace: "tags"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_14', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Image.delete({ + session: test_session, + product_id: 632910392, + id: 850703190, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-07/products/632910392/images/850703190.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-07/inventory_item.test.ts b/src/rest-resources/__tests__/2021-07/inventory_item.test.ts new file mode 100644 index 000000000..53773a783 --- /dev/null +++ b/src/rest-resources/__tests__/2021-07/inventory_item.test.ts @@ -0,0 +1,89 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {InventoryItem} from '../../2021-07'; + +describe('InventoryItem resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.July21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await InventoryItem.all({ + session: test_session, + ids: "808950810,39072856,457924702", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/inventory_items.json', + query: 'ids=808950810%2C39072856%2C457924702', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await InventoryItem.find({ + session: test_session, + id: 808950810, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/inventory_items/808950810.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const inventory_item = new InventoryItem({session: test_session}); + inventory_item.id = 808950810; + inventory_item.sku = "new sku"; + await inventory_item.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/inventory_items/808950810.json', + query: '', + headers, + data: { "inventory_item": {id: 808950810, sku: "new sku"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const inventory_item = new InventoryItem({session: test_session}); + inventory_item.id = 808950810; + inventory_item.cost = "25.00"; + await inventory_item.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/inventory_items/808950810.json', + query: '', + headers, + data: { "inventory_item": {id: 808950810, cost: "25.00"} } + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-07/inventory_level.test.ts b/src/rest-resources/__tests__/2021-07/inventory_level.test.ts new file mode 100644 index 000000000..fa5425618 --- /dev/null +++ b/src/rest-resources/__tests__/2021-07/inventory_level.test.ts @@ -0,0 +1,148 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {InventoryLevel} from '../../2021-07'; + +describe('InventoryLevel resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.July21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await InventoryLevel.all({ + session: test_session, + inventory_item_ids: "808950810,39072856", + location_ids: "655441491,487838322", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/inventory_levels.json', + query: 'inventory_item_ids=808950810%2C39072856&location_ids=655441491%2C487838322', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await InventoryLevel.all({ + session: test_session, + inventory_item_ids: "808950810", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/inventory_levels.json', + query: 'inventory_item_ids=808950810', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await InventoryLevel.all({ + session: test_session, + location_ids: "655441491", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/inventory_levels.json', + query: 'location_ids=655441491', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const inventory_level = new InventoryLevel({session: test_session}); + + await inventory_level.adjust({ + body: {location_id: 655441491, inventory_item_id: 808950810, available_adjustment: 5}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/inventory_levels/adjust.json', + query: '', + headers, + data: {location_id: 655441491, inventory_item_id: 808950810, available_adjustment: 5} + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await InventoryLevel.delete({ + session: test_session, + inventory_item_id: "808950810", + location_id: "655441491", + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-07/inventory_levels.json', + query: 'inventory_item_id=808950810&location_id=655441491', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const inventory_level = new InventoryLevel({session: test_session}); + + await inventory_level.connect({ + body: {location_id: 844681632, inventory_item_id: 457924702}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/inventory_levels/connect.json', + query: '', + headers, + data: {location_id: 844681632, inventory_item_id: 457924702} + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const inventory_level = new InventoryLevel({session: test_session}); + + await inventory_level.set({ + body: {location_id: 655441491, inventory_item_id: 808950810, available: 42}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/inventory_levels/set.json', + query: '', + headers, + data: {location_id: 655441491, inventory_item_id: 808950810, available: 42} + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-07/location.test.ts b/src/rest-resources/__tests__/2021-07/location.test.ts new file mode 100644 index 000000000..00ba7335d --- /dev/null +++ b/src/rest-resources/__tests__/2021-07/location.test.ts @@ -0,0 +1,87 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Location} from '../../2021-07'; + +describe('Location resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.July21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Location.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/locations.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Location.find({ + session: test_session, + id: 487838322, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/locations/487838322.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Location.count({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/locations/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Location.inventory_levels({ + session: test_session, + id: 487838322, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/locations/487838322/inventory_levels.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-07/locations_for_move.test.ts b/src/rest-resources/__tests__/2021-07/locations_for_move.test.ts new file mode 100644 index 000000000..d05579d27 --- /dev/null +++ b/src/rest-resources/__tests__/2021-07/locations_for_move.test.ts @@ -0,0 +1,35 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {LocationsForMove} from '../../2021-07'; + +describe('LocationsForMove resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.July21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await LocationsForMove.all({ + session: test_session, + fulfillment_order_id: 1046000833, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/fulfillment_orders/1046000833/locations_for_move.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-07/marketing_event.test.ts b/src/rest-resources/__tests__/2021-07/marketing_event.test.ts new file mode 100644 index 000000000..9208965c3 --- /dev/null +++ b/src/rest-resources/__tests__/2021-07/marketing_event.test.ts @@ -0,0 +1,159 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {MarketingEvent} from '../../2021-07'; + +describe('MarketingEvent resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.July21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await MarketingEvent.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/marketing_events.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const marketing_event = new MarketingEvent({session: test_session}); + marketing_event.started_at = "2022-12-15"; + marketing_event.utm_campaign = "Christmas2022"; + marketing_event.utm_source = "facebook"; + marketing_event.utm_medium = "cpc"; + marketing_event.event_type = "ad"; + marketing_event.referring_domain = "facebook.com"; + marketing_event.marketing_channel = "social"; + marketing_event.paid = true; + await marketing_event.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/marketing_events.json', + query: '', + headers, + data: { "marketing_event": {started_at: "2022-12-15", utm_campaign: "Christmas2022", utm_source: "facebook", utm_medium: "cpc", event_type: "ad", referring_domain: "facebook.com", marketing_channel: "social", paid: true} } + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await MarketingEvent.count({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/marketing_events/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await MarketingEvent.find({ + session: test_session, + id: 998730532, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/marketing_events/998730532.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const marketing_event = new MarketingEvent({session: test_session}); + marketing_event.id = 998730532; + marketing_event.remote_id = "1000:2000"; + marketing_event.started_at = "2022-02-02T00:00 00:00"; + marketing_event.ended_at = "2022-02-03T00:00 00:00"; + marketing_event.scheduled_to_end_at = "2022-02-04T00:00 00:00"; + marketing_event.budget = "11.1"; + marketing_event.budget_type = "daily"; + marketing_event.currency = "CAD"; + marketing_event.utm_campaign = "other"; + marketing_event.utm_source = "other"; + marketing_event.utm_medium = "other"; + marketing_event.event_type = "ad"; + marketing_event.referring_domain = "instagram.com"; + await marketing_event.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/marketing_events/998730532.json', + query: '', + headers, + data: { "marketing_event": {id: 998730532, remote_id: "1000:2000", started_at: "2022-02-02T00:00 00:00", ended_at: "2022-02-03T00:00 00:00", scheduled_to_end_at: "2022-02-04T00:00 00:00", budget: "11.1", budget_type: "daily", currency: "CAD", utm_campaign: "other", utm_source: "other", utm_medium: "other", event_type: "ad", referring_domain: "instagram.com"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await MarketingEvent.delete({ + session: test_session, + id: 998730532, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-07/marketing_events/998730532.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const marketing_event = new MarketingEvent({session: test_session}); + marketing_event.id = 998730532; + await marketing_event.engagements({ + body: {engagements: [{occurred_on: "2022-01-15", views_count: 0, clicks_count: 0, favorites_count: 0, ad_spend: 10.0, is_cumulative: true}, {occurred_on: "2022-01-16", views_count: 100, clicks_count: 50, is_cumulative: true}, {occurred_on: "2022-01-17", views_count: 200, clicks_count: 100, is_cumulative: true}]}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/marketing_events/998730532/engagements.json', + query: '', + headers, + data: {engagements: [{occurred_on: "2022-01-15", views_count: 0, clicks_count: 0, favorites_count: 0, ad_spend: 10.0, is_cumulative: true}, {occurred_on: "2022-01-16", views_count: 100, clicks_count: 50, is_cumulative: true}, {occurred_on: "2022-01-17", views_count: 200, clicks_count: 100, is_cumulative: true}]} + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-07/metafield.test.ts b/src/rest-resources/__tests__/2021-07/metafield.test.ts new file mode 100644 index 000000000..09bd9a1ba --- /dev/null +++ b/src/rest-resources/__tests__/2021-07/metafield.test.ts @@ -0,0 +1,162 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Metafield} from '../../2021-07'; + +describe('Metafield resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.July21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Metafield.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/metafields.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Metafield.all({ + session: test_session, + since_id: "721389482", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/metafields.json', + query: 'since_id=721389482', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const metafield = new Metafield({session: test_session}); + metafield.namespace = "inventory"; + metafield.key = "warehouse"; + metafield.value = 25; + metafield.type = "number_integer"; + await metafield.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/metafields.json', + query: '', + headers, + data: { "metafield": {namespace: "inventory", key: "warehouse", value: 25, type: "number_integer"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Metafield.all({ + session: test_session, + metafield: {owner_id: "850703190", owner_resource: "product_image"}, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/metafields.json', + query: 'metafield%5Bowner_id%5D=850703190&metafield%5Bowner_resource%5D=product_image', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Metafield.count({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/metafields/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Metafield.find({ + session: test_session, + id: 721389482, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/metafields/721389482.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const metafield = new Metafield({session: test_session}); + metafield.id = 721389482; + metafield.value = "something new"; + metafield.type = "single_line_text_field"; + await metafield.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/metafields/721389482.json', + query: '', + headers, + data: { "metafield": {id: 721389482, value: "something new", type: "single_line_text_field"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Metafield.delete({ + session: test_session, + id: 721389482, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-07/metafields/721389482.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-07/mobile_platform_application.test.ts b/src/rest-resources/__tests__/2021-07/mobile_platform_application.test.ts new file mode 100644 index 000000000..e87a21724 --- /dev/null +++ b/src/rest-resources/__tests__/2021-07/mobile_platform_application.test.ts @@ -0,0 +1,162 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {MobilePlatformApplication} from '../../2021-07'; + +describe('MobilePlatformApplication resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.July21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await MobilePlatformApplication.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/mobile_platform_applications.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const mobile_platform_application = new MobilePlatformApplication({session: test_session}); + mobile_platform_application.platform = "ios"; + mobile_platform_application.application_id = "X1Y2.ca.domain.app"; + mobile_platform_application.enabled_universal_or_app_links = true; + mobile_platform_application.enabled_shared_webcredentials = true; + await mobile_platform_application.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/mobile_platform_applications.json', + query: '', + headers, + data: { "mobile_platform_application": {platform: "ios", application_id: "X1Y2.ca.domain.app", enabled_universal_or_app_links: true, enabled_shared_webcredentials: true} } + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const mobile_platform_application = new MobilePlatformApplication({session: test_session}); + mobile_platform_application.platform = "android"; + mobile_platform_application.application_id = "com.example"; + mobile_platform_application.sha256_cert_fingerprints = [ + "14:6D:E9:83:C5:73:06:50:D8:EE:B9:95:2F:34:FC:64:16:A0:83:42:E6:1D:BE:A8:8A:04:96:B2:3F:CF:44:E5" + ]; + mobile_platform_application.enabled_universal_or_app_links = true; + await mobile_platform_application.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/mobile_platform_applications.json', + query: '', + headers, + data: { "mobile_platform_application": {platform: "android", application_id: "com.example", sha256_cert_fingerprints: ["14:6D:E9:83:C5:73:06:50:D8:EE:B9:95:2F:34:FC:64:16:A0:83:42:E6:1D:BE:A8:8A:04:96:B2:3F:CF:44:E5"], enabled_universal_or_app_links: true} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await MobilePlatformApplication.find({ + session: test_session, + id: 1066176008, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/mobile_platform_applications/1066176008.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const mobile_platform_application = new MobilePlatformApplication({session: test_session}); + mobile_platform_application.id = 1066176009; + mobile_platform_application.application_id = "A1B2.ca.domain.app"; + mobile_platform_application.platform = "ios"; + mobile_platform_application.created_at = "2022-02-03T16:41:55-05:00"; + mobile_platform_application.updated_at = "2022-02-03T16:41:55-05:00"; + mobile_platform_application.sha256_cert_fingerprints = []; + mobile_platform_application.enabled_universal_or_app_links = true; + mobile_platform_application.enabled_shared_webcredentials = true; + await mobile_platform_application.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/mobile_platform_applications/1066176009.json', + query: '', + headers, + data: { "mobile_platform_application": {id: 1066176009, application_id: "A1B2.ca.domain.app", platform: "ios", created_at: "2022-02-03T16:41:55-05:00", updated_at: "2022-02-03T16:41:55-05:00", sha256_cert_fingerprints: [], enabled_universal_or_app_links: true, enabled_shared_webcredentials: true} } + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const mobile_platform_application = new MobilePlatformApplication({session: test_session}); + mobile_platform_application.id = 1066176010; + mobile_platform_application.application_id = "com.example.news.app"; + mobile_platform_application.platform = "android"; + mobile_platform_application.created_at = "2022-02-03T16:41:57-05:00"; + mobile_platform_application.updated_at = "2022-02-03T16:41:57-05:00"; + mobile_platform_application.sha256_cert_fingerprints = [ + "14:6D:E9:83:C5:73:06:50:D8:EE:B9:95:2F:34:FC:64:16:A0:83:42:E6:1D:BE:A8:8A:04:96:B2:3F:CF:44:E5" + ]; + mobile_platform_application.enabled_universal_or_app_links = true; + mobile_platform_application.enabled_shared_webcredentials = false; + await mobile_platform_application.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/mobile_platform_applications/1066176010.json', + query: '', + headers, + data: { "mobile_platform_application": {id: 1066176010, application_id: "com.example.news.app", platform: "android", created_at: "2022-02-03T16:41:57-05:00", updated_at: "2022-02-03T16:41:57-05:00", sha256_cert_fingerprints: ["14:6D:E9:83:C5:73:06:50:D8:EE:B9:95:2F:34:FC:64:16:A0:83:42:E6:1D:BE:A8:8A:04:96:B2:3F:CF:44:E5"], enabled_universal_or_app_links: true, enabled_shared_webcredentials: false} } + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await MobilePlatformApplication.delete({ + session: test_session, + id: 1066176011, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-07/mobile_platform_applications/1066176011.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-07/order.test.ts b/src/rest-resources/__tests__/2021-07/order.test.ts new file mode 100644 index 000000000..16b1ad89e --- /dev/null +++ b/src/rest-resources/__tests__/2021-07/order.test.ts @@ -0,0 +1,814 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Order} from '../../2021-07'; + +describe('Order resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.July21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Order.all({ + session: test_session, + status: "any", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/orders.json', + query: 'status=any', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Order.all({ + session: test_session, + ids: "1073459980", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/orders.json', + query: 'ids=1073459980', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Order.all({ + session: test_session, + financial_status: "authorized", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/orders.json', + query: 'financial_status=authorized', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Order.all({ + session: test_session, + updated_at_min: "2005-07-31T15:57:11-04:00", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/orders.json', + query: 'updated_at_min=2005-07-31T15%3A57%3A11-04%3A00', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Order.all({ + session: test_session, + fields: "created_at,id,name,total-price", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/orders.json', + query: 'fields=created_at%2Cid%2Cname%2Ctotal-price', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Order.all({ + session: test_session, + since_id: "123", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/orders.json', + query: 'since_id=123', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Order.find({ + session: test_session, + id: 450789469, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/orders/450789469.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Order.find({ + session: test_session, + id: 450789469, + fields: "id,line_items,name,total_price", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/orders/450789469.json', + query: 'fields=id%2Cline_items%2Cname%2Ctotal_price', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order = new Order({session: test_session}); + order.id = 450789469; + order.note = "Customer contacted us about a custom engraving on this iPod"; + await order.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/orders/450789469.json', + query: '', + headers, + data: { "order": {id: 450789469, note: "Customer contacted us about a custom engraving on this iPod"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_10', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order = new Order({session: test_session}); + order.id = 450789469; + order.note_attributes = [ + { + name: "colour", + value: "red" + } + ]; + await order.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/orders/450789469.json', + query: '', + headers, + data: { "order": {id: 450789469, note_attributes: [{name: "colour", value: "red"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_11', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order = new Order({session: test_session}); + order.id = 450789469; + order.email = "a-different@email.com"; + await order.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/orders/450789469.json', + query: '', + headers, + data: { "order": {id: 450789469, email: "a-different@email.com"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_12', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order = new Order({session: test_session}); + order.id = 450789469; + order.phone = " 15145556677"; + await order.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/orders/450789469.json', + query: '', + headers, + data: { "order": {id: 450789469, phone: " 15145556677"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_13', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order = new Order({session: test_session}); + order.id = 450789469; + order.buyer_accepts_marketing = true; + await order.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/orders/450789469.json', + query: '', + headers, + data: { "order": {id: 450789469, buyer_accepts_marketing: true} } + }).toMatchMadeHttpRequest(); + }); + + it('test_14', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order = new Order({session: test_session}); + order.id = 450789469; + order.shipping_address = { + address1: "123 Ship Street", + city: "Shipsville" + }; + await order.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/orders/450789469.json', + query: '', + headers, + data: { "order": {id: 450789469, shipping_address: {address1: "123 Ship Street", city: "Shipsville"}} } + }).toMatchMadeHttpRequest(); + }); + + it('test_15', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order = new Order({session: test_session}); + order.id = 450789469; + order.customer = null; + await order.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/orders/450789469.json', + query: '', + headers, + data: { "order": {id: 450789469, customer: null} } + }).toMatchMadeHttpRequest(); + }); + + it('test_16', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order = new Order({session: test_session}); + order.id = 450789469; + order.tags = "External, Inbound, Outbound"; + await order.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/orders/450789469.json', + query: '', + headers, + data: { "order": {id: 450789469, tags: "External, Inbound, Outbound"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_17', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order = new Order({session: test_session}); + order.id = 450789469; + order.metafields = [ + { + key: "new", + value: "newvalue", + type: "single_line_text_field", + namespace: "global" + } + ]; + await order.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/orders/450789469.json', + query: '', + headers, + data: { "order": {id: 450789469, metafields: [{key: "new", value: "newvalue", type: "single_line_text_field", namespace: "global"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_18', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Order.delete({ + session: test_session, + id: 450789469, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-07/orders/450789469.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_19', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Order.count({ + session: test_session, + status: "any", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/orders/count.json', + query: 'status=any', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_20', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Order.count({ + session: test_session, + financial_status: "authorized", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/orders/count.json', + query: 'financial_status=authorized', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_21', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order = new Order({session: test_session}); + order.id = 450789469; + await order.close({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/orders/450789469/close.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_22', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order = new Order({session: test_session}); + order.id = 450789469; + await order.open({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/orders/450789469/open.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_23', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order = new Order({session: test_session}); + order.id = 450789469; + await order.cancel({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/orders/450789469/cancel.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_24', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order = new Order({session: test_session}); + order.id = 450789469; + await order.cancel({ + body: {amount: "10.00", currency: "USD"}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/orders/450789469/cancel.json', + query: '', + headers, + data: {amount: "10.00", currency: "USD"} + }).toMatchMadeHttpRequest(); + }); + + it('test_25', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order = new Order({session: test_session}); + order.id = 450789469; + await order.cancel({ + body: {refund: {note: "Customer made a mistake", shipping: {full_refund: true}, refund_line_items: [{line_item_id: 466157049, quantity: 1, restock_type: "cancel", location_id: 24826418}], transactions: [{parent_id: 1068278509, amount: "10.00", kind: "refund", gateway: "bogus"}, {parent_id: 1068278510, amount: "100.00", kind: "refund", gateway: "gift_card"}]}}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/orders/450789469/cancel.json', + query: '', + headers, + data: {refund: {note: "Customer made a mistake", shipping: {full_refund: true}, refund_line_items: [{line_item_id: 466157049, quantity: 1, restock_type: "cancel", location_id: 24826418}], transactions: [{parent_id: 1068278509, amount: "10.00", kind: "refund", gateway: "bogus"}, {parent_id: 1068278510, amount: "100.00", kind: "refund", gateway: "gift_card"}]}} + }).toMatchMadeHttpRequest(); + }); + + it('test_26', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order = new Order({session: test_session}); + order.line_items = [ + { + variant_id: 447654529, + quantity: 1 + } + ]; + await order.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/orders.json', + query: '', + headers, + data: { "order": {line_items: [{variant_id: 447654529, quantity: 1}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_27', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order = new Order({session: test_session}); + order.email = "foo@example.com"; + order.fulfillment_status = "fulfilled"; + order.send_receipt = true; + order.send_fulfillment_receipt = true; + order.line_items = [ + { + variant_id: 457924702, + quantity: 1 + } + ]; + await order.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/orders.json', + query: '', + headers, + data: { "order": {email: "foo@example.com", fulfillment_status: "fulfilled", send_receipt: true, send_fulfillment_receipt: true, line_items: [{variant_id: 457924702, quantity: 1}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_28', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order = new Order({session: test_session}); + order.email = "foo@example.com"; + order.fulfillment_status = "fulfilled"; + order.line_items = [ + { + variant_id: 447654529, + quantity: 1 + } + ]; + await order.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/orders.json', + query: '', + headers, + data: { "order": {email: "foo@example.com", fulfillment_status: "fulfilled", line_items: [{variant_id: 447654529, quantity: 1}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_29', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order = new Order({session: test_session}); + order.email = "foo@example.com"; + order.fulfillment_status = "fulfilled"; + order.fulfillments = [ + { + location_id: 24826418 + } + ]; + order.line_items = [ + { + variant_id: 447654529, + quantity: 1 + } + ]; + await order.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/orders.json', + query: '', + headers, + data: { "order": {email: "foo@example.com", fulfillment_status: "fulfilled", fulfillments: [{location_id: 24826418}], line_items: [{variant_id: 447654529, quantity: 1}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_30', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order = new Order({session: test_session}); + order.line_items = [ + { + title: "Big Brown Bear Boots", + price: 74.99, + grams: "1300", + quantity: 3, + tax_lines: [ + { + price: 13.5, + rate: 0.06, + title: "State tax" + } + ] + } + ]; + order.transactions = [ + { + kind: "sale", + status: "success", + amount: 238.47 + } + ]; + order.total_tax = 13.5; + order.currency = "EUR"; + await order.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/orders.json', + query: '', + headers, + data: { "order": {line_items: [{title: "Big Brown Bear Boots", price: 74.99, grams: "1300", quantity: 3, tax_lines: [{price: 13.5, rate: 0.06, title: "State tax"}]}], transactions: [{kind: "sale", status: "success", amount: 238.47}], total_tax: 13.5, currency: "EUR"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_31', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order = new Order({session: test_session}); + order.line_items = [ + { + title: "Red Leather Coat", + price: 129.99, + grams: "1700", + quantity: 1 + }, + { + title: "Blue Suede Shoes", + price: 85.95, + grams: "750", + quantity: 1, + taxable: false + }, + { + title: "Raspberry Beret", + price: 19.99, + grams: "320", + quantity: 2 + } + ]; + order.tax_lines = [ + { + price: 10.2, + rate: 0.06, + title: "State tax" + }, + { + price: 4.25, + rate: 0.025, + title: "County tax" + } + ]; + order.total_tax = 14.45; + await order.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/orders.json', + query: '', + headers, + data: { "order": {line_items: [{title: "Red Leather Coat", price: 129.99, grams: "1700", quantity: 1}, {title: "Blue Suede Shoes", price: 85.95, grams: "750", quantity: 1, taxable: false}, {title: "Raspberry Beret", price: 19.99, grams: "320", quantity: 2}], tax_lines: [{price: 10.2, rate: 0.06, title: "State tax"}, {price: 4.25, rate: 0.025, title: "County tax"}], total_tax: 14.45} } + }).toMatchMadeHttpRequest(); + }); + + it('test_32', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order = new Order({session: test_session}); + order.line_items = [ + { + variant_id: 447654529, + quantity: 1 + } + ]; + order.customer = { + id: 207119551 + }; + order.financial_status = "pending"; + await order.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/orders.json', + query: '', + headers, + data: { "order": {line_items: [{variant_id: 447654529, quantity: 1}], customer: {id: 207119551}, financial_status: "pending"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_33', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order = new Order({session: test_session}); + order.line_items = [ + { + variant_id: 447654529, + quantity: 1 + } + ]; + order.customer = { + first_name: "Paul", + last_name: "Norman", + email: "paul.norman@example.com" + }; + order.billing_address = { + first_name: "John", + last_name: "Smith", + address1: "123 Fake Street", + phone: "555-555-5555", + city: "Fakecity", + province: "Ontario", + country: "Canada", + zip: "K2P 1L4" + }; + order.shipping_address = { + first_name: "Jane", + last_name: "Smith", + address1: "123 Fake Street", + phone: "777-777-7777", + city: "Fakecity", + province: "Ontario", + country: "Canada", + zip: "K2P 1L4" + }; + order.email = "jane@example.com"; + order.transactions = [ + { + kind: "authorization", + status: "success", + amount: 50.0 + } + ]; + order.financial_status = "partially_paid"; + await order.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/orders.json', + query: '', + headers, + data: { "order": {line_items: [{variant_id: 447654529, quantity: 1}], customer: {first_name: "Paul", last_name: "Norman", email: "paul.norman@example.com"}, billing_address: {first_name: "John", last_name: "Smith", address1: "123 Fake Street", phone: "555-555-5555", city: "Fakecity", province: "Ontario", country: "Canada", zip: "K2P 1L4"}, shipping_address: {first_name: "Jane", last_name: "Smith", address1: "123 Fake Street", phone: "777-777-7777", city: "Fakecity", province: "Ontario", country: "Canada", zip: "K2P 1L4"}, email: "jane@example.com", transactions: [{kind: "authorization", status: "success", amount: 50.0}], financial_status: "partially_paid"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_34', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order = new Order({session: test_session}); + order.line_items = [ + { + variant_id: 447654529, + quantity: 1 + } + ]; + order.email = "jane@example.com"; + order.phone = "18885551234"; + order.billing_address = { + first_name: "John", + last_name: "Smith", + address1: "123 Fake Street", + phone: "555-555-5555", + city: "Fakecity", + province: "Ontario", + country: "Canada", + zip: "K2P 1L4" + }; + order.shipping_address = { + first_name: "Jane", + last_name: "Smith", + address1: "123 Fake Street", + phone: "777-777-7777", + city: "Fakecity", + province: "Ontario", + country: "Canada", + zip: "K2P 1L4" + }; + order.transactions = [ + { + kind: "sale", + status: "success", + amount: 50.0 + } + ]; + order.financial_status = "paid"; + order.discount_codes = [ + { + code: "FAKE30", + amount: "9.00", + type: "percentage" + } + ]; + await order.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/orders.json', + query: '', + headers, + data: { "order": {line_items: [{variant_id: 447654529, quantity: 1}], email: "jane@example.com", phone: "18885551234", billing_address: {first_name: "John", last_name: "Smith", address1: "123 Fake Street", phone: "555-555-5555", city: "Fakecity", province: "Ontario", country: "Canada", zip: "K2P 1L4"}, shipping_address: {first_name: "Jane", last_name: "Smith", address1: "123 Fake Street", phone: "777-777-7777", city: "Fakecity", province: "Ontario", country: "Canada", zip: "K2P 1L4"}, transactions: [{kind: "sale", status: "success", amount: 50.0}], financial_status: "paid", discount_codes: [{code: "FAKE30", amount: "9.00", type: "percentage"}]} } + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-07/order_risk.test.ts b/src/rest-resources/__tests__/2021-07/order_risk.test.ts new file mode 100644 index 000000000..f33a5355f --- /dev/null +++ b/src/rest-resources/__tests__/2021-07/order_risk.test.ts @@ -0,0 +1,119 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {OrderRisk} from '../../2021-07'; + +describe('OrderRisk resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.July21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order_risk = new OrderRisk({session: test_session}); + order_risk.order_id = 450789469; + order_risk.message = "This order came from an anonymous proxy"; + order_risk.recommendation = "cancel"; + order_risk.score = 1.0; + order_risk.source = "External"; + order_risk.cause_cancel = true; + order_risk.display = true; + await order_risk.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/orders/450789469/risks.json', + query: '', + headers, + data: { "risk": {message: "This order came from an anonymous proxy", recommendation: "cancel", score: 1.0, source: "External", cause_cancel: true, display: true} } + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await OrderRisk.all({ + session: test_session, + order_id: 450789469, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/orders/450789469/risks.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await OrderRisk.find({ + session: test_session, + order_id: 450789469, + id: 284138680, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/orders/450789469/risks/284138680.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order_risk = new OrderRisk({session: test_session}); + order_risk.order_id = 450789469; + order_risk.id = 284138680; + order_risk.message = "After further review, this is a legitimate order"; + order_risk.recommendation = "accept"; + order_risk.source = "External"; + order_risk.cause_cancel = false; + order_risk.score = 0.0; + await order_risk.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/orders/450789469/risks/284138680.json', + query: '', + headers, + data: { "risk": {id: 284138680, message: "After further review, this is a legitimate order", recommendation: "accept", source: "External", cause_cancel: false, score: 0.0} } + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await OrderRisk.delete({ + session: test_session, + order_id: 450789469, + id: 284138680, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-07/orders/450789469/risks/284138680.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-07/page.test.ts b/src/rest-resources/__tests__/2021-07/page.test.ts new file mode 100644 index 000000000..585c329ba --- /dev/null +++ b/src/rest-resources/__tests__/2021-07/page.test.ts @@ -0,0 +1,268 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Page} from '../../2021-07'; + +describe('Page resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.July21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Page.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/pages.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Page.all({ + session: test_session, + since_id: "108828309", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/pages.json', + query: 'since_id=108828309', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const page = new Page({session: test_session}); + page.title = "Warranty information"; + page.body_html = "

Warranty

\n

Returns accepted if we receive items 30 days after purchase.

"; + await page.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/pages.json', + query: '', + headers, + data: { "page": {title: "Warranty information", body_html: "

Warranty

\n

Returns accepted if we receive items 30 days after purchase.

"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const page = new Page({session: test_session}); + page.title = "Warranty information"; + page.body_html = "

Warranty

\n

Returns accepted if we receive items 30 days after purchase.

"; + page.published = false; + await page.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/pages.json', + query: '', + headers, + data: { "page": {title: "Warranty information", body_html: "

Warranty

\n

Returns accepted if we receive items 30 days after purchase.

", published: false} } + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const page = new Page({session: test_session}); + page.title = "Warranty information"; + page.body_html = "

Warranty

\n

Returns accepted if we receive items 30 days after purchase.

"; + page.metafields = [ + { + key: "new", + value: "new value", + type: "single_line_text_field", + namespace: "global" + } + ]; + await page.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/pages.json', + query: '', + headers, + data: { "page": {title: "Warranty information", body_html: "

Warranty

\n

Returns accepted if we receive items 30 days after purchase.

", metafields: [{key: "new", value: "new value", type: "single_line_text_field", namespace: "global"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Page.count({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/pages/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Page.find({ + session: test_session, + id: 131092082, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/pages/131092082.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const page = new Page({session: test_session}); + page.id = 131092082; + page.body_html = "

Returns accepted if we receive the items 14 days after purchase.

"; + await page.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/pages/131092082.json', + query: '', + headers, + data: { "page": {id: 131092082, body_html: "

Returns accepted if we receive the items 14 days after purchase.

"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const page = new Page({session: test_session}); + page.id = 131092082; + page.body_html = "

Returns accepted if we receive the items 14 days after purchase.

"; + page.author = "Christopher Gorski"; + page.title = "New warranty"; + page.handle = "new-warranty"; + await page.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/pages/131092082.json', + query: '', + headers, + data: { "page": {id: 131092082, body_html: "

Returns accepted if we receive the items 14 days after purchase.

", author: "Christopher Gorski", title: "New warranty", handle: "new-warranty"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_10', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const page = new Page({session: test_session}); + page.id = 131092082; + page.published = true; + await page.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/pages/131092082.json', + query: '', + headers, + data: { "page": {id: 131092082, published: true} } + }).toMatchMadeHttpRequest(); + }); + + it('test_11', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const page = new Page({session: test_session}); + page.id = 131092082; + page.published = false; + await page.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/pages/131092082.json', + query: '', + headers, + data: { "page": {id: 131092082, published: false} } + }).toMatchMadeHttpRequest(); + }); + + it('test_12', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const page = new Page({session: test_session}); + page.id = 131092082; + page.metafields = [ + { + key: "new", + value: "new value", + type: "single_line_text_field", + namespace: "global" + } + ]; + await page.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/pages/131092082.json', + query: '', + headers, + data: { "page": {id: 131092082, metafields: [{key: "new", value: "new value", type: "single_line_text_field", namespace: "global"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_13', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Page.delete({ + session: test_session, + id: 131092082, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-07/pages/131092082.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-07/payment.test.ts b/src/rest-resources/__tests__/2021-07/payment.test.ts new file mode 100644 index 000000000..376cd37c9 --- /dev/null +++ b/src/rest-resources/__tests__/2021-07/payment.test.ts @@ -0,0 +1,116 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Payment} from '../../2021-07'; + +describe('Payment resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.July21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const payment = new Payment({session: test_session}); + payment.checkout_id = "7yjf4v2we7gamku6a6h7tvm8h3mmvs4x"; + payment.request_details = { + ip_address: "123.1.1.1", + accept_language: "en-US,en;q=0.8,fr;q=0.6", + user_agent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.98 Safari/537.36" + }; + payment.amount = "398.00"; + payment.session_id = "global-4f10a3a42a3b4d41"; + payment.unique_token = "client-side-idempotency-token"; + await payment.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/checkouts/7yjf4v2we7gamku6a6h7tvm8h3mmvs4x/payments.json', + query: '', + headers, + data: { "payment": {request_details: {ip_address: "123.1.1.1", accept_language: "en-US,en;q=0.8,fr;q=0.6", user_agent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.98 Safari/537.36"}, amount: "398.00", session_id: "global-4f10a3a42a3b4d41", unique_token: "client-side-idempotency-token"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Payment.all({ + session: test_session, + checkout_id: "7yjf4v2we7gamku6a6h7tvm8h3mmvs4x", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/checkouts/7yjf4v2we7gamku6a6h7tvm8h3mmvs4x/payments.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Payment.find({ + session: test_session, + checkout_id: "7yjf4v2we7gamku6a6h7tvm8h3mmvs4x", + id: 25428999, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/checkouts/7yjf4v2we7gamku6a6h7tvm8h3mmvs4x/payments/25428999.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Payment.find({ + session: test_session, + checkout_id: "7yjf4v2we7gamku6a6h7tvm8h3mmvs4x", + id: 25428999, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/checkouts/7yjf4v2we7gamku6a6h7tvm8h3mmvs4x/payments/25428999.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Payment.count({ + session: test_session, + checkout_id: "7yjf4v2we7gamku6a6h7tvm8h3mmvs4x", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/checkouts/7yjf4v2we7gamku6a6h7tvm8h3mmvs4x/payments/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-07/payment_gateway.test.ts b/src/rest-resources/__tests__/2021-07/payment_gateway.test.ts new file mode 100644 index 000000000..42dbe372a --- /dev/null +++ b/src/rest-resources/__tests__/2021-07/payment_gateway.test.ts @@ -0,0 +1,124 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {PaymentGateway} from '../../2021-07'; + +describe('PaymentGateway resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.July21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await PaymentGateway.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/payment_gateways.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await PaymentGateway.all({ + session: test_session, + disabled: "false", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/payment_gateways.json', + query: 'disabled=false', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const payment_gateway = new PaymentGateway({session: test_session}); + payment_gateway.credential1 = "someone@example.com"; + payment_gateway.provider_id = 7; + await payment_gateway.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/payment_gateways.json', + query: '', + headers, + data: { "payment_gateway": {credential1: "someone@example.com", provider_id: 7} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await PaymentGateway.find({ + session: test_session, + id: 431363653, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/payment_gateways/431363653.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const payment_gateway = new PaymentGateway({session: test_session}); + payment_gateway.id = 170508070; + payment_gateway.sandbox = true; + await payment_gateway.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/payment_gateways/170508070.json', + query: '', + headers, + data: { "payment_gateway": {id: 170508070, sandbox: true} } + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await PaymentGateway.delete({ + session: test_session, + id: 170508070, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-07/payment_gateways/170508070.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-07/payment_transaction.test.ts b/src/rest-resources/__tests__/2021-07/payment_transaction.test.ts new file mode 100644 index 000000000..35bdf8edd --- /dev/null +++ b/src/rest-resources/__tests__/2021-07/payment_transaction.test.ts @@ -0,0 +1,35 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {PaymentTransaction} from '../../2021-07'; + +describe('PaymentTransaction resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.July21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await PaymentTransaction.transactions({ + session: test_session, + payout_id: "623721858", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/shopify_payments/balance/transactions.json', + query: 'payout_id=623721858', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-07/payout.test.ts b/src/rest-resources/__tests__/2021-07/payout.test.ts new file mode 100644 index 000000000..a1d94ffad --- /dev/null +++ b/src/rest-resources/__tests__/2021-07/payout.test.ts @@ -0,0 +1,70 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Payout} from '../../2021-07'; + +describe('Payout resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.July21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Payout.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/shopify_payments/payouts.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Payout.all({ + session: test_session, + date_max: "2012-11-12", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/shopify_payments/payouts.json', + query: 'date_max=2012-11-12', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Payout.find({ + session: test_session, + id: 623721858, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/shopify_payments/payouts/623721858.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-07/policy.test.ts b/src/rest-resources/__tests__/2021-07/policy.test.ts new file mode 100644 index 000000000..252966e22 --- /dev/null +++ b/src/rest-resources/__tests__/2021-07/policy.test.ts @@ -0,0 +1,34 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Policy} from '../../2021-07'; + +describe('Policy resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.July21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Policy.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/policies.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-07/price_rule.test.ts b/src/rest-resources/__tests__/2021-07/price_rule.test.ts new file mode 100644 index 000000000..f83e34592 --- /dev/null +++ b/src/rest-resources/__tests__/2021-07/price_rule.test.ts @@ -0,0 +1,246 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {PriceRule} from '../../2021-07'; + +describe('PriceRule resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.July21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const price_rule = new PriceRule({session: test_session}); + price_rule.title = "SUMMERSALE10OFF"; + price_rule.target_type = "line_item"; + price_rule.target_selection = "all"; + price_rule.allocation_method = "across"; + price_rule.value_type = "fixed_amount"; + price_rule.value = "-10.0"; + price_rule.customer_selection = "all"; + price_rule.starts_at = "2017-01-19T17:59:10Z"; + await price_rule.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/price_rules.json', + query: '', + headers, + data: { "price_rule": {title: "SUMMERSALE10OFF", target_type: "line_item", target_selection: "all", allocation_method: "across", value_type: "fixed_amount", value: "-10.0", customer_selection: "all", starts_at: "2017-01-19T17:59:10Z"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const price_rule = new PriceRule({session: test_session}); + price_rule.title = "15OFFCOLLECTION"; + price_rule.target_type = "line_item"; + price_rule.target_selection = "entitled"; + price_rule.allocation_method = "across"; + price_rule.value_type = "percentage"; + price_rule.value = "-15.0"; + price_rule.customer_selection = "all"; + price_rule.entitled_collection_ids = [ + 841564295 + ]; + price_rule.starts_at = "2017-01-19T17:59:10Z"; + await price_rule.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/price_rules.json', + query: '', + headers, + data: { "price_rule": {title: "15OFFCOLLECTION", target_type: "line_item", target_selection: "entitled", allocation_method: "across", value_type: "percentage", value: "-15.0", customer_selection: "all", entitled_collection_ids: [841564295], starts_at: "2017-01-19T17:59:10Z"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const price_rule = new PriceRule({session: test_session}); + price_rule.title = "FREESHIPPING"; + price_rule.target_type = "shipping_line"; + price_rule.target_selection = "all"; + price_rule.allocation_method = "each"; + price_rule.value_type = "percentage"; + price_rule.value = "-100.0"; + price_rule.usage_limit = 20; + price_rule.customer_selection = "all"; + price_rule.prerequisite_subtotal_range = { + greater_than_or_equal_to: "50.0" + }; + price_rule.starts_at = "2017-01-19T17:59:10Z"; + await price_rule.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/price_rules.json', + query: '', + headers, + data: { "price_rule": {title: "FREESHIPPING", target_type: "shipping_line", target_selection: "all", allocation_method: "each", value_type: "percentage", value: "-100.0", usage_limit: 20, customer_selection: "all", prerequisite_subtotal_range: {greater_than_or_equal_to: "50.0"}, starts_at: "2017-01-19T17:59:10Z"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const price_rule = new PriceRule({session: test_session}); + price_rule.title = "5OFFCUSTOMERGROUP"; + price_rule.target_type = "line_item"; + price_rule.target_selection = "all"; + price_rule.allocation_method = "across"; + price_rule.value_type = "fixed_amount"; + price_rule.value = "-5.0"; + price_rule.customer_selection = "prerequisite"; + price_rule.prerequisite_saved_search_ids = [ + 789629109 + ]; + price_rule.starts_at = "2017-01-19T17:59:10Z"; + await price_rule.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/price_rules.json', + query: '', + headers, + data: { "price_rule": {title: "5OFFCUSTOMERGROUP", target_type: "line_item", target_selection: "all", allocation_method: "across", value_type: "fixed_amount", value: "-5.0", customer_selection: "prerequisite", prerequisite_saved_search_ids: [789629109], starts_at: "2017-01-19T17:59:10Z"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const price_rule = new PriceRule({session: test_session}); + price_rule.title = "Buy2iPodsGetiPodTouchForFree"; + price_rule.value_type = "percentage"; + price_rule.value = "-100.0"; + price_rule.customer_selection = "all"; + price_rule.target_type = "line_item"; + price_rule.target_selection = "entitled"; + price_rule.allocation_method = "each"; + price_rule.starts_at = "2018-03-22T00:00:00-00:00"; + price_rule.prerequisite_collection_ids = [ + 841564295 + ]; + price_rule.entitled_product_ids = [ + 921728736 + ]; + price_rule.prerequisite_to_entitlement_quantity_ratio = { + prerequisite_quantity: 2, + entitled_quantity: 1 + }; + price_rule.allocation_limit = 3; + await price_rule.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/price_rules.json', + query: '', + headers, + data: { "price_rule": {title: "Buy2iPodsGetiPodTouchForFree", value_type: "percentage", value: "-100.0", customer_selection: "all", target_type: "line_item", target_selection: "entitled", allocation_method: "each", starts_at: "2018-03-22T00:00:00-00:00", prerequisite_collection_ids: [841564295], entitled_product_ids: [921728736], prerequisite_to_entitlement_quantity_ratio: {prerequisite_quantity: 2, entitled_quantity: 1}, allocation_limit: 3} } + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await PriceRule.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/price_rules.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const price_rule = new PriceRule({session: test_session}); + price_rule.id = 507328175; + price_rule.title = "WINTER SALE"; + await price_rule.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/price_rules/507328175.json', + query: '', + headers, + data: { "price_rule": {id: 507328175, title: "WINTER SALE"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await PriceRule.find({ + session: test_session, + id: 507328175, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/price_rules/507328175.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await PriceRule.delete({ + session: test_session, + id: 507328175, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-07/price_rules/507328175.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_10', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await PriceRule.count({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/price_rules/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-07/product.test.ts b/src/rest-resources/__tests__/2021-07/product.test.ts new file mode 100644 index 000000000..db7a62cb0 --- /dev/null +++ b/src/rest-resources/__tests__/2021-07/product.test.ts @@ -0,0 +1,738 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Product} from '../../2021-07'; + +describe('Product resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.July21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Product.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/products.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Product.all({ + session: test_session, + ids: "632910392,921728736", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/products.json', + query: 'ids=632910392%2C921728736', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Product.all({ + session: test_session, + fields: "id,images,title", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/products.json', + query: 'fields=id%2Cimages%2Ctitle', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Product.all({ + session: test_session, + collection_id: "841564295", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/products.json', + query: 'collection_id=841564295', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Product.all({ + session: test_session, + since_id: "632910392", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/products.json', + query: 'since_id=632910392', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Product.all({ + session: test_session, + presentment_currencies: "USD", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/products.json', + query: 'presentment_currencies=USD', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product = new Product({session: test_session}); + product.title = "Burton Custom Freestyle 151"; + product.body_html = "Good snowboard!"; + product.vendor = "Burton"; + product.product_type = "Snowboard"; + product.tags = [ + "Barnes & Noble", + "Big Air", + "John's Fav" + ]; + await product.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/products.json', + query: '', + headers, + data: { "product": {title: "Burton Custom Freestyle 151", body_html: "Good snowboard!", vendor: "Burton", product_type: "Snowboard", tags: ["Barnes & Noble", "Big Air", "John's Fav"]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product = new Product({session: test_session}); + product.title = "Burton Custom Freestyle 151"; + product.body_html = "Good snowboard!"; + product.vendor = "Burton"; + product.product_type = "Snowboard"; + product.published = false; + await product.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/products.json', + query: '', + headers, + data: { "product": {title: "Burton Custom Freestyle 151", body_html: "Good snowboard!", vendor: "Burton", product_type: "Snowboard", published: false} } + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product = new Product({session: test_session}); + product.title = "Burton Custom Freestyle 151"; + product.body_html = "Good snowboard!"; + product.vendor = "Burton"; + product.product_type = "Snowboard"; + product.status = "draft"; + await product.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/products.json', + query: '', + headers, + data: { "product": {title: "Burton Custom Freestyle 151", body_html: "Good snowboard!", vendor: "Burton", product_type: "Snowboard", status: "draft"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_10', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product = new Product({session: test_session}); + product.title = "Burton Custom Freestyle 151"; + product.body_html = "Good snowboard!"; + product.vendor = "Burton"; + product.product_type = "Snowboard"; + product.variants = [ + { + option1: "First", + price: "10.00", + sku: "123" + }, + { + option1: "Second", + price: "20.00", + sku: "123" + } + ]; + await product.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/products.json', + query: '', + headers, + data: { "product": {title: "Burton Custom Freestyle 151", body_html: "Good snowboard!", vendor: "Burton", product_type: "Snowboard", variants: [{option1: "First", price: "10.00", sku: "123"}, {option1: "Second", price: "20.00", sku: "123"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_11', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product = new Product({session: test_session}); + product.title = "Burton Custom Freestyle 151"; + product.body_html = "Good snowboard!"; + product.vendor = "Burton"; + product.product_type = "Snowboard"; + product.variants = [ + { + option1: "Blue", + option2: "155" + }, + { + option1: "Black", + option2: "159" + } + ]; + product.options = [ + { + name: "Color", + values: [ + "Blue", + "Black" + ] + }, + { + name: "Size", + values: [ + "155", + "159" + ] + } + ]; + await product.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/products.json', + query: '', + headers, + data: { "product": {title: "Burton Custom Freestyle 151", body_html: "Good snowboard!", vendor: "Burton", product_type: "Snowboard", variants: [{option1: "Blue", option2: "155"}, {option1: "Black", option2: "159"}], options: [{name: "Color", values: ["Blue", "Black"]}, {name: "Size", values: ["155", "159"]}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_12', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product = new Product({session: test_session}); + product.title = "Burton Custom Freestyle 151"; + product.body_html = "Good snowboard!"; + product.vendor = "Burton"; + product.product_type = "Snowboard"; + product.images = [ + { + attachment: "R0lGODlhAQABAIAAAAAAAAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==\n" + } + ]; + await product.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/products.json', + query: '', + headers, + data: { "product": {title: "Burton Custom Freestyle 151", body_html: "Good snowboard!", vendor: "Burton", product_type: "Snowboard", images: [{attachment: "R0lGODlhAQABAIAAAAAAAAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==\n"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_13', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product = new Product({session: test_session}); + product.title = "Burton Custom Freestyle 151"; + product.body_html = "Good snowboard!"; + product.vendor = "Burton"; + product.product_type = "Snowboard"; + product.images = [ + { + src: "http://example.com/rails_logo.gif" + } + ]; + await product.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/products.json', + query: '', + headers, + data: { "product": {title: "Burton Custom Freestyle 151", body_html: "Good snowboard!", vendor: "Burton", product_type: "Snowboard", images: [{src: "http://example.com/rails_logo.gif"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_14', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product = new Product({session: test_session}); + product.title = "Burton Custom Freestyle 151"; + product.body_html = "Good snowboard!"; + product.vendor = "Burton"; + product.product_type = "Snowboard"; + product.metafields_global_title_tag = "Product SEO Title"; + product.metafields_global_description_tag = "Product SEO Description"; + await product.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/products.json', + query: '', + headers, + data: { "product": {title: "Burton Custom Freestyle 151", body_html: "Good snowboard!", vendor: "Burton", product_type: "Snowboard", metafields_global_title_tag: "Product SEO Title", metafields_global_description_tag: "Product SEO Description"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_15', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product = new Product({session: test_session}); + product.title = "Burton Custom Freestyle 151"; + product.body_html = "Good snowboard!"; + product.vendor = "Burton"; + product.product_type = "Snowboard"; + product.metafields = [ + { + key: "new", + value: "newvalue", + type: "single_line_text_field", + namespace: "global" + } + ]; + await product.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/products.json', + query: '', + headers, + data: { "product": {title: "Burton Custom Freestyle 151", body_html: "Good snowboard!", vendor: "Burton", product_type: "Snowboard", metafields: [{key: "new", value: "newvalue", type: "single_line_text_field", namespace: "global"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_16', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Product.count({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/products/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_17', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Product.count({ + session: test_session, + collection_id: "841564295", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/products/count.json', + query: 'collection_id=841564295', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_18', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Product.find({ + session: test_session, + id: 632910392, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/products/632910392.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_19', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Product.find({ + session: test_session, + id: 632910392, + fields: "id,images,title", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/products/632910392.json', + query: 'fields=id%2Cimages%2Ctitle', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_20', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product = new Product({session: test_session}); + product.id = 632910392; + product.title = "New product title"; + await product.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/products/632910392.json', + query: '', + headers, + data: { "product": {id: 632910392, title: "New product title"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_21', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product = new Product({session: test_session}); + product.id = 632910392; + product.status = "draft"; + await product.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/products/632910392.json', + query: '', + headers, + data: { "product": {id: 632910392, status: "draft"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_22', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product = new Product({session: test_session}); + product.id = 632910392; + product.tags = "Barnes & Noble, John's Fav"; + await product.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/products/632910392.json', + query: '', + headers, + data: { "product": {id: 632910392, tags: "Barnes & Noble, John's Fav"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_23', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product = new Product({session: test_session}); + product.id = 632910392; + product.images = []; + await product.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/products/632910392.json', + query: '', + headers, + data: { "product": {id: 632910392, images: []} } + }).toMatchMadeHttpRequest(); + }); + + it('test_24', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product = new Product({session: test_session}); + product.id = 632910392; + product.images = [ + { + id: 850703190 + }, + { + id: 562641783 + }, + { + id: 378407906 + }, + { + src: "http://example.com/rails_logo.gif" + } + ]; + await product.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/products/632910392.json', + query: '', + headers, + data: { "product": {id: 632910392, images: [{id: 850703190}, {id: 562641783}, {id: 378407906}, {src: "http://example.com/rails_logo.gif"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_25', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product = new Product({session: test_session}); + product.id = 632910392; + product.images = [ + { + id: 850703190, + position: 3 + }, + { + id: 562641783, + position: 2 + }, + { + id: 378407906, + position: 1 + } + ]; + await product.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/products/632910392.json', + query: '', + headers, + data: { "product": {id: 632910392, images: [{id: 850703190, position: 3}, {id: 562641783, position: 2}, {id: 378407906, position: 1}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_26', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product = new Product({session: test_session}); + product.id = 632910392; + product.variants = [ + { + id: 457924702 + }, + { + id: 39072856 + }, + { + id: 49148385 + }, + { + id: 808950810 + } + ]; + await product.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/products/632910392.json', + query: '', + headers, + data: { "product": {id: 632910392, variants: [{id: 457924702}, {id: 39072856}, {id: 49148385}, {id: 808950810}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_27', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product = new Product({session: test_session}); + product.id = 632910392; + product.title = "Updated Product Title"; + product.variants = [ + { + id: 808950810, + price: "2000.00", + sku: "Updating the Product SKU" + }, + { + id: 49148385 + }, + { + id: 39072856 + }, + { + id: 457924702 + } + ]; + await product.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/products/632910392.json', + query: '', + headers, + data: { "product": {id: 632910392, title: "Updated Product Title", variants: [{id: 808950810, price: "2000.00", sku: "Updating the Product SKU"}, {id: 49148385}, {id: 39072856}, {id: 457924702}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_28', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product = new Product({session: test_session}); + product.id = 632910392; + product.metafields_global_title_tag = "Brand new title"; + product.metafields_global_description_tag = "Brand new description"; + await product.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/products/632910392.json', + query: '', + headers, + data: { "product": {id: 632910392, metafields_global_title_tag: "Brand new title", metafields_global_description_tag: "Brand new description"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_29', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product = new Product({session: test_session}); + product.id = 632910392; + product.published = true; + await product.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/products/632910392.json', + query: '', + headers, + data: { "product": {id: 632910392, published: true} } + }).toMatchMadeHttpRequest(); + }); + + it('test_30', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product = new Product({session: test_session}); + product.id = 632910392; + product.published = false; + await product.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/products/632910392.json', + query: '', + headers, + data: { "product": {id: 632910392, published: false} } + }).toMatchMadeHttpRequest(); + }); + + it('test_31', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product = new Product({session: test_session}); + product.id = 632910392; + product.metafields = [ + { + key: "new", + value: "newvalue", + type: "single_line_text_field", + namespace: "global" + } + ]; + await product.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/products/632910392.json', + query: '', + headers, + data: { "product": {id: 632910392, metafields: [{key: "new", value: "newvalue", type: "single_line_text_field", namespace: "global"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_32', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Product.delete({ + session: test_session, + id: 632910392, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-07/products/632910392.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-07/product_listing.test.ts b/src/rest-resources/__tests__/2021-07/product_listing.test.ts new file mode 100644 index 000000000..1a972b92c --- /dev/null +++ b/src/rest-resources/__tests__/2021-07/product_listing.test.ts @@ -0,0 +1,121 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {ProductListing} from '../../2021-07'; + +describe('ProductListing resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.July21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await ProductListing.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/product_listings.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await ProductListing.product_ids({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/product_listings/product_ids.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await ProductListing.count({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/product_listings/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await ProductListing.find({ + session: test_session, + product_id: 921728736, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/product_listings/921728736.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product_listing = new ProductListing({session: test_session}); + product_listing.product_id = 921728736; + await product_listing.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/product_listings/921728736.json', + query: '', + headers, + data: { "product_listing": {product_id: 921728736} } + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await ProductListing.delete({ + session: test_session, + product_id: 921728736, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-07/product_listings/921728736.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-07/product_resource_feedback.test.ts b/src/rest-resources/__tests__/2021-07/product_resource_feedback.test.ts new file mode 100644 index 000000000..1cc28981c --- /dev/null +++ b/src/rest-resources/__tests__/2021-07/product_resource_feedback.test.ts @@ -0,0 +1,78 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {ProductResourceFeedback} from '../../2021-07'; + +describe('ProductResourceFeedback resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.July21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product_resource_feedback = new ProductResourceFeedback({session: test_session}); + product_resource_feedback.product_id = 632910392; + product_resource_feedback.state = "requires_action"; + product_resource_feedback.messages = [ + "Needs at least one image." + ]; + product_resource_feedback.resource_updated_at = "2022-02-03T16:53:36-05:00"; + product_resource_feedback.feedback_generated_at = "2022-02-03T22:11:14.477009Z"; + await product_resource_feedback.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/products/632910392/resource_feedback.json', + query: '', + headers, + data: { "resource_feedback": {state: "requires_action", messages: ["Needs at least one image."], resource_updated_at: "2022-02-03T16:53:36-05:00", feedback_generated_at: "2022-02-03T22:11:14.477009Z"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product_resource_feedback = new ProductResourceFeedback({session: test_session}); + product_resource_feedback.product_id = 632910392; + product_resource_feedback.state = "success"; + product_resource_feedback.resource_updated_at = "2022-02-03T16:53:36-05:00"; + product_resource_feedback.feedback_generated_at = "2022-02-03T22:11:15.898793Z"; + await product_resource_feedback.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/products/632910392/resource_feedback.json', + query: '', + headers, + data: { "resource_feedback": {state: "success", resource_updated_at: "2022-02-03T16:53:36-05:00", feedback_generated_at: "2022-02-03T22:11:15.898793Z"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await ProductResourceFeedback.all({ + session: test_session, + product_id: 632910392, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/products/632910392/resource_feedback.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-07/province.test.ts b/src/rest-resources/__tests__/2021-07/province.test.ts new file mode 100644 index 000000000..e553dea8d --- /dev/null +++ b/src/rest-resources/__tests__/2021-07/province.test.ts @@ -0,0 +1,110 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Province} from '../../2021-07'; + +describe('Province resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.July21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Province.all({ + session: test_session, + country_id: 879921427, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/countries/879921427/provinces.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Province.all({ + session: test_session, + country_id: 879921427, + since_id: "536137098", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/countries/879921427/provinces.json', + query: 'since_id=536137098', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Province.count({ + session: test_session, + country_id: 879921427, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/countries/879921427/provinces/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Province.find({ + session: test_session, + country_id: 879921427, + id: 224293623, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/countries/879921427/provinces/224293623.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const province = new Province({session: test_session}); + province.country_id = 879921427; + province.id = 224293623; + province.tax = 0.09; + await province.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/countries/879921427/provinces/224293623.json', + query: '', + headers, + data: { "province": {id: 224293623, tax: 0.09} } + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-07/recurring_application_charge.test.ts b/src/rest-resources/__tests__/2021-07/recurring_application_charge.test.ts new file mode 100644 index 000000000..4377968af --- /dev/null +++ b/src/rest-resources/__tests__/2021-07/recurring_application_charge.test.ts @@ -0,0 +1,187 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {RecurringApplicationCharge} from '../../2021-07'; + +describe('RecurringApplicationCharge resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.July21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const recurring_application_charge = new RecurringApplicationCharge({session: test_session}); + recurring_application_charge.name = "Super Duper Plan"; + recurring_application_charge.price = 10.0; + recurring_application_charge.return_url = "http://super-duper.shopifyapps.com"; + await recurring_application_charge.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/recurring_application_charges.json', + query: '', + headers, + data: { "recurring_application_charge": {name: "Super Duper Plan", price: 10.0, return_url: "http://super-duper.shopifyapps.com"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const recurring_application_charge = new RecurringApplicationCharge({session: test_session}); + recurring_application_charge.name = "Super Duper Plan"; + recurring_application_charge.price = 10.0; + recurring_application_charge.return_url = "http://super-duper.shopifyapps.com"; + recurring_application_charge.capped_amount = 100; + recurring_application_charge.terms = "$1 for 1000 emails"; + await recurring_application_charge.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/recurring_application_charges.json', + query: '', + headers, + data: { "recurring_application_charge": {name: "Super Duper Plan", price: 10.0, return_url: "http://super-duper.shopifyapps.com", capped_amount: 100, terms: "$1 for 1000 emails"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const recurring_application_charge = new RecurringApplicationCharge({session: test_session}); + recurring_application_charge.name = "Super Duper Plan"; + recurring_application_charge.price = 10.0; + recurring_application_charge.return_url = "http://super-duper.shopifyapps.com"; + recurring_application_charge.trial_days = 5; + await recurring_application_charge.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/recurring_application_charges.json', + query: '', + headers, + data: { "recurring_application_charge": {name: "Super Duper Plan", price: 10.0, return_url: "http://super-duper.shopifyapps.com", trial_days: 5} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const recurring_application_charge = new RecurringApplicationCharge({session: test_session}); + recurring_application_charge.name = "Super Duper Plan"; + recurring_application_charge.price = 10.0; + recurring_application_charge.return_url = "http://super-duper.shopifyapps.com"; + recurring_application_charge.test = true; + await recurring_application_charge.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/recurring_application_charges.json', + query: '', + headers, + data: { "recurring_application_charge": {name: "Super Duper Plan", price: 10.0, return_url: "http://super-duper.shopifyapps.com", test: true} } + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await RecurringApplicationCharge.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/recurring_application_charges.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await RecurringApplicationCharge.all({ + session: test_session, + since_id: "455696195", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/recurring_application_charges.json', + query: 'since_id=455696195', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await RecurringApplicationCharge.find({ + session: test_session, + id: 455696195, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/recurring_application_charges/455696195.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await RecurringApplicationCharge.delete({ + session: test_session, + id: 455696195, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-07/recurring_application_charges/455696195.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const recurring_application_charge = new RecurringApplicationCharge({session: test_session}); + recurring_application_charge.id = 455696195; + await recurring_application_charge.customize({ + recurring_application_charge: {capped_amount: "200"}, + }); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/recurring_application_charges/455696195/customize.json', + query: 'recurring_application_charge%5Bcapped_amount%5D=200', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-07/redirect.test.ts b/src/rest-resources/__tests__/2021-07/redirect.test.ts new file mode 100644 index 000000000..6c5a5dfef --- /dev/null +++ b/src/rest-resources/__tests__/2021-07/redirect.test.ts @@ -0,0 +1,196 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Redirect} from '../../2021-07'; + +describe('Redirect resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.July21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Redirect.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/redirects.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Redirect.all({ + session: test_session, + since_id: "668809255", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/redirects.json', + query: 'since_id=668809255', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const redirect = new Redirect({session: test_session}); + redirect.path = "/ipod"; + redirect.target = "/pages/itunes"; + await redirect.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/redirects.json', + query: '', + headers, + data: { "redirect": {path: "/ipod", target: "/pages/itunes"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const redirect = new Redirect({session: test_session}); + redirect.path = "http://www.apple.com/forums"; + redirect.target = "http://forums.apple.com"; + await redirect.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/redirects.json', + query: '', + headers, + data: { "redirect": {path: "http://www.apple.com/forums", target: "http://forums.apple.com"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Redirect.count({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/redirects/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Redirect.find({ + session: test_session, + id: 668809255, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/redirects/668809255.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const redirect = new Redirect({session: test_session}); + redirect.id = 668809255; + redirect.path = "/tiger"; + await redirect.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/redirects/668809255.json', + query: '', + headers, + data: { "redirect": {id: 668809255, path: "/tiger"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const redirect = new Redirect({session: test_session}); + redirect.id = 668809255; + redirect.target = "/pages/macpro"; + await redirect.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/redirects/668809255.json', + query: '', + headers, + data: { "redirect": {id: 668809255, target: "/pages/macpro"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const redirect = new Redirect({session: test_session}); + redirect.id = 950115854; + redirect.path = "/powermac"; + redirect.target = "/pages/macpro"; + await redirect.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/redirects/950115854.json', + query: '', + headers, + data: { "redirect": {id: 950115854, path: "/powermac", target: "/pages/macpro"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_10', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Redirect.delete({ + session: test_session, + id: 668809255, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-07/redirects/668809255.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-07/refund.test.ts b/src/rest-resources/__tests__/2021-07/refund.test.ts new file mode 100644 index 000000000..952f615f7 --- /dev/null +++ b/src/rest-resources/__tests__/2021-07/refund.test.ts @@ -0,0 +1,179 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Refund} from '../../2021-07'; + +describe('Refund resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.July21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Refund.all({ + session: test_session, + order_id: 450789469, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/orders/450789469/refunds.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const refund = new Refund({session: test_session}); + refund.order_id = 450789469; + refund.currency = "USD"; + refund.notify = true; + refund.note = "wrong size"; + refund.shipping = { + full_refund: true + }; + refund.refund_line_items = [ + { + line_item_id: 518995019, + quantity: 1, + restock_type: "return", + location_id: 487838322 + } + ]; + refund.transactions = [ + { + parent_id: 801038806, + amount: 41.94, + kind: "refund", + gateway: "bogus" + } + ]; + await refund.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/orders/450789469/refunds.json', + query: '', + headers, + data: { "refund": {currency: "USD", notify: true, note: "wrong size", shipping: {full_refund: true}, refund_line_items: [{line_item_id: 518995019, quantity: 1, restock_type: "return", location_id: 487838322}], transactions: [{parent_id: 801038806, amount: 41.94, kind: "refund", gateway: "bogus"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const refund = new Refund({session: test_session}); + refund.order_id = 450789469; + refund.currency = "USD"; + refund.shipping = { + amount: 5.0 + }; + refund.transactions = [ + { + parent_id: 801038806, + amount: 5.0, + kind: "refund", + gateway: "bogus" + } + ]; + await refund.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/orders/450789469/refunds.json', + query: '', + headers, + data: { "refund": {currency: "USD", shipping: {amount: 5.0}, transactions: [{parent_id: 801038806, amount: 5.0, kind: "refund", gateway: "bogus"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Refund.find({ + session: test_session, + order_id: 450789469, + id: 509562969, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/orders/450789469/refunds/509562969.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const refund = new Refund({session: test_session}); + refund.order_id = 450789469; + await refund.calculate({ + body: {refund: {shipping: {full_refund: true}, refund_line_items: [{line_item_id: 518995019, quantity: 1, restock_type: "no_restock"}]}}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/orders/450789469/refunds/calculate.json', + query: '', + headers, + data: { "refund": {shipping: {full_refund: true}, refund_line_items: [{line_item_id: 518995019, quantity: 1, restock_type: "no_restock"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const refund = new Refund({session: test_session}); + refund.order_id = 450789469; + await refund.calculate({ + body: {refund: {currency: "USD", shipping: {full_refund: true}, refund_line_items: [{line_item_id: 518995019, quantity: 1, restock_type: "no_restock"}]}}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/orders/450789469/refunds/calculate.json', + query: '', + headers, + data: { "refund": {currency: "USD", shipping: {full_refund: true}, refund_line_items: [{line_item_id: 518995019, quantity: 1, restock_type: "no_restock"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const refund = new Refund({session: test_session}); + refund.order_id = 450789469; + await refund.calculate({ + body: {refund: {currency: "USD", shipping: {amount: 2.0}}}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/orders/450789469/refunds/calculate.json', + query: '', + headers, + data: { "refund": {currency: "USD", shipping: {amount: 2.0}} } + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-07/report.test.ts b/src/rest-resources/__tests__/2021-07/report.test.ts new file mode 100644 index 000000000..702a5763a --- /dev/null +++ b/src/rest-resources/__tests__/2021-07/report.test.ts @@ -0,0 +1,198 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Report} from '../../2021-07'; + +describe('Report resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.July21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Report.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/reports.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Report.all({ + session: test_session, + ids: "517154478", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/reports.json', + query: 'ids=517154478', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Report.all({ + session: test_session, + updated_at_min: "2005-07-31 15:57:11 EDT -04:00", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/reports.json', + query: 'updated_at_min=2005-07-31+15%3A57%3A11+EDT+-04%3A00', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Report.all({ + session: test_session, + fields: "id,shopify_ql", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/reports.json', + query: 'fields=id%2Cshopify_ql', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Report.all({ + session: test_session, + since_id: "123", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/reports.json', + query: 'since_id=123', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const report = new Report({session: test_session}); + report.name = "A new app report"; + report.shopify_ql = "SHOW total_sales BY order_id FROM sales SINCE -1m UNTIL today ORDER BY total_sales"; + await report.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/reports.json', + query: '', + headers, + data: { "report": {name: "A new app report", shopify_ql: "SHOW total_sales BY order_id FROM sales SINCE -1m UNTIL today ORDER BY total_sales"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Report.find({ + session: test_session, + id: 517154478, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/reports/517154478.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Report.find({ + session: test_session, + id: 517154478, + fields: "id,shopify_ql", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/reports/517154478.json', + query: 'fields=id%2Cshopify_ql', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const report = new Report({session: test_session}); + report.id = 517154478; + report.name = "Changed Report Name"; + report.shopify_ql = "SHOW total_sales BY order_id FROM sales SINCE -12m UNTIL today ORDER BY total_sales"; + await report.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/reports/517154478.json', + query: '', + headers, + data: { "report": {id: 517154478, name: "Changed Report Name", shopify_ql: "SHOW total_sales BY order_id FROM sales SINCE -12m UNTIL today ORDER BY total_sales"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_10', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Report.delete({ + session: test_session, + id: 517154478, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-07/reports/517154478.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-07/resource_feedback.test.ts b/src/rest-resources/__tests__/2021-07/resource_feedback.test.ts new file mode 100644 index 000000000..50fcf85d8 --- /dev/null +++ b/src/rest-resources/__tests__/2021-07/resource_feedback.test.ts @@ -0,0 +1,73 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {ResourceFeedback} from '../../2021-07'; + +describe('ResourceFeedback resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.July21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const resource_feedback = new ResourceFeedback({session: test_session}); + resource_feedback.state = "requires_action"; + resource_feedback.messages = [ + "is not connected. Connect your account to use this sales channel." + ]; + resource_feedback.feedback_generated_at = "2022-02-03T22:00:23.179942Z"; + await resource_feedback.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/resource_feedback.json', + query: '', + headers, + data: { "resource_feedback": {state: "requires_action", messages: ["is not connected. Connect your account to use this sales channel."], feedback_generated_at: "2022-02-03T22:00:23.179942Z"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const resource_feedback = new ResourceFeedback({session: test_session}); + resource_feedback.state = "success"; + resource_feedback.feedback_generated_at = "2022-02-03T22:00:24.490026Z"; + await resource_feedback.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/resource_feedback.json', + query: '', + headers, + data: { "resource_feedback": {state: "success", feedback_generated_at: "2022-02-03T22:00:24.490026Z"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await ResourceFeedback.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/resource_feedback.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-07/script_tag.test.ts b/src/rest-resources/__tests__/2021-07/script_tag.test.ts new file mode 100644 index 000000000..9277fd883 --- /dev/null +++ b/src/rest-resources/__tests__/2021-07/script_tag.test.ts @@ -0,0 +1,159 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {ScriptTag} from '../../2021-07'; + +describe('ScriptTag resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.July21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await ScriptTag.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/script_tags.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await ScriptTag.all({ + session: test_session, + src: "https://js-aplenty.com/foo.js", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/script_tags.json', + query: 'src=https%3A%2F%2Fjs-aplenty.com%2Ffoo.js', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await ScriptTag.all({ + session: test_session, + since_id: "421379493", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/script_tags.json', + query: 'since_id=421379493', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const script_tag = new ScriptTag({session: test_session}); + script_tag.event = "onload"; + script_tag.src = "https://djavaskripped.org/fancy.js"; + await script_tag.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/script_tags.json', + query: '', + headers, + data: { "script_tag": {event: "onload", src: "https://djavaskripped.org/fancy.js"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await ScriptTag.count({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/script_tags/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await ScriptTag.find({ + session: test_session, + id: 596726825, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/script_tags/596726825.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const script_tag = new ScriptTag({session: test_session}); + script_tag.id = 596726825; + script_tag.src = "https://somewhere-else.com/another.js"; + await script_tag.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/script_tags/596726825.json', + query: '', + headers, + data: { "script_tag": {id: 596726825, src: "https://somewhere-else.com/another.js"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await ScriptTag.delete({ + session: test_session, + id: 596726825, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-07/script_tags/596726825.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-07/shipping_zone.test.ts b/src/rest-resources/__tests__/2021-07/shipping_zone.test.ts new file mode 100644 index 000000000..2ac23a36a --- /dev/null +++ b/src/rest-resources/__tests__/2021-07/shipping_zone.test.ts @@ -0,0 +1,34 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {ShippingZone} from '../../2021-07'; + +describe('ShippingZone resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.July21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await ShippingZone.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/shipping_zones.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-07/shop.test.ts b/src/rest-resources/__tests__/2021-07/shop.test.ts new file mode 100644 index 000000000..507718423 --- /dev/null +++ b/src/rest-resources/__tests__/2021-07/shop.test.ts @@ -0,0 +1,52 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Shop} from '../../2021-07'; + +describe('Shop resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.July21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Shop.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/shop.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Shop.all({ + session: test_session, + fields: "address1,address2,city,province,country", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/shop.json', + query: 'fields=address1%2Caddress2%2Ccity%2Cprovince%2Ccountry', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-07/smart_collection.test.ts b/src/rest-resources/__tests__/2021-07/smart_collection.test.ts new file mode 100644 index 000000000..fa1f658a4 --- /dev/null +++ b/src/rest-resources/__tests__/2021-07/smart_collection.test.ts @@ -0,0 +1,456 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {SmartCollection} from '../../2021-07'; + +describe('SmartCollection resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.July21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await SmartCollection.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/smart_collections.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await SmartCollection.all({ + session: test_session, + since_id: "482865238", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/smart_collections.json', + query: 'since_id=482865238', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await SmartCollection.all({ + session: test_session, + product_id: "632910392", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/smart_collections.json', + query: 'product_id=632910392', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await SmartCollection.all({ + session: test_session, + ids: "482865238,1063001375", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/smart_collections.json', + query: 'ids=482865238%2C1063001375', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const smart_collection = new SmartCollection({session: test_session}); + smart_collection.title = "IPods"; + smart_collection.rules = [ + { + column: "title", + relation: "starts_with", + condition: "iPod" + } + ]; + await smart_collection.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/smart_collections.json', + query: '', + headers, + data: { "smart_collection": {title: "IPods", rules: [{column: "title", relation: "starts_with", condition: "iPod"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const smart_collection = new SmartCollection({session: test_session}); + smart_collection.title = "Macbooks"; + smart_collection.rules = [ + { + column: "vendor", + relation: "equals", + condition: "Apple" + } + ]; + await smart_collection.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/smart_collections.json', + query: '', + headers, + data: { "smart_collection": {title: "Macbooks", rules: [{column: "vendor", relation: "equals", condition: "Apple"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const smart_collection = new SmartCollection({session: test_session}); + smart_collection.title = "Macbooks"; + smart_collection.rules = [ + { + column: "vendor", + relation: "equals", + condition: "Apple" + } + ]; + smart_collection.published = false; + await smart_collection.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/smart_collections.json', + query: '', + headers, + data: { "smart_collection": {title: "Macbooks", rules: [{column: "vendor", relation: "equals", condition: "Apple"}], published: false} } + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const smart_collection = new SmartCollection({session: test_session}); + smart_collection.title = "Macbooks"; + smart_collection.rules = [ + { + column: "vendor", + relation: "equals", + condition: "Apple" + } + ]; + smart_collection.image = { + attachment: "R0lGODlhAQABAIAAAAAAAAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==\n", + alt: "iPod" + }; + await smart_collection.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/smart_collections.json', + query: '', + headers, + data: { "smart_collection": {title: "Macbooks", rules: [{column: "vendor", relation: "equals", condition: "Apple"}], image: {attachment: "R0lGODlhAQABAIAAAAAAAAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==\n", alt: "iPod"}} } + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const smart_collection = new SmartCollection({session: test_session}); + smart_collection.title = "Macbooks"; + smart_collection.rules = [ + { + column: "vendor", + relation: "equals", + condition: "Apple" + } + ]; + smart_collection.image = { + src: "http://example.com/rails_logo.gif", + alt: "Rails Logo" + }; + await smart_collection.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/smart_collections.json', + query: '', + headers, + data: { "smart_collection": {title: "Macbooks", rules: [{column: "vendor", relation: "equals", condition: "Apple"}], image: {src: "http://example.com/rails_logo.gif", alt: "Rails Logo"}} } + }).toMatchMadeHttpRequest(); + }); + + it('test_10', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await SmartCollection.count({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/smart_collections/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_11', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await SmartCollection.count({ + session: test_session, + product_id: "632910392", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/smart_collections/count.json', + query: 'product_id=632910392', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_12', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await SmartCollection.find({ + session: test_session, + id: 482865238, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/smart_collections/482865238.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_13', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const smart_collection = new SmartCollection({session: test_session}); + smart_collection.id = 482865238; + smart_collection.body_html = "

5000 songs in your pocket

"; + await smart_collection.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/smart_collections/482865238.json', + query: '', + headers, + data: { "smart_collection": {id: 482865238, body_html: "

5000 songs in your pocket

"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_14', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const smart_collection = new SmartCollection({session: test_session}); + smart_collection.id = 482865238; + smart_collection.published = true; + await smart_collection.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/smart_collections/482865238.json', + query: '', + headers, + data: { "smart_collection": {id: 482865238, published: true} } + }).toMatchMadeHttpRequest(); + }); + + it('test_15', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const smart_collection = new SmartCollection({session: test_session}); + smart_collection.id = 482865238; + smart_collection.published = false; + await smart_collection.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/smart_collections/482865238.json', + query: '', + headers, + data: { "smart_collection": {id: 482865238, published: false} } + }).toMatchMadeHttpRequest(); + }); + + it('test_16', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const smart_collection = new SmartCollection({session: test_session}); + smart_collection.id = 482865238; + smart_collection.image = { + attachment: "R0lGODlhbgCMAPf/APbr48VySrxTO7IgKt2qmKQdJeK8lsFjROG5p/nz7Zg3\nMNmnd7Q1MLNVS9GId71hSJMZIuzTu4UtKbeEeakhKMl8U8WYjfr18YQaIbAf\nKKwhKdKzqpQtLebFortOOejKrOjZ1Mt7aMNpVbAqLLV7bsNqR 3WwMqEWenN\nsZYxL/Ddy/Pm2e7ZxLlUQrIjNPXp3bU5MbhENbEtLtqhj5ZQTfHh0bMxL7Ip\nNsNyUYkZIrZJPcqGdYIUHb5aPKkeJnoUHd2yiJkiLKYiKLRFOsyJXKVDO8up\nosFaS TBnK4kKti5sNaYg/z49aqYl5kqLrljUtORfMOlo/36 H4ZH8yDYq0f\nKKFYTaU9MrY8MrZBNXwXHpgaIdGVYu/byLZNP9SaZLIyOuXCtHkpJst Wpcm\nLMyCa8BfP9GMb9KQdPDd1PPk1sd5VP79/L5dQZ0bI9 ymqssK9WcfIoXHdzG\nxdWWfteib79lSr1YP86MYurQxKdcUKdMQr5ZSfPs6YEZH8uhl4oWIenMuurQ\nttmejaqoqsqBVaAcJLlJN5kvMLlZRMNsSL5fRak0LbdQQMVvSPjw6cJnRpkf\nKtmjhvfu5cJtT7IuOMVvWLY/M/37 o0YH9ibhtSYdObErc6HarM9NnYSGNGR\navLi09unje3WyeO8rsVrT7tdRtK3uffu6NWeaL9pTJIjJrM4NPbx8cdyX7M7\nPYYVHu7j4KgoNJAYIKtkV5o9MsOcldicis RYNutfrhFOZ0hJbqinZ8bI8h5\nUObFuOfItJsfJrJfUOfIqc PXqQtK8RnSbA4Mcd3Tm0SGbpXQ8aqp7RLNs s\novHfzpVhV9iggMd1TLtbRKUdKXEQFsd4XrZRPLIgMZUeJ jKvrAlK6AhJ65A\nMpMpKuC3j5obIsRwS7hAN8l/YtvDvnYXHbAoLI47SIUsOMenorF4gO/m4 fH\npo4vLZ8oKMukqp0cJbhVSMV2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lwkB0BiUoR3x4EfmrYlCNjAF\nCRAoIWmwQexQqQcyxHe 9eXAfVOQAg7k16v7jQsAHGi2Bv0gUzyQQ05Ga Cy\n0MBEDsZgN8gQ4QnXt7oJ0QOGOZACDTeEu0aTCwC80EKhDcAHMDGHWATMsuMC\nFsVl/9GnP0Jg0kw24MUv/qUTOGDlCj8WETfGsVx2vI UzsATIFZUaTIRk3QY\n ZYlFq0Ce5QJHBXgdU MRCSwEYlVBCHPQZhyn7vhhD9fWdAc2DKhKXxhRCc6\n0Yi4LOPcl6hGVUFqc4gJLGaxufKO1s2VkrOj63znOkciCKMedZ n7ARUp1rQ\niLAyIlyNYURcONaInrWs9ci4JyJOaFYawDzP8Q ZwAICLckbgd08i290eh9V\nCIadQw3qO5Oa1H1GNRlSjeorO2HLruZ2rLudAm Dm9Gxcx/GXmSIMbnjH5W2\nzy2RbOzM cENBRAWs0N9b3zXWdp8pra1r61tbXdb4N/2Nv8i5gzeIJd5Gjui\nwT AzQ9YVGrYnNO0Agm27GBkvNnNzje 921qf/ b1QEfuMDFPe5lk/lspUG3\nWKbQCofLBBBuwNEs3C3aikcrB2TTeM81HgmOd3zf/PZ3yFPNaqSXfODF0EDK\nE9e6liZmCvJwOLD7AQhU2efSbG6zm7VgiG1ofBc //nGgZ7vbYw67aVux4v/\nfXSSK53by/HVrzIwDZTBBANUrzpMeAAIWASeB4P/AQ9 cHjEJx7xWgDE5nLQ\neMdHXvKbg/zkMZ23H/1oFRjYPOc9v3nQ58Aw0xn9LACvO7HQAOZVf/jl0ii1\nHcXe9bPX3euftaPL5R71tIf97nsy7/o0WlP2r4/JOU7B r5nqva7jz1EdZ97\n4qNe bonfvCfVXvly1762beOOdLBd Q7PCAAOw==\n", + alt: "Rails logo" + }; + await smart_collection.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/smart_collections/482865238.json', + query: '', + headers, + data: { "smart_collection": {id: 482865238, image: {attachment: "R0lGODlhbgCMAPf/APbr48VySrxTO7Ig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Cy\n0MBEDsZgN8gQ4QnXt7oJ0QOGOZACDTeEu0aTCwC80EKhDcAHMDGHWATMsuMC\nFsVl/9GnP0Jg0kw24MUv/qUTOGDlCj8WETfGsVx2vI UzsATIFZUaTIRk3QY\n ZYlFq0Ce5QJHBXgdU MRCSwEYlVBCHPQZhyn7vhhD9fWdAc2DKhKXxhRCc6\n0Yi4LOPcl6hGVUFqc4gJLGaxufKO1s2VkrOj63znOkciCKMedZ n7ARUp1rQ\niLAyIlyNYURcONaInrWs9ci4JyJOaFYawDzP8Q ZwAICLckbgd08i290eh9V\nCIadQw3qO5Oa1H1GNRlSjeorO2HLruZ2rLudAm Dm9Gxcx/GXmSIMbnjH5W2\nzy2RbOzM cENBRAWs0N9b3zXWdp8pra1r61tbXdb4N/2Nv8i5gzeIJd5Gjui\nwT AzQ9YVGrYnNO0Agm27GBkvNnNzje 921qf/ b1QEfuMDFPe5lk/lspUG3\nWKbQCofLBBBuwNEs3C3aikcrB2TTeM81HgmOd3zf/PZ3yFPNaqSXfODF0EDK\nE9e6liZmCvJwOLD7AQhU2efSbG6zm7VgiG1ofBc //nGgZ7vbYw67aVux4v/\nfXSSK53by/HVrzIwDZTBBANUrzpMeAAIWASeB4P/AQ9 cHjEJx7xWgDE5nLQ\neMdHXvKbg/zkMZ23H/1oFRjYPOc9v3nQ58Aw0xn9LACvO7HQAOZVf/jl0ii1\nHcXe9bPX3euftaPL5R71tIf97nsy7/o0WlP2r4/JOU7B r5nqva7jz1EdZ97\n4qNe bonfvCfVXvly1762beOOdLBd Q7PCAAOw==\n", alt: "Rails logo"}} } + }).toMatchMadeHttpRequest(); + }); + + it('test_17', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const smart_collection = new SmartCollection({session: test_session}); + smart_collection.id = 482865238; + smart_collection.image = { + alt: "Rails logo" + }; + await smart_collection.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/smart_collections/482865238.json', + query: '', + headers, + data: { "smart_collection": {id: 482865238, image: {alt: "Rails logo"}} } + }).toMatchMadeHttpRequest(); + }); + + it('test_18', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const smart_collection = new SmartCollection({session: test_session}); + smart_collection.id = 482865238; + smart_collection.image = ""; + smart_collection.updated_at = "2022-02-03T17:04:39-05:00"; + smart_collection.title = "Smart iPods"; + smart_collection.handle = "smart-ipods"; + smart_collection.body_html = "

The best selling ipod ever

"; + smart_collection.published_at = "2008-02-01T19:00:00-05:00"; + smart_collection.sort_order = "manual"; + smart_collection.template_suffix = null; + smart_collection.disjunctive = false; + smart_collection.rules = [ + { + column: "type", + relation: "equals", + condition: "Cult Products" + } + ]; + smart_collection.published_scope = "web"; + smart_collection.admin_graphql_api_id = "gid://shopify/Collection/482865238"; + await smart_collection.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/smart_collections/482865238.json', + query: '', + headers, + data: { "smart_collection": {id: 482865238, image: "", updated_at: "2022-02-03T17:04:39-05:00", title: "Smart iPods", handle: "smart-ipods", body_html: "

The best selling ipod ever

", published_at: "2008-02-01T19:00:00-05:00", sort_order: "manual", template_suffix: null, disjunctive: false, rules: [{column: "type", relation: "equals", condition: "Cult Products"}], published_scope: "web", admin_graphql_api_id: "gid://shopify/Collection/482865238"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_19', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await SmartCollection.delete({ + session: test_session, + id: 482865238, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-07/smart_collections/482865238.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_20', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const smart_collection = new SmartCollection({session: test_session}); + smart_collection.id = 482865238; + await smart_collection.order({ + products: ["921728736", "632910392"], + }); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/smart_collections/482865238/order.json', + query: 'products%5B%5D=921728736&products%5B%5D=632910392', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_21', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const smart_collection = new SmartCollection({session: test_session}); + smart_collection.id = 482865238; + await smart_collection.order({ + sort_order: "alpha-desc", + }); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/smart_collections/482865238/order.json', + query: 'sort_order=alpha-desc', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-07/storefront_access_token.test.ts b/src/rest-resources/__tests__/2021-07/storefront_access_token.test.ts new file mode 100644 index 000000000..266b6034f --- /dev/null +++ b/src/rest-resources/__tests__/2021-07/storefront_access_token.test.ts @@ -0,0 +1,69 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {StorefrontAccessToken} from '../../2021-07'; + +describe('StorefrontAccessToken resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.July21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const storefront_access_token = new StorefrontAccessToken({session: test_session}); + storefront_access_token.title = "Test"; + await storefront_access_token.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/storefront_access_tokens.json', + query: '', + headers, + data: { "storefront_access_token": {title: "Test"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await StorefrontAccessToken.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/storefront_access_tokens.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await StorefrontAccessToken.delete({ + session: test_session, + id: 755357713, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-07/storefront_access_tokens/755357713.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-07/tender_transaction.test.ts b/src/rest-resources/__tests__/2021-07/tender_transaction.test.ts new file mode 100644 index 000000000..3d279c763 --- /dev/null +++ b/src/rest-resources/__tests__/2021-07/tender_transaction.test.ts @@ -0,0 +1,124 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {TenderTransaction} from '../../2021-07'; + +describe('TenderTransaction resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.July21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await TenderTransaction.all({ + session: test_session, + processed_at_max: "2005-08-05 10:22:51 -0400", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/tender_transactions.json', + query: 'processed_at_max=2005-08-05+10%3A22%3A51+-0400', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await TenderTransaction.all({ + session: test_session, + order: "processed_at ASC", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/tender_transactions.json', + query: 'order=processed_at+ASC', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await TenderTransaction.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/tender_transactions.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await TenderTransaction.all({ + session: test_session, + since_id: "1011222896", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/tender_transactions.json', + query: 'since_id=1011222896', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await TenderTransaction.all({ + session: test_session, + processed_at_min: "2005-08-06 10:22:51 -0400", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/tender_transactions.json', + query: 'processed_at_min=2005-08-06+10%3A22%3A51+-0400', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await TenderTransaction.all({ + session: test_session, + processed_at_max: "2005-08-06 10:22:51 -0400", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/tender_transactions.json', + query: 'processed_at_max=2005-08-06+10%3A22%3A51+-0400', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-07/theme.test.ts b/src/rest-resources/__tests__/2021-07/theme.test.ts new file mode 100644 index 000000000..7f83100b9 --- /dev/null +++ b/src/rest-resources/__tests__/2021-07/theme.test.ts @@ -0,0 +1,125 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Theme} from '../../2021-07'; + +describe('Theme resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.July21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Theme.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/themes.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const theme = new Theme({session: test_session}); + theme.name = "Lemongrass"; + theme.src = "http://themes.shopify.com/theme.zip"; + theme.role = "main"; + await theme.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/themes.json', + query: '', + headers, + data: { "theme": {name: "Lemongrass", src: "http://themes.shopify.com/theme.zip", role: "main"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Theme.find({ + session: test_session, + id: 828155753, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/themes/828155753.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const theme = new Theme({session: test_session}); + theme.id = 752253240; + theme.name = "Experimental"; + await theme.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/themes/752253240.json', + query: '', + headers, + data: { "theme": {id: 752253240, name: "Experimental"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const theme = new Theme({session: test_session}); + theme.id = 752253240; + theme.role = "main"; + await theme.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/themes/752253240.json', + query: '', + headers, + data: { "theme": {id: 752253240, role: "main"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Theme.delete({ + session: test_session, + id: 752253240, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-07/themes/752253240.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-07/transaction.test.ts b/src/rest-resources/__tests__/2021-07/transaction.test.ts new file mode 100644 index 000000000..b034876cb --- /dev/null +++ b/src/rest-resources/__tests__/2021-07/transaction.test.ts @@ -0,0 +1,174 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Transaction} from '../../2021-07'; + +describe('Transaction resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.July21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Transaction.all({ + session: test_session, + order_id: 450789469, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/orders/450789469/transactions.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Transaction.all({ + session: test_session, + order_id: 450789469, + since_id: "801038806", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/orders/450789469/transactions.json', + query: 'since_id=801038806', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const transaction = new Transaction({session: test_session}); + transaction.order_id = 450789469; + transaction.currency = "USD"; + transaction.amount = "10.00"; + transaction.kind = "capture"; + transaction.parent_id = 389404469; + await transaction.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/orders/450789469/transactions.json', + query: '', + headers, + data: { "transaction": {currency: "USD", amount: "10.00", kind: "capture", parent_id: 389404469} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const transaction = new Transaction({session: test_session}); + transaction.order_id = 450789469; + transaction.currency = "USD"; + transaction.amount = "10.00"; + transaction.kind = "void"; + transaction.parent_id = 389404469; + await transaction.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/orders/450789469/transactions.json', + query: '', + headers, + data: { "transaction": {currency: "USD", amount: "10.00", kind: "void", parent_id: 389404469} } + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const transaction = new Transaction({session: test_session}); + transaction.order_id = 450789469; + transaction.currency = "USD"; + transaction.amount = "10.00"; + transaction.kind = "capture"; + transaction.parent_id = 389404469; + transaction.test = true; + await transaction.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/orders/450789469/transactions.json', + query: '', + headers, + data: { "transaction": {currency: "USD", amount: "10.00", kind: "capture", parent_id: 389404469, test: true} } + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const transaction = new Transaction({session: test_session}); + transaction.order_id = 450789469; + transaction.kind = "capture"; + transaction.authorization = "authorization-key"; + await transaction.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/orders/450789469/transactions.json', + query: '', + headers, + data: { "transaction": {kind: "capture", authorization: "authorization-key"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Transaction.count({ + session: test_session, + order_id: 450789469, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/orders/450789469/transactions/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Transaction.find({ + session: test_session, + order_id: 450789469, + id: 389404469, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/orders/450789469/transactions/389404469.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-07/usage_charge.test.ts b/src/rest-resources/__tests__/2021-07/usage_charge.test.ts new file mode 100644 index 000000000..ad5e86d4a --- /dev/null +++ b/src/rest-resources/__tests__/2021-07/usage_charge.test.ts @@ -0,0 +1,73 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {UsageCharge} from '../../2021-07'; + +describe('UsageCharge resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.July21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const usage_charge = new UsageCharge({session: test_session}); + usage_charge.recurring_application_charge_id = 455696195; + usage_charge.description = "Super Mega Plan 1000 emails"; + usage_charge.price = 1.0; + await usage_charge.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/recurring_application_charges/455696195/usage_charges.json', + query: '', + headers, + data: { "usage_charge": {description: "Super Mega Plan 1000 emails", price: 1.0} } + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await UsageCharge.all({ + session: test_session, + recurring_application_charge_id: 455696195, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/recurring_application_charges/455696195/usage_charges.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await UsageCharge.find({ + session: test_session, + recurring_application_charge_id: 455696195, + id: 1034618217, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/recurring_application_charges/455696195/usage_charges/1034618217.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-07/user.test.ts b/src/rest-resources/__tests__/2021-07/user.test.ts new file mode 100644 index 000000000..b89deb54b --- /dev/null +++ b/src/rest-resources/__tests__/2021-07/user.test.ts @@ -0,0 +1,69 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {User} from '../../2021-07'; + +describe('User resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.July21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await User.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/users.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await User.find({ + session: test_session, + id: 548380009, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/users/548380009.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await User.current({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/users/current.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-07/variant.test.ts b/src/rest-resources/__tests__/2021-07/variant.test.ts new file mode 100644 index 000000000..c34a865b5 --- /dev/null +++ b/src/rest-resources/__tests__/2021-07/variant.test.ts @@ -0,0 +1,254 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Variant} from '../../2021-07'; + +describe('Variant resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.July21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Variant.all({ + session: test_session, + product_id: 632910392, + since_id: "49148385", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/products/632910392/variants.json', + query: 'since_id=49148385', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Variant.all({ + session: test_session, + product_id: 632910392, + presentment_currencies: "USD,CAD", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/products/632910392/variants.json', + query: 'presentment_currencies=USD%2CCAD', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Variant.all({ + session: test_session, + product_id: 632910392, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/products/632910392/variants.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Variant.count({ + session: test_session, + product_id: 632910392, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/products/632910392/variants/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Variant.find({ + session: test_session, + id: 808950810, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/variants/808950810.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const variant = new Variant({session: test_session}); + variant.id = 808950810; + variant.option1 = "Not Pink"; + variant.price = "99.00"; + await variant.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/variants/808950810.json', + query: '', + headers, + data: { "variant": {id: 808950810, option1: "Not Pink", price: "99.00"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const variant = new Variant({session: test_session}); + variant.id = 808950810; + variant.image_id = 562641783; + await variant.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/variants/808950810.json', + query: '', + headers, + data: { "variant": {id: 808950810, image_id: 562641783} } + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const variant = new Variant({session: test_session}); + variant.id = 808950810; + variant.metafields = [ + { + key: "new", + value: "newvalue", + type: "single_line_text_field", + namespace: "global" + } + ]; + await variant.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/variants/808950810.json', + query: '', + headers, + data: { "variant": {id: 808950810, metafields: [{key: "new", value: "newvalue", type: "single_line_text_field", namespace: "global"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const variant = new Variant({session: test_session}); + variant.product_id = 632910392; + variant.option1 = "Yellow"; + variant.price = "1.00"; + await variant.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/products/632910392/variants.json', + query: '', + headers, + data: { "variant": {option1: "Yellow", price: "1.00"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_10', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const variant = new Variant({session: test_session}); + variant.product_id = 632910392; + variant.image_id = 850703190; + variant.option1 = "Purple"; + await variant.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/products/632910392/variants.json', + query: '', + headers, + data: { "variant": {image_id: 850703190, option1: "Purple"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_11', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const variant = new Variant({session: test_session}); + variant.product_id = 632910392; + variant.option1 = "Blue"; + variant.metafields = [ + { + key: "new", + value: "newvalue", + type: "single_line_text_field", + namespace: "global" + } + ]; + await variant.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/products/632910392/variants.json', + query: '', + headers, + data: { "variant": {option1: "Blue", metafields: [{key: "new", value: "newvalue", type: "single_line_text_field", namespace: "global"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_12', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Variant.delete({ + session: test_session, + product_id: 632910392, + id: 808950810, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-07/products/632910392/variants/808950810.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-07/webhook.test.ts b/src/rest-resources/__tests__/2021-07/webhook.test.ts new file mode 100644 index 000000000..b8f7a4a4d --- /dev/null +++ b/src/rest-resources/__tests__/2021-07/webhook.test.ts @@ -0,0 +1,202 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Webhook} from '../../2021-07'; + +describe('Webhook resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.July21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Webhook.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/webhooks.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Webhook.all({ + session: test_session, + since_id: "901431826", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/webhooks.json', + query: 'since_id=901431826', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const webhook = new Webhook({session: test_session}); + webhook.topic = "orders/create"; + webhook.address = "https://example.hostname.com/"; + webhook.format = "json"; + webhook.fields = [ + "id", + "note" + ]; + await webhook.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/webhooks.json', + query: '', + headers, + data: { "webhook": {topic: "orders/create", address: "https://example.hostname.com/", format: "json", fields: ["id", "note"]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const webhook = new Webhook({session: test_session}); + webhook.address = "arn:aws:events:us-east-1::event-source/aws.partner/shopify.com/755357713/example-event-source"; + webhook.topic = "customers/update"; + webhook.format = "json"; + await webhook.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/webhooks.json', + query: '', + headers, + data: { "webhook": {address: "arn:aws:events:us-east-1::event-source/aws.partner/shopify.com/755357713/example-event-source", topic: "customers/update", format: "json"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const webhook = new Webhook({session: test_session}); + webhook.address = "pubsub://projectName:topicName"; + webhook.topic = "customers/update"; + webhook.format = "json"; + await webhook.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-07/webhooks.json', + query: '', + headers, + data: { "webhook": {address: "pubsub://projectName:topicName", topic: "customers/update", format: "json"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Webhook.count({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/webhooks/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Webhook.count({ + session: test_session, + topic: "orders/create", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/webhooks/count.json', + query: 'topic=orders%2Fcreate', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Webhook.find({ + session: test_session, + id: 4759306, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-07/webhooks/4759306.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const webhook = new Webhook({session: test_session}); + webhook.id = 4759306; + webhook.address = "https://somewhere-else.com/"; + await webhook.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-07/webhooks/4759306.json', + query: '', + headers, + data: { "webhook": {id: 4759306, address: "https://somewhere-else.com/"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_10', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Webhook.delete({ + session: test_session, + id: 4759306, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-07/webhooks/4759306.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-10/abandoned_checkout.test.ts b/src/rest-resources/__tests__/2021-10/abandoned_checkout.test.ts new file mode 100644 index 000000000..bfc77486a --- /dev/null +++ b/src/rest-resources/__tests__/2021-10/abandoned_checkout.test.ts @@ -0,0 +1,141 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {AbandonedCheckout} from '../../2021-10'; + +describe('AbandonedCheckout resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.October21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await AbandonedCheckout.checkouts({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/checkouts.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await AbandonedCheckout.checkouts({ + session: test_session, + status: "closed", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/checkouts.json', + query: 'status=closed', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await AbandonedCheckout.checkouts({ + session: test_session, + created_at_max: "2013-10-12T07:05:27-02:00", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/checkouts.json', + query: 'created_at_max=2013-10-12T07%3A05%3A27-02%3A00', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await AbandonedCheckout.checkouts({ + session: test_session, + limit: "1", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/checkouts.json', + query: 'limit=1', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await AbandonedCheckout.checkouts({ + session: test_session, + status: "closed", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/checkouts.json', + query: 'status=closed', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await AbandonedCheckout.checkouts({ + session: test_session, + created_at_max: "2013-10-12T07:05:27-02:00", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/checkouts.json', + query: 'created_at_max=2013-10-12T07%3A05%3A27-02%3A00', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await AbandonedCheckout.checkouts({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/checkouts.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-10/access_scope.test.ts b/src/rest-resources/__tests__/2021-10/access_scope.test.ts new file mode 100644 index 000000000..605aa8a63 --- /dev/null +++ b/src/rest-resources/__tests__/2021-10/access_scope.test.ts @@ -0,0 +1,34 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {AccessScope} from '../../2021-10'; + +describe('AccessScope resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.October21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await AccessScope.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/oauth/access_scopes.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-10/android_pay_key.test.ts b/src/rest-resources/__tests__/2021-10/android_pay_key.test.ts new file mode 100644 index 000000000..294e8a60d --- /dev/null +++ b/src/rest-resources/__tests__/2021-10/android_pay_key.test.ts @@ -0,0 +1,70 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {AndroidPayKey} from '../../2021-10'; + +describe('AndroidPayKey resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.October21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const android_pay_key = new AndroidPayKey({session: test_session}); + + await android_pay_key.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/android_pay_keys.json', + query: '', + headers, + data: { "android_pay_key": {} } + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await AndroidPayKey.find({ + session: test_session, + id: 964811897, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/android_pay_keys/964811897.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await AndroidPayKey.delete({ + session: test_session, + id: 964811898, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-10/android_pay_keys/964811898.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-10/apple_pay_certificate.test.ts b/src/rest-resources/__tests__/2021-10/apple_pay_certificate.test.ts new file mode 100644 index 000000000..686e19714 --- /dev/null +++ b/src/rest-resources/__tests__/2021-10/apple_pay_certificate.test.ts @@ -0,0 +1,108 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {ApplePayCertificate} from '../../2021-10'; + +describe('ApplePayCertificate resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.October21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const apple_pay_certificate = new ApplePayCertificate({session: test_session}); + + await apple_pay_certificate.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/apple_pay_certificates.json', + query: '', + headers, + data: { "apple_pay_certificate": {} } + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await ApplePayCertificate.find({ + session: test_session, + id: 1068938280, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/apple_pay_certificates/1068938280.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const apple_pay_certificate = new ApplePayCertificate({session: test_session}); + apple_pay_certificate.id = 1068938282; + apple_pay_certificate.status = "completed"; + apple_pay_certificate.merchant_id = "merchant.something"; + apple_pay_certificate.encoded_signed_certificate = "MIIEZzCCBA6gAwIBAgIIWGMideLkDJAwCgYIKoZIzj0EAwIwgYAxNDAyBgNV\nBAMMK0FwcGxlIFdvcmxkd2lkZSBEZXZlbG9wZXIgUmVsYXRpb25zIENBIC0g\nRzIxJjAkBgNVBAsMHUFwcGxlIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MRMw\nEQYDVQQKDApBcHBsZSBJbmMuMQswCQYDVQQGEwJVUzAeFw0xNDEyMDgyMTMy\nMDBaF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CAygwTwYJKoZIhvdjZAYgBEIMQDM0NTBBMjhB\nOTlGRjIyRkI5OTdDRERFODU1REREOTI5NTE4RjVGMDdBQUM4NzdDMzRCQjM3\nODFCQTg2MzkyNjIwCgYIKoZIzj0EAwIDRwAwRAIgZ/oNx0gCc/PM4pYhOWL2\nCecFQrIgzHr/fZd8qcy3Be8CIEQCaAPpmvQrXEX0hFexoYMHtOHY9dgN2D8L\nNKpVyn3t\n"; + await apple_pay_certificate.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/apple_pay_certificates/1068938282.json', + query: '', + headers, + data: { "apple_pay_certificate": {id: 1068938282, status: "completed", merchant_id: "merchant.something", encoded_signed_certificate: "MIIEZzCCBA6gAwIBAgIIWGMideLkDJAwCgYIKoZIzj0EAwIwgYAxNDAyBgNV\nBAMMK0FwcGxlIFdvcmxkd2lkZSBEZXZlbG9wZXIgUmVsYXRpb25zIENBIC0g\nRzIxJjAkBgNVBAsMHUFwcGxlIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MRMw\nEQYDVQQKDApBcHBsZSBJbmMuMQswCQYDVQQGEwJVUzAeFw0xNDEyMDgyMTMy\nMDBaFw0xNzAxMDYyMTMyMDBaMIGZMSowKAYKCZImiZPyLGQBAQwabWVyY2hh\nbnQuY29tLm5vcm1vcmUuamFzb24xMDAuBgNVBAMMJ01lcmNoYW50IElEOiBt\nZXJjaGFudC5jb20ubm9ybW9yZS5qYXNvbjETMBEGA1UECwwKNVVZMzJOTE5O\nOTEXMBUGA1UECgwOSm9zaHVhIFRlc3NpZXIxCzAJBgNVBAYTAkNBMFkwEwYH\nKoZIzj0CAQYIKoZIzj0DAQcDQgAEAxDDCvzG6MnsZSJOtbr0hr3MRq 4HzTZ\nx8J4FD34E3kU5CallEnZLBmnzfqmjP8644SO28LLJxvWBnrg7lHFtaOCAlUw\nggJRMEcGCCsGAQUFBwEBBDswOTA3BggrBgEFBQcwAYYraHR0cDovL29jc3Au\nYXBwbGUuY29tL29jc3AwNC1hcHBsZXd3ZHJjYTIwMTAdBgNVHQ4EFgQUkPsO\nKEKvhL/takKomy5GWXtCd8wwDAYDVR0TAQH/BAIwADAfBgNVHSMEGDAWgBSE\ntoTMOoZichZZlOgao71I3zrfCzCCAR0GA1UdIASCARQwggEQMIIBDAYJKoZI\nhvdjZAUBMIH MIHDBggrBgEFBQcCAjCBtgyBs1JlbGlhbmNlIG9uIHRoaXMg\nY2VydGlmaWNhdGUgYnkgYW55IHBhcnR5IGFzc3VtZXMgYWNjZXB0YW5jZSBv\nZiB0aGUgdGhlbiBhcHBsaWNhYmxlIHN0YW5kYXJkIHRlcm1zIGFuZCBjb25k\naXRpb25zIG9mIHVzZSwgY2VydGlmaWNhdGUgcG9saWN5IGFuZCBjZXJ0aWZp\nY2F0aW9uIHByYWN0aWNlIHN0YXRlbWVudHMuMDYGCCsGAQUFBwIBFipodHRw\nOi8vd3d3LmFwcGxlLmNvbS9jZXJ0aWZpY2F0ZWF1dGhvcml0eS8wNgYDVR0f\nBC8wLTAroCmgJ4YlaHR0cDovL2NybC5hcHBsZS5jb20vYXBwbGV3d2RyY2Ey\nLmNybDAOBgNVHQ8BAf8EBAMCAygwTwYJKoZIhvdjZAYgBEIMQDM0NTBBMjhB\nOTlGRjIyRkI5OTdDRERFODU1REREOTI5NTE4RjVGMDdBQUM4NzdDMzRCQjM3\nODFCQTg2MzkyNjIwCgYIKoZIzj0EAwIDRwAwRAIgZ/oNx0gCc/PM4pYhOWL2\nCecFQrIgzHr/fZd8qcy3Be8CIEQCaAPpmvQrXEX0hFexoYMHtOHY9dgN2D8L\nNKpVyn3t\n"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await ApplePayCertificate.delete({ + session: test_session, + id: 1068938283, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-10/apple_pay_certificates/1068938283.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await ApplePayCertificate.csr({ + session: test_session, + id: 1068938281, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/apple_pay_certificates/1068938281/csr.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-10/application_charge.test.ts b/src/rest-resources/__tests__/2021-10/application_charge.test.ts new file mode 100644 index 000000000..9799aaa99 --- /dev/null +++ b/src/rest-resources/__tests__/2021-10/application_charge.test.ts @@ -0,0 +1,109 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {ApplicationCharge} from '../../2021-10'; + +describe('ApplicationCharge resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.October21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const application_charge = new ApplicationCharge({session: test_session}); + application_charge.name = "Super Duper Expensive action"; + application_charge.price = 100.0; + application_charge.return_url = "http://super-duper.shopifyapps.com"; + await application_charge.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/application_charges.json', + query: '', + headers, + data: { "application_charge": {name: "Super Duper Expensive action", price: 100.0, return_url: "http://super-duper.shopifyapps.com"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const application_charge = new ApplicationCharge({session: test_session}); + application_charge.name = "Super Duper Expensive action"; + application_charge.price = 100.0; + application_charge.return_url = "http://super-duper.shopifyapps.com"; + application_charge.test = true; + await application_charge.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/application_charges.json', + query: '', + headers, + data: { "application_charge": {name: "Super Duper Expensive action", price: 100.0, return_url: "http://super-duper.shopifyapps.com", test: true} } + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await ApplicationCharge.find({ + session: test_session, + id: 675931192, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/application_charges/675931192.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await ApplicationCharge.all({ + session: test_session, + since_id: "556467234", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/application_charges.json', + query: 'since_id=556467234', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await ApplicationCharge.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/application_charges.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-10/application_credit.test.ts b/src/rest-resources/__tests__/2021-10/application_credit.test.ts new file mode 100644 index 000000000..1e757534f --- /dev/null +++ b/src/rest-resources/__tests__/2021-10/application_credit.test.ts @@ -0,0 +1,89 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {ApplicationCredit} from '../../2021-10'; + +describe('ApplicationCredit resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.October21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const application_credit = new ApplicationCredit({session: test_session}); + application_credit.description = "application credit for refund"; + application_credit.amount = 5.0; + await application_credit.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/application_credits.json', + query: '', + headers, + data: { "application_credit": {description: "application credit for refund", amount: 5.0} } + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const application_credit = new ApplicationCredit({session: test_session}); + application_credit.description = "application credit for refund"; + application_credit.amount = 5.0; + application_credit.test = true; + await application_credit.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/application_credits.json', + query: '', + headers, + data: { "application_credit": {description: "application credit for refund", amount: 5.0, test: true} } + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await ApplicationCredit.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/application_credits.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await ApplicationCredit.find({ + session: test_session, + id: 140583599, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/application_credits/140583599.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-10/article.test.ts b/src/rest-resources/__tests__/2021-10/article.test.ts new file mode 100644 index 000000000..d5f80eaa2 --- /dev/null +++ b/src/rest-resources/__tests__/2021-10/article.test.ts @@ -0,0 +1,484 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Article} from '../../2021-10'; + +describe('Article resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.October21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Article.all({ + session: test_session, + blog_id: 241253187, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/blogs/241253187/articles.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Article.all({ + session: test_session, + blog_id: 241253187, + since_id: "134645308", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/blogs/241253187/articles.json', + query: 'since_id=134645308', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const article = new Article({session: test_session}); + article.blog_id = 241253187; + article.title = "My new Article title"; + article.author = "John Smith"; + article.tags = "This Post, Has Been Tagged"; + article.body_html = "

I like articles

\n

Yea, I like posting them through REST.

"; + article.published_at = "Thu Mar 24 15:45:47 UTC 2011"; + await article.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/blogs/241253187/articles.json', + query: '', + headers, + data: { "article": {title: "My new Article title", author: "John Smith", tags: "This Post, Has Been Tagged", body_html: "

I like articles

\n

Yea, I like posting them through REST.

", published_at: "Thu Mar 24 15:45:47 UTC 2011"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const article = new Article({session: test_session}); + article.blog_id = 241253187; + article.title = "My new Article title"; + article.author = "John Smith"; + article.tags = "This Post, Has Been Tagged"; + article.body_html = "

I like articles

\n

Yea, I like posting them through REST.

"; + article.published = false; + await article.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/blogs/241253187/articles.json', + query: '', + headers, + data: { "article": {title: "My new Article title", author: "John Smith", tags: "This Post, Has Been Tagged", body_html: "

I like articles

\n

Yea, I like posting them through REST.

", published: false} } + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const article = new Article({session: test_session}); + article.blog_id = 241253187; + article.title = "My new Article title"; + article.author = "John Smith"; + article.tags = "This Post, Has Been Tagged"; + article.body_html = "

I like articles

\n

Yea, I like posting them through REST.

"; + article.published_at = "Thu Mar 24 15:45:47 UTC 2011"; + article.image = { + attachment: "R0lGODlhAQABAIAAAAAAAAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==\n" + }; + await article.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/blogs/241253187/articles.json', + query: '', + headers, + data: { "article": {title: "My new Article title", author: "John Smith", tags: "This Post, Has Been Tagged", body_html: "

I like articles

\n

Yea, I like posting them through REST.

", published_at: "Thu Mar 24 15:45:47 UTC 2011", image: {attachment: "R0lGODlhAQABAIAAAAAAAAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==\n"}} } + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const article = new Article({session: test_session}); + article.blog_id = 241253187; + article.title = "My new Article title"; + article.author = "John Smith"; + article.tags = "This Post, Has Been Tagged"; + article.body_html = "

I like articles

\n

Yea, I like posting them through REST.

"; + article.published_at = "Thu Mar 24 15:45:47 UTC 2011"; + article.image = { + src: "http://example.com/rails_logo.gif", + alt: "Rails logo" + }; + await article.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/blogs/241253187/articles.json', + query: '', + headers, + data: { "article": {title: "My new Article title", author: "John Smith", tags: "This Post, Has Been Tagged", body_html: "

I like articles

\n

Yea, I like posting them through REST.

", published_at: "Thu Mar 24 15:45:47 UTC 2011", image: {src: "http://example.com/rails_logo.gif", alt: "Rails logo"}} } + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const article = new Article({session: test_session}); + article.blog_id = 241253187; + article.title = "My new Article title"; + article.author = "John Smith"; + article.tags = "This Post, Has Been Tagged"; + article.body_html = "

I like articles

\n

Yea, I like posting them through REST.

"; + article.published_at = "Thu Mar 24 15:45:47 UTC 2011"; + article.metafields = [ + { + key: "new", + value: "newvalue", + type: "single_line_text_field", + namespace: "global" + } + ]; + await article.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/blogs/241253187/articles.json', + query: '', + headers, + data: { "article": {title: "My new Article title", author: "John Smith", tags: "This Post, Has Been Tagged", body_html: "

I like articles

\n

Yea, I like posting them through REST.

", published_at: "Thu Mar 24 15:45:47 UTC 2011", metafields: [{key: "new", value: "newvalue", type: "single_line_text_field", namespace: "global"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Article.count({ + session: test_session, + blog_id: 241253187, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/blogs/241253187/articles/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Article.find({ + session: test_session, + blog_id: 241253187, + id: 134645308, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/blogs/241253187/articles/134645308.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_10', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const article = new Article({session: test_session}); + article.blog_id = 241253187; + article.id = 134645308; + article.title = "My new Title"; + article.author = "Your name"; + article.tags = "Tags, Will Be, Updated"; + article.body_html = "

Look, I can even update through a web service.

"; + article.published_at = "Thu Mar 24 15:45:47 UTC 2011"; + await article.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/blogs/241253187/articles/134645308.json', + query: '', + headers, + data: { "article": {id: 134645308, title: "My new Title", author: "Your name", tags: "Tags, Will Be, Updated", body_html: "

Look, I can even update through a web service.

", published_at: "Thu Mar 24 15:45:47 UTC 2011"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_11', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const article = new Article({session: test_session}); + article.blog_id = 241253187; + article.id = 134645308; + article.published = true; + await article.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/blogs/241253187/articles/134645308.json', + query: '', + headers, + data: { "article": {id: 134645308, published: true} } + }).toMatchMadeHttpRequest(); + }); + + it('test_12', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const article = new Article({session: test_session}); + article.blog_id = 241253187; + article.id = 134645308; + article.published = false; + await article.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/blogs/241253187/articles/134645308.json', + query: '', + headers, + data: { "article": {id: 134645308, published: false} } + }).toMatchMadeHttpRequest(); + }); + + it('test_13', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const article = new Article({session: test_session}); + article.blog_id = 241253187; + article.id = 134645308; + article.title = "My new Title"; + article.author = "Your name"; + article.tags = "Tags, Will Be, Updated"; + article.body_html = "

Look, I can even update through a web service.

"; + article.published_at = "Thu Mar 24 15:45:47 UTC 2011"; + article.image = { + attachment: "R0lGODlhbgCMAPf/APbr48VySrxTO7IgKt2qmKQdJeK8lsFjROG5p/nz7Zg3\nMNmnd7Q1MLNVS9GId71hSJMZIuzTu4UtKbeEeakhKMl8U8WYjfr18YQaIbAf\nKKwhKdKzqpQtLebFortOOejKrOjZ1Mt7aMNpVbAqLLV7bsNqR 3WwMqEWenN\nsZYxL/Ddy/Pm2e7ZxLlUQrIjNPXp3bU5MbhENbEtLtqhj5ZQTfHh0bMxL7Ip\nNsNyUYkZIrZJPcqGdYIUHb5aPKkeJnoUHd2yiJkiLKYiKLRFOsyJXKVDO8up\nosFaS TBnK4kKti5sNaYg/z49aqYl5kqLrljUtORfMOlo/36 H4ZH8yDYq0f\nKKFYTaU9MrY8MrZBNXwXHpgaIdGVYu/byLZNP9SaZLIyOuXCtHkpJst Wpcm\nLMyCa8BfP9GMb9KQdPDd1PPk1sd5VP79/L5dQZ0bI9 ymqssK9WcfIoXHdzG\nxdWWfteib79lSr1YP86MYurQxKdcUKdMQr5ZSfPs6YEZH8uhl4oWIenMuurQ\nttmejaqoqsqBVaAcJLlJN5kvMLlZRMNsSL5fRak0LbdQQMVvSPjw6cJnRpkf\nKtmjhvfu5cJtT7IuOMVvWLY/M/37 o0YH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HVrzIwDZTBBANUrzpMeAAIWASeB4P/AQ9 cHjEJx7xWgDE5nLQ\neMdHXvKbg/zkMZ23H/1oFRjYPOc9v3nQ58Aw0xn9LACvO7HQAOZVf/jl0ii1\nHcXe9bPX3euftaPL5R71tIf97nsy7/o0WlP2r4/JOU7B r5nqva7jz1EdZ97\n4qNe bonfvCfVXvly1762beOOdLBd Q7PCAAOw==\n" + }; + await article.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/blogs/241253187/articles/134645308.json', + query: '', + headers, + data: { "article": {id: 134645308, title: "My new Title", author: "Your name", tags: "Tags, Will Be, Updated", body_html: "

Look, I can even update through a web service.

", published_at: "Thu Mar 24 15:45:47 UTC 2011", image: {attachment: "R0lGODlhbgCMAPf/APbr48VySrxTO7IgKt2qmKQdJeK8lsFjROG5p/nz7Zg3\nMNmnd7Q1MLNVS9GId71hSJMZIuzTu4UtKbeEeakhKMl8U8WYjfr18YQaIbAf\nKKwhKdKzqpQtLebFortOOejKrOjZ1Mt7aMNpVbAqLLV7bsNqR 3WwMqEWenN\nsZYxL/Ddy/Pm2e7ZxLlUQrIjNPXp3bU5MbhENbEtLtqhj5ZQTfHh0bMxL7Ip\nNsNyUYkZIrZJPcqGdYIUHb5aPKkeJnoUHd2yiJkiLKYiKLRFOsyJXKVDO8up\nosFaS TBnK4kKti5sNaYg/z49aqYl5kqLrljUtORfMOlo/36 H4ZH8yDYq0f\nKKFYTaU9MrY8MrZBNXwXHpgaIdGVYu/byLZNP9SaZLIyOuXCtHkpJst Wpcm\nLMyCa8BfP9GMb9KQdPDd1PPk1sd5VP79/L5dQZ0bI9 ymqssK9WcfIoXHdzG\nxdWWfteib79lSr1YP86MYurQxKdcUKdMQr5ZSfPs6YEZH8uhl4oWIenMuurQ\nttmejaqoqsqBVaAcJLlJN5kvMLlZRMNsSL5fRak0LbdQQMVvSPjw6cJnRpkf\nKtmjhvfu5cJtT7IuOMVvWLY/M/37 o0YH9ibhtSYdObErc6HarM9Nn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AAIWASeB4P/AQ9 cHjEJx7xWgDE5nLQ\neMdHXvKbg/zkMZ23H/1oFRjYPOc9v3nQ58Aw0xn9LACvO7HQAOZVf/jl0ii1\nHcXe9bPX3euftaPL5R71tIf97nsy7/o0WlP2r4/JOU7B r5nqva7jz1EdZ97\n4qNe bonfvCfVXvly1762beOOdLBd Q7PCAAOw==\n"}} } + }).toMatchMadeHttpRequest(); + }); + + it('test_14', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const article = new Article({session: test_session}); + article.blog_id = 241253187; + article.id = 134645308; + article.title = "My new Title"; + article.author = "Your name"; + article.tags = "Tags, Will Be, Updated"; + article.body_html = "

Look, I can even update through a web service.

"; + article.published_at = "Thu Mar 24 15:45:47 UTC 2011"; + article.image = { + alt: "Rails logo" + }; + await article.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/blogs/241253187/articles/134645308.json', + query: '', + headers, + data: { "article": {id: 134645308, title: "My new Title", author: "Your name", tags: "Tags, Will Be, Updated", body_html: "

Look, I can even update through a web service.

", published_at: "Thu Mar 24 15:45:47 UTC 2011", image: {alt: "Rails logo"}} } + }).toMatchMadeHttpRequest(); + }); + + it('test_15', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const article = new Article({session: test_session}); + article.blog_id = 241253187; + article.id = 134645308; + article.image = ""; + await article.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/blogs/241253187/articles/134645308.json', + query: '', + headers, + data: { "article": {id: 134645308, image: ""} } + }).toMatchMadeHttpRequest(); + }); + + it('test_16', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const article = new Article({session: test_session}); + article.blog_id = 241253187; + article.id = 134645308; + article.metafields = [ + { + key: "new", + value: "newvalue", + type: "single_line_text_field", + namespace: "global" + } + ]; + await article.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/blogs/241253187/articles/134645308.json', + query: '', + headers, + data: { "article": {id: 134645308, metafields: [{key: "new", value: "newvalue", type: "single_line_text_field", namespace: "global"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_17', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Article.delete({ + session: test_session, + blog_id: 241253187, + id: 134645308, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-10/blogs/241253187/articles/134645308.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_18', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Article.authors({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/articles/authors.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_19', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Article.tags({ + session: test_session, + blog_id: 241253187, + limit: "1", + popular: "1", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/blogs/241253187/articles/tags.json', + query: 'limit=1&popular=1', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_20', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Article.tags({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/articles/tags.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_21', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Article.tags({ + session: test_session, + blog_id: 241253187, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/blogs/241253187/articles/tags.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_22', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Article.tags({ + session: test_session, + limit: "1", + popular: "1", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/articles/tags.json', + query: 'limit=1&popular=1', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-10/asset.test.ts b/src/rest-resources/__tests__/2021-10/asset.test.ts new file mode 100644 index 000000000..dbdcfb85b --- /dev/null +++ b/src/rest-resources/__tests__/2021-10/asset.test.ts @@ -0,0 +1,149 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Asset} from '../../2021-10'; + +describe('Asset resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.October21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Asset.all({ + session: test_session, + theme_id: 828155753, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/themes/828155753/assets.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const asset = new Asset({session: test_session}); + asset.theme_id = 828155753; + asset.key = "templates/index.liquid"; + asset.value = "

We are busy updating the store for you and will be back within the hour.

"; + await asset.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/themes/828155753/assets.json', + query: '', + headers, + data: { "asset": {key: "templates/index.liquid", value: "

We are busy updating the store for you and will be back within the hour.

"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const asset = new Asset({session: test_session}); + asset.theme_id = 828155753; + asset.key = "assets/empty.gif"; + asset.attachment = "R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw==\n"; + await asset.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/themes/828155753/assets.json', + query: '', + headers, + data: { "asset": {key: "assets/empty.gif", attachment: "R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw==\n"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const asset = new Asset({session: test_session}); + asset.theme_id = 828155753; + asset.key = "assets/bg-body.gif"; + asset.src = "http://apple.com/new_bg.gif"; + await asset.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/themes/828155753/assets.json', + query: '', + headers, + data: { "asset": {key: "assets/bg-body.gif", src: "http://apple.com/new_bg.gif"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const asset = new Asset({session: test_session}); + asset.theme_id = 828155753; + asset.key = "layout/alternate.liquid"; + asset.source_key = "layout/theme.liquid"; + await asset.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/themes/828155753/assets.json', + query: '', + headers, + data: { "asset": {key: "layout/alternate.liquid", source_key: "layout/theme.liquid"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Asset.all({ + session: test_session, + theme_id: 828155753, + asset: {key: "templates/index.liquid"}, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/themes/828155753/assets.json', + query: 'asset%5Bkey%5D=templates%2Findex.liquid', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Asset.delete({ + session: test_session, + theme_id: 828155753, + asset: {key: "assets/bg-body.gif"}, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-10/themes/828155753/assets.json', + query: 'asset%5Bkey%5D=assets%2Fbg-body.gif', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-10/assigned_fulfillment_order.test.ts b/src/rest-resources/__tests__/2021-10/assigned_fulfillment_order.test.ts new file mode 100644 index 000000000..346e7dbaf --- /dev/null +++ b/src/rest-resources/__tests__/2021-10/assigned_fulfillment_order.test.ts @@ -0,0 +1,36 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {AssignedFulfillmentOrder} from '../../2021-10'; + +describe('AssignedFulfillmentOrder resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.October21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await AssignedFulfillmentOrder.all({ + session: test_session, + assignment_status: "cancellation_requested", + location_ids: ["24826418"], + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/assigned_fulfillment_orders.json', + query: 'assignment_status=cancellation_requested&location_ids%5B%5D=24826418', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-10/balance.test.ts b/src/rest-resources/__tests__/2021-10/balance.test.ts new file mode 100644 index 000000000..426155fab --- /dev/null +++ b/src/rest-resources/__tests__/2021-10/balance.test.ts @@ -0,0 +1,34 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Balance} from '../../2021-10'; + +describe('Balance resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.October21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Balance.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/shopify_payments/balance.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-10/blog.test.ts b/src/rest-resources/__tests__/2021-10/blog.test.ts new file mode 100644 index 000000000..38c50407c --- /dev/null +++ b/src/rest-resources/__tests__/2021-10/blog.test.ts @@ -0,0 +1,229 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Blog} from '../../2021-10'; + +describe('Blog resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.October21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Blog.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/blogs.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Blog.all({ + session: test_session, + since_id: "241253187", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/blogs.json', + query: 'since_id=241253187', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const blog = new Blog({session: test_session}); + blog.title = "Apple main blog"; + await blog.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/blogs.json', + query: '', + headers, + data: { "blog": {title: "Apple main blog"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const blog = new Blog({session: test_session}); + blog.title = "Apple main blog"; + blog.metafields = [ + { + key: "sponsor", + value: "Shopify", + type: "single_line_text_field", + namespace: "global" + } + ]; + await blog.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/blogs.json', + query: '', + headers, + data: { "blog": {title: "Apple main blog", metafields: [{key: "sponsor", value: "Shopify", type: "single_line_text_field", namespace: "global"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Blog.count({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/blogs/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Blog.find({ + session: test_session, + id: 241253187, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/blogs/241253187.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Blog.find({ + session: test_session, + id: 241253187, + fields: "id,title", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/blogs/241253187.json', + query: 'fields=id%2Ctitle', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const blog = new Blog({session: test_session}); + blog.id = 241253187; + blog.title = "IPod Updates"; + await blog.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/blogs/241253187.json', + query: '', + headers, + data: { "blog": {id: 241253187, title: "IPod Updates"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const blog = new Blog({session: test_session}); + blog.id = 241253187; + blog.title = "IPod Updates"; + blog.handle = "ipod-updates"; + blog.commentable = "moderate"; + await blog.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/blogs/241253187.json', + query: '', + headers, + data: { "blog": {id: 241253187, title: "IPod Updates", handle: "ipod-updates", commentable: "moderate"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_10', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const blog = new Blog({session: test_session}); + blog.id = 241253187; + blog.metafields = [ + { + key: "sponsor", + value: "Shopify", + type: "single_line_text_field", + namespace: "global" + } + ]; + await blog.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/blogs/241253187.json', + query: '', + headers, + data: { "blog": {id: 241253187, metafields: [{key: "sponsor", value: "Shopify", type: "single_line_text_field", namespace: "global"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_11', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Blog.delete({ + session: test_session, + id: 241253187, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-10/blogs/241253187.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-10/cancellation_request.test.ts b/src/rest-resources/__tests__/2021-10/cancellation_request.test.ts new file mode 100644 index 000000000..26304a1bd --- /dev/null +++ b/src/rest-resources/__tests__/2021-10/cancellation_request.test.ts @@ -0,0 +1,73 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {CancellationRequest} from '../../2021-10'; + +describe('CancellationRequest resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.October21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const cancellation_request = new CancellationRequest({session: test_session}); + cancellation_request.fulfillment_order_id = 1046000837; + cancellation_request.message = "The customer changed his mind."; + await cancellation_request.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/fulfillment_orders/1046000837/cancellation_request.json', + query: '', + headers, + data: { "cancellation_request": {message: "The customer changed his mind."} } + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const cancellation_request = new CancellationRequest({session: test_session}); + cancellation_request.fulfillment_order_id = 1046000838; + await cancellation_request.accept({ + body: {cancellation_request: {message: "We had not started any processing yet."}}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/fulfillment_orders/1046000838/cancellation_request/accept.json', + query: '', + headers, + data: { "cancellation_request": {message: "We had not started any processing yet."} } + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const cancellation_request = new CancellationRequest({session: test_session}); + cancellation_request.fulfillment_order_id = 1046000839; + await cancellation_request.reject({ + body: {cancellation_request: {message: "We have already send the shipment out."}}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/fulfillment_orders/1046000839/cancellation_request/reject.json', + query: '', + headers, + data: { "cancellation_request": {message: "We have already send the shipment out."} } + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-10/carrier_service.test.ts b/src/rest-resources/__tests__/2021-10/carrier_service.test.ts new file mode 100644 index 000000000..c334c6e7b --- /dev/null +++ b/src/rest-resources/__tests__/2021-10/carrier_service.test.ts @@ -0,0 +1,108 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {CarrierService} from '../../2021-10'; + +describe('CarrierService resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.October21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const carrier_service = new CarrierService({session: test_session}); + carrier_service.name = "Shipping Rate Provider"; + carrier_service.callback_url = "http://shippingrateprovider.com"; + carrier_service.service_discovery = true; + await carrier_service.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/carrier_services.json', + query: '', + headers, + data: { "carrier_service": {name: "Shipping Rate Provider", callback_url: "http://shippingrateprovider.com", service_discovery: true} } + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CarrierService.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/carrier_services.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const carrier_service = new CarrierService({session: test_session}); + carrier_service.id = 1036894964; + carrier_service.name = "Some new name"; + carrier_service.active = false; + await carrier_service.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/carrier_services/1036894964.json', + query: '', + headers, + data: { "carrier_service": {id: 1036894964, name: "Some new name", active: false} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CarrierService.find({ + session: test_session, + id: 1036894966, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/carrier_services/1036894966.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CarrierService.delete({ + session: test_session, + id: 1036894967, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-10/carrier_services/1036894967.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-10/checkout.test.ts b/src/rest-resources/__tests__/2021-10/checkout.test.ts new file mode 100644 index 000000000..eacb28dc5 --- /dev/null +++ b/src/rest-resources/__tests__/2021-10/checkout.test.ts @@ -0,0 +1,229 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Checkout} from '../../2021-10'; + +describe('Checkout resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.October21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const checkout = new Checkout({session: test_session}); + checkout.line_items = [ + { + variant_id: 39072856, + quantity: 5 + } + ]; + await checkout.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/checkouts.json', + query: '', + headers, + data: { "checkout": {line_items: [{variant_id: 39072856, quantity: 5}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const checkout = new Checkout({session: test_session}); + checkout.email = "me@example.com"; + await checkout.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/checkouts.json', + query: '', + headers, + data: { "checkout": {email: "me@example.com"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const checkout = new Checkout({session: test_session}); + checkout.token = "b490a9220cd14d7344024f4874f640a6"; + await checkout.complete({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/checkouts/b490a9220cd14d7344024f4874f640a6/complete.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Checkout.find({ + session: test_session, + token: "bd5a8aa1ecd019dd3520ff791ee3a24c", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/checkouts/bd5a8aa1ecd019dd3520ff791ee3a24c.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Checkout.find({ + session: test_session, + token: "7yjf4v2we7gamku6a6h7tvm8h3mmvs4x", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/checkouts/7yjf4v2we7gamku6a6h7tvm8h3mmvs4x.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Checkout.find({ + session: test_session, + token: "exuw7apwoycchjuwtiqg8nytfhphr62a", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/checkouts/exuw7apwoycchjuwtiqg8nytfhphr62a.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const checkout = new Checkout({session: test_session}); + checkout.token = "exuw7apwoycchjuwtiqg8nytfhphr62a"; + checkout.email = "john.smith@example.com"; + checkout.shipping_address = { + first_name: "John", + last_name: "Smith", + address1: "126 York St.", + city: "Los Angeles", + province_code: "CA", + country_code: "US", + phone: "(123)456-7890", + zip: "90002" + }; + await checkout.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/checkouts/exuw7apwoycchjuwtiqg8nytfhphr62a.json', + query: '', + headers, + data: { "checkout": {token: "exuw7apwoycchjuwtiqg8nytfhphr62a", email: "john.smith@example.com", shipping_address: {first_name: "John", last_name: "Smith", address1: "126 York St.", city: "Los Angeles", province_code: "CA", country_code: "US", phone: "(123)456-7890", zip: "90002"}} } + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const checkout = new Checkout({session: test_session}); + checkout.token = "exuw7apwoycchjuwtiqg8nytfhphr62a"; + checkout.shipping_line = { + handle: "shopify-Free Shipping-0.00" + }; + await checkout.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/checkouts/exuw7apwoycchjuwtiqg8nytfhphr62a.json', + query: '', + headers, + data: { "checkout": {token: "exuw7apwoycchjuwtiqg8nytfhphr62a", shipping_line: {handle: "shopify-Free Shipping-0.00"}} } + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Checkout.shipping_rates({ + session: test_session, + token: "exuw7apwoycchjuwtiqg8nytfhphr62a", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/checkouts/exuw7apwoycchjuwtiqg8nytfhphr62a/shipping_rates.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_10', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Checkout.shipping_rates({ + session: test_session, + token: "exuw7apwoycchjuwtiqg8nytfhphr62a", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/checkouts/exuw7apwoycchjuwtiqg8nytfhphr62a/shipping_rates.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_11', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Checkout.shipping_rates({ + session: test_session, + token: "zs9ru89kuqcdagk8bz4r9hnxt22wwd42", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/checkouts/zs9ru89kuqcdagk8bz4r9hnxt22wwd42/shipping_rates.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-10/collect.test.ts b/src/rest-resources/__tests__/2021-10/collect.test.ts new file mode 100644 index 000000000..7cb3eb226 --- /dev/null +++ b/src/rest-resources/__tests__/2021-10/collect.test.ts @@ -0,0 +1,177 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Collect} from '../../2021-10'; + +describe('Collect resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.October21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const collect = new Collect({session: test_session}); + collect.product_id = 921728736; + collect.collection_id = 841564295; + await collect.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/collects.json', + query: '', + headers, + data: { "collect": {product_id: 921728736, collection_id: 841564295} } + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Collect.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/collects.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Collect.all({ + session: test_session, + product_id: "632910392", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/collects.json', + query: 'product_id=632910392', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Collect.all({ + session: test_session, + collection_id: "841564295", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/collects.json', + query: 'collection_id=841564295', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Collect.delete({ + session: test_session, + id: 455204334, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-10/collects/455204334.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Collect.find({ + session: test_session, + id: 455204334, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/collects/455204334.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Collect.count({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/collects/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Collect.count({ + session: test_session, + product_id: "632910392", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/collects/count.json', + query: 'product_id=632910392', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Collect.count({ + session: test_session, + collection_id: "841564295", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/collects/count.json', + query: 'collection_id=841564295', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-10/collection.test.ts b/src/rest-resources/__tests__/2021-10/collection.test.ts new file mode 100644 index 000000000..43ffed41e --- /dev/null +++ b/src/rest-resources/__tests__/2021-10/collection.test.ts @@ -0,0 +1,53 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Collection} from '../../2021-10'; + +describe('Collection resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.October21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Collection.find({ + session: test_session, + id: 841564295, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/collections/841564295.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Collection.products({ + session: test_session, + id: 841564295, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/collections/841564295/products.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-10/collection_listing.test.ts b/src/rest-resources/__tests__/2021-10/collection_listing.test.ts new file mode 100644 index 000000000..bc174238a --- /dev/null +++ b/src/rest-resources/__tests__/2021-10/collection_listing.test.ts @@ -0,0 +1,105 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {CollectionListing} from '../../2021-10'; + +describe('CollectionListing resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.October21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CollectionListing.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/collection_listings.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CollectionListing.product_ids({ + session: test_session, + collection_id: 841564295, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/collection_listings/841564295/product_ids.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CollectionListing.find({ + session: test_session, + collection_id: 482865238, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/collection_listings/482865238.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const collection_listing = new CollectionListing({session: test_session}); + collection_listing.collection_id = 482865238; + await collection_listing.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/collection_listings/482865238.json', + query: '', + headers, + data: { "collection_listing": {collection_id: 482865238} } + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CollectionListing.delete({ + session: test_session, + collection_id: 482865238, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-10/collection_listings/482865238.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-10/comment.test.ts b/src/rest-resources/__tests__/2021-10/comment.test.ts new file mode 100644 index 000000000..3c0b4ae27 --- /dev/null +++ b/src/rest-resources/__tests__/2021-10/comment.test.ts @@ -0,0 +1,289 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Comment} from '../../2021-10'; + +describe('Comment resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.October21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Comment.all({ + session: test_session, + article_id: "134645308", + blog_id: "241253187", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/comments.json', + query: 'article_id=134645308&blog_id=241253187', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Comment.all({ + session: test_session, + blog_id: "241253187", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/comments.json', + query: 'blog_id=241253187', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Comment.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/comments.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Comment.all({ + session: test_session, + since_id: "118373535", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/comments.json', + query: 'since_id=118373535', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Comment.count({ + session: test_session, + article_id: "134645308", + blog_id: "241253187", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/comments/count.json', + query: 'article_id=134645308&blog_id=241253187', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Comment.count({ + session: test_session, + blog_id: "241253187", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/comments/count.json', + query: 'blog_id=241253187', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Comment.count({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/comments/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Comment.find({ + session: test_session, + id: 118373535, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/comments/118373535.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const comment = new Comment({session: test_session}); + comment.id = 118373535; + comment.body = "You can even update through a web service."; + comment.author = "Your new name"; + comment.email = "your@updated-email.com"; + comment.published_at = "2022-02-03T22:13:53.233Z"; + await comment.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/comments/118373535.json', + query: '', + headers, + data: { "comment": {id: 118373535, body: "You can even update through a web service.", author: "Your new name", email: "your@updated-email.com", published_at: "2022-02-03T22:13:53.233Z"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_10', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const comment = new Comment({session: test_session}); + comment.body = "I like comments\nAnd I like posting them *RESTfully*."; + comment.author = "Your name"; + comment.email = "your@email.com"; + comment.ip = "107.20.160.121"; + comment.blog_id = 241253187; + comment.article_id = 134645308; + await comment.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/comments.json', + query: '', + headers, + data: { "comment": {body: "I like comments\nAnd I like posting them *RESTfully*.", author: "Your name", email: "your@email.com", ip: "107.20.160.121", blog_id: 241253187, article_id: 134645308} } + }).toMatchMadeHttpRequest(); + }); + + it('test_11', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const comment = new Comment({session: test_session}); + comment.id = 653537639; + await comment.spam({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/comments/653537639/spam.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_12', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const comment = new Comment({session: test_session}); + comment.id = 653537639; + await comment.not_spam({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/comments/653537639/not_spam.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_13', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const comment = new Comment({session: test_session}); + comment.id = 653537639; + await comment.approve({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/comments/653537639/approve.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_14', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const comment = new Comment({session: test_session}); + comment.id = 653537639; + await comment.remove({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/comments/653537639/remove.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_15', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const comment = new Comment({session: test_session}); + comment.id = 653537639; + await comment.restore({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/comments/653537639/restore.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-10/country.test.ts b/src/rest-resources/__tests__/2021-10/country.test.ts new file mode 100644 index 000000000..d62275711 --- /dev/null +++ b/src/rest-resources/__tests__/2021-10/country.test.ts @@ -0,0 +1,158 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Country} from '../../2021-10'; + +describe('Country resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.October21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Country.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/countries.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Country.all({ + session: test_session, + since_id: "359115488", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/countries.json', + query: 'since_id=359115488', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const country = new Country({session: test_session}); + country.code = "FR"; + await country.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/countries.json', + query: '', + headers, + data: { "country": {code: "FR"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const country = new Country({session: test_session}); + country.code = "FR"; + country.tax = 0.2; + await country.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/countries.json', + query: '', + headers, + data: { "country": {code: "FR", tax: 0.2} } + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Country.count({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/countries/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Country.find({ + session: test_session, + id: 879921427, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/countries/879921427.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const country = new Country({session: test_session}); + country.id = 879921427; + country.tax = 0.05; + await country.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/countries/879921427.json', + query: '', + headers, + data: { "country": {id: 879921427, tax: 0.05} } + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Country.delete({ + session: test_session, + id: 879921427, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-10/countries/879921427.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-10/currency.test.ts b/src/rest-resources/__tests__/2021-10/currency.test.ts new file mode 100644 index 000000000..36c4fe8d4 --- /dev/null +++ b/src/rest-resources/__tests__/2021-10/currency.test.ts @@ -0,0 +1,34 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Currency} from '../../2021-10'; + +describe('Currency resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.October21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Currency.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/currencies.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-10/custom_collection.test.ts b/src/rest-resources/__tests__/2021-10/custom_collection.test.ts new file mode 100644 index 000000000..7cb47ee8d --- /dev/null +++ b/src/rest-resources/__tests__/2021-10/custom_collection.test.ts @@ -0,0 +1,436 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {CustomCollection} from '../../2021-10'; + +describe('CustomCollection resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.October21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CustomCollection.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/custom_collections.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CustomCollection.all({ + session: test_session, + since_id: "841564295", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/custom_collections.json', + query: 'since_id=841564295', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CustomCollection.all({ + session: test_session, + product_id: "632910392", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/custom_collections.json', + query: 'product_id=632910392', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CustomCollection.all({ + session: test_session, + ids: "395646240,691652237,841564295", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/custom_collections.json', + query: 'ids=395646240%2C691652237%2C841564295', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const custom_collection = new CustomCollection({session: test_session}); + custom_collection.title = "Macbooks"; + await custom_collection.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/custom_collections.json', + query: '', + headers, + data: { "custom_collection": {title: "Macbooks"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const custom_collection = new CustomCollection({session: test_session}); + custom_collection.title = "Macbooks"; + custom_collection.published = false; + await custom_collection.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/custom_collections.json', + query: '', + headers, + data: { "custom_collection": {title: "Macbooks", published: false} } + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const custom_collection = new CustomCollection({session: test_session}); + custom_collection.title = "Macbooks"; + custom_collection.image = { + src: "http://example.com/rails_logo.gif", + alt: "Rails Logo" + }; + await custom_collection.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/custom_collections.json', + query: '', + headers, + data: { "custom_collection": {title: "Macbooks", image: {src: "http://example.com/rails_logo.gif", alt: "Rails Logo"}} } + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const custom_collection = new CustomCollection({session: test_session}); + custom_collection.title = "IPods"; + custom_collection.collects = [ + { + product_id: 921728736 + } + ]; + await custom_collection.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/custom_collections.json', + query: '', + headers, + data: { "custom_collection": {title: "IPods", collects: [{product_id: 921728736}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const custom_collection = new CustomCollection({session: test_session}); + custom_collection.title = "Macbooks"; + custom_collection.metafields = [ + { + key: "new", + value: "newvalue", + type: "single_line_text_field", + namespace: "global" + } + ]; + await custom_collection.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/custom_collections.json', + query: '', + headers, + data: { "custom_collection": {title: "Macbooks", metafields: [{key: "new", value: "newvalue", type: "single_line_text_field", namespace: "global"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_10', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CustomCollection.count({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/custom_collections/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_11', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CustomCollection.count({ + session: test_session, + product_id: "632910392", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/custom_collections/count.json', + query: 'product_id=632910392', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_12', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CustomCollection.find({ + session: test_session, + id: 841564295, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/custom_collections/841564295.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_13', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const custom_collection = new CustomCollection({session: test_session}); + custom_collection.id = 841564295; + custom_collection.image = ""; + custom_collection.updated_at = "2022-02-03T17:11:24-05:00"; + custom_collection.title = "IPods"; + custom_collection.handle = "ipods"; + custom_collection.body_html = "

The best selling ipod ever

"; + custom_collection.published_at = "2008-02-01T19:00:00-05:00"; + custom_collection.sort_order = "manual"; + custom_collection.template_suffix = null; + custom_collection.published_scope = "web"; + custom_collection.admin_graphql_api_id = "gid://shopify/Collection/841564295"; + await custom_collection.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/custom_collections/841564295.json', + query: '', + headers, + data: { "custom_collection": {id: 841564295, image: "", updated_at: "2022-02-03T17:11:24-05:00", title: "IPods", handle: "ipods", body_html: "

The best selling ipod ever

", published_at: "2008-02-01T19:00:00-05:00", sort_order: "manual", template_suffix: null, published_scope: "web", admin_graphql_api_id: "gid://shopify/Collection/841564295"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_14', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const custom_collection = new CustomCollection({session: test_session}); + custom_collection.id = 841564295; + custom_collection.metafields = [ + { + key: "new", + value: "newvalue", + type: "single_line_text_field", + namespace: "global" + } + ]; + await custom_collection.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/custom_collections/841564295.json', + query: '', + headers, + data: { "custom_collection": {id: 841564295, metafields: [{key: "new", value: "newvalue", type: "single_line_text_field", namespace: "global"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_15', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const custom_collection = new CustomCollection({session: test_session}); + custom_collection.id = 841564295; + custom_collection.body_html = "

5000 songs in your pocket

"; + await custom_collection.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/custom_collections/841564295.json', + query: '', + headers, + data: { "custom_collection": {id: 841564295, body_html: "

5000 songs in your pocket

"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_16', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const custom_collection = new CustomCollection({session: test_session}); + custom_collection.id = 841564295; + custom_collection.collects = [ + { + product_id: 921728736, + position: 1 + }, + { + id: 455204334, + position: 2 + } + ]; + await custom_collection.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/custom_collections/841564295.json', + query: '', + headers, + data: { "custom_collection": {id: 841564295, collects: [{product_id: 921728736, position: 1}, {id: 455204334, position: 2}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_17', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const custom_collection = new CustomCollection({session: test_session}); + custom_collection.id = 841564295; + custom_collection.published = true; + await custom_collection.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/custom_collections/841564295.json', + query: '', + headers, + data: { "custom_collection": {id: 841564295, published: true} } + }).toMatchMadeHttpRequest(); + }); + + it('test_18', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const custom_collection = new CustomCollection({session: test_session}); + custom_collection.id = 841564295; + custom_collection.published = false; + await custom_collection.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/custom_collections/841564295.json', + query: '', + headers, + data: { "custom_collection": {id: 841564295, published: false} } + }).toMatchMadeHttpRequest(); + }); + + it('test_19', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const custom_collection = new CustomCollection({session: test_session}); + custom_collection.id = 841564295; + custom_collection.image = { + attachment: "R0lGODlhbgCMAPf/APbr48VySrxTO7IgKt2qmKQdJeK8lsFjROG5p/nz7Zg3\nMNmnd7Q1MLNVS9GId71hSJMZIuzTu4UtKbeEeakhKMl8U8WYjfr18YQaIbAf\nKKw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DlCj8WETfGsVx2vI UzsATIFZUaTIRk3QY\n ZYlFq0Ce5QJHBXgdU MRCSwEYlVBCHPQZhyn7vhhD9fWdAc2DKhKXxhRCc6\n0Yi4LOPcl6hGVUFqc4gJLGaxufKO1s2VkrOj63znOkciCKMedZ n7ARUp1rQ\niLAyIlyNYURcONaInrWs9ci4JyJOaFYawDzP8Q ZwAICLckbgd08i290eh9V\nCIadQw3qO5Oa1H1GNRlSjeorO2HLruZ2rLudAm Dm9Gxcx/GXmSIMbnjH5W2\nzy2RbOzM cENBRAWs0N9b3zXWdp8pra1r61tbXdb4N/2Nv8i5gzeIJd5Gjui\nwT AzQ9YVGrYnNO0Agm27GBkvNnNzje 921qf/ b1QEfuMDFPe5lk/lspUG3\nWKbQCofLBBBuwNEs3C3aikcrB2TTeM81HgmOd3zf/PZ3yFPNaqSXfODF0EDK\nE9e6liZmCvJwOLD7AQhU2efSbG6zm7VgiG1ofBc //nGgZ7vbYw67aVux4v/\nfXSSK53by/HVrzIwDZTBBANUrzpMeAAIWASeB4P/AQ9 cHjEJx7xWgDE5nLQ\neMdHXvKbg/zkMZ23H/1oFRjYPOc9v3nQ58Aw0xn9LACvO7HQAOZVf/jl0ii1\nHcXe9bPX3euftaPL5R71tIf97nsy7/o0WlP2r4/JOU7B r5nqva7jz1EdZ97\n4qNe bonfvCfVXvly1762beOOdLBd Q7PCAAOw==\n", + alt: "Rails logo" + }; + await custom_collection.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/custom_collections/841564295.json', + query: '', + headers, + data: { "custom_collection": {id: 841564295, image: {attachment: "R0lGODlhbgCMAPf/APbr48VySrxTO7IgKt2qmKQdJeK8lsFjROG5p/nz7Zg3\nMNmnd7Q1MLNVS9GId71hSJMZIuzTu4UtKbeEeakhKMl8U8WYjfr18YQaIbAf\nKKwhKdKzqpQtLebFortOOejKrOjZ1Mt7aMNpVbAqLLV7bsNqR 3WwMqEWenN\nsZYxL/Ddy/Pm2e7ZxLlUQrIj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KhKXxhRCc6\n0Yi4LOPcl6hGVUFqc4gJLGaxufKO1s2VkrOj63znOkciCKMedZ n7ARUp1rQ\niLAyIlyNYURcONaInrWs9ci4JyJOaFYawDzP8Q ZwAICLckbgd08i290eh9V\nCIadQw3qO5Oa1H1GNRlSjeorO2HLruZ2rLudAm Dm9Gxcx/GXmSIMbnjH5W2\nzy2RbOzM cENBRAWs0N9b3zXWdp8pra1r61tbXdb4N/2Nv8i5gzeIJd5Gjui\nwT AzQ9YVGrYnNO0Agm27GBkvNnNzje 921qf/ b1QEfuMDFPe5lk/lspUG3\nWKbQCofLBBBuwNEs3C3aikcrB2TTeM81HgmOd3zf/PZ3yFPNaqSXfODF0EDK\nE9e6liZmCvJwOLD7AQhU2efSbG6zm7VgiG1ofBc //nGgZ7vbYw67aVux4v/\nfXSSK53by/HVrzIwDZTBBANUrzpMeAAIWASeB4P/AQ9 cHjEJx7xWgDE5nLQ\neMdHXvKbg/zkMZ23H/1oFRjYPOc9v3nQ58Aw0xn9LACvO7HQAOZVf/jl0ii1\nHcXe9bPX3euftaPL5R71tIf97nsy7/o0WlP2r4/JOU7B r5nqva7jz1EdZ97\n4qNe bonfvCfVXvly1762beOOdLBd Q7PCAAOw==\n", alt: "Rails logo"}} } + }).toMatchMadeHttpRequest(); + }); + + it('test_20', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const custom_collection = new CustomCollection({session: test_session}); + custom_collection.id = 841564295; + custom_collection.image = { + alt: "Rails logo" + }; + await custom_collection.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/custom_collections/841564295.json', + query: '', + headers, + data: { "custom_collection": {id: 841564295, image: {alt: "Rails logo"}} } + }).toMatchMadeHttpRequest(); + }); + + it('test_21', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CustomCollection.delete({ + session: test_session, + id: 841564295, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-10/custom_collections/841564295.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-10/customer.test.ts b/src/rest-resources/__tests__/2021-10/customer.test.ts new file mode 100644 index 000000000..136ad10cb --- /dev/null +++ b/src/rest-resources/__tests__/2021-10/customer.test.ts @@ -0,0 +1,440 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Customer} from '../../2021-10'; + +describe('Customer resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.October21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Customer.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/customers.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Customer.all({ + session: test_session, + since_id: "207119551", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/customers.json', + query: 'since_id=207119551', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Customer.all({ + session: test_session, + updated_at_min: "2022-02-02 21:51:21", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/customers.json', + query: 'updated_at_min=2022-02-02+21%3A51%3A21', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Customer.all({ + session: test_session, + ids: "207119551,1073339489", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/customers.json', + query: 'ids=207119551%2C1073339489', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const customer = new Customer({session: test_session}); + customer.first_name = "Steve"; + customer.last_name = "Lastnameson"; + customer.email = "steve.lastnameson@example.com"; + customer.phone = " 15142546011"; + customer.verified_email = true; + customer.addresses = [ + { + address1: "123 Oak St", + city: "Ottawa", + province: "ON", + phone: "555-1212", + zip: "123 ABC", + last_name: "Lastnameson", + first_name: "Mother", + country: "CA" + } + ]; + customer.password = "newpass"; + customer.password_confirmation = "newpass"; + customer.send_email_welcome = false; + await customer.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/customers.json', + query: '', + headers, + data: { "customer": {first_name: "Steve", last_name: "Lastnameson", email: "steve.lastnameson@example.com", phone: " 15142546011", verified_email: true, addresses: [{address1: "123 Oak St", city: "Ottawa", province: "ON", phone: "555-1212", zip: "123 ABC", last_name: "Lastnameson", first_name: "Mother", country: "CA"}], password: "newpass", password_confirmation: "newpass", send_email_welcome: false} } + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const customer = new Customer({session: test_session}); + customer.first_name = "Steve"; + customer.last_name = "Lastnameson"; + customer.email = "steve.lastnameson@example.com"; + customer.phone = " 15142546011"; + customer.verified_email = true; + customer.addresses = [ + { + address1: "123 Oak St", + city: "Ottawa", + province: "ON", + phone: "555-1212", + zip: "123 ABC", + last_name: "Lastnameson", + first_name: "Mother", + country: "CA" + } + ]; + await customer.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/customers.json', + query: '', + headers, + data: { "customer": {first_name: "Steve", last_name: "Lastnameson", email: "steve.lastnameson@example.com", phone: " 15142546011", verified_email: true, addresses: [{address1: "123 Oak St", city: "Ottawa", province: "ON", phone: "555-1212", zip: "123 ABC", last_name: "Lastnameson", first_name: "Mother", country: "CA"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const customer = new Customer({session: test_session}); + customer.first_name = "Steve"; + customer.last_name = "Lastnameson"; + customer.email = "steve.lastnameson@example.com"; + customer.phone = " 15142546011"; + customer.verified_email = true; + customer.addresses = [ + { + address1: "123 Oak St", + city: "Ottawa", + province: "ON", + phone: "555-1212", + zip: "123 ABC", + last_name: "Lastnameson", + first_name: "Mother", + country: "CA" + } + ]; + customer.metafields = [ + { + key: "new", + value: "newvalue", + value_type: "string", + namespace: "global" + } + ]; + await customer.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/customers.json', + query: '', + headers, + data: { "customer": {first_name: "Steve", last_name: "Lastnameson", email: "steve.lastnameson@example.com", phone: " 15142546011", verified_email: true, addresses: [{address1: "123 Oak St", city: "Ottawa", province: "ON", phone: "555-1212", zip: "123 ABC", last_name: "Lastnameson", first_name: "Mother", country: "CA"}], metafields: [{key: "new", value: "newvalue", value_type: "string", namespace: "global"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const customer = new Customer({session: test_session}); + customer.first_name = "Steve"; + customer.last_name = "Lastnameson"; + customer.email = "steve.lastnameson@example.com"; + customer.phone = " 15142546011"; + customer.verified_email = true; + customer.addresses = [ + { + address1: "123 Oak St", + city: "Ottawa", + province: "ON", + phone: "555-1212", + zip: "123 ABC", + last_name: "Lastnameson", + first_name: "Mother", + country: "CA" + } + ]; + customer.send_email_invite = true; + await customer.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/customers.json', + query: '', + headers, + data: { "customer": {first_name: "Steve", last_name: "Lastnameson", email: "steve.lastnameson@example.com", phone: " 15142546011", verified_email: true, addresses: [{address1: "123 Oak St", city: "Ottawa", province: "ON", phone: "555-1212", zip: "123 ABC", last_name: "Lastnameson", first_name: "Mother", country: "CA"}], send_email_invite: true} } + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Customer.search({ + session: test_session, + query: "Bob country:United States", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/customers/search.json', + query: 'query=Bob+country%3AUnited+States', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_10', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Customer.find({ + session: test_session, + id: 207119551, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/customers/207119551.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_11', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const customer = new Customer({session: test_session}); + customer.id = 207119551; + customer.email = "changed@email.address.com"; + customer.note = "Customer is a great guy"; + await customer.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/customers/207119551.json', + query: '', + headers, + data: { "customer": {id: 207119551, email: "changed@email.address.com", note: "Customer is a great guy"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_12', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const customer = new Customer({session: test_session}); + customer.id = 207119551; + customer.metafields = [ + { + key: "new", + value: "newvalue", + value_type: "string", + namespace: "global" + } + ]; + await customer.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/customers/207119551.json', + query: '', + headers, + data: { "customer": {id: 207119551, metafields: [{key: "new", value: "newvalue", value_type: "string", namespace: "global"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_13', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const customer = new Customer({session: test_session}); + customer.id = 207119551; + customer.tags = "New Customer, Repeat Customer"; + await customer.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/customers/207119551.json', + query: '', + headers, + data: { "customer": {id: 207119551, tags: "New Customer, Repeat Customer"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_14', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const customer = new Customer({session: test_session}); + customer.id = 207119551; + customer.accepts_marketing = true; + customer.accepts_marketing_updated_at = "2022-01-31T16:45:55-05:00"; + customer.marketing_opt_in_level = "confirmed_opt_in"; + await customer.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/customers/207119551.json', + query: '', + headers, + data: { "customer": {id: 207119551, accepts_marketing: true, accepts_marketing_updated_at: "2022-01-31T16:45:55-05:00", marketing_opt_in_level: "confirmed_opt_in"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_15', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const customer = new Customer({session: test_session}); + customer.id = 207119551; + await customer.account_activation_url({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/customers/207119551/account_activation_url.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_16', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const customer = new Customer({session: test_session}); + customer.id = 207119551; + await customer.send_invite({ + body: {customer_invite: {}}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/customers/207119551/send_invite.json', + query: '', + headers, + data: {customer_invite: {}} + }).toMatchMadeHttpRequest(); + }); + + it('test_17', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const customer = new Customer({session: test_session}); + customer.id = 207119551; + await customer.send_invite({ + body: {customer_invite: {to: "new_test_email@shopify.com", from: "j.limited@example.com", bcc: ["j.limited@example.com"], subject: "Welcome to my new shop", custom_message: "My awesome new store"}}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/customers/207119551/send_invite.json', + query: '', + headers, + data: {customer_invite: {to: "new_test_email@shopify.com", from: "j.limited@example.com", bcc: ["j.limited@example.com"], subject: "Welcome to my new shop", custom_message: "My awesome new store"}} + }).toMatchMadeHttpRequest(); + }); + + it('test_18', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Customer.count({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/customers/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_19', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Customer.orders({ + session: test_session, + id: 207119551, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/customers/207119551/orders.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-10/customer_address.test.ts b/src/rest-resources/__tests__/2021-10/customer_address.test.ts new file mode 100644 index 000000000..ee7d3e5a9 --- /dev/null +++ b/src/rest-resources/__tests__/2021-10/customer_address.test.ts @@ -0,0 +1,180 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {CustomerAddress} from '../../2021-10'; + +describe('CustomerAddress resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.October21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CustomerAddress.all({ + session: test_session, + customer_id: 207119551, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/customers/207119551/addresses.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CustomerAddress.all({ + session: test_session, + customer_id: 207119551, + limit: "1", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/customers/207119551/addresses.json', + query: 'limit=1', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const customer_address = new CustomerAddress({session: test_session}); + customer_address.customer_id = 207119551; + customer_address.address1 = "1 Rue des Carrieres"; + customer_address.address2 = "Suite 1234"; + customer_address.city = "Montreal"; + customer_address.company = "Fancy Co."; + customer_address.first_name = "Samuel"; + customer_address.last_name = "de Champlain"; + customer_address.phone = "819-555-5555"; + customer_address.province = "Quebec"; + customer_address.country = "Canada"; + customer_address.zip = "G1R 4P5"; + customer_address.name = "Samuel de Champlain"; + customer_address.province_code = "QC"; + customer_address.country_code = "CA"; + customer_address.country_name = "Canada"; + await customer_address.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/customers/207119551/addresses.json', + query: '', + headers, + data: { "address": {address1: "1 Rue des Carrieres", address2: "Suite 1234", city: "Montreal", company: "Fancy Co.", first_name: "Samuel", last_name: "de Champlain", phone: "819-555-5555", province: "Quebec", country: "Canada", zip: "G1R 4P5", name: "Samuel de Champlain", province_code: "QC", country_code: "CA", country_name: "Canada"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CustomerAddress.find({ + session: test_session, + customer_id: 207119551, + id: 207119551, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/customers/207119551/addresses/207119551.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const customer_address = new CustomerAddress({session: test_session}); + customer_address.customer_id = 207119551; + customer_address.id = 207119551; + customer_address.zip = "90210"; + await customer_address.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/customers/207119551/addresses/207119551.json', + query: '', + headers, + data: { "address": {id: 207119551, zip: "90210"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CustomerAddress.delete({ + session: test_session, + customer_id: 207119551, + id: 1053317335, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-10/customers/207119551/addresses/1053317335.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const customer_address = new CustomerAddress({session: test_session}); + customer_address.customer_id = 207119551; + await customer_address.set({ + address_ids: ["1053317336"], + operation: "destroy", + }); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/customers/207119551/addresses/set.json', + query: 'address_ids%5B%5D=1053317336&operation=destroy', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const customer_address = new CustomerAddress({session: test_session}); + customer_address.customer_id = 207119551; + customer_address.id = 1053317337; + await customer_address.default({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/customers/207119551/addresses/1053317337/default.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-10/customer_saved_search.test.ts b/src/rest-resources/__tests__/2021-10/customer_saved_search.test.ts new file mode 100644 index 000000000..245cd9a50 --- /dev/null +++ b/src/rest-resources/__tests__/2021-10/customer_saved_search.test.ts @@ -0,0 +1,195 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {CustomerSavedSearch} from '../../2021-10'; + +describe('CustomerSavedSearch resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.October21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CustomerSavedSearch.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/customer_saved_searches.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CustomerSavedSearch.all({ + session: test_session, + since_id: "20610973", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/customer_saved_searches.json', + query: 'since_id=20610973', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const customer_saved_search = new CustomerSavedSearch({session: test_session}); + customer_saved_search.name = "Spent more than $50"; + customer_saved_search.query = "total_spent:>50"; + await customer_saved_search.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/customer_saved_searches.json', + query: '', + headers, + data: { "customer_saved_search": {name: "Spent more than $50", query: "total_spent:>50"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const customer_saved_search = new CustomerSavedSearch({session: test_session}); + customer_saved_search.name = "Spent more than $50 and after 2013"; + customer_saved_search.query = "total_spent:>50 order_date:>=2013-01-01"; + await customer_saved_search.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/customer_saved_searches.json', + query: '', + headers, + data: { "customer_saved_search": {name: "Spent more than $50 and after 2013", query: "total_spent:>50 order_date:>=2013-01-01"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CustomerSavedSearch.count({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/customer_saved_searches/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CustomerSavedSearch.count({ + session: test_session, + since_id: "20610973", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/customer_saved_searches/count.json', + query: 'since_id=20610973', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CustomerSavedSearch.find({ + session: test_session, + id: 789629109, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/customer_saved_searches/789629109.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const customer_saved_search = new CustomerSavedSearch({session: test_session}); + customer_saved_search.id = 789629109; + customer_saved_search.name = "This Name Has Been Changed"; + await customer_saved_search.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/customer_saved_searches/789629109.json', + query: '', + headers, + data: { "customer_saved_search": {id: 789629109, name: "This Name Has Been Changed"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CustomerSavedSearch.delete({ + session: test_session, + id: 789629109, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-10/customer_saved_searches/789629109.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_10', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CustomerSavedSearch.customers({ + session: test_session, + id: 789629109, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/customer_saved_searches/789629109/customers.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-10/deprecated_api_call.test.ts b/src/rest-resources/__tests__/2021-10/deprecated_api_call.test.ts new file mode 100644 index 000000000..870f1b6d0 --- /dev/null +++ b/src/rest-resources/__tests__/2021-10/deprecated_api_call.test.ts @@ -0,0 +1,34 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {DeprecatedApiCall} from '../../2021-10'; + +describe('DeprecatedApiCall resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.October21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await DeprecatedApiCall.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/deprecated_api_calls.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-10/discount_code.test.ts b/src/rest-resources/__tests__/2021-10/discount_code.test.ts new file mode 100644 index 000000000..1c0d632be --- /dev/null +++ b/src/rest-resources/__tests__/2021-10/discount_code.test.ts @@ -0,0 +1,184 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {DiscountCode} from '../../2021-10'; + +describe('DiscountCode resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.October21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const discount_code = new DiscountCode({session: test_session}); + discount_code.price_rule_id = 507328175; + discount_code.code = "SUMMERSALE10OFF"; + await discount_code.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/price_rules/507328175/discount_codes.json', + query: '', + headers, + data: { "discount_code": {code: "SUMMERSALE10OFF"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await DiscountCode.all({ + session: test_session, + price_rule_id: 507328175, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/price_rules/507328175/discount_codes.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const discount_code = new DiscountCode({session: test_session}); + discount_code.price_rule_id = 507328175; + discount_code.id = 507328175; + discount_code.code = "WINTERSALE20OFF"; + await discount_code.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/price_rules/507328175/discount_codes/507328175.json', + query: '', + headers, + data: { "discount_code": {id: 507328175, code: "WINTERSALE20OFF"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await DiscountCode.find({ + session: test_session, + price_rule_id: 507328175, + id: 507328175, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/price_rules/507328175/discount_codes/507328175.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await DiscountCode.delete({ + session: test_session, + price_rule_id: 507328175, + id: 507328175, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-10/price_rules/507328175/discount_codes/507328175.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await DiscountCode.count({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/discount_codes/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const discount_code = new DiscountCode({session: test_session}); + discount_code.price_rule_id = 507328175; + await discount_code.batch({ + body: {discount_codes: [{code: "SUMMER1"}, {code: "SUMMER2"}, {code: "SUMMER3"}]}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/price_rules/507328175/batch.json', + query: '', + headers, + data: {discount_codes: [{code: "SUMMER1"}, {code: "SUMMER2"}, {code: "SUMMER3"}]} + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await DiscountCode.get_all({ + session: test_session, + price_rule_id: 507328175, + batch_id: 173232803, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/price_rules/507328175/batch/173232803.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await DiscountCode.all({ + session: test_session, + price_rule_id: 507328175, + batch_id: 173232803, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/price_rules/507328175/batch/173232803/discount_codes.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-10/dispute.test.ts b/src/rest-resources/__tests__/2021-10/dispute.test.ts new file mode 100644 index 000000000..f0135be96 --- /dev/null +++ b/src/rest-resources/__tests__/2021-10/dispute.test.ts @@ -0,0 +1,88 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Dispute} from '../../2021-10'; + +describe('Dispute resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.October21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Dispute.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/shopify_payments/disputes.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Dispute.all({ + session: test_session, + status: "won", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/shopify_payments/disputes.json', + query: 'status=won', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Dispute.all({ + session: test_session, + initiated_at: "2013-05-03", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/shopify_payments/disputes.json', + query: 'initiated_at=2013-05-03', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Dispute.find({ + session: test_session, + id: 598735659, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/shopify_payments/disputes/598735659.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-10/draft_order.test.ts b/src/rest-resources/__tests__/2021-10/draft_order.test.ts new file mode 100644 index 000000000..06836b10b --- /dev/null +++ b/src/rest-resources/__tests__/2021-10/draft_order.test.ts @@ -0,0 +1,346 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {DraftOrder} from '../../2021-10'; + +describe('DraftOrder resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.October21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const draft_order = new DraftOrder({session: test_session}); + draft_order.line_items = [ + { + variant_id: 447654529, + quantity: 1 + } + ]; + await draft_order.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/draft_orders.json', + query: '', + headers, + data: { "draft_order": {line_items: [{variant_id: 447654529, quantity: 1}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const draft_order = new DraftOrder({session: test_session}); + draft_order.line_items = [ + { + title: "Custom Tee", + price: "20.00", + quantity: 2 + } + ]; + draft_order.applied_discount = { + description: "Custom discount", + value_type: "fixed_amount", + value: "10.0", + amount: "10.00", + title: "Custom" + }; + draft_order.customer = { + id: 207119551 + }; + draft_order.use_customer_default_address = true; + await draft_order.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/draft_orders.json', + query: '', + headers, + data: { "draft_order": {line_items: [{title: "Custom Tee", price: "20.00", quantity: 2}], applied_discount: {description: "Custom discount", value_type: "fixed_amount", value: "10.0", amount: "10.00", title: "Custom"}, customer: {id: 207119551}, use_customer_default_address: true} } + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const draft_order = new DraftOrder({session: test_session}); + draft_order.line_items = [ + { + title: "Custom Tee", + price: "20.00", + quantity: 1, + applied_discount: { + description: "Custom discount", + value_type: "fixed_amount", + value: "10.0", + amount: "10.0", + title: "Custom" + } + } + ]; + await draft_order.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/draft_orders.json', + query: '', + headers, + data: { "draft_order": {line_items: [{title: "Custom Tee", price: "20.00", quantity: 1, applied_discount: {description: "Custom discount", value_type: "fixed_amount", value: "10.0", amount: "10.0", title: "Custom"}}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const draft_order = new DraftOrder({session: test_session}); + draft_order.line_items = [ + { + title: "Custom Tee", + price: "20.00", + quantity: 1, + applied_discount: { + description: "Custom discount", + value_type: "percentage", + value: "10.0", + amount: "2.0", + title: "Custom" + } + } + ]; + await draft_order.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/draft_orders.json', + query: '', + headers, + data: { "draft_order": {line_items: [{title: "Custom Tee", price: "20.00", quantity: 1, applied_discount: {description: "Custom discount", value_type: "percentage", value: "10.0", amount: "2.0", title: "Custom"}}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const draft_order = new DraftOrder({session: test_session}); + draft_order.line_items = [ + { + title: "Custom Tee", + price: "20.00", + quantity: 2 + } + ]; + draft_order.customer = { + id: 207119551 + }; + draft_order.use_customer_default_address = true; + await draft_order.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/draft_orders.json', + query: '', + headers, + data: { "draft_order": {line_items: [{title: "Custom Tee", price: "20.00", quantity: 2}], customer: {id: 207119551}, use_customer_default_address: true} } + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await DraftOrder.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/draft_orders.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const draft_order = new DraftOrder({session: test_session}); + draft_order.id = 994118539; + draft_order.note = "Customer contacted us about a custom engraving on this iPod"; + await draft_order.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/draft_orders/994118539.json', + query: '', + headers, + data: { "draft_order": {id: 994118539, note: "Customer contacted us about a custom engraving on this iPod"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const draft_order = new DraftOrder({session: test_session}); + draft_order.id = 994118539; + draft_order.applied_discount = { + description: "Custom discount", + value_type: "percentage", + value: "10.0", + amount: "19.90", + title: "Custom" + }; + await draft_order.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/draft_orders/994118539.json', + query: '', + headers, + data: { "draft_order": {id: 994118539, applied_discount: {description: "Custom discount", value_type: "percentage", value: "10.0", amount: "19.90", title: "Custom"}} } + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await DraftOrder.find({ + session: test_session, + id: 994118539, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/draft_orders/994118539.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_10', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await DraftOrder.delete({ + session: test_session, + id: 994118539, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-10/draft_orders/994118539.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_11', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await DraftOrder.count({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/draft_orders/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_12', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const draft_order = new DraftOrder({session: test_session}); + draft_order.id = 994118539; + await draft_order.send_invoice({ + body: {draft_order_invoice: {to: "first@example.com", from: "j.smith@example.com", bcc: ["j.smith@example.com"], subject: "Apple Computer Invoice", custom_message: "Thank you for ordering!"}}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/draft_orders/994118539/send_invoice.json', + query: '', + headers, + data: {draft_order_invoice: {to: "first@example.com", from: "j.smith@example.com", bcc: ["j.smith@example.com"], subject: "Apple Computer Invoice", custom_message: "Thank you for ordering!"}} + }).toMatchMadeHttpRequest(); + }); + + it('test_13', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const draft_order = new DraftOrder({session: test_session}); + draft_order.id = 994118539; + await draft_order.send_invoice({ + body: {draft_order_invoice: {}}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/draft_orders/994118539/send_invoice.json', + query: '', + headers, + data: {draft_order_invoice: {}} + }).toMatchMadeHttpRequest(); + }); + + it('test_14', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const draft_order = new DraftOrder({session: test_session}); + draft_order.id = 994118539; + await draft_order.complete({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/draft_orders/994118539/complete.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_15', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const draft_order = new DraftOrder({session: test_session}); + draft_order.id = 994118539; + await draft_order.complete({ + payment_pending: "true", + }); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/draft_orders/994118539/complete.json', + query: 'payment_pending=true', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-10/event.test.ts b/src/rest-resources/__tests__/2021-10/event.test.ts new file mode 100644 index 000000000..be1e30501 --- /dev/null +++ b/src/rest-resources/__tests__/2021-10/event.test.ts @@ -0,0 +1,216 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Event} from '../../2021-10'; + +describe('Event resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.October21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Event.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/events.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Event.all({ + session: test_session, + created_at_min: "2008-01-10 12:30:00+00:00", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/events.json', + query: 'created_at_min=2008-01-10+12%3A30%3A00%2B00%3A00', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Event.all({ + session: test_session, + order_id: 450789469, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/orders/450789469/events.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Event.all({ + session: test_session, + order_id: 450789469, + limit: "1", + since_id: "164748010", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/orders/450789469/events.json', + query: 'limit=1&since_id=164748010', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Event.all({ + session: test_session, + product_id: 921728736, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/products/921728736/events.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Event.all({ + session: test_session, + since_id: "164748010", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/events.json', + query: 'since_id=164748010', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Event.all({ + session: test_session, + filter: "Product,Order", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/events.json', + query: 'filter=Product%2COrder', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Event.all({ + session: test_session, + filter: "Product", + verb: "destroy", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/events.json', + query: 'filter=Product&verb=destroy', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Event.find({ + session: test_session, + id: 677313116, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/events/677313116.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_10', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Event.count({ + session: test_session, + created_at_min: "2008-01-10T13:00:00+00:00", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/events/count.json', + query: 'created_at_min=2008-01-10T13%3A00%3A00%2B00%3A00', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_11', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Event.count({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/events/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-10/fulfillment.test.ts b/src/rest-resources/__tests__/2021-10/fulfillment.test.ts new file mode 100644 index 000000000..7d1a23846 --- /dev/null +++ b/src/rest-resources/__tests__/2021-10/fulfillment.test.ts @@ -0,0 +1,581 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Fulfillment} from '../../2021-10'; + +describe('Fulfillment resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.October21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Fulfillment.all({ + session: test_session, + order_id: 450789469, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/orders/450789469/fulfillments.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Fulfillment.all({ + session: test_session, + order_id: 450789469, + since_id: "255858046", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/orders/450789469/fulfillments.json', + query: 'since_id=255858046', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment = new Fulfillment({session: test_session}); + fulfillment.order_id = 450789469; + fulfillment.location_id = 487838322; + fulfillment.tracking_number = "123456789"; + fulfillment.tracking_urls = [ + "https://shipping.xyz/track.php?num=123456789", + "https://anothershipper.corp/track.php?code=abc" + ]; + fulfillment.notify_customer = true; + await fulfillment.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/orders/450789469/fulfillments.json', + query: '', + headers, + data: { "fulfillment": {location_id: 487838322, tracking_number: "123456789", tracking_urls: ["https://shipping.xyz/track.php?num=123456789", "https://anothershipper.corp/track.php?code=abc"], notify_customer: true} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment = new Fulfillment({session: test_session}); + fulfillment.order_id = 450789469; + fulfillment.location_id = 655441491; + fulfillment.tracking_number = null; + fulfillment.line_items = [ + { + id: 518995019 + } + ]; + await fulfillment.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/orders/450789469/fulfillments.json', + query: '', + headers, + data: { "fulfillment": {location_id: 655441491, tracking_number: null, line_items: [{id: 518995019}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment = new Fulfillment({session: test_session}); + fulfillment.order_id = 450789469; + fulfillment.location_id = 655441491; + fulfillment.tracking_numbers = [ + "88b451840563b72cc15d3fcb6179f302", + "aee587edbd98ad725d27974c808ec7d6", + "94e71192ecf091ea5c25b69c385c2b1b" + ]; + fulfillment.line_items = [ + { + id: 518995019 + } + ]; + await fulfillment.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/orders/450789469/fulfillments.json', + query: '', + headers, + data: { "fulfillment": {location_id: 655441491, tracking_numbers: ["88b451840563b72cc15d3fcb6179f302", "aee587edbd98ad725d27974c808ec7d6", "94e71192ecf091ea5c25b69c385c2b1b"], line_items: [{id: 518995019}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment = new Fulfillment({session: test_session}); + fulfillment.order_id = 450789469; + fulfillment.location_id = 655441491; + fulfillment.tracking_url = "http://www.packagetrackr.com/track/somecarrier/1234567"; + fulfillment.tracking_company = "Jack Black's Pack, Stack and Track"; + fulfillment.line_items = [ + { + id: 518995019 + } + ]; + await fulfillment.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/orders/450789469/fulfillments.json', + query: '', + headers, + data: { "fulfillment": {location_id: 655441491, tracking_url: "http://www.packagetrackr.com/track/somecarrier/1234567", tracking_company: "Jack Black's Pack, Stack and Track", line_items: [{id: 518995019}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment = new Fulfillment({session: test_session}); + fulfillment.order_id = 450789469; + fulfillment.location_id = 655441491; + fulfillment.tracking_number = "123456789"; + fulfillment.tracking_company = "4PX"; + fulfillment.line_items = [ + { + id: 518995019 + } + ]; + await fulfillment.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/orders/450789469/fulfillments.json', + query: '', + headers, + data: { "fulfillment": {location_id: 655441491, tracking_number: "123456789", tracking_company: "4PX", line_items: [{id: 518995019}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment = new Fulfillment({session: test_session}); + fulfillment.order_id = 450789469; + fulfillment.location_id = 655441491; + fulfillment.tracking_number = "123456789010"; + fulfillment.tracking_company = "fed ex"; + fulfillment.line_items = [ + { + id: 518995019 + } + ]; + await fulfillment.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/orders/450789469/fulfillments.json', + query: '', + headers, + data: { "fulfillment": {location_id: 655441491, tracking_number: "123456789010", tracking_company: "fed ex", line_items: [{id: 518995019}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment = new Fulfillment({session: test_session}); + fulfillment.order_id = 450789469; + fulfillment.location_id = 655441491; + fulfillment.tracking_number = "123456789010"; + fulfillment.tracking_company = "fed ex"; + fulfillment.tracking_url = "https://www.new-fedex-tracking.com/?number=123456789010"; + fulfillment.line_items = [ + { + id: 518995019 + } + ]; + await fulfillment.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/orders/450789469/fulfillments.json', + query: '', + headers, + data: { "fulfillment": {location_id: 655441491, tracking_number: "123456789010", tracking_company: "fed ex", tracking_url: "https://www.new-fedex-tracking.com/?number=123456789010", line_items: [{id: 518995019}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_10', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment = new Fulfillment({session: test_session}); + fulfillment.order_id = 450789469; + fulfillment.location_id = 655441491; + fulfillment.tracking_number = "RR123456789CN"; + fulfillment.tracking_company = "Chinese Post"; + fulfillment.line_items = [ + { + id: 518995019 + } + ]; + await fulfillment.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/orders/450789469/fulfillments.json', + query: '', + headers, + data: { "fulfillment": {location_id: 655441491, tracking_number: "RR123456789CN", tracking_company: "Chinese Post", line_items: [{id: 518995019}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_11', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment = new Fulfillment({session: test_session}); + fulfillment.order_id = 450789469; + fulfillment.location_id = 655441491; + fulfillment.tracking_number = "1234567"; + fulfillment.tracking_company = "Custom Tracking Company"; + fulfillment.line_items = [ + { + id: 518995019 + } + ]; + await fulfillment.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/orders/450789469/fulfillments.json', + query: '', + headers, + data: { "fulfillment": {location_id: 655441491, tracking_number: "1234567", tracking_company: "Custom Tracking Company", line_items: [{id: 518995019}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_12', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment = new Fulfillment({session: test_session}); + fulfillment.order_id = 450789469; + fulfillment.location_id = 655441491; + fulfillment.tracking_number = "CJ274101086US"; + fulfillment.tracking_url = "http://www.custom-tracking.com/?tracking_number=CJ274101086US"; + fulfillment.line_items = [ + { + id: 518995019 + } + ]; + await fulfillment.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/orders/450789469/fulfillments.json', + query: '', + headers, + data: { "fulfillment": {location_id: 655441491, tracking_number: "CJ274101086US", tracking_url: "http://www.custom-tracking.com/?tracking_number=CJ274101086US", line_items: [{id: 518995019}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_13', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment = new Fulfillment({session: test_session}); + fulfillment.order_id = 450789469; + fulfillment.location_id = 655441491; + fulfillment.tracking_number = null; + fulfillment.line_items = [ + { + id: 518995019 + } + ]; + await fulfillment.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/orders/450789469/fulfillments.json', + query: '', + headers, + data: { "fulfillment": {location_id: 655441491, tracking_number: null, line_items: [{id: 518995019}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_14', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment = new Fulfillment({session: test_session}); + fulfillment.order_id = 450789469; + fulfillment.location_id = 655441491; + fulfillment.tracking_number = null; + fulfillment.line_items = [ + { + id: 518995019, + quantity: 1 + } + ]; + await fulfillment.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/orders/450789469/fulfillments.json', + query: '', + headers, + data: { "fulfillment": {location_id: 655441491, tracking_number: null, line_items: [{id: 518995019, quantity: 1}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_15', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Fulfillment.all({ + session: test_session, + fulfillment_order_id: 1046000859, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/fulfillment_orders/1046000859/fulfillments.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_16', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Fulfillment.count({ + session: test_session, + order_id: 450789469, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/orders/450789469/fulfillments/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_17', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Fulfillment.find({ + session: test_session, + order_id: 450789469, + id: 255858046, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/orders/450789469/fulfillments/255858046.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_18', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment = new Fulfillment({session: test_session}); + fulfillment.order_id = 450789469; + fulfillment.id = 255858046; + fulfillment.tracking_number = "987654321"; + await fulfillment.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/orders/450789469/fulfillments/255858046.json', + query: '', + headers, + data: { "fulfillment": {tracking_number: "987654321", id: 255858046} } + }).toMatchMadeHttpRequest(); + }); + + it('test_19', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment = new Fulfillment({session: test_session}); + fulfillment.message = "The package was shipped this morning."; + fulfillment.notify_customer = false; + fulfillment.tracking_info = { + number: 1562678, + url: "https://www.my-shipping-company.com", + company: "my-shipping-company" + }; + fulfillment.line_items_by_fulfillment_order = [ + { + fulfillment_order_id: 1046000873, + fulfillment_order_line_items: [ + { + id: 1058737644, + quantity: 1 + } + ] + } + ]; + await fulfillment.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/fulfillments.json', + query: '', + headers, + data: { "fulfillment": {message: "The package was shipped this morning.", notify_customer: false, tracking_info: {number: 1562678, url: "https://www.my-shipping-company.com", company: "my-shipping-company"}, line_items_by_fulfillment_order: [{fulfillment_order_id: 1046000873, fulfillment_order_line_items: [{id: 1058737644, quantity: 1}]}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_20', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment = new Fulfillment({session: test_session}); + fulfillment.message = "The package was shipped this morning."; + fulfillment.notify_customer = false; + fulfillment.tracking_info = { + number: 1562678, + url: "https://www.my-shipping-company.com", + company: "my-shipping-company" + }; + fulfillment.line_items_by_fulfillment_order = [ + { + fulfillment_order_id: 1046000874 + } + ]; + await fulfillment.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/fulfillments.json', + query: '', + headers, + data: { "fulfillment": {message: "The package was shipped this morning.", notify_customer: false, tracking_info: {number: 1562678, url: "https://www.my-shipping-company.com", company: "my-shipping-company"}, line_items_by_fulfillment_order: [{fulfillment_order_id: 1046000874}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_21', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment = new Fulfillment({session: test_session}); + fulfillment.id = 1069019908; + await fulfillment.update_tracking({ + body: {fulfillment: {notify_customer: true, tracking_info: {number: "1111", url: "http://www.my-url.com", company: "my-company"}}}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/fulfillments/1069019908/update_tracking.json', + query: '', + headers, + data: { "fulfillment": {notify_customer: true, tracking_info: {number: "1111", url: "http://www.my-url.com", company: "my-company"}} } + }).toMatchMadeHttpRequest(); + }); + + it('test_22', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment = new Fulfillment({session: test_session}); + fulfillment.order_id = 450789469; + fulfillment.id = 255858046; + await fulfillment.complete({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/orders/450789469/fulfillments/255858046/complete.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_23', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment = new Fulfillment({session: test_session}); + fulfillment.order_id = 450789469; + fulfillment.id = 255858046; + await fulfillment.open({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/orders/450789469/fulfillments/255858046/open.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_24', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment = new Fulfillment({session: test_session}); + fulfillment.order_id = 450789469; + fulfillment.id = 255858046; + await fulfillment.cancel({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/orders/450789469/fulfillments/255858046/cancel.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_25', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment = new Fulfillment({session: test_session}); + fulfillment.id = 1069019909; + await fulfillment.cancel({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/fulfillments/1069019909/cancel.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-10/fulfillment_event.test.ts b/src/rest-resources/__tests__/2021-10/fulfillment_event.test.ts new file mode 100644 index 000000000..dc11d04c2 --- /dev/null +++ b/src/rest-resources/__tests__/2021-10/fulfillment_event.test.ts @@ -0,0 +1,95 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {FulfillmentEvent} from '../../2021-10'; + +describe('FulfillmentEvent resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.October21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await FulfillmentEvent.all({ + session: test_session, + order_id: 450789469, + fulfillment_id: 255858046, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/orders/450789469/fulfillments/255858046/events.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment_event = new FulfillmentEvent({session: test_session}); + fulfillment_event.order_id = 450789469; + fulfillment_event.fulfillment_id = 255858046; + fulfillment_event.status = "in_transit"; + await fulfillment_event.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/orders/450789469/fulfillments/255858046/events.json', + query: '', + headers, + data: { "event": {status: "in_transit"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await FulfillmentEvent.find({ + session: test_session, + order_id: 450789469, + fulfillment_id: 255858046, + id: 944956395, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/orders/450789469/fulfillments/255858046/events/944956395.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await FulfillmentEvent.delete({ + session: test_session, + order_id: 450789469, + fulfillment_id: 255858046, + id: 944956397, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-10/orders/450789469/fulfillments/255858046/events/944956397.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-10/fulfillment_order.test.ts b/src/rest-resources/__tests__/2021-10/fulfillment_order.test.ts new file mode 100644 index 000000000..7adde6f15 --- /dev/null +++ b/src/rest-resources/__tests__/2021-10/fulfillment_order.test.ts @@ -0,0 +1,180 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {FulfillmentOrder} from '../../2021-10'; + +describe('FulfillmentOrder resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.October21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await FulfillmentOrder.all({ + session: test_session, + order_id: 450789469, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/orders/450789469/fulfillment_orders.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await FulfillmentOrder.find({ + session: test_session, + id: 1046000847, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/fulfillment_orders/1046000847.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment_order = new FulfillmentOrder({session: test_session}); + fulfillment_order.id = 1046000848; + await fulfillment_order.cancel({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/fulfillment_orders/1046000848/cancel.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment_order = new FulfillmentOrder({session: test_session}); + fulfillment_order.id = 1046000851; + await fulfillment_order.close({ + body: {fulfillment_order: {message: "Not enough inventory to complete this work."}}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/fulfillment_orders/1046000851/close.json', + query: '', + headers, + data: { "fulfillment_order": {message: "Not enough inventory to complete this work."} } + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment_order = new FulfillmentOrder({session: test_session}); + fulfillment_order.id = 1046000852; + await fulfillment_order.move({ + body: {fulfillment_order: {new_location_id: 655441491}}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/fulfillment_orders/1046000852/move.json', + query: '', + headers, + data: { "fulfillment_order": {new_location_id: 655441491} } + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment_order = new FulfillmentOrder({session: test_session}); + fulfillment_order.id = 1046000854; + await fulfillment_order.open({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/fulfillment_orders/1046000854/open.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment_order = new FulfillmentOrder({session: test_session}); + fulfillment_order.id = 1046000855; + await fulfillment_order.reschedule({ + body: {fulfillment_order: {new_fulfill_at: "2023-03-03"}}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/fulfillment_orders/1046000855/reschedule.json', + query: '', + headers, + data: { "fulfillment_order": {new_fulfill_at: "2023-03-03"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment_order = new FulfillmentOrder({session: test_session}); + fulfillment_order.id = 1046000856; + await fulfillment_order.hold({ + body: {fulfillment_hold: {reason: "inventory_out_of_stock", reason_notes: "Not enough inventory to complete this work."}}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/fulfillment_orders/1046000856/hold.json', + query: '', + headers, + data: {fulfillment_hold: {reason: "inventory_out_of_stock", reason_notes: "Not enough inventory to complete this work."}} + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment_order = new FulfillmentOrder({session: test_session}); + fulfillment_order.id = 1046000858; + await fulfillment_order.release_hold({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/fulfillment_orders/1046000858/release_hold.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-10/fulfillment_request.test.ts b/src/rest-resources/__tests__/2021-10/fulfillment_request.test.ts new file mode 100644 index 000000000..463f1c8bc --- /dev/null +++ b/src/rest-resources/__tests__/2021-10/fulfillment_request.test.ts @@ -0,0 +1,101 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {FulfillmentRequest} from '../../2021-10'; + +describe('FulfillmentRequest resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.October21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment_request = new FulfillmentRequest({session: test_session}); + fulfillment_request.fulfillment_order_id = 1046000840; + fulfillment_request.message = "Fulfill this ASAP please."; + fulfillment_request.fulfillment_order_line_items = [ + { + id: 1058737578, + quantity: 1 + }, + { + id: 1058737579, + quantity: 1 + } + ]; + await fulfillment_request.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/fulfillment_orders/1046000840/fulfillment_request.json', + query: '', + headers, + data: { "fulfillment_request": {message: "Fulfill this ASAP please.", fulfillment_order_line_items: [{id: 1058737578, quantity: 1}, {id: 1058737579, quantity: 1}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment_request = new FulfillmentRequest({session: test_session}); + fulfillment_request.fulfillment_order_id = 1046000843; + fulfillment_request.message = "Fulfill this ASAP please."; + await fulfillment_request.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/fulfillment_orders/1046000843/fulfillment_request.json', + query: '', + headers, + data: { "fulfillment_request": {message: "Fulfill this ASAP please."} } + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment_request = new FulfillmentRequest({session: test_session}); + fulfillment_request.fulfillment_order_id = 1046000844; + await fulfillment_request.accept({ + body: {fulfillment_request: {message: "We will start processing your fulfillment on the next business day."}}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/fulfillment_orders/1046000844/fulfillment_request/accept.json', + query: '', + headers, + data: { "fulfillment_request": {message: "We will start processing your fulfillment on the next business day."} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment_request = new FulfillmentRequest({session: test_session}); + fulfillment_request.fulfillment_order_id = 1046000845; + await fulfillment_request.reject({ + body: {fulfillment_request: {message: "Not enough inventory on hand to complete the work."}}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/fulfillment_orders/1046000845/fulfillment_request/reject.json', + query: '', + headers, + data: { "fulfillment_request": {message: "Not enough inventory on hand to complete the work."} } + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-10/fulfillment_service.test.ts b/src/rest-resources/__tests__/2021-10/fulfillment_service.test.ts new file mode 100644 index 000000000..eb9bd2819 --- /dev/null +++ b/src/rest-resources/__tests__/2021-10/fulfillment_service.test.ts @@ -0,0 +1,128 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {FulfillmentService} from '../../2021-10'; + +describe('FulfillmentService resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.October21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await FulfillmentService.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/fulfillment_services.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await FulfillmentService.all({ + session: test_session, + scope: "all", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/fulfillment_services.json', + query: 'scope=all', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment_service = new FulfillmentService({session: test_session}); + fulfillment_service.name = "Jupiter Fulfillment"; + fulfillment_service.callback_url = "http://google.com"; + fulfillment_service.inventory_management = true; + fulfillment_service.tracking_support = true; + fulfillment_service.requires_shipping_method = true; + fulfillment_service.format = "json"; + await fulfillment_service.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/fulfillment_services.json', + query: '', + headers, + data: { "fulfillment_service": {name: "Jupiter Fulfillment", callback_url: "http://google.com", inventory_management: true, tracking_support: true, requires_shipping_method: true, format: "json"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await FulfillmentService.find({ + session: test_session, + id: 755357713, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/fulfillment_services/755357713.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment_service = new FulfillmentService({session: test_session}); + fulfillment_service.id = 755357713; + fulfillment_service.name = "New Fulfillment Service Name"; + await fulfillment_service.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/fulfillment_services/755357713.json', + query: '', + headers, + data: { "fulfillment_service": {id: 755357713, name: "New Fulfillment Service Name"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await FulfillmentService.delete({ + session: test_session, + id: 755357713, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-10/fulfillment_services/755357713.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-10/gift_card.test.ts b/src/rest-resources/__tests__/2021-10/gift_card.test.ts new file mode 100644 index 000000000..f84d4b6c0 --- /dev/null +++ b/src/rest-resources/__tests__/2021-10/gift_card.test.ts @@ -0,0 +1,215 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {GiftCard} from '../../2021-10'; + +describe('GiftCard resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.October21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await GiftCard.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/gift_cards.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await GiftCard.all({ + session: test_session, + status: "enabled", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/gift_cards.json', + query: 'status=enabled', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const gift_card = new GiftCard({session: test_session}); + gift_card.note = "This is a note"; + gift_card.initial_value = 100.0; + gift_card.code = "ABCD EFGH IJKL MNOP"; + gift_card.template_suffix = "gift_cards.birthday.liquid"; + await gift_card.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/gift_cards.json', + query: '', + headers, + data: { "gift_card": {note: "This is a note", initial_value: 100.0, code: "ABCD EFGH IJKL MNOP", template_suffix: "gift_cards.birthday.liquid"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const gift_card = new GiftCard({session: test_session}); + gift_card.initial_value = 25.0; + await gift_card.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/gift_cards.json', + query: '', + headers, + data: { "gift_card": {initial_value: 25.0} } + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await GiftCard.find({ + session: test_session, + id: 1035197676, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/gift_cards/1035197676.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const gift_card = new GiftCard({session: test_session}); + gift_card.id = 1035197676; + gift_card.note = "Updating with a new note"; + await gift_card.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/gift_cards/1035197676.json', + query: '', + headers, + data: { "gift_card": {id: 1035197676, note: "Updating with a new note"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const gift_card = new GiftCard({session: test_session}); + gift_card.id = 1035197676; + gift_card.expires_on = "2020-01-01"; + await gift_card.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/gift_cards/1035197676.json', + query: '', + headers, + data: { "gift_card": {id: 1035197676, expires_on: "2020-01-01"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await GiftCard.count({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/gift_cards/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await GiftCard.count({ + session: test_session, + status: "enabled", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/gift_cards/count.json', + query: 'status=enabled', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_10', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const gift_card = new GiftCard({session: test_session}); + gift_card.id = 1035197676; + await gift_card.disable({ + body: {gift_card: {id: 1035197676}}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/gift_cards/1035197676/disable.json', + query: '', + headers, + data: { "gift_card": {id: 1035197676} } + }).toMatchMadeHttpRequest(); + }); + + it('test_11', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await GiftCard.search({ + session: test_session, + query: "last_characters:mnop", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/gift_cards/search.json', + query: 'query=last_characters%3Amnop', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-10/gift_card_adjustment.test.ts b/src/rest-resources/__tests__/2021-10/gift_card_adjustment.test.ts new file mode 100644 index 000000000..4829e8735 --- /dev/null +++ b/src/rest-resources/__tests__/2021-10/gift_card_adjustment.test.ts @@ -0,0 +1,131 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {GiftCardAdjustment} from '../../2021-10'; + +describe('GiftCardAdjustment resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.October21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await GiftCardAdjustment.all({ + session: test_session, + gift_card_id: 1035197676, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/gift_cards/1035197676/adjustments.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const gift_card_adjustment = new GiftCardAdjustment({session: test_session}); + gift_card_adjustment.gift_card_id = 1035197676; + gift_card_adjustment.amount = 10.0; + gift_card_adjustment.note = "Customer refilled gift card by $10"; + await gift_card_adjustment.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/gift_cards/1035197676/adjustments.json', + query: '', + headers, + data: { "adjustment": {amount: 10.0, note: "Customer refilled gift card by $10"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const gift_card_adjustment = new GiftCardAdjustment({session: test_session}); + gift_card_adjustment.gift_card_id = 1035197676; + gift_card_adjustment.amount = -20.0; + gift_card_adjustment.note = "Customer spent $20 via external service"; + await gift_card_adjustment.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/gift_cards/1035197676/adjustments.json', + query: '', + headers, + data: { "adjustment": {amount: -20.0, note: "Customer spent $20 via external service"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const gift_card_adjustment = new GiftCardAdjustment({session: test_session}); + gift_card_adjustment.gift_card_id = 1035197676; + gift_card_adjustment.amount = 10.0; + gift_card_adjustment.remote_transaction_ref = "gift_card_app_transaction_193402"; + gift_card_adjustment.remote_transaction_url = "http://example.com/my-gift-card-app/gift_card_adjustments/193402"; + await gift_card_adjustment.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/gift_cards/1035197676/adjustments.json', + query: '', + headers, + data: { "adjustment": {amount: 10.0, remote_transaction_ref: "gift_card_app_transaction_193402", remote_transaction_url: "http://example.com/my-gift-card-app/gift_card_adjustments/193402"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const gift_card_adjustment = new GiftCardAdjustment({session: test_session}); + gift_card_adjustment.gift_card_id = 1035197676; + gift_card_adjustment.amount = 10.0; + gift_card_adjustment.processed_at = "2021-08-03T16:57:35-04:00"; + await gift_card_adjustment.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/gift_cards/1035197676/adjustments.json', + query: '', + headers, + data: { "adjustment": {amount: 10.0, processed_at: "2021-08-03T16:57:35-04:00"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await GiftCardAdjustment.find({ + session: test_session, + gift_card_id: 1035197676, + id: 9, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/gift_cards/1035197676/adjustments/9.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-10/image.test.ts b/src/rest-resources/__tests__/2021-10/image.test.ts new file mode 100644 index 000000000..36399274b --- /dev/null +++ b/src/rest-resources/__tests__/2021-10/image.test.ts @@ -0,0 +1,305 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Image} from '../../2021-10'; + +describe('Image resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.October21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Image.all({ + session: test_session, + product_id: 632910392, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/products/632910392/images.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Image.all({ + session: test_session, + product_id: 632910392, + since_id: "850703190", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/products/632910392/images.json', + query: 'since_id=850703190', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const image = new Image({session: test_session}); + image.product_id = 632910392; + image.attachment = "R0lGODlhbgCMAPf/APbr48VySrxTO7IgKt2qmKQdJeK8lsFjROG5p/nz7Zg3\nMNmnd7Q1MLNVS9GId71hSJMZIuzTu4UtKbeEeakhKMl8U8WYjfr18YQaIbAf\nKKwhKdKzqpQtLebFortOOejKrOjZ1Mt7aMNpVbAqLLV7bsNqR 3WwMqEWenN\nsZYxL/Ddy/Pm2e7ZxLlUQrIjNPXp3bU5MbhENbEtLtqhj5ZQTfHh0bMxL7Ip\nNsNyUYkZIrZJPcqGdYIUHb5aPKkeJnoUHd2yiJkiLKYiKLRFOsyJXKVDO8up\nosFaS TBnK4kKti5sNaYg/z49aqYl5kqLrljUtORfMOlo/36 H4ZH8yDYq0f\nKKFYTaU9MrY8MrZBNXwXHpgaIdGVYu/byLZNP9SaZLIyOuXCtHkpJst Wpcm\nLMyCa8BfP9GMb9KQdPDd1PPk1sd5VP79/L5dQZ0bI9 ymqssK9WcfIoXHdzG\nxdWWfteib79lSr1YP86MYurQxKdcUKdMQr5ZSfPs6YEZH8uhl4oWIenMuurQ\nttmejaqoqsqBVaAcJLlJN5kvMLlZRMNsSL5fRak0LbdQQMVvSPjw6cJnRpkf\nKtmjhvfu5cJtT7IuOMVvWLY/M/37 o0YH9ibhtSYdObErc6HarM9NnYSGNGR\navLi09unje3WyeO8rsVrT7tdRtK3uffu6NWeaL9pTJIjJrM4NPbx8cdyX7M7\nPYYVHu7j4KgoNJAYIKtkV5o9MsOcldicis RYNutfrhFOZ0hJbqinZ8bI8h5\nU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WlP2r4/JOU7B r5nqva7jz1EdZ97\n4qNe bonfvCfVXvly1762beOOdLBd Q7PCAAOw==\n"; + image.filename = "rails_logo.gif"; + await image.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/products/632910392/images.json', + query: '', + headers, + data: { "image": {attachment: "R0lGODlhbgCMAPf/APbr48VySrxTO7IgKt2qmKQdJeK8lsFjROG5p/nz7Zg3\nMNmnd7Q1MLNVS9GId71hSJMZIuzTu4UtKbeEeakhKMl8U8WYjfr18YQaIbAf\nKKwhKdKzqpQtLebFortOOejKrOjZ1Mt7aMNpVbAqLLV7bsNqR 3WwMqEWenN\nsZYxL/Ddy/Pm2e7ZxLlUQrIjNPXp3bU5MbhENbEtLtqhj5ZQTfHh0bMxL7Ip\nNsNyUYkZIrZJPcqGdYIUHb5aPKkeJnoUHd2yiJkiLKYiKLRFOsyJXKVDO8up\nosFaS TBnK4kKti5sNaYg/z49aqYl5kqLrljUtORfMOlo/36 H4ZH8yDYq0f\nKKFYTaU9MrY8MrZBNXwXHpgaIdGVYu/byLZNP9SaZLIyOuXCtHkpJst Wpcm\nLMyCa8BfP9GMb9KQdPDd1PPk1sd5VP79/L5dQZ0bI9 ymqssK9WcfIoXHdzG\nxdWWfteib79lSr1YP86MYurQxKdcUKdMQr5ZSfPs6YEZH8uhl4oWIenMuurQ\nttmejaqoqsqBVaAcJLlJN5kvMLlZRMNsSL5fRak0LbdQQMVvSPjw6cJnRpkf\nKtmjhvfu5cJtT7IuOMVvWLY/M/37 o0YH9ibhtSYdObErc6HarM9NnYSGNGR\navLi09unje3WyeO8rsVrT7tdRtK3uffu6NWeaL9pTJIjJrM4NPbx8cdyX7M7\nPYYVHu7j4KgoNJAYIKtkV5o9MsOcldicis RYNutfrhFOZ0hJbqinZ8bI8h5\nUObFuOfItJsfJrJfUOfIqc PXqQtK8RnSbA4Mcd3Tm0SGbpXQ8aqp7RLNs s\novHfzpVhV9iggMd1TLtbRKUdKXEQFsd4XrZRPLIgMZU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+ + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const image = new Image({session: test_session}); + image.product_id = 632910392; + image.src = "http://example.com/rails_logo.gif"; + await image.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/products/632910392/images.json', + query: '', + headers, + data: { "image": {src: "http://example.com/rails_logo.gif"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const image = new Image({session: test_session}); + image.product_id = 632910392; + image.position = 1; + image.attachment = "R0lGODlhbgCMAPf/APbr48VySrxTO7IgKt2qmKQdJeK8lsFjROG5p/nz7Zg3\nMNmnd7Q1MLNVS9GId71hSJMZIuzTu4UtKbeEeakhKMl8U8WYjfr18YQaIbAf\nKKwhKdKzqpQtLebFortOOejKrOjZ1Mt7aMNpVbAqLLV7bsNqR 3WwMqEWenN\nsZYxL/Ddy/Pm2e7ZxLlUQrIjNPXp3bU5MbhENbEtLtqhj5ZQTfHh0bMxL7Ip\nNsNyUYkZIrZJPcqGdYIUHb5aPKkeJnoUHd2yiJkiLKYiKLRFOsyJXKVDO8up\nosFaS TBnK4kKti5sNaYg/z49aqYl5kqLrljUtORfMOlo/36 H4ZH8yDYq0f\nKKFYTaU9MrY8MrZBNXwXHpgaIdGVYu/byLZNP9SaZLIyOuXCtHkpJst Wpcm\nLMyCa8BfP9GMb9KQdPDd1PPk1sd5VP79/L5dQZ0bI9 ymqssK9WcfIoXHdzG\nxdWWfteib79lSr1YP86MYurQxKdcUKdMQr5ZSfPs6YEZH8uhl4oWIenMuurQ\nttmejaqoqsqBVaAcJLlJN5kvMLlZRMNsSL5fRak0LbdQQMVvSPjw6cJnRpkf\nKtmjhvfu5cJtT7IuOMVvWLY/M/37 o0YH9ibhtSYdObErc6HarM9NnYSGNGR\navLi09unje3WyeO8rsVrT7tdRtK3uffu6NWeaL9pTJIjJrM4NPbx8cdyX7M7\nPYYVHu7j4KgoNJAYIKtkV5o9MsOcldicis RYNut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9bPX3euftaPL5R71tIf97nsy7/o0WlP2r4/JOU7B r5nqva7jz1EdZ97\n4qNe bonfvCfVXvly1762beOOdLBd Q7PCAAOw==\n"; + image.filename = "rails_logo.gif"; + await image.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/products/632910392/images.json', + query: '', + headers, + data: { "image": {position: 1, attachment: "R0lGODlhbgCMAPf/APbr48VySrxTO7IgKt2qmKQdJeK8lsFjROG5p/nz7Zg3\nMNmnd7Q1MLNVS9GId71hSJMZIuzTu4UtKbeEeakhKMl8U8WYjfr18YQaIbAf\nKKwhKdKzqpQtLebFortOOejKrOjZ1Mt7aMNpVbAqLLV7bsNqR 3WwMqEWenN\nsZYxL/Ddy/Pm2e7ZxLlUQrIjNPXp3bU5MbhENbEtLtqhj5ZQTfHh0bMxL7Ip\nNsNyUYkZIrZJPcqGdYIUHb5aPKkeJnoUHd2yiJkiLKYiKLRFOsyJXKVDO8up\nosFaS TBnK4kKti5sNaYg/z49aqYl5kqLrljUtORfMOlo/36 H4ZH8yDYq0f\nKKFYTaU9MrY8MrZBNXwXHpgaIdGVYu/byLZNP9SaZLIyOuXCtHkpJst Wpcm\nLMyCa8BfP9GMb9KQdPDd1PPk1sd5VP79/L5dQZ0bI9 ymqssK9WcfIoXHdzG\nxdWWfteib79lSr1YP86MYurQxKdcUKdMQr5ZSfPs6YEZH8uhl4oWIenMuurQ\nttmejaqoqsqBVaAcJLlJN5kvMLlZRMNsSL5fRak0LbdQQMVvSPjw6cJnRpkf\nKtmjhvfu5cJtT7IuOMVvWLY/M/37 o0YH9ibhtSYdObErc6HarM9NnYSGNGR\navLi09unje3WyeO8rsVrT7tdRtK3uffu6NWeaL9pTJIjJrM4NPbx8cdyX7M7\nPYYVHu7j4KgoNJAYIKtkV5o9MsOcldicis RYNutfrhFOZ0hJbqinZ8bI8h5\nUObFuOfItJsfJrJfUOfIqc PXqQtK8RnSbA4Mcd3Tm0SGbpXQ8aqp7RLNs s\novHfzpVhV9iggM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logo.gif"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const image = new Image({session: test_session}); + image.product_id = 632910392; + image.variant_ids = [ + 808950810, + 457924702 + ]; + image.attachment = "R0lGODlhbgCMAPf/APbr48VySrxTO7IgKt2qmKQdJeK8lsFjROG5p/nz7Zg3\nMNmnd7Q1MLNVS9GId71hSJMZIuzTu4UtKbeEeakhKMl8U8WYjfr18YQaIbAf\nKKwhKdKzqpQtLebFortOOejKrOjZ1Mt7aMNpVbAqLLV7bsNqR 3WwMqEWenN\nsZYxL/Ddy/Pm2e7ZxLlUQrIjNPXp3bU5MbhENbEtLtqhj5ZQTfHh0bMxL7Ip\nNsNyUYkZIrZJPcqGdYIUHb5aPKkeJnoUHd2yiJkiLKYiKLRFOsyJXKVDO8up\nosFaS TBnK4kKti5sNaYg/z49aqYl5kqLrljUtORfMOlo/36 H4ZH8yDYq0f\nKKFYTaU9MrY8MrZBNXwXHpgaIdGVYu/byLZNP9SaZLIyOuXCtHkpJst Wpcm\nLMyCa8BfP9GMb9KQdPDd1PPk1sd5VP79/L5dQZ0bI9 ymqssK9WcfIoXHdzG\nxdWWfteib79lSr1YP86MYurQxKdcUKdMQr5ZSfPs6YEZH8uhl4oWIenMuurQ\nttmejaqoqsqBVaAcJLlJN5kvMLlZRMNsSL5fRak0LbdQQMVvSPjw6cJnRpkf\nKtmjhvfu5cJtT7IuOMVvWLY/M/37 o0YH9ibhtSYdObErc6HarM9NnYSGNGR\navLi09unje3WyeO8rsVrT7tdRtK3uffu6NWeaL9pTJIjJrM4NPbx8cdyX7M7\nPYYVHu7j4KgoNJAYIKtkV5o9MsOcldicis RYNutfrhFOZ0hJbqinZ8bI8h5\nUObFuOfItJsfJrJfUOfIqc PXqQtK8RnSbA4Mcd3Tm0SGbpXQ8aqp7RLNs s\novHfzpVhV9iggMd1TLtbRKUdKXEQFsd4XrZRPLIgMZUeJ jKvrAlK6AhJ65A\nMpMpKu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Wsy01rXs2MFj2ZGC6862KKRgHGY6K9zlEPdyP8AJcteo\n3ClsQCHq0AF0QdkN HbjlxygL31hO13tMrW7lwkB0BiUoR3x4EfmrYlCNjAF\nCRAoIWmwQexQqQcyxHe 9eXAfVOQAg7k16v7jQsAHGi2Bv0gUzyQQ05Ga Cy\n0MBEDsZgN8gQ4QnXt7oJ0QOGOZACDTeEu0aTCwC80EKhDcAHMDGHWATMsuMC\nFsVl/9GnP0Jg0kw24MUv/qUTOGDlCj8WETfGsVx2vI UzsATIFZUaTIRk3QY\n ZYlFq0Ce5QJHBXgdU MRCSwEYlVBCHPQZhyn7vhhD9fWdAc2DKhKXxhRCc6\n0Yi4LOPcl6hGVUFqc4gJLGaxufKO1s2VkrOj63znOkciCKMedZ n7ARUp1rQ\niLAyIlyNYURcONaInrWs9ci4JyJOaFYawDzP8Q ZwAICLckbgd08i290eh9V\nCIadQw3qO5Oa1H1GNRlSjeorO2HLruZ2rLudAm Dm9Gxcx/GXmSIMbnjH5W2\nzy2RbOzM cENBRAWs0N9b3zXWdp8pra1r61tbXdb4N/2Nv8i5gzeIJd5Gjui\nwT AzQ9YVGrYnNO0Agm27GBkvNnNzje 921qf/ b1QEfuMDFPe5lk/lspUG3\nWKbQCofLBBBuwNEs3C3aikcrB2TTeM81HgmOd3zf/PZ3yFPNaqSXfODF0EDK\nE9e6liZmCvJwOLD7AQhU2efSbG6zm7VgiG1ofBc //nGgZ7vbYw67aVux4v/\nfXSSK53by/HVrzIwDZTBBANUrzpMeAAIWASeB4P/AQ9 cHjEJx7xWgDE5nLQ\neMdHXvKbg/zkMZ23H/1oFRjYPOc9v3nQ58Aw0xn9LACvO7HQAOZVf/jl0ii1\nHcXe9bPX3euftaPL5R71tIf97nsy7/o0WlP2r4/JOU7B r5nqva7jz1EdZ97\n4qNe bonfvCfVXvly1762beOOdLBd Q7PCAAOw==\n"; + image.filename = "rails_logo.gif"; + await image.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/products/632910392/images.json', + query: '', + headers, + data: { "image": {variant_ids: [808950810, 457924702], attachment: "R0lGODlhbgCMAPf/APbr48VySrxTO7IgKt2qmKQdJeK8lsFjROG5p/nz7Zg3\nMNmnd7Q1MLNVS9GId71hSJMZIuzTu4UtKbeEeakhKMl8U8WYjfr18YQaIbAf\nKKwhKdKzqpQtLebFortOOejKrOjZ1Mt7aMNpVbAqLLV7bsNqR 3WwMqEWenN\nsZYxL/Ddy/Pm2e7ZxLlUQrIjNPXp3bU5MbhENbEtLtqhj5ZQTfHh0bMxL7Ip\nNsNyUYkZIrZJPcqGdYIUHb5aPKkeJnoUHd2yiJkiLKYiKLRFOsyJXKVDO8up\nosFaS TBnK4kKti5sNaYg/z49aqYl5kqLrljUtORfMOlo/36 H4ZH8yDYq0f\nKKFYTaU9MrY8MrZBNXwXHpgaIdGVYu/byLZNP9SaZLIyOuXCtHkpJst Wpcm\nLMyCa8BfP9GMb9KQdPDd1PPk1sd5VP79/L5dQZ0bI9 ymqssK9WcfIoXHdzG\nxdWWfteib79lSr1YP86MYurQxKdcUKdMQr5ZSfPs6YEZH8uhl4oWIenMuurQ\nttmejaqoqsqBVaAcJLlJN5kvMLlZRMNsSL5fRak0LbdQQMVvSPjw6cJnRpkf\nKtmjhvfu5cJtT7IuOMVvWLY/M/37 o0YH9ibhtSYdObErc6HarM9NnYSGNGR\navLi09unje3WyeO8rsVrT7tdRtK3uffu6NWeaL9pTJIjJrM4NPbx8cdyX7M7\nPYYVHu7j4KgoNJAYIKtkV5o9MsOcldicis RYNutfrhFOZ0hJbqinZ8bI8h5\nUObFuOfItJsfJrJfUOfIqc PXqQtK8RnSbA4Mcd3Tm0SGbpXQ8aqp7RLNs s\novHfzpVhV9iggMd1TLtbRKUdKXEQFsd4XrZRPLIgMZUeJ jKvrAlK6AhJ65A\nMpMpKuC3j5obIsRwS7hAN8l/YtvDvnYXHbAoLI47SIUsOMenorF4gO/m4 fH\npo4vLZ8oKMukqp0cJbhVSMV2UuPR0bAfM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R3x4EfmrYlCNjAF\nCRAoIWmwQexQqQcyxHe 9eXAfVOQAg7k16v7jQsAHGi2Bv0gUzyQQ05Ga Cy\n0MBEDsZgN8gQ4QnXt7oJ0QOGOZACDTeEu0aTCwC80EKhDcAHMDGHWATMsuMC\nFsVl/9GnP0Jg0kw24MUv/qUTOGDlCj8WETfGsVx2vI UzsATIFZUaTIRk3QY\n ZYlFq0Ce5QJHBXgdU MRCSwEYlVBCHPQZhyn7vhhD9fWdAc2DKhKXxhRCc6\n0Yi4LOPcl6hGVUFqc4gJLGaxufKO1s2VkrOj63znOkciCKMedZ n7ARUp1rQ\niLAyIlyNYURcONaInrWs9ci4JyJOaFYawDzP8Q ZwAICLckbgd08i290eh9V\nCIadQw3qO5Oa1H1GNRlSjeorO2HLruZ2rLudAm Dm9Gxcx/GXmSIMbnjH5W2\nzy2RbOzM cENBRAWs0N9b3zXWdp8pra1r61tbXdb4N/2Nv8i5gzeIJd5Gjui\nwT AzQ9YVGrYnNO0Agm27GBkvNnNzje 921qf/ b1QEfuMDFPe5lk/lspUG3\nWKbQCofLBBBuwNEs3C3aikcrB2TTeM81HgmOd3zf/PZ3yFPNaqSXfODF0EDK\nE9e6liZmCvJwOLD7AQhU2efSbG6zm7VgiG1ofBc //nGgZ7vbYw67aVux4v/\nfXSSK53by/HVrzIwDZTBBANUrzpMeAAIWASeB4P/AQ9 cHjEJx7xWgDE5nLQ\neMdHXvKbg/zkMZ23H/1oFRjYPOc9v3nQ58Aw0xn9LACvO7HQAOZVf/jl0ii1\nHcXe9bPX3euftaPL5R71tIf97nsy7/o0WlP2r4/JOU7B r5nqva7jz1EdZ97\n4qNe bonfvCfVXvly1762beOOdLBd Q7PCAAOw==\n", filename: "rails_logo.gif"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const image = new Image({session: test_session}); + image.product_id = 632910392; + image.position = 1; + image.metafields = [ + { + key: "new", + value: "newvalue", + type: "single_line_text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IWmwQexQqQcyxHe 9eXAfVOQAg7k16v7jQsAHGi2Bv0gUzyQQ05Ga Cy\n0MBEDsZgN8gQ4QnXt7oJ0QOGOZACDTeEu0aTCwC80EKhDcAHMDGHWATMsuMC\nFsVl/9GnP0Jg0kw24MUv/qUTOGDlCj8WETfGsVx2vI UzsATIFZUaTIRk3QY\n ZYlFq0Ce5QJHBXgdU MRCSwEYlVBCHPQZhyn7vhhD9fWdAc2DKhKXxhRCc6\n0Yi4LOPcl6hGVUFqc4gJLGaxufKO1s2VkrOj63znOkciCKMedZ n7ARUp1rQ\niLAyIlyNYURcONaInrWs9ci4JyJOaFYawDzP8Q ZwAICLckbgd08i290eh9V\nCIadQw3qO5Oa1H1GNRlSjeorO2HLruZ2rLudAm Dm9Gxcx/GXmSIMbnjH5W2\nzy2RbOzM cENBRAWs0N9b3zXWdp8pra1r61tbXdb4N/2Nv8i5gzeIJd5Gjui\nwT AzQ9YVGrYnNO0Agm27GBkvNnNzje 921qf/ b1QEfuMDFPe5lk/lspUG3\nWKbQCofLBBBuwNEs3C3aikcrB2TTeM81HgmOd3zf/PZ3yFPNaqSXfODF0EDK\nE9e6liZmCvJwOLD7AQhU2efSbG6zm7VgiG1ofBc //nGgZ7vbYw67aVux4v/\nfXSSK53by/HVrzIwDZTBBANUrzpMeAAIWASeB4P/AQ9 cHjEJx7xWgDE5nLQ\neMdHXvKbg/zkMZ23H/1oFRjYPOc9v3nQ58Aw0xn9LACvO7HQAOZVf/jl0ii1\nHcXe9bPX3euftaPL5R71tIf97nsy7/o0WlP2r4/JOU7B r5nqva7jz1EdZ97\n4qNe bonfvCfVXvly1762beOOdLBd Q7PCAAOw==\n"; + image.filename = "rails_logo.gif"; + await image.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/products/632910392/images.json', + query: '', + headers, + data: { "image": {position: 1, metafields: [{key: "new", value: "newvalue", type: "single_line_text_field", namespace: "global"}], attachment: "R0lGODlhbgCMAPf/APbr48VySrxTO7IgKt2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\n0MBEDsZgN8gQ4QnXt7oJ0QOGOZACDTeEu0aTCwC80EKhDcAHMDGHWATMsuMC\nFsVl/9GnP0Jg0kw24MUv/qUTOGDlCj8WETfGsVx2vI UzsATIFZUaTIRk3QY\n ZYlFq0Ce5QJHBXgdU MRCSwEYlVBCHPQZhyn7vhhD9fWdAc2DKhKXxhRCc6\n0Yi4LOPcl6hGVUFqc4gJLGaxufKO1s2VkrOj63znOkciCKMedZ n7ARUp1rQ\niLAyIlyNYURcONaInrWs9ci4JyJOaFYawDzP8Q ZwAICLckbgd08i290eh9V\nCIadQw3qO5Oa1H1GNRlSjeorO2HLruZ2rLudAm Dm9Gxcx/GXmSIMbnjH5W2\nzy2RbOzM cENBRAWs0N9b3zXWdp8pra1r61tbXdb4N/2Nv8i5gzeIJd5Gjui\nwT AzQ9YVGrYnNO0Agm27GBkvNnNzje 921qf/ b1QEfuMDFPe5lk/lspUG3\nWKbQCofLBBBuwNEs3C3aikcrB2TTeM81HgmOd3zf/PZ3yFPNaqSXfODF0EDK\nE9e6liZmCvJwOLD7AQhU2efSbG6zm7VgiG1ofBc //nGgZ7vbYw67aVux4v/\nfXSSK53by/HVrzIwDZTBBANUrzpMeAAIWASeB4P/AQ9 cHjEJx7xWgDE5nLQ\neMdHXvKbg/zkMZ23H/1oFRjYPOc9v3nQ58Aw0xn9LACvO7HQAOZVf/jl0ii1\nHcXe9bPX3euftaPL5R71tIf97nsy7/o0WlP2r4/JOU7B r5nqva7jz1EdZ97\n4qNe bonfvCfVXvly1762beOOdLBd Q7PCAAOw==\n", filename: "rails_logo.gif"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Image.count({ + session: test_session, + product_id: 632910392, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/products/632910392/images/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Image.count({ + session: test_session, + product_id: 632910392, + since_id: "850703190", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/products/632910392/images/count.json', + query: 'since_id=850703190', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_10', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Image.find({ + session: test_session, + product_id: 632910392, + id: 850703190, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/products/632910392/images/850703190.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_11', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const image = new Image({session: test_session}); + image.product_id = 632910392; + image.id = 850703190; + image.position = 2; + image.alt = "new alt tag content"; + await image.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/products/632910392/images/850703190.json', + query: '', + headers, + data: { "image": {id: 850703190, position: 2, alt: "new alt tag content"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_12', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const image = new Image({session: test_session}); + image.product_id = 632910392; + image.id = 850703190; + image.variant_ids = [ + 808950810, + 457924702 + ]; + await image.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/products/632910392/images/850703190.json', + query: '', + headers, + data: { "image": {id: 850703190, variant_ids: [808950810, 457924702]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_13', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const image = new Image({session: test_session}); + image.product_id = 632910392; + image.id = 850703190; + image.metafields = [ + { + key: "my_new_metafield", + value: "my_new_value", + type: "single_line_text_field", + namespace: "tags" + } + ]; + await image.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/products/632910392/images/850703190.json', + query: '', + headers, + data: { "image": {id: 850703190, metafields: [{key: "my_new_metafield", value: "my_new_value", type: "single_line_text_field", namespace: "tags"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_14', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Image.delete({ + session: test_session, + product_id: 632910392, + id: 850703190, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-10/products/632910392/images/850703190.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-10/inventory_item.test.ts b/src/rest-resources/__tests__/2021-10/inventory_item.test.ts new file mode 100644 index 000000000..e46e75ab1 --- /dev/null +++ b/src/rest-resources/__tests__/2021-10/inventory_item.test.ts @@ -0,0 +1,89 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {InventoryItem} from '../../2021-10'; + +describe('InventoryItem resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.October21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await InventoryItem.all({ + session: test_session, + ids: "808950810,39072856,457924702", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/inventory_items.json', + query: 'ids=808950810%2C39072856%2C457924702', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await InventoryItem.find({ + session: test_session, + id: 808950810, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/inventory_items/808950810.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const inventory_item = new InventoryItem({session: test_session}); + inventory_item.id = 808950810; + inventory_item.sku = "new sku"; + await inventory_item.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/inventory_items/808950810.json', + query: '', + headers, + data: { "inventory_item": {id: 808950810, sku: "new sku"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const inventory_item = new InventoryItem({session: test_session}); + inventory_item.id = 808950810; + inventory_item.cost = "25.00"; + await inventory_item.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/inventory_items/808950810.json', + query: '', + headers, + data: { "inventory_item": {id: 808950810, cost: "25.00"} } + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-10/inventory_level.test.ts b/src/rest-resources/__tests__/2021-10/inventory_level.test.ts new file mode 100644 index 000000000..e5a1b3884 --- /dev/null +++ b/src/rest-resources/__tests__/2021-10/inventory_level.test.ts @@ -0,0 +1,148 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {InventoryLevel} from '../../2021-10'; + +describe('InventoryLevel resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.October21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await InventoryLevel.all({ + session: test_session, + inventory_item_ids: "808950810,39072856", + location_ids: "655441491,487838322", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/inventory_levels.json', + query: 'inventory_item_ids=808950810%2C39072856&location_ids=655441491%2C487838322', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await InventoryLevel.all({ + session: test_session, + inventory_item_ids: "808950810", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/inventory_levels.json', + query: 'inventory_item_ids=808950810', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await InventoryLevel.all({ + session: test_session, + location_ids: "655441491", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/inventory_levels.json', + query: 'location_ids=655441491', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const inventory_level = new InventoryLevel({session: test_session}); + + await inventory_level.adjust({ + body: {location_id: 655441491, inventory_item_id: 808950810, available_adjustment: 5}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/inventory_levels/adjust.json', + query: '', + headers, + data: {location_id: 655441491, inventory_item_id: 808950810, available_adjustment: 5} + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await InventoryLevel.delete({ + session: test_session, + inventory_item_id: "808950810", + location_id: "655441491", + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-10/inventory_levels.json', + query: 'inventory_item_id=808950810&location_id=655441491', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const inventory_level = new InventoryLevel({session: test_session}); + + await inventory_level.connect({ + body: {location_id: 844681632, inventory_item_id: 457924702}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/inventory_levels/connect.json', + query: '', + headers, + data: {location_id: 844681632, inventory_item_id: 457924702} + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const inventory_level = new InventoryLevel({session: test_session}); + + await inventory_level.set({ + body: {location_id: 655441491, inventory_item_id: 808950810, available: 42}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/inventory_levels/set.json', + query: '', + headers, + data: {location_id: 655441491, inventory_item_id: 808950810, available: 42} + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-10/location.test.ts b/src/rest-resources/__tests__/2021-10/location.test.ts new file mode 100644 index 000000000..d8fa16287 --- /dev/null +++ b/src/rest-resources/__tests__/2021-10/location.test.ts @@ -0,0 +1,87 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Location} from '../../2021-10'; + +describe('Location resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.October21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Location.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/locations.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Location.find({ + session: test_session, + id: 487838322, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/locations/487838322.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Location.count({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/locations/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Location.inventory_levels({ + session: test_session, + id: 487838322, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/locations/487838322/inventory_levels.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-10/locations_for_move.test.ts b/src/rest-resources/__tests__/2021-10/locations_for_move.test.ts new file mode 100644 index 000000000..8e748da97 --- /dev/null +++ b/src/rest-resources/__tests__/2021-10/locations_for_move.test.ts @@ -0,0 +1,35 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {LocationsForMove} from '../../2021-10'; + +describe('LocationsForMove resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.October21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await LocationsForMove.all({ + session: test_session, + fulfillment_order_id: 1046000833, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/fulfillment_orders/1046000833/locations_for_move.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-10/marketing_event.test.ts b/src/rest-resources/__tests__/2021-10/marketing_event.test.ts new file mode 100644 index 000000000..6594c8508 --- /dev/null +++ b/src/rest-resources/__tests__/2021-10/marketing_event.test.ts @@ -0,0 +1,159 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {MarketingEvent} from '../../2021-10'; + +describe('MarketingEvent resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.October21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await MarketingEvent.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/marketing_events.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const marketing_event = new MarketingEvent({session: test_session}); + marketing_event.started_at = "2022-12-15"; + marketing_event.utm_campaign = "Christmas2022"; + marketing_event.utm_source = "facebook"; + marketing_event.utm_medium = "cpc"; + marketing_event.event_type = "ad"; + marketing_event.referring_domain = "facebook.com"; + marketing_event.marketing_channel = "social"; + marketing_event.paid = true; + await marketing_event.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/marketing_events.json', + query: '', + headers, + data: { "marketing_event": {started_at: "2022-12-15", utm_campaign: "Christmas2022", utm_source: "facebook", utm_medium: "cpc", event_type: "ad", referring_domain: "facebook.com", marketing_channel: "social", paid: true} } + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await MarketingEvent.count({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/marketing_events/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await MarketingEvent.find({ + session: test_session, + id: 998730532, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/marketing_events/998730532.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const marketing_event = new MarketingEvent({session: test_session}); + marketing_event.id = 998730532; + marketing_event.remote_id = "1000:2000"; + marketing_event.started_at = "2022-02-02T00:00 00:00"; + marketing_event.ended_at = "2022-02-03T00:00 00:00"; + marketing_event.scheduled_to_end_at = "2022-02-04T00:00 00:00"; + marketing_event.budget = "11.1"; + marketing_event.budget_type = "daily"; + marketing_event.currency = "CAD"; + marketing_event.utm_campaign = "other"; + marketing_event.utm_source = "other"; + marketing_event.utm_medium = "other"; + marketing_event.event_type = "ad"; + marketing_event.referring_domain = "instagram.com"; + await marketing_event.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/marketing_events/998730532.json', + query: '', + headers, + data: { "marketing_event": {id: 998730532, remote_id: "1000:2000", started_at: "2022-02-02T00:00 00:00", ended_at: "2022-02-03T00:00 00:00", scheduled_to_end_at: "2022-02-04T00:00 00:00", budget: "11.1", budget_type: "daily", currency: "CAD", utm_campaign: "other", utm_source: "other", utm_medium: "other", event_type: "ad", referring_domain: "instagram.com"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await MarketingEvent.delete({ + session: test_session, + id: 998730532, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-10/marketing_events/998730532.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const marketing_event = new MarketingEvent({session: test_session}); + marketing_event.id = 998730532; + await marketing_event.engagements({ + body: {engagements: [{occurred_on: "2022-01-15", views_count: 0, clicks_count: 0, favorites_count: 0, ad_spend: 10.0, is_cumulative: true}, {occurred_on: "2022-01-16", views_count: 100, clicks_count: 50, is_cumulative: true}, {occurred_on: "2022-01-17", views_count: 200, clicks_count: 100, is_cumulative: true}]}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/marketing_events/998730532/engagements.json', + query: '', + headers, + data: {engagements: [{occurred_on: "2022-01-15", views_count: 0, clicks_count: 0, favorites_count: 0, ad_spend: 10.0, is_cumulative: true}, {occurred_on: "2022-01-16", views_count: 100, clicks_count: 50, is_cumulative: true}, {occurred_on: "2022-01-17", views_count: 200, clicks_count: 100, is_cumulative: true}]} + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-10/metafield.test.ts b/src/rest-resources/__tests__/2021-10/metafield.test.ts new file mode 100644 index 000000000..47cc57711 --- /dev/null +++ b/src/rest-resources/__tests__/2021-10/metafield.test.ts @@ -0,0 +1,162 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Metafield} from '../../2021-10'; + +describe('Metafield resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.October21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Metafield.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/metafields.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Metafield.all({ + session: test_session, + since_id: "721389482", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/metafields.json', + query: 'since_id=721389482', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const metafield = new Metafield({session: test_session}); + metafield.namespace = "inventory"; + metafield.key = "warehouse"; + metafield.value = 25; + metafield.type = "number_integer"; + await metafield.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/metafields.json', + query: '', + headers, + data: { "metafield": {namespace: "inventory", key: "warehouse", value: 25, type: "number_integer"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Metafield.all({ + session: test_session, + metafield: {owner_id: "850703190", owner_resource: "product_image"}, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/metafields.json', + query: 'metafield%5Bowner_id%5D=850703190&metafield%5Bowner_resource%5D=product_image', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Metafield.count({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/metafields/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Metafield.find({ + session: test_session, + id: 721389482, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/metafields/721389482.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const metafield = new Metafield({session: test_session}); + metafield.id = 721389482; + metafield.value = "something new"; + metafield.type = "single_line_text_field"; + await metafield.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/metafields/721389482.json', + query: '', + headers, + data: { "metafield": {id: 721389482, value: "something new", type: "single_line_text_field"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Metafield.delete({ + session: test_session, + id: 721389482, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-10/metafields/721389482.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-10/mobile_platform_application.test.ts b/src/rest-resources/__tests__/2021-10/mobile_platform_application.test.ts new file mode 100644 index 000000000..9fe634020 --- /dev/null +++ b/src/rest-resources/__tests__/2021-10/mobile_platform_application.test.ts @@ -0,0 +1,162 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {MobilePlatformApplication} from '../../2021-10'; + +describe('MobilePlatformApplication resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.October21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await MobilePlatformApplication.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/mobile_platform_applications.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const mobile_platform_application = new MobilePlatformApplication({session: test_session}); + mobile_platform_application.platform = "ios"; + mobile_platform_application.application_id = "X1Y2.ca.domain.app"; + mobile_platform_application.enabled_universal_or_app_links = true; + mobile_platform_application.enabled_shared_webcredentials = true; + await mobile_platform_application.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/mobile_platform_applications.json', + query: '', + headers, + data: { "mobile_platform_application": {platform: "ios", application_id: "X1Y2.ca.domain.app", enabled_universal_or_app_links: true, enabled_shared_webcredentials: true} } + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const mobile_platform_application = new MobilePlatformApplication({session: test_session}); + mobile_platform_application.platform = "android"; + mobile_platform_application.application_id = "com.example"; + mobile_platform_application.sha256_cert_fingerprints = [ + "14:6D:E9:83:C5:73:06:50:D8:EE:B9:95:2F:34:FC:64:16:A0:83:42:E6:1D:BE:A8:8A:04:96:B2:3F:CF:44:E5" + ]; + mobile_platform_application.enabled_universal_or_app_links = true; + await mobile_platform_application.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/mobile_platform_applications.json', + query: '', + headers, + data: { "mobile_platform_application": {platform: "android", application_id: "com.example", sha256_cert_fingerprints: ["14:6D:E9:83:C5:73:06:50:D8:EE:B9:95:2F:34:FC:64:16:A0:83:42:E6:1D:BE:A8:8A:04:96:B2:3F:CF:44:E5"], enabled_universal_or_app_links: true} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await MobilePlatformApplication.find({ + session: test_session, + id: 1066176008, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/mobile_platform_applications/1066176008.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const mobile_platform_application = new MobilePlatformApplication({session: test_session}); + mobile_platform_application.id = 1066176009; + mobile_platform_application.application_id = "A1B2.ca.domain.app"; + mobile_platform_application.platform = "ios"; + mobile_platform_application.created_at = "2022-02-03T16:41:55-05:00"; + mobile_platform_application.updated_at = "2022-02-03T16:41:55-05:00"; + mobile_platform_application.sha256_cert_fingerprints = []; + mobile_platform_application.enabled_universal_or_app_links = true; + mobile_platform_application.enabled_shared_webcredentials = true; + await mobile_platform_application.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/mobile_platform_applications/1066176009.json', + query: '', + headers, + data: { "mobile_platform_application": {id: 1066176009, application_id: "A1B2.ca.domain.app", platform: "ios", created_at: "2022-02-03T16:41:55-05:00", updated_at: "2022-02-03T16:41:55-05:00", sha256_cert_fingerprints: [], enabled_universal_or_app_links: true, enabled_shared_webcredentials: true} } + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const mobile_platform_application = new MobilePlatformApplication({session: test_session}); + mobile_platform_application.id = 1066176010; + mobile_platform_application.application_id = "com.example.news.app"; + mobile_platform_application.platform = "android"; + mobile_platform_application.created_at = "2022-02-03T16:41:57-05:00"; + mobile_platform_application.updated_at = "2022-02-03T16:41:57-05:00"; + mobile_platform_application.sha256_cert_fingerprints = [ + "14:6D:E9:83:C5:73:06:50:D8:EE:B9:95:2F:34:FC:64:16:A0:83:42:E6:1D:BE:A8:8A:04:96:B2:3F:CF:44:E5" + ]; + mobile_platform_application.enabled_universal_or_app_links = true; + mobile_platform_application.enabled_shared_webcredentials = false; + await mobile_platform_application.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/mobile_platform_applications/1066176010.json', + query: '', + headers, + data: { "mobile_platform_application": {id: 1066176010, application_id: "com.example.news.app", platform: "android", created_at: "2022-02-03T16:41:57-05:00", updated_at: "2022-02-03T16:41:57-05:00", sha256_cert_fingerprints: ["14:6D:E9:83:C5:73:06:50:D8:EE:B9:95:2F:34:FC:64:16:A0:83:42:E6:1D:BE:A8:8A:04:96:B2:3F:CF:44:E5"], enabled_universal_or_app_links: true, enabled_shared_webcredentials: false} } + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await MobilePlatformApplication.delete({ + session: test_session, + id: 1066176011, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-10/mobile_platform_applications/1066176011.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-10/order.test.ts b/src/rest-resources/__tests__/2021-10/order.test.ts new file mode 100644 index 000000000..8c500d48e --- /dev/null +++ b/src/rest-resources/__tests__/2021-10/order.test.ts @@ -0,0 +1,814 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Order} from '../../2021-10'; + +describe('Order resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.October21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Order.all({ + session: test_session, + status: "any", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/orders.json', + query: 'status=any', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Order.all({ + session: test_session, + ids: "1073459980", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/orders.json', + query: 'ids=1073459980', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Order.all({ + session: test_session, + financial_status: "authorized", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/orders.json', + query: 'financial_status=authorized', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Order.all({ + session: test_session, + updated_at_min: "2005-07-31T15:57:11-04:00", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/orders.json', + query: 'updated_at_min=2005-07-31T15%3A57%3A11-04%3A00', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Order.all({ + session: test_session, + fields: "created_at,id,name,total-price", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/orders.json', + query: 'fields=created_at%2Cid%2Cname%2Ctotal-price', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Order.all({ + session: test_session, + since_id: "123", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/orders.json', + query: 'since_id=123', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Order.find({ + session: test_session, + id: 450789469, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/orders/450789469.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Order.find({ + session: test_session, + id: 450789469, + fields: "id,line_items,name,total_price", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/orders/450789469.json', + query: 'fields=id%2Cline_items%2Cname%2Ctotal_price', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order = new Order({session: test_session}); + order.id = 450789469; + order.note = "Customer contacted us about a custom engraving on this iPod"; + await order.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/orders/450789469.json', + query: '', + headers, + data: { "order": {id: 450789469, note: "Customer contacted us about a custom engraving on this iPod"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_10', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order = new Order({session: test_session}); + order.id = 450789469; + order.note_attributes = [ + { + name: "colour", + value: "red" + } + ]; + await order.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/orders/450789469.json', + query: '', + headers, + data: { "order": {id: 450789469, note_attributes: [{name: "colour", value: "red"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_11', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order = new Order({session: test_session}); + order.id = 450789469; + order.email = "a-different@email.com"; + await order.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/orders/450789469.json', + query: '', + headers, + data: { "order": {id: 450789469, email: "a-different@email.com"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_12', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order = new Order({session: test_session}); + order.id = 450789469; + order.phone = " 15145556677"; + await order.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/orders/450789469.json', + query: '', + headers, + data: { "order": {id: 450789469, phone: " 15145556677"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_13', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order = new Order({session: test_session}); + order.id = 450789469; + order.buyer_accepts_marketing = true; + await order.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/orders/450789469.json', + query: '', + headers, + data: { "order": {id: 450789469, buyer_accepts_marketing: true} } + }).toMatchMadeHttpRequest(); + }); + + it('test_14', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order = new Order({session: test_session}); + order.id = 450789469; + order.shipping_address = { + address1: "123 Ship Street", + city: "Shipsville" + }; + await order.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/orders/450789469.json', + query: '', + headers, + data: { "order": {id: 450789469, shipping_address: {address1: "123 Ship Street", city: "Shipsville"}} } + }).toMatchMadeHttpRequest(); + }); + + it('test_15', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order = new Order({session: test_session}); + order.id = 450789469; + order.customer = null; + await order.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/orders/450789469.json', + query: '', + headers, + data: { "order": {id: 450789469, customer: null} } + }).toMatchMadeHttpRequest(); + }); + + it('test_16', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order = new Order({session: test_session}); + order.id = 450789469; + order.tags = "External, Inbound, Outbound"; + await order.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/orders/450789469.json', + query: '', + headers, + data: { "order": {id: 450789469, tags: "External, Inbound, Outbound"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_17', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order = new Order({session: test_session}); + order.id = 450789469; + order.metafields = [ + { + key: "new", + value: "newvalue", + type: "single_line_text_field", + namespace: "global" + } + ]; + await order.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/orders/450789469.json', + query: '', + headers, + data: { "order": {id: 450789469, metafields: [{key: "new", value: "newvalue", type: "single_line_text_field", namespace: "global"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_18', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Order.delete({ + session: test_session, + id: 450789469, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-10/orders/450789469.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_19', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Order.count({ + session: test_session, + status: "any", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/orders/count.json', + query: 'status=any', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_20', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Order.count({ + session: test_session, + financial_status: "authorized", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/orders/count.json', + query: 'financial_status=authorized', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_21', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order = new Order({session: test_session}); + order.id = 450789469; + await order.close({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/orders/450789469/close.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_22', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order = new Order({session: test_session}); + order.id = 450789469; + await order.open({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/orders/450789469/open.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_23', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order = new Order({session: test_session}); + order.id = 450789469; + await order.cancel({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/orders/450789469/cancel.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_24', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order = new Order({session: test_session}); + order.id = 450789469; + await order.cancel({ + body: {amount: "10.00", currency: "USD"}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/orders/450789469/cancel.json', + query: '', + headers, + data: {amount: "10.00", currency: "USD"} + }).toMatchMadeHttpRequest(); + }); + + it('test_25', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order = new Order({session: test_session}); + order.id = 450789469; + await order.cancel({ + body: {refund: {note: "Customer made a mistake", shipping: {full_refund: true}, refund_line_items: [{line_item_id: 466157049, quantity: 1, restock_type: "cancel", location_id: 24826418}], transactions: [{parent_id: 1068278509, amount: "10.00", kind: "refund", gateway: "bogus"}, {parent_id: 1068278510, amount: "100.00", kind: "refund", gateway: "gift_card"}]}}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/orders/450789469/cancel.json', + query: '', + headers, + data: {refund: {note: "Customer made a mistake", shipping: {full_refund: true}, refund_line_items: [{line_item_id: 466157049, quantity: 1, restock_type: "cancel", location_id: 24826418}], transactions: [{parent_id: 1068278509, amount: "10.00", kind: "refund", gateway: "bogus"}, {parent_id: 1068278510, amount: "100.00", kind: "refund", gateway: "gift_card"}]}} + }).toMatchMadeHttpRequest(); + }); + + it('test_26', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order = new Order({session: test_session}); + order.line_items = [ + { + variant_id: 447654529, + quantity: 1 + } + ]; + await order.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/orders.json', + query: '', + headers, + data: { "order": {line_items: [{variant_id: 447654529, quantity: 1}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_27', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order = new Order({session: test_session}); + order.email = "foo@example.com"; + order.fulfillment_status = "fulfilled"; + order.send_receipt = true; + order.send_fulfillment_receipt = true; + order.line_items = [ + { + variant_id: 457924702, + quantity: 1 + } + ]; + await order.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/orders.json', + query: '', + headers, + data: { "order": {email: "foo@example.com", fulfillment_status: "fulfilled", send_receipt: true, send_fulfillment_receipt: true, line_items: [{variant_id: 457924702, quantity: 1}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_28', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order = new Order({session: test_session}); + order.email = "foo@example.com"; + order.fulfillment_status = "fulfilled"; + order.line_items = [ + { + variant_id: 447654529, + quantity: 1 + } + ]; + await order.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/orders.json', + query: '', + headers, + data: { "order": {email: "foo@example.com", fulfillment_status: "fulfilled", line_items: [{variant_id: 447654529, quantity: 1}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_29', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order = new Order({session: test_session}); + order.email = "foo@example.com"; + order.fulfillment_status = "fulfilled"; + order.fulfillments = [ + { + location_id: 24826418 + } + ]; + order.line_items = [ + { + variant_id: 447654529, + quantity: 1 + } + ]; + await order.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/orders.json', + query: '', + headers, + data: { "order": {email: "foo@example.com", fulfillment_status: "fulfilled", fulfillments: [{location_id: 24826418}], line_items: [{variant_id: 447654529, quantity: 1}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_30', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order = new Order({session: test_session}); + order.line_items = [ + { + title: "Big Brown Bear Boots", + price: 74.99, + grams: "1300", + quantity: 3, + tax_lines: [ + { + price: 13.5, + rate: 0.06, + title: "State tax" + } + ] + } + ]; + order.transactions = [ + { + kind: "sale", + status: "success", + amount: 238.47 + } + ]; + order.total_tax = 13.5; + order.currency = "EUR"; + await order.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/orders.json', + query: '', + headers, + data: { "order": {line_items: [{title: "Big Brown Bear Boots", price: 74.99, grams: "1300", quantity: 3, tax_lines: [{price: 13.5, rate: 0.06, title: "State tax"}]}], transactions: [{kind: "sale", status: "success", amount: 238.47}], total_tax: 13.5, currency: "EUR"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_31', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order = new Order({session: test_session}); + order.line_items = [ + { + title: "Red Leather Coat", + price: 129.99, + grams: "1700", + quantity: 1 + }, + { + title: "Blue Suede Shoes", + price: 85.95, + grams: "750", + quantity: 1, + taxable: false + }, + { + title: "Raspberry Beret", + price: 19.99, + grams: "320", + quantity: 2 + } + ]; + order.tax_lines = [ + { + price: 10.2, + rate: 0.06, + title: "State tax" + }, + { + price: 4.25, + rate: 0.025, + title: "County tax" + } + ]; + order.total_tax = 14.45; + await order.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/orders.json', + query: '', + headers, + data: { "order": {line_items: [{title: "Red Leather Coat", price: 129.99, grams: "1700", quantity: 1}, {title: "Blue Suede Shoes", price: 85.95, grams: "750", quantity: 1, taxable: false}, {title: "Raspberry Beret", price: 19.99, grams: "320", quantity: 2}], tax_lines: [{price: 10.2, rate: 0.06, title: "State tax"}, {price: 4.25, rate: 0.025, title: "County tax"}], total_tax: 14.45} } + }).toMatchMadeHttpRequest(); + }); + + it('test_32', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order = new Order({session: test_session}); + order.line_items = [ + { + variant_id: 447654529, + quantity: 1 + } + ]; + order.customer = { + id: 207119551 + }; + order.financial_status = "pending"; + await order.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/orders.json', + query: '', + headers, + data: { "order": {line_items: [{variant_id: 447654529, quantity: 1}], customer: {id: 207119551}, financial_status: "pending"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_33', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order = new Order({session: test_session}); + order.line_items = [ + { + variant_id: 447654529, + quantity: 1 + } + ]; + order.customer = { + first_name: "Paul", + last_name: "Norman", + email: "paul.norman@example.com" + }; + order.billing_address = { + first_name: "John", + last_name: "Smith", + address1: "123 Fake Street", + phone: "555-555-5555", + city: "Fakecity", + province: "Ontario", + country: "Canada", + zip: "K2P 1L4" + }; + order.shipping_address = { + first_name: "Jane", + last_name: "Smith", + address1: "123 Fake Street", + phone: "777-777-7777", + city: "Fakecity", + province: "Ontario", + country: "Canada", + zip: "K2P 1L4" + }; + order.email = "jane@example.com"; + order.transactions = [ + { + kind: "authorization", + status: "success", + amount: 50.0 + } + ]; + order.financial_status = "partially_paid"; + await order.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/orders.json', + query: '', + headers, + data: { "order": {line_items: [{variant_id: 447654529, quantity: 1}], customer: {first_name: "Paul", last_name: "Norman", email: "paul.norman@example.com"}, billing_address: {first_name: "John", last_name: "Smith", address1: "123 Fake Street", phone: "555-555-5555", city: "Fakecity", province: "Ontario", country: "Canada", zip: "K2P 1L4"}, shipping_address: {first_name: "Jane", last_name: "Smith", address1: "123 Fake Street", phone: "777-777-7777", city: "Fakecity", province: "Ontario", country: "Canada", zip: "K2P 1L4"}, email: "jane@example.com", transactions: [{kind: "authorization", status: "success", amount: 50.0}], financial_status: "partially_paid"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_34', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order = new Order({session: test_session}); + order.line_items = [ + { + variant_id: 447654529, + quantity: 1 + } + ]; + order.email = "jane@example.com"; + order.phone = "18885551234"; + order.billing_address = { + first_name: "John", + last_name: "Smith", + address1: "123 Fake Street", + phone: "555-555-5555", + city: "Fakecity", + province: "Ontario", + country: "Canada", + zip: "K2P 1L4" + }; + order.shipping_address = { + first_name: "Jane", + last_name: "Smith", + address1: "123 Fake Street", + phone: "777-777-7777", + city: "Fakecity", + province: "Ontario", + country: "Canada", + zip: "K2P 1L4" + }; + order.transactions = [ + { + kind: "sale", + status: "success", + amount: 50.0 + } + ]; + order.financial_status = "paid"; + order.discount_codes = [ + { + code: "FAKE30", + amount: "9.00", + type: "percentage" + } + ]; + await order.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/orders.json', + query: '', + headers, + data: { "order": {line_items: [{variant_id: 447654529, quantity: 1}], email: "jane@example.com", phone: "18885551234", billing_address: {first_name: "John", last_name: "Smith", address1: "123 Fake Street", phone: "555-555-5555", city: "Fakecity", province: "Ontario", country: "Canada", zip: "K2P 1L4"}, shipping_address: {first_name: "Jane", last_name: "Smith", address1: "123 Fake Street", phone: "777-777-7777", city: "Fakecity", province: "Ontario", country: "Canada", zip: "K2P 1L4"}, transactions: [{kind: "sale", status: "success", amount: 50.0}], financial_status: "paid", discount_codes: [{code: "FAKE30", amount: "9.00", type: "percentage"}]} } + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-10/order_risk.test.ts b/src/rest-resources/__tests__/2021-10/order_risk.test.ts new file mode 100644 index 000000000..ce661dbca --- /dev/null +++ b/src/rest-resources/__tests__/2021-10/order_risk.test.ts @@ -0,0 +1,119 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {OrderRisk} from '../../2021-10'; + +describe('OrderRisk resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.October21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order_risk = new OrderRisk({session: test_session}); + order_risk.order_id = 450789469; + order_risk.message = "This order came from an anonymous proxy"; + order_risk.recommendation = "cancel"; + order_risk.score = 1.0; + order_risk.source = "External"; + order_risk.cause_cancel = true; + order_risk.display = true; + await order_risk.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/orders/450789469/risks.json', + query: '', + headers, + data: { "risk": {message: "This order came from an anonymous proxy", recommendation: "cancel", score: 1.0, source: "External", cause_cancel: true, display: true} } + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await OrderRisk.all({ + session: test_session, + order_id: 450789469, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/orders/450789469/risks.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await OrderRisk.find({ + session: test_session, + order_id: 450789469, + id: 284138680, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/orders/450789469/risks/284138680.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order_risk = new OrderRisk({session: test_session}); + order_risk.order_id = 450789469; + order_risk.id = 284138680; + order_risk.message = "After further review, this is a legitimate order"; + order_risk.recommendation = "accept"; + order_risk.source = "External"; + order_risk.cause_cancel = false; + order_risk.score = 0.0; + await order_risk.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/orders/450789469/risks/284138680.json', + query: '', + headers, + data: { "risk": {id: 284138680, message: "After further review, this is a legitimate order", recommendation: "accept", source: "External", cause_cancel: false, score: 0.0} } + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await OrderRisk.delete({ + session: test_session, + order_id: 450789469, + id: 284138680, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-10/orders/450789469/risks/284138680.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-10/page.test.ts b/src/rest-resources/__tests__/2021-10/page.test.ts new file mode 100644 index 000000000..ee3d3ad91 --- /dev/null +++ b/src/rest-resources/__tests__/2021-10/page.test.ts @@ -0,0 +1,268 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Page} from '../../2021-10'; + +describe('Page resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.October21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Page.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/pages.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Page.all({ + session: test_session, + since_id: "108828309", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/pages.json', + query: 'since_id=108828309', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const page = new Page({session: test_session}); + page.title = "Warranty information"; + page.body_html = "

Warranty

\n

Returns accepted if we receive items 30 days after purchase.

"; + await page.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/pages.json', + query: '', + headers, + data: { "page": {title: "Warranty information", body_html: "

Warranty

\n

Returns accepted if we receive items 30 days after purchase.

"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const page = new Page({session: test_session}); + page.title = "Warranty information"; + page.body_html = "

Warranty

\n

Returns accepted if we receive items 30 days after purchase.

"; + page.published = false; + await page.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/pages.json', + query: '', + headers, + data: { "page": {title: "Warranty information", body_html: "

Warranty

\n

Returns accepted if we receive items 30 days after purchase.

", published: false} } + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const page = new Page({session: test_session}); + page.title = "Warranty information"; + page.body_html = "

Warranty

\n

Returns accepted if we receive items 30 days after purchase.

"; + page.metafields = [ + { + key: "new", + value: "new value", + type: "single_line_text_field", + namespace: "global" + } + ]; + await page.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/pages.json', + query: '', + headers, + data: { "page": {title: "Warranty information", body_html: "

Warranty

\n

Returns accepted if we receive items 30 days after purchase.

", metafields: [{key: "new", value: "new value", type: "single_line_text_field", namespace: "global"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Page.count({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/pages/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Page.find({ + session: test_session, + id: 131092082, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/pages/131092082.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const page = new Page({session: test_session}); + page.id = 131092082; + page.body_html = "

Returns accepted if we receive the items 14 days after purchase.

"; + await page.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/pages/131092082.json', + query: '', + headers, + data: { "page": {id: 131092082, body_html: "

Returns accepted if we receive the items 14 days after purchase.

"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const page = new Page({session: test_session}); + page.id = 131092082; + page.body_html = "

Returns accepted if we receive the items 14 days after purchase.

"; + page.author = "Christopher Gorski"; + page.title = "New warranty"; + page.handle = "new-warranty"; + await page.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/pages/131092082.json', + query: '', + headers, + data: { "page": {id: 131092082, body_html: "

Returns accepted if we receive the items 14 days after purchase.

", author: "Christopher Gorski", title: "New warranty", handle: "new-warranty"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_10', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const page = new Page({session: test_session}); + page.id = 131092082; + page.published = true; + await page.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/pages/131092082.json', + query: '', + headers, + data: { "page": {id: 131092082, published: true} } + }).toMatchMadeHttpRequest(); + }); + + it('test_11', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const page = new Page({session: test_session}); + page.id = 131092082; + page.published = false; + await page.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/pages/131092082.json', + query: '', + headers, + data: { "page": {id: 131092082, published: false} } + }).toMatchMadeHttpRequest(); + }); + + it('test_12', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const page = new Page({session: test_session}); + page.id = 131092082; + page.metafields = [ + { + key: "new", + value: "new value", + type: "single_line_text_field", + namespace: "global" + } + ]; + await page.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/pages/131092082.json', + query: '', + headers, + data: { "page": {id: 131092082, metafields: [{key: "new", value: "new value", type: "single_line_text_field", namespace: "global"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_13', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Page.delete({ + session: test_session, + id: 131092082, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-10/pages/131092082.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-10/payment.test.ts b/src/rest-resources/__tests__/2021-10/payment.test.ts new file mode 100644 index 000000000..6fc5fc37c --- /dev/null +++ b/src/rest-resources/__tests__/2021-10/payment.test.ts @@ -0,0 +1,116 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Payment} from '../../2021-10'; + +describe('Payment resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.October21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const payment = new Payment({session: test_session}); + payment.checkout_id = "7yjf4v2we7gamku6a6h7tvm8h3mmvs4x"; + payment.request_details = { + ip_address: "123.1.1.1", + accept_language: "en-US,en;q=0.8,fr;q=0.6", + user_agent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.98 Safari/537.36" + }; + payment.amount = "398.00"; + payment.session_id = "global-4f10a3a42a3b4d41"; + payment.unique_token = "client-side-idempotency-token"; + await payment.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/checkouts/7yjf4v2we7gamku6a6h7tvm8h3mmvs4x/payments.json', + query: '', + headers, + data: { "payment": {request_details: {ip_address: "123.1.1.1", accept_language: "en-US,en;q=0.8,fr;q=0.6", user_agent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.98 Safari/537.36"}, amount: "398.00", session_id: "global-4f10a3a42a3b4d41", unique_token: "client-side-idempotency-token"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Payment.all({ + session: test_session, + checkout_id: "7yjf4v2we7gamku6a6h7tvm8h3mmvs4x", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/checkouts/7yjf4v2we7gamku6a6h7tvm8h3mmvs4x/payments.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Payment.find({ + session: test_session, + checkout_id: "7yjf4v2we7gamku6a6h7tvm8h3mmvs4x", + id: 25428999, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/checkouts/7yjf4v2we7gamku6a6h7tvm8h3mmvs4x/payments/25428999.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Payment.find({ + session: test_session, + checkout_id: "7yjf4v2we7gamku6a6h7tvm8h3mmvs4x", + id: 25428999, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/checkouts/7yjf4v2we7gamku6a6h7tvm8h3mmvs4x/payments/25428999.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Payment.count({ + session: test_session, + checkout_id: "7yjf4v2we7gamku6a6h7tvm8h3mmvs4x", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/checkouts/7yjf4v2we7gamku6a6h7tvm8h3mmvs4x/payments/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-10/payment_gateway.test.ts b/src/rest-resources/__tests__/2021-10/payment_gateway.test.ts new file mode 100644 index 000000000..29817fd1c --- /dev/null +++ b/src/rest-resources/__tests__/2021-10/payment_gateway.test.ts @@ -0,0 +1,124 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {PaymentGateway} from '../../2021-10'; + +describe('PaymentGateway resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.October21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await PaymentGateway.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/payment_gateways.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await PaymentGateway.all({ + session: test_session, + disabled: "false", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/payment_gateways.json', + query: 'disabled=false', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const payment_gateway = new PaymentGateway({session: test_session}); + payment_gateway.credential1 = "someone@example.com"; + payment_gateway.provider_id = 7; + await payment_gateway.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/payment_gateways.json', + query: '', + headers, + data: { "payment_gateway": {credential1: "someone@example.com", provider_id: 7} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await PaymentGateway.find({ + session: test_session, + id: 431363653, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/payment_gateways/431363653.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const payment_gateway = new PaymentGateway({session: test_session}); + payment_gateway.id = 170508070; + payment_gateway.sandbox = true; + await payment_gateway.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/payment_gateways/170508070.json', + query: '', + headers, + data: { "payment_gateway": {id: 170508070, sandbox: true} } + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await PaymentGateway.delete({ + session: test_session, + id: 170508070, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-10/payment_gateways/170508070.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-10/payment_transaction.test.ts b/src/rest-resources/__tests__/2021-10/payment_transaction.test.ts new file mode 100644 index 000000000..0c5732a3a --- /dev/null +++ b/src/rest-resources/__tests__/2021-10/payment_transaction.test.ts @@ -0,0 +1,35 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {PaymentTransaction} from '../../2021-10'; + +describe('PaymentTransaction resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.October21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await PaymentTransaction.transactions({ + session: test_session, + payout_id: "623721858", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/shopify_payments/balance/transactions.json', + query: 'payout_id=623721858', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-10/payout.test.ts b/src/rest-resources/__tests__/2021-10/payout.test.ts new file mode 100644 index 000000000..db472b1ea --- /dev/null +++ b/src/rest-resources/__tests__/2021-10/payout.test.ts @@ -0,0 +1,70 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Payout} from '../../2021-10'; + +describe('Payout resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.October21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Payout.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/shopify_payments/payouts.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Payout.all({ + session: test_session, + date_max: "2012-11-12", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/shopify_payments/payouts.json', + query: 'date_max=2012-11-12', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Payout.find({ + session: test_session, + id: 623721858, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/shopify_payments/payouts/623721858.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-10/policy.test.ts b/src/rest-resources/__tests__/2021-10/policy.test.ts new file mode 100644 index 000000000..9937fa0b0 --- /dev/null +++ b/src/rest-resources/__tests__/2021-10/policy.test.ts @@ -0,0 +1,34 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Policy} from '../../2021-10'; + +describe('Policy resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.October21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Policy.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/policies.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-10/price_rule.test.ts b/src/rest-resources/__tests__/2021-10/price_rule.test.ts new file mode 100644 index 000000000..08e39c8ac --- /dev/null +++ b/src/rest-resources/__tests__/2021-10/price_rule.test.ts @@ -0,0 +1,246 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {PriceRule} from '../../2021-10'; + +describe('PriceRule resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.October21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const price_rule = new PriceRule({session: test_session}); + price_rule.title = "SUMMERSALE10OFF"; + price_rule.target_type = "line_item"; + price_rule.target_selection = "all"; + price_rule.allocation_method = "across"; + price_rule.value_type = "fixed_amount"; + price_rule.value = "-10.0"; + price_rule.customer_selection = "all"; + price_rule.starts_at = "2017-01-19T17:59:10Z"; + await price_rule.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/price_rules.json', + query: '', + headers, + data: { "price_rule": {title: "SUMMERSALE10OFF", target_type: "line_item", target_selection: "all", allocation_method: "across", value_type: "fixed_amount", value: "-10.0", customer_selection: "all", starts_at: "2017-01-19T17:59:10Z"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const price_rule = new PriceRule({session: test_session}); + price_rule.title = "15OFFCOLLECTION"; + price_rule.target_type = "line_item"; + price_rule.target_selection = "entitled"; + price_rule.allocation_method = "across"; + price_rule.value_type = "percentage"; + price_rule.value = "-15.0"; + price_rule.customer_selection = "all"; + price_rule.entitled_collection_ids = [ + 841564295 + ]; + price_rule.starts_at = "2017-01-19T17:59:10Z"; + await price_rule.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/price_rules.json', + query: '', + headers, + data: { "price_rule": {title: "15OFFCOLLECTION", target_type: "line_item", target_selection: "entitled", allocation_method: "across", value_type: "percentage", value: "-15.0", customer_selection: "all", entitled_collection_ids: [841564295], starts_at: "2017-01-19T17:59:10Z"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const price_rule = new PriceRule({session: test_session}); + price_rule.title = "FREESHIPPING"; + price_rule.target_type = "shipping_line"; + price_rule.target_selection = "all"; + price_rule.allocation_method = "each"; + price_rule.value_type = "percentage"; + price_rule.value = "-100.0"; + price_rule.usage_limit = 20; + price_rule.customer_selection = "all"; + price_rule.prerequisite_subtotal_range = { + greater_than_or_equal_to: "50.0" + }; + price_rule.starts_at = "2017-01-19T17:59:10Z"; + await price_rule.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/price_rules.json', + query: '', + headers, + data: { "price_rule": {title: "FREESHIPPING", target_type: "shipping_line", target_selection: "all", allocation_method: "each", value_type: "percentage", value: "-100.0", usage_limit: 20, customer_selection: "all", prerequisite_subtotal_range: {greater_than_or_equal_to: "50.0"}, starts_at: "2017-01-19T17:59:10Z"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const price_rule = new PriceRule({session: test_session}); + price_rule.title = "5OFFCUSTOMERGROUP"; + price_rule.target_type = "line_item"; + price_rule.target_selection = "all"; + price_rule.allocation_method = "across"; + price_rule.value_type = "fixed_amount"; + price_rule.value = "-5.0"; + price_rule.customer_selection = "prerequisite"; + price_rule.prerequisite_saved_search_ids = [ + 789629109 + ]; + price_rule.starts_at = "2017-01-19T17:59:10Z"; + await price_rule.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/price_rules.json', + query: '', + headers, + data: { "price_rule": {title: "5OFFCUSTOMERGROUP", target_type: "line_item", target_selection: "all", allocation_method: "across", value_type: "fixed_amount", value: "-5.0", customer_selection: "prerequisite", prerequisite_saved_search_ids: [789629109], starts_at: "2017-01-19T17:59:10Z"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const price_rule = new PriceRule({session: test_session}); + price_rule.title = "Buy2iPodsGetiPodTouchForFree"; + price_rule.value_type = "percentage"; + price_rule.value = "-100.0"; + price_rule.customer_selection = "all"; + price_rule.target_type = "line_item"; + price_rule.target_selection = "entitled"; + price_rule.allocation_method = "each"; + price_rule.starts_at = "2018-03-22T00:00:00-00:00"; + price_rule.prerequisite_collection_ids = [ + 841564295 + ]; + price_rule.entitled_product_ids = [ + 921728736 + ]; + price_rule.prerequisite_to_entitlement_quantity_ratio = { + prerequisite_quantity: 2, + entitled_quantity: 1 + }; + price_rule.allocation_limit = 3; + await price_rule.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/price_rules.json', + query: '', + headers, + data: { "price_rule": {title: "Buy2iPodsGetiPodTouchForFree", value_type: "percentage", value: "-100.0", customer_selection: "all", target_type: "line_item", target_selection: "entitled", allocation_method: "each", starts_at: "2018-03-22T00:00:00-00:00", prerequisite_collection_ids: [841564295], entitled_product_ids: [921728736], prerequisite_to_entitlement_quantity_ratio: {prerequisite_quantity: 2, entitled_quantity: 1}, allocation_limit: 3} } + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await PriceRule.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/price_rules.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const price_rule = new PriceRule({session: test_session}); + price_rule.id = 507328175; + price_rule.title = "WINTER SALE"; + await price_rule.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/price_rules/507328175.json', + query: '', + headers, + data: { "price_rule": {id: 507328175, title: "WINTER SALE"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await PriceRule.find({ + session: test_session, + id: 507328175, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/price_rules/507328175.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await PriceRule.delete({ + session: test_session, + id: 507328175, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-10/price_rules/507328175.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_10', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await PriceRule.count({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/price_rules/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-10/product.test.ts b/src/rest-resources/__tests__/2021-10/product.test.ts new file mode 100644 index 000000000..c3a972982 --- /dev/null +++ b/src/rest-resources/__tests__/2021-10/product.test.ts @@ -0,0 +1,738 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Product} from '../../2021-10'; + +describe('Product resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.October21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Product.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/products.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Product.all({ + session: test_session, + ids: "632910392,921728736", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/products.json', + query: 'ids=632910392%2C921728736', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Product.all({ + session: test_session, + fields: "id,images,title", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/products.json', + query: 'fields=id%2Cimages%2Ctitle', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Product.all({ + session: test_session, + collection_id: "841564295", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/products.json', + query: 'collection_id=841564295', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Product.all({ + session: test_session, + since_id: "632910392", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/products.json', + query: 'since_id=632910392', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Product.all({ + session: test_session, + presentment_currencies: "USD", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/products.json', + query: 'presentment_currencies=USD', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product = new Product({session: test_session}); + product.title = "Burton Custom Freestyle 151"; + product.body_html = "Good snowboard!"; + product.vendor = "Burton"; + product.product_type = "Snowboard"; + product.tags = [ + "Barnes & Noble", + "Big Air", + "John's Fav" + ]; + await product.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/products.json', + query: '', + headers, + data: { "product": {title: "Burton Custom Freestyle 151", body_html: "Good snowboard!", vendor: "Burton", product_type: "Snowboard", tags: ["Barnes & Noble", "Big Air", "John's Fav"]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product = new Product({session: test_session}); + product.title = "Burton Custom Freestyle 151"; + product.body_html = "Good snowboard!"; + product.vendor = "Burton"; + product.product_type = "Snowboard"; + product.published = false; + await product.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/products.json', + query: '', + headers, + data: { "product": {title: "Burton Custom Freestyle 151", body_html: "Good snowboard!", vendor: "Burton", product_type: "Snowboard", published: false} } + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product = new Product({session: test_session}); + product.title = "Burton Custom Freestyle 151"; + product.body_html = "Good snowboard!"; + product.vendor = "Burton"; + product.product_type = "Snowboard"; + product.status = "draft"; + await product.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/products.json', + query: '', + headers, + data: { "product": {title: "Burton Custom Freestyle 151", body_html: "Good snowboard!", vendor: "Burton", product_type: "Snowboard", status: "draft"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_10', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product = new Product({session: test_session}); + product.title = "Burton Custom Freestyle 151"; + product.body_html = "Good snowboard!"; + product.vendor = "Burton"; + product.product_type = "Snowboard"; + product.variants = [ + { + option1: "First", + price: "10.00", + sku: "123" + }, + { + option1: "Second", + price: "20.00", + sku: "123" + } + ]; + await product.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/products.json', + query: '', + headers, + data: { "product": {title: "Burton Custom Freestyle 151", body_html: "Good snowboard!", vendor: "Burton", product_type: "Snowboard", variants: [{option1: "First", price: "10.00", sku: "123"}, {option1: "Second", price: "20.00", sku: "123"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_11', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product = new Product({session: test_session}); + product.title = "Burton Custom Freestyle 151"; + product.body_html = "Good snowboard!"; + product.vendor = "Burton"; + product.product_type = "Snowboard"; + product.variants = [ + { + option1: "Blue", + option2: "155" + }, + { + option1: "Black", + option2: "159" + } + ]; + product.options = [ + { + name: "Color", + values: [ + "Blue", + "Black" + ] + }, + { + name: "Size", + values: [ + "155", + "159" + ] + } + ]; + await product.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/products.json', + query: '', + headers, + data: { "product": {title: "Burton Custom Freestyle 151", body_html: "Good snowboard!", vendor: "Burton", product_type: "Snowboard", variants: [{option1: "Blue", option2: "155"}, {option1: "Black", option2: "159"}], options: [{name: "Color", values: ["Blue", "Black"]}, {name: "Size", values: ["155", "159"]}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_12', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product = new Product({session: test_session}); + product.title = "Burton Custom Freestyle 151"; + product.body_html = "Good snowboard!"; + product.vendor = "Burton"; + product.product_type = "Snowboard"; + product.images = [ + { + attachment: "R0lGODlhAQABAIAAAAAAAAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==\n" + } + ]; + await product.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/products.json', + query: '', + headers, + data: { "product": {title: "Burton Custom Freestyle 151", body_html: "Good snowboard!", vendor: "Burton", product_type: "Snowboard", images: [{attachment: "R0lGODlhAQABAIAAAAAAAAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==\n"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_13', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product = new Product({session: test_session}); + product.title = "Burton Custom Freestyle 151"; + product.body_html = "Good snowboard!"; + product.vendor = "Burton"; + product.product_type = "Snowboard"; + product.images = [ + { + src: "http://example.com/rails_logo.gif" + } + ]; + await product.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/products.json', + query: '', + headers, + data: { "product": {title: "Burton Custom Freestyle 151", body_html: "Good snowboard!", vendor: "Burton", product_type: "Snowboard", images: [{src: "http://example.com/rails_logo.gif"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_14', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product = new Product({session: test_session}); + product.title = "Burton Custom Freestyle 151"; + product.body_html = "Good snowboard!"; + product.vendor = "Burton"; + product.product_type = "Snowboard"; + product.metafields_global_title_tag = "Product SEO Title"; + product.metafields_global_description_tag = "Product SEO Description"; + await product.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/products.json', + query: '', + headers, + data: { "product": {title: "Burton Custom Freestyle 151", body_html: "Good snowboard!", vendor: "Burton", product_type: "Snowboard", metafields_global_title_tag: "Product SEO Title", metafields_global_description_tag: "Product SEO Description"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_15', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product = new Product({session: test_session}); + product.title = "Burton Custom Freestyle 151"; + product.body_html = "Good snowboard!"; + product.vendor = "Burton"; + product.product_type = "Snowboard"; + product.metafields = [ + { + key: "new", + value: "newvalue", + type: "single_line_text_field", + namespace: "global" + } + ]; + await product.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/products.json', + query: '', + headers, + data: { "product": {title: "Burton Custom Freestyle 151", body_html: "Good snowboard!", vendor: "Burton", product_type: "Snowboard", metafields: [{key: "new", value: "newvalue", type: "single_line_text_field", namespace: "global"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_16', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Product.count({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/products/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_17', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Product.count({ + session: test_session, + collection_id: "841564295", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/products/count.json', + query: 'collection_id=841564295', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_18', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Product.find({ + session: test_session, + id: 632910392, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/products/632910392.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_19', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Product.find({ + session: test_session, + id: 632910392, + fields: "id,images,title", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/products/632910392.json', + query: 'fields=id%2Cimages%2Ctitle', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_20', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product = new Product({session: test_session}); + product.id = 632910392; + product.title = "New product title"; + await product.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/products/632910392.json', + query: '', + headers, + data: { "product": {id: 632910392, title: "New product title"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_21', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product = new Product({session: test_session}); + product.id = 632910392; + product.status = "draft"; + await product.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/products/632910392.json', + query: '', + headers, + data: { "product": {id: 632910392, status: "draft"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_22', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product = new Product({session: test_session}); + product.id = 632910392; + product.tags = "Barnes & Noble, John's Fav"; + await product.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/products/632910392.json', + query: '', + headers, + data: { "product": {id: 632910392, tags: "Barnes & Noble, John's Fav"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_23', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product = new Product({session: test_session}); + product.id = 632910392; + product.images = []; + await product.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/products/632910392.json', + query: '', + headers, + data: { "product": {id: 632910392, images: []} } + }).toMatchMadeHttpRequest(); + }); + + it('test_24', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product = new Product({session: test_session}); + product.id = 632910392; + product.images = [ + { + id: 850703190 + }, + { + id: 562641783 + }, + { + id: 378407906 + }, + { + src: "http://example.com/rails_logo.gif" + } + ]; + await product.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/products/632910392.json', + query: '', + headers, + data: { "product": {id: 632910392, images: [{id: 850703190}, {id: 562641783}, {id: 378407906}, {src: "http://example.com/rails_logo.gif"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_25', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product = new Product({session: test_session}); + product.id = 632910392; + product.images = [ + { + id: 850703190, + position: 3 + }, + { + id: 562641783, + position: 2 + }, + { + id: 378407906, + position: 1 + } + ]; + await product.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/products/632910392.json', + query: '', + headers, + data: { "product": {id: 632910392, images: [{id: 850703190, position: 3}, {id: 562641783, position: 2}, {id: 378407906, position: 1}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_26', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product = new Product({session: test_session}); + product.id = 632910392; + product.variants = [ + { + id: 457924702 + }, + { + id: 39072856 + }, + { + id: 49148385 + }, + { + id: 808950810 + } + ]; + await product.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/products/632910392.json', + query: '', + headers, + data: { "product": {id: 632910392, variants: [{id: 457924702}, {id: 39072856}, {id: 49148385}, {id: 808950810}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_27', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product = new Product({session: test_session}); + product.id = 632910392; + product.title = "Updated Product Title"; + product.variants = [ + { + id: 808950810, + price: "2000.00", + sku: "Updating the Product SKU" + }, + { + id: 49148385 + }, + { + id: 39072856 + }, + { + id: 457924702 + } + ]; + await product.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/products/632910392.json', + query: '', + headers, + data: { "product": {id: 632910392, title: "Updated Product Title", variants: [{id: 808950810, price: "2000.00", sku: "Updating the Product SKU"}, {id: 49148385}, {id: 39072856}, {id: 457924702}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_28', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product = new Product({session: test_session}); + product.id = 632910392; + product.metafields_global_title_tag = "Brand new title"; + product.metafields_global_description_tag = "Brand new description"; + await product.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/products/632910392.json', + query: '', + headers, + data: { "product": {id: 632910392, metafields_global_title_tag: "Brand new title", metafields_global_description_tag: "Brand new description"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_29', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product = new Product({session: test_session}); + product.id = 632910392; + product.published = true; + await product.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/products/632910392.json', + query: '', + headers, + data: { "product": {id: 632910392, published: true} } + }).toMatchMadeHttpRequest(); + }); + + it('test_30', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product = new Product({session: test_session}); + product.id = 632910392; + product.published = false; + await product.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/products/632910392.json', + query: '', + headers, + data: { "product": {id: 632910392, published: false} } + }).toMatchMadeHttpRequest(); + }); + + it('test_31', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product = new Product({session: test_session}); + product.id = 632910392; + product.metafields = [ + { + key: "new", + value: "newvalue", + type: "single_line_text_field", + namespace: "global" + } + ]; + await product.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/products/632910392.json', + query: '', + headers, + data: { "product": {id: 632910392, metafields: [{key: "new", value: "newvalue", type: "single_line_text_field", namespace: "global"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_32', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Product.delete({ + session: test_session, + id: 632910392, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-10/products/632910392.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-10/product_listing.test.ts b/src/rest-resources/__tests__/2021-10/product_listing.test.ts new file mode 100644 index 000000000..d59785ba8 --- /dev/null +++ b/src/rest-resources/__tests__/2021-10/product_listing.test.ts @@ -0,0 +1,121 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {ProductListing} from '../../2021-10'; + +describe('ProductListing resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.October21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await ProductListing.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/product_listings.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await ProductListing.product_ids({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/product_listings/product_ids.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await ProductListing.count({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/product_listings/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await ProductListing.find({ + session: test_session, + product_id: 921728736, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/product_listings/921728736.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product_listing = new ProductListing({session: test_session}); + product_listing.product_id = 921728736; + await product_listing.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/product_listings/921728736.json', + query: '', + headers, + data: { "product_listing": {product_id: 921728736} } + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await ProductListing.delete({ + session: test_session, + product_id: 921728736, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-10/product_listings/921728736.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-10/product_resource_feedback.test.ts b/src/rest-resources/__tests__/2021-10/product_resource_feedback.test.ts new file mode 100644 index 000000000..de000befc --- /dev/null +++ b/src/rest-resources/__tests__/2021-10/product_resource_feedback.test.ts @@ -0,0 +1,78 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {ProductResourceFeedback} from '../../2021-10'; + +describe('ProductResourceFeedback resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.October21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product_resource_feedback = new ProductResourceFeedback({session: test_session}); + product_resource_feedback.product_id = 632910392; + product_resource_feedback.state = "requires_action"; + product_resource_feedback.messages = [ + "Needs at least one image." + ]; + product_resource_feedback.resource_updated_at = "2022-02-03T16:53:36-05:00"; + product_resource_feedback.feedback_generated_at = "2022-02-03T22:11:14.477009Z"; + await product_resource_feedback.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/products/632910392/resource_feedback.json', + query: '', + headers, + data: { "resource_feedback": {state: "requires_action", messages: ["Needs at least one image."], resource_updated_at: "2022-02-03T16:53:36-05:00", feedback_generated_at: "2022-02-03T22:11:14.477009Z"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product_resource_feedback = new ProductResourceFeedback({session: test_session}); + product_resource_feedback.product_id = 632910392; + product_resource_feedback.state = "success"; + product_resource_feedback.resource_updated_at = "2022-02-03T16:53:36-05:00"; + product_resource_feedback.feedback_generated_at = "2022-02-03T22:11:15.898793Z"; + await product_resource_feedback.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/products/632910392/resource_feedback.json', + query: '', + headers, + data: { "resource_feedback": {state: "success", resource_updated_at: "2022-02-03T16:53:36-05:00", feedback_generated_at: "2022-02-03T22:11:15.898793Z"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await ProductResourceFeedback.all({ + session: test_session, + product_id: 632910392, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/products/632910392/resource_feedback.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-10/province.test.ts b/src/rest-resources/__tests__/2021-10/province.test.ts new file mode 100644 index 000000000..03ca42fbb --- /dev/null +++ b/src/rest-resources/__tests__/2021-10/province.test.ts @@ -0,0 +1,110 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Province} from '../../2021-10'; + +describe('Province resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.October21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Province.all({ + session: test_session, + country_id: 879921427, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/countries/879921427/provinces.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Province.all({ + session: test_session, + country_id: 879921427, + since_id: "536137098", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/countries/879921427/provinces.json', + query: 'since_id=536137098', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Province.count({ + session: test_session, + country_id: 879921427, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/countries/879921427/provinces/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Province.find({ + session: test_session, + country_id: 879921427, + id: 224293623, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/countries/879921427/provinces/224293623.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const province = new Province({session: test_session}); + province.country_id = 879921427; + province.id = 224293623; + province.tax = 0.09; + await province.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/countries/879921427/provinces/224293623.json', + query: '', + headers, + data: { "province": {id: 224293623, tax: 0.09} } + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-10/recurring_application_charge.test.ts b/src/rest-resources/__tests__/2021-10/recurring_application_charge.test.ts new file mode 100644 index 000000000..1f9ebc110 --- /dev/null +++ b/src/rest-resources/__tests__/2021-10/recurring_application_charge.test.ts @@ -0,0 +1,187 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {RecurringApplicationCharge} from '../../2021-10'; + +describe('RecurringApplicationCharge resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.October21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const recurring_application_charge = new RecurringApplicationCharge({session: test_session}); + recurring_application_charge.name = "Super Duper Plan"; + recurring_application_charge.price = 10.0; + recurring_application_charge.return_url = "http://super-duper.shopifyapps.com"; + await recurring_application_charge.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/recurring_application_charges.json', + query: '', + headers, + data: { "recurring_application_charge": {name: "Super Duper Plan", price: 10.0, return_url: "http://super-duper.shopifyapps.com"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const recurring_application_charge = new RecurringApplicationCharge({session: test_session}); + recurring_application_charge.name = "Super Duper Plan"; + recurring_application_charge.price = 10.0; + recurring_application_charge.return_url = "http://super-duper.shopifyapps.com"; + recurring_application_charge.capped_amount = 100; + recurring_application_charge.terms = "$1 for 1000 emails"; + await recurring_application_charge.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/recurring_application_charges.json', + query: '', + headers, + data: { "recurring_application_charge": {name: "Super Duper Plan", price: 10.0, return_url: "http://super-duper.shopifyapps.com", capped_amount: 100, terms: "$1 for 1000 emails"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const recurring_application_charge = new RecurringApplicationCharge({session: test_session}); + recurring_application_charge.name = "Super Duper Plan"; + recurring_application_charge.price = 10.0; + recurring_application_charge.return_url = "http://super-duper.shopifyapps.com"; + recurring_application_charge.trial_days = 5; + await recurring_application_charge.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/recurring_application_charges.json', + query: '', + headers, + data: { "recurring_application_charge": {name: "Super Duper Plan", price: 10.0, return_url: "http://super-duper.shopifyapps.com", trial_days: 5} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const recurring_application_charge = new RecurringApplicationCharge({session: test_session}); + recurring_application_charge.name = "Super Duper Plan"; + recurring_application_charge.price = 10.0; + recurring_application_charge.return_url = "http://super-duper.shopifyapps.com"; + recurring_application_charge.test = true; + await recurring_application_charge.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/recurring_application_charges.json', + query: '', + headers, + data: { "recurring_application_charge": {name: "Super Duper Plan", price: 10.0, return_url: "http://super-duper.shopifyapps.com", test: true} } + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await RecurringApplicationCharge.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/recurring_application_charges.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await RecurringApplicationCharge.all({ + session: test_session, + since_id: "455696195", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/recurring_application_charges.json', + query: 'since_id=455696195', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await RecurringApplicationCharge.find({ + session: test_session, + id: 455696195, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/recurring_application_charges/455696195.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await RecurringApplicationCharge.delete({ + session: test_session, + id: 455696195, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-10/recurring_application_charges/455696195.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const recurring_application_charge = new RecurringApplicationCharge({session: test_session}); + recurring_application_charge.id = 455696195; + await recurring_application_charge.customize({ + recurring_application_charge: {capped_amount: "200"}, + }); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/recurring_application_charges/455696195/customize.json', + query: 'recurring_application_charge%5Bcapped_amount%5D=200', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-10/redirect.test.ts b/src/rest-resources/__tests__/2021-10/redirect.test.ts new file mode 100644 index 000000000..1697dfd41 --- /dev/null +++ b/src/rest-resources/__tests__/2021-10/redirect.test.ts @@ -0,0 +1,196 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Redirect} from '../../2021-10'; + +describe('Redirect resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.October21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Redirect.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/redirects.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Redirect.all({ + session: test_session, + since_id: "668809255", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/redirects.json', + query: 'since_id=668809255', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const redirect = new Redirect({session: test_session}); + redirect.path = "/ipod"; + redirect.target = "/pages/itunes"; + await redirect.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/redirects.json', + query: '', + headers, + data: { "redirect": {path: "/ipod", target: "/pages/itunes"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const redirect = new Redirect({session: test_session}); + redirect.path = "http://www.apple.com/forums"; + redirect.target = "http://forums.apple.com"; + await redirect.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/redirects.json', + query: '', + headers, + data: { "redirect": {path: "http://www.apple.com/forums", target: "http://forums.apple.com"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Redirect.count({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/redirects/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Redirect.find({ + session: test_session, + id: 668809255, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/redirects/668809255.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const redirect = new Redirect({session: test_session}); + redirect.id = 668809255; + redirect.path = "/tiger"; + await redirect.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/redirects/668809255.json', + query: '', + headers, + data: { "redirect": {id: 668809255, path: "/tiger"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const redirect = new Redirect({session: test_session}); + redirect.id = 668809255; + redirect.target = "/pages/macpro"; + await redirect.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/redirects/668809255.json', + query: '', + headers, + data: { "redirect": {id: 668809255, target: "/pages/macpro"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const redirect = new Redirect({session: test_session}); + redirect.id = 950115854; + redirect.path = "/powermac"; + redirect.target = "/pages/macpro"; + await redirect.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/redirects/950115854.json', + query: '', + headers, + data: { "redirect": {id: 950115854, path: "/powermac", target: "/pages/macpro"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_10', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Redirect.delete({ + session: test_session, + id: 668809255, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-10/redirects/668809255.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-10/refund.test.ts b/src/rest-resources/__tests__/2021-10/refund.test.ts new file mode 100644 index 000000000..8ec342dd6 --- /dev/null +++ b/src/rest-resources/__tests__/2021-10/refund.test.ts @@ -0,0 +1,179 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Refund} from '../../2021-10'; + +describe('Refund resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.October21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Refund.all({ + session: test_session, + order_id: 450789469, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/orders/450789469/refunds.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const refund = new Refund({session: test_session}); + refund.order_id = 450789469; + refund.currency = "USD"; + refund.notify = true; + refund.note = "wrong size"; + refund.shipping = { + full_refund: true + }; + refund.refund_line_items = [ + { + line_item_id: 518995019, + quantity: 1, + restock_type: "return", + location_id: 487838322 + } + ]; + refund.transactions = [ + { + parent_id: 801038806, + amount: 41.94, + kind: "refund", + gateway: "bogus" + } + ]; + await refund.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/orders/450789469/refunds.json', + query: '', + headers, + data: { "refund": {currency: "USD", notify: true, note: "wrong size", shipping: {full_refund: true}, refund_line_items: [{line_item_id: 518995019, quantity: 1, restock_type: "return", location_id: 487838322}], transactions: [{parent_id: 801038806, amount: 41.94, kind: "refund", gateway: "bogus"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const refund = new Refund({session: test_session}); + refund.order_id = 450789469; + refund.currency = "USD"; + refund.shipping = { + amount: 5.0 + }; + refund.transactions = [ + { + parent_id: 801038806, + amount: 5.0, + kind: "refund", + gateway: "bogus" + } + ]; + await refund.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/orders/450789469/refunds.json', + query: '', + headers, + data: { "refund": {currency: "USD", shipping: {amount: 5.0}, transactions: [{parent_id: 801038806, amount: 5.0, kind: "refund", gateway: "bogus"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Refund.find({ + session: test_session, + order_id: 450789469, + id: 509562969, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/orders/450789469/refunds/509562969.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const refund = new Refund({session: test_session}); + refund.order_id = 450789469; + await refund.calculate({ + body: {refund: {shipping: {full_refund: true}, refund_line_items: [{line_item_id: 518995019, quantity: 1, restock_type: "no_restock"}]}}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/orders/450789469/refunds/calculate.json', + query: '', + headers, + data: { "refund": {shipping: {full_refund: true}, refund_line_items: [{line_item_id: 518995019, quantity: 1, restock_type: "no_restock"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const refund = new Refund({session: test_session}); + refund.order_id = 450789469; + await refund.calculate({ + body: {refund: {currency: "USD", shipping: {full_refund: true}, refund_line_items: [{line_item_id: 518995019, quantity: 1, restock_type: "no_restock"}]}}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/orders/450789469/refunds/calculate.json', + query: '', + headers, + data: { "refund": {currency: "USD", shipping: {full_refund: true}, refund_line_items: [{line_item_id: 518995019, quantity: 1, restock_type: "no_restock"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const refund = new Refund({session: test_session}); + refund.order_id = 450789469; + await refund.calculate({ + body: {refund: {currency: "USD", shipping: {amount: 2.0}}}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/orders/450789469/refunds/calculate.json', + query: '', + headers, + data: { "refund": {currency: "USD", shipping: {amount: 2.0}} } + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-10/report.test.ts b/src/rest-resources/__tests__/2021-10/report.test.ts new file mode 100644 index 000000000..79a81e2ad --- /dev/null +++ b/src/rest-resources/__tests__/2021-10/report.test.ts @@ -0,0 +1,198 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Report} from '../../2021-10'; + +describe('Report resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.October21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Report.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/reports.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Report.all({ + session: test_session, + ids: "517154478", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/reports.json', + query: 'ids=517154478', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Report.all({ + session: test_session, + updated_at_min: "2005-07-31 15:57:11 EDT -04:00", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/reports.json', + query: 'updated_at_min=2005-07-31+15%3A57%3A11+EDT+-04%3A00', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Report.all({ + session: test_session, + fields: "id,shopify_ql", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/reports.json', + query: 'fields=id%2Cshopify_ql', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Report.all({ + session: test_session, + since_id: "123", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/reports.json', + query: 'since_id=123', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const report = new Report({session: test_session}); + report.name = "A new app report"; + report.shopify_ql = "SHOW total_sales BY order_id FROM sales SINCE -1m UNTIL today ORDER BY total_sales"; + await report.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/reports.json', + query: '', + headers, + data: { "report": {name: "A new app report", shopify_ql: "SHOW total_sales BY order_id FROM sales SINCE -1m UNTIL today ORDER BY total_sales"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Report.find({ + session: test_session, + id: 517154478, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/reports/517154478.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Report.find({ + session: test_session, + id: 517154478, + fields: "id,shopify_ql", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/reports/517154478.json', + query: 'fields=id%2Cshopify_ql', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const report = new Report({session: test_session}); + report.id = 517154478; + report.name = "Changed Report Name"; + report.shopify_ql = "SHOW total_sales BY order_id FROM sales SINCE -12m UNTIL today ORDER BY total_sales"; + await report.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/reports/517154478.json', + query: '', + headers, + data: { "report": {id: 517154478, name: "Changed Report Name", shopify_ql: "SHOW total_sales BY order_id FROM sales SINCE -12m UNTIL today ORDER BY total_sales"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_10', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Report.delete({ + session: test_session, + id: 517154478, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-10/reports/517154478.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-10/resource_feedback.test.ts b/src/rest-resources/__tests__/2021-10/resource_feedback.test.ts new file mode 100644 index 000000000..a413dab17 --- /dev/null +++ b/src/rest-resources/__tests__/2021-10/resource_feedback.test.ts @@ -0,0 +1,73 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {ResourceFeedback} from '../../2021-10'; + +describe('ResourceFeedback resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.October21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const resource_feedback = new ResourceFeedback({session: test_session}); + resource_feedback.state = "requires_action"; + resource_feedback.messages = [ + "is not connected. Connect your account to use this sales channel." + ]; + resource_feedback.feedback_generated_at = "2022-02-03T22:00:23.179942Z"; + await resource_feedback.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/resource_feedback.json', + query: '', + headers, + data: { "resource_feedback": {state: "requires_action", messages: ["is not connected. Connect your account to use this sales channel."], feedback_generated_at: "2022-02-03T22:00:23.179942Z"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const resource_feedback = new ResourceFeedback({session: test_session}); + resource_feedback.state = "success"; + resource_feedback.feedback_generated_at = "2022-02-03T22:00:24.490026Z"; + await resource_feedback.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/resource_feedback.json', + query: '', + headers, + data: { "resource_feedback": {state: "success", feedback_generated_at: "2022-02-03T22:00:24.490026Z"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await ResourceFeedback.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/resource_feedback.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-10/script_tag.test.ts b/src/rest-resources/__tests__/2021-10/script_tag.test.ts new file mode 100644 index 000000000..ed250865b --- /dev/null +++ b/src/rest-resources/__tests__/2021-10/script_tag.test.ts @@ -0,0 +1,159 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {ScriptTag} from '../../2021-10'; + +describe('ScriptTag resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.October21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await ScriptTag.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/script_tags.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await ScriptTag.all({ + session: test_session, + src: "https://js-aplenty.com/foo.js", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/script_tags.json', + query: 'src=https%3A%2F%2Fjs-aplenty.com%2Ffoo.js', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await ScriptTag.all({ + session: test_session, + since_id: "421379493", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/script_tags.json', + query: 'since_id=421379493', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const script_tag = new ScriptTag({session: test_session}); + script_tag.event = "onload"; + script_tag.src = "https://djavaskripped.org/fancy.js"; + await script_tag.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/script_tags.json', + query: '', + headers, + data: { "script_tag": {event: "onload", src: "https://djavaskripped.org/fancy.js"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await ScriptTag.count({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/script_tags/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await ScriptTag.find({ + session: test_session, + id: 596726825, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/script_tags/596726825.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const script_tag = new ScriptTag({session: test_session}); + script_tag.id = 596726825; + script_tag.src = "https://somewhere-else.com/another.js"; + await script_tag.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/script_tags/596726825.json', + query: '', + headers, + data: { "script_tag": {id: 596726825, src: "https://somewhere-else.com/another.js"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await ScriptTag.delete({ + session: test_session, + id: 596726825, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-10/script_tags/596726825.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-10/shipping_zone.test.ts b/src/rest-resources/__tests__/2021-10/shipping_zone.test.ts new file mode 100644 index 000000000..d53831854 --- /dev/null +++ b/src/rest-resources/__tests__/2021-10/shipping_zone.test.ts @@ -0,0 +1,34 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {ShippingZone} from '../../2021-10'; + +describe('ShippingZone resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.October21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await ShippingZone.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/shipping_zones.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-10/shop.test.ts b/src/rest-resources/__tests__/2021-10/shop.test.ts new file mode 100644 index 000000000..b999abdc6 --- /dev/null +++ b/src/rest-resources/__tests__/2021-10/shop.test.ts @@ -0,0 +1,52 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Shop} from '../../2021-10'; + +describe('Shop resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.October21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Shop.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/shop.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Shop.all({ + session: test_session, + fields: "address1,address2,city,province,country", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/shop.json', + query: 'fields=address1%2Caddress2%2Ccity%2Cprovince%2Ccountry', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-10/smart_collection.test.ts b/src/rest-resources/__tests__/2021-10/smart_collection.test.ts new file mode 100644 index 000000000..8b55898af --- /dev/null +++ b/src/rest-resources/__tests__/2021-10/smart_collection.test.ts @@ -0,0 +1,456 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {SmartCollection} from '../../2021-10'; + +describe('SmartCollection resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.October21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await SmartCollection.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/smart_collections.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await SmartCollection.all({ + session: test_session, + since_id: "482865238", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/smart_collections.json', + query: 'since_id=482865238', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await SmartCollection.all({ + session: test_session, + product_id: "632910392", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/smart_collections.json', + query: 'product_id=632910392', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await SmartCollection.all({ + session: test_session, + ids: "482865238,1063001375", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/smart_collections.json', + query: 'ids=482865238%2C1063001375', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const smart_collection = new SmartCollection({session: test_session}); + smart_collection.title = "IPods"; + smart_collection.rules = [ + { + column: "title", + relation: "starts_with", + condition: "iPod" + } + ]; + await smart_collection.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/smart_collections.json', + query: '', + headers, + data: { "smart_collection": {title: "IPods", rules: [{column: "title", relation: "starts_with", condition: "iPod"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const smart_collection = new SmartCollection({session: test_session}); + smart_collection.title = "Macbooks"; + smart_collection.rules = [ + { + column: "vendor", + relation: "equals", + condition: "Apple" + } + ]; + await smart_collection.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/smart_collections.json', + query: '', + headers, + data: { "smart_collection": {title: "Macbooks", rules: [{column: "vendor", relation: "equals", condition: "Apple"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const smart_collection = new SmartCollection({session: test_session}); + smart_collection.title = "Macbooks"; + smart_collection.rules = [ + { + column: "vendor", + relation: "equals", + condition: "Apple" + } + ]; + smart_collection.published = false; + await smart_collection.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/smart_collections.json', + query: '', + headers, + data: { "smart_collection": {title: "Macbooks", rules: [{column: "vendor", relation: "equals", condition: "Apple"}], published: false} } + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const smart_collection = new SmartCollection({session: test_session}); + smart_collection.title = "Macbooks"; + smart_collection.rules = [ + { + column: "vendor", + relation: "equals", + condition: "Apple" + } + ]; + smart_collection.image = { + attachment: "R0lGODlhAQABAIAAAAAAAAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==\n", + alt: "iPod" + }; + await smart_collection.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/smart_collections.json', + query: '', + headers, + data: { "smart_collection": {title: "Macbooks", rules: [{column: "vendor", relation: "equals", condition: "Apple"}], image: {attachment: "R0lGODlhAQABAIAAAAAAAAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==\n", alt: "iPod"}} } + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const smart_collection = new SmartCollection({session: test_session}); + smart_collection.title = "Macbooks"; + smart_collection.rules = [ + { + column: "vendor", + relation: "equals", + condition: "Apple" + } + ]; + smart_collection.image = { + src: "http://example.com/rails_logo.gif", + alt: "Rails Logo" + }; + await smart_collection.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/smart_collections.json', + query: '', + headers, + data: { "smart_collection": {title: "Macbooks", rules: [{column: "vendor", relation: "equals", condition: "Apple"}], image: {src: "http://example.com/rails_logo.gif", alt: "Rails Logo"}} } + }).toMatchMadeHttpRequest(); + }); + + it('test_10', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await SmartCollection.count({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/smart_collections/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_11', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await SmartCollection.count({ + session: test_session, + product_id: "632910392", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/smart_collections/count.json', + query: 'product_id=632910392', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_12', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await SmartCollection.find({ + session: test_session, + id: 482865238, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/smart_collections/482865238.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_13', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const smart_collection = new SmartCollection({session: test_session}); + smart_collection.id = 482865238; + smart_collection.body_html = "

5000 songs in your pocket

"; + await smart_collection.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/smart_collections/482865238.json', + query: '', + headers, + data: { "smart_collection": {id: 482865238, body_html: "

5000 songs in your pocket

"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_14', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const smart_collection = new SmartCollection({session: test_session}); + smart_collection.id = 482865238; + smart_collection.published = true; + await smart_collection.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/smart_collections/482865238.json', + query: '', + headers, + data: { "smart_collection": {id: 482865238, published: true} } + }).toMatchMadeHttpRequest(); + }); + + it('test_15', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const smart_collection = new SmartCollection({session: test_session}); + smart_collection.id = 482865238; + smart_collection.published = false; + await smart_collection.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/smart_collections/482865238.json', + query: '', + headers, + data: { "smart_collection": {id: 482865238, published: false} } + }).toMatchMadeHttpRequest(); + }); + + it('test_16', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const smart_collection = new SmartCollection({session: test_session}); + smart_collection.id = 482865238; + smart_collection.image = { + attachment: "R0lGODlhbgCMAPf/APbr48VySrxTO7IgKt2qmKQdJeK8lsFjROG5p/nz7Zg3\nMNmnd7Q1MLNVS9GId71hSJMZIuzTu4UtKbeEeakhKMl8U8WY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Jg0kw24MUv/qUTOGDlCj8WETfGsVx2vI UzsATIFZUaTIRk3QY\n ZYlFq0Ce5QJHBXgdU MRCSwEYlVBCHPQZhyn7vhhD9fWdAc2DKhKXxhRCc6\n0Yi4LOPcl6hGVUFqc4gJLGaxufKO1s2VkrOj63znOkciCKMedZ n7ARUp1rQ\niLAyIlyNYURcONaInrWs9ci4JyJOaFYawDzP8Q ZwAICLckbgd08i290eh9V\nCIadQw3qO5Oa1H1GNRlSjeorO2HLruZ2rLudAm Dm9Gxcx/GXmSIMbnjH5W2\nzy2RbOzM cENBRAWs0N9b3zXWdp8pra1r61tbXdb4N/2Nv8i5gzeIJd5Gjui\nwT AzQ9YVGrYnNO0Agm27GBkvNnNzje 921qf/ b1QEfuMDFPe5lk/lspUG3\nWKbQCofLBBBuwNEs3C3aikcrB2TTeM81HgmOd3zf/PZ3yFPNaqSXfODF0EDK\nE9e6liZmCvJwOLD7AQhU2efSbG6zm7VgiG1ofBc //nGgZ7vbYw67aVux4v/\nfXSSK53by/HVrzIwDZTBBANUrzpMeAAIWASeB4P/AQ9 cHjEJx7xWgDE5nLQ\neMdHXvKbg/zkMZ23H/1oFRjYPOc9v3nQ58Aw0xn9LACvO7HQAOZVf/jl0ii1\nHcXe9bPX3euftaPL5R71tIf97nsy7/o0WlP2r4/JOU7B r5nqva7jz1EdZ97\n4qNe bonfvCfVXvly1762beOOdLBd Q7PCAAOw==\n", + alt: "Rails logo" + }; + await smart_collection.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/smart_collections/482865238.json', + query: '', + headers, + data: { "smart_collection": {id: 482865238, image: {attachment: "R0lGODlhbgCMAPf/APbr48VySrxTO7IgKt2qmKQdJeK8lsFjROG5p/nz7Zg3\nMNmnd7Q1MLNVS9GId71hSJMZIuzTu4UtKbeEeakhKMl8U8WYjfr18YQaIbAf\nKKwhKdKzqpQtLebFortOOejKrOjZ1Mt7aMNpVbAqLLV7bsNqR 3WwMqEWenN\nsZYxL/Ddy/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hyn7vhhD9fWdAc2DKhKXxhRCc6\n0Yi4LOPcl6hGVUFqc4gJLGaxufKO1s2VkrOj63znOkciCKMedZ n7ARUp1rQ\niLAyIlyNYURcONaInrWs9ci4JyJOaFYawDzP8Q ZwAICLckbgd08i290eh9V\nCIadQw3qO5Oa1H1GNRlSjeorO2HLruZ2rLudAm Dm9Gxcx/GXmSIMbnjH5W2\nzy2RbOzM cENBRAWs0N9b3zXWdp8pra1r61tbXdb4N/2Nv8i5gzeIJd5Gjui\nwT AzQ9YVGrYnNO0Agm27GBkvNnNzje 921qf/ b1QEfuMDFPe5lk/lspUG3\nWKbQCofLBBBuwNEs3C3aikcrB2TTeM81HgmOd3zf/PZ3yFPNaqSXfODF0EDK\nE9e6liZmCvJwOLD7AQhU2efSbG6zm7VgiG1ofBc //nGgZ7vbYw67aVux4v/\nfXSSK53by/HVrzIwDZTBBANUrzpMeAAIWASeB4P/AQ9 cHjEJx7xWgDE5nLQ\neMdHXvKbg/zkMZ23H/1oFRjYPOc9v3nQ58Aw0xn9LACvO7HQAOZVf/jl0ii1\nHcXe9bPX3euftaPL5R71tIf97nsy7/o0WlP2r4/JOU7B r5nqva7jz1EdZ97\n4qNe bonfvCfVXvly1762beOOdLBd Q7PCAAOw==\n", alt: "Rails logo"}} } + }).toMatchMadeHttpRequest(); + }); + + it('test_17', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const smart_collection = new SmartCollection({session: test_session}); + smart_collection.id = 482865238; + smart_collection.image = { + alt: "Rails logo" + }; + await smart_collection.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/smart_collections/482865238.json', + query: '', + headers, + data: { "smart_collection": {id: 482865238, image: {alt: "Rails logo"}} } + }).toMatchMadeHttpRequest(); + }); + + it('test_18', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const smart_collection = new SmartCollection({session: test_session}); + smart_collection.id = 482865238; + smart_collection.image = ""; + smart_collection.updated_at = "2022-02-03T17:04:39-05:00"; + smart_collection.title = "Smart iPods"; + smart_collection.handle = "smart-ipods"; + smart_collection.body_html = "

The best selling ipod ever

"; + smart_collection.published_at = "2008-02-01T19:00:00-05:00"; + smart_collection.sort_order = "manual"; + smart_collection.template_suffix = null; + smart_collection.disjunctive = false; + smart_collection.rules = [ + { + column: "type", + relation: "equals", + condition: "Cult Products" + } + ]; + smart_collection.published_scope = "web"; + smart_collection.admin_graphql_api_id = "gid://shopify/Collection/482865238"; + await smart_collection.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/smart_collections/482865238.json', + query: '', + headers, + data: { "smart_collection": {id: 482865238, image: "", updated_at: "2022-02-03T17:04:39-05:00", title: "Smart iPods", handle: "smart-ipods", body_html: "

The best selling ipod ever

", published_at: "2008-02-01T19:00:00-05:00", sort_order: "manual", template_suffix: null, disjunctive: false, rules: [{column: "type", relation: "equals", condition: "Cult Products"}], published_scope: "web", admin_graphql_api_id: "gid://shopify/Collection/482865238"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_19', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await SmartCollection.delete({ + session: test_session, + id: 482865238, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-10/smart_collections/482865238.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_20', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const smart_collection = new SmartCollection({session: test_session}); + smart_collection.id = 482865238; + await smart_collection.order({ + products: ["921728736", "632910392"], + }); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/smart_collections/482865238/order.json', + query: 'products%5B%5D=921728736&products%5B%5D=632910392', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_21', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const smart_collection = new SmartCollection({session: test_session}); + smart_collection.id = 482865238; + await smart_collection.order({ + sort_order: "alpha-desc", + }); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/smart_collections/482865238/order.json', + query: 'sort_order=alpha-desc', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-10/storefront_access_token.test.ts b/src/rest-resources/__tests__/2021-10/storefront_access_token.test.ts new file mode 100644 index 000000000..3eea8096c --- /dev/null +++ b/src/rest-resources/__tests__/2021-10/storefront_access_token.test.ts @@ -0,0 +1,69 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {StorefrontAccessToken} from '../../2021-10'; + +describe('StorefrontAccessToken resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.October21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const storefront_access_token = new StorefrontAccessToken({session: test_session}); + storefront_access_token.title = "Test"; + await storefront_access_token.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/storefront_access_tokens.json', + query: '', + headers, + data: { "storefront_access_token": {title: "Test"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await StorefrontAccessToken.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/storefront_access_tokens.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await StorefrontAccessToken.delete({ + session: test_session, + id: 755357713, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-10/storefront_access_tokens/755357713.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-10/tender_transaction.test.ts b/src/rest-resources/__tests__/2021-10/tender_transaction.test.ts new file mode 100644 index 000000000..4a67d2d40 --- /dev/null +++ b/src/rest-resources/__tests__/2021-10/tender_transaction.test.ts @@ -0,0 +1,124 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {TenderTransaction} from '../../2021-10'; + +describe('TenderTransaction resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.October21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await TenderTransaction.all({ + session: test_session, + processed_at_max: "2005-08-05 10:22:51 -0400", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/tender_transactions.json', + query: 'processed_at_max=2005-08-05+10%3A22%3A51+-0400', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await TenderTransaction.all({ + session: test_session, + order: "processed_at ASC", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/tender_transactions.json', + query: 'order=processed_at+ASC', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await TenderTransaction.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/tender_transactions.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await TenderTransaction.all({ + session: test_session, + since_id: "1011222896", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/tender_transactions.json', + query: 'since_id=1011222896', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await TenderTransaction.all({ + session: test_session, + processed_at_min: "2005-08-06 10:22:51 -0400", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/tender_transactions.json', + query: 'processed_at_min=2005-08-06+10%3A22%3A51+-0400', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await TenderTransaction.all({ + session: test_session, + processed_at_max: "2005-08-06 10:22:51 -0400", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/tender_transactions.json', + query: 'processed_at_max=2005-08-06+10%3A22%3A51+-0400', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-10/theme.test.ts b/src/rest-resources/__tests__/2021-10/theme.test.ts new file mode 100644 index 000000000..89e22f092 --- /dev/null +++ b/src/rest-resources/__tests__/2021-10/theme.test.ts @@ -0,0 +1,125 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Theme} from '../../2021-10'; + +describe('Theme resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.October21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Theme.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/themes.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const theme = new Theme({session: test_session}); + theme.name = "Lemongrass"; + theme.src = "http://themes.shopify.com/theme.zip"; + theme.role = "main"; + await theme.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/themes.json', + query: '', + headers, + data: { "theme": {name: "Lemongrass", src: "http://themes.shopify.com/theme.zip", role: "main"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Theme.find({ + session: test_session, + id: 828155753, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/themes/828155753.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const theme = new Theme({session: test_session}); + theme.id = 752253240; + theme.name = "Experimental"; + await theme.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/themes/752253240.json', + query: '', + headers, + data: { "theme": {id: 752253240, name: "Experimental"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const theme = new Theme({session: test_session}); + theme.id = 752253240; + theme.role = "main"; + await theme.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/themes/752253240.json', + query: '', + headers, + data: { "theme": {id: 752253240, role: "main"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Theme.delete({ + session: test_session, + id: 752253240, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-10/themes/752253240.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-10/transaction.test.ts b/src/rest-resources/__tests__/2021-10/transaction.test.ts new file mode 100644 index 000000000..bfce9346b --- /dev/null +++ b/src/rest-resources/__tests__/2021-10/transaction.test.ts @@ -0,0 +1,174 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Transaction} from '../../2021-10'; + +describe('Transaction resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.October21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Transaction.all({ + session: test_session, + order_id: 450789469, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/orders/450789469/transactions.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Transaction.all({ + session: test_session, + order_id: 450789469, + since_id: "801038806", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/orders/450789469/transactions.json', + query: 'since_id=801038806', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const transaction = new Transaction({session: test_session}); + transaction.order_id = 450789469; + transaction.currency = "USD"; + transaction.amount = "10.00"; + transaction.kind = "capture"; + transaction.parent_id = 389404469; + await transaction.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/orders/450789469/transactions.json', + query: '', + headers, + data: { "transaction": {currency: "USD", amount: "10.00", kind: "capture", parent_id: 389404469} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const transaction = new Transaction({session: test_session}); + transaction.order_id = 450789469; + transaction.currency = "USD"; + transaction.amount = "10.00"; + transaction.kind = "void"; + transaction.parent_id = 389404469; + await transaction.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/orders/450789469/transactions.json', + query: '', + headers, + data: { "transaction": {currency: "USD", amount: "10.00", kind: "void", parent_id: 389404469} } + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const transaction = new Transaction({session: test_session}); + transaction.order_id = 450789469; + transaction.currency = "USD"; + transaction.amount = "10.00"; + transaction.kind = "capture"; + transaction.parent_id = 389404469; + transaction.test = true; + await transaction.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/orders/450789469/transactions.json', + query: '', + headers, + data: { "transaction": {currency: "USD", amount: "10.00", kind: "capture", parent_id: 389404469, test: true} } + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const transaction = new Transaction({session: test_session}); + transaction.order_id = 450789469; + transaction.kind = "capture"; + transaction.authorization = "authorization-key"; + await transaction.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/orders/450789469/transactions.json', + query: '', + headers, + data: { "transaction": {kind: "capture", authorization: "authorization-key"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Transaction.count({ + session: test_session, + order_id: 450789469, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/orders/450789469/transactions/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Transaction.find({ + session: test_session, + order_id: 450789469, + id: 389404469, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/orders/450789469/transactions/389404469.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-10/usage_charge.test.ts b/src/rest-resources/__tests__/2021-10/usage_charge.test.ts new file mode 100644 index 000000000..5f14b7004 --- /dev/null +++ b/src/rest-resources/__tests__/2021-10/usage_charge.test.ts @@ -0,0 +1,73 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {UsageCharge} from '../../2021-10'; + +describe('UsageCharge resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.October21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const usage_charge = new UsageCharge({session: test_session}); + usage_charge.recurring_application_charge_id = 455696195; + usage_charge.description = "Super Mega Plan 1000 emails"; + usage_charge.price = 1.0; + await usage_charge.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/recurring_application_charges/455696195/usage_charges.json', + query: '', + headers, + data: { "usage_charge": {description: "Super Mega Plan 1000 emails", price: 1.0} } + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await UsageCharge.all({ + session: test_session, + recurring_application_charge_id: 455696195, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/recurring_application_charges/455696195/usage_charges.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await UsageCharge.find({ + session: test_session, + recurring_application_charge_id: 455696195, + id: 1034618217, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/recurring_application_charges/455696195/usage_charges/1034618217.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-10/user.test.ts b/src/rest-resources/__tests__/2021-10/user.test.ts new file mode 100644 index 000000000..8a6c6cbb8 --- /dev/null +++ b/src/rest-resources/__tests__/2021-10/user.test.ts @@ -0,0 +1,69 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {User} from '../../2021-10'; + +describe('User resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.October21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await User.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/users.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await User.find({ + session: test_session, + id: 548380009, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/users/548380009.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await User.current({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/users/current.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-10/variant.test.ts b/src/rest-resources/__tests__/2021-10/variant.test.ts new file mode 100644 index 000000000..143e23a00 --- /dev/null +++ b/src/rest-resources/__tests__/2021-10/variant.test.ts @@ -0,0 +1,254 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Variant} from '../../2021-10'; + +describe('Variant resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.October21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Variant.all({ + session: test_session, + product_id: 632910392, + since_id: "49148385", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/products/632910392/variants.json', + query: 'since_id=49148385', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Variant.all({ + session: test_session, + product_id: 632910392, + presentment_currencies: "USD,CAD", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/products/632910392/variants.json', + query: 'presentment_currencies=USD%2CCAD', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Variant.all({ + session: test_session, + product_id: 632910392, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/products/632910392/variants.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Variant.count({ + session: test_session, + product_id: 632910392, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/products/632910392/variants/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Variant.find({ + session: test_session, + id: 808950810, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/variants/808950810.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const variant = new Variant({session: test_session}); + variant.id = 808950810; + variant.option1 = "Not Pink"; + variant.price = "99.00"; + await variant.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/variants/808950810.json', + query: '', + headers, + data: { "variant": {id: 808950810, option1: "Not Pink", price: "99.00"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const variant = new Variant({session: test_session}); + variant.id = 808950810; + variant.image_id = 562641783; + await variant.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/variants/808950810.json', + query: '', + headers, + data: { "variant": {id: 808950810, image_id: 562641783} } + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const variant = new Variant({session: test_session}); + variant.id = 808950810; + variant.metafields = [ + { + key: "new", + value: "newvalue", + type: "single_line_text_field", + namespace: "global" + } + ]; + await variant.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/variants/808950810.json', + query: '', + headers, + data: { "variant": {id: 808950810, metafields: [{key: "new", value: "newvalue", type: "single_line_text_field", namespace: "global"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const variant = new Variant({session: test_session}); + variant.product_id = 632910392; + variant.option1 = "Yellow"; + variant.price = "1.00"; + await variant.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/products/632910392/variants.json', + query: '', + headers, + data: { "variant": {option1: "Yellow", price: "1.00"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_10', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const variant = new Variant({session: test_session}); + variant.product_id = 632910392; + variant.image_id = 850703190; + variant.option1 = "Purple"; + await variant.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/products/632910392/variants.json', + query: '', + headers, + data: { "variant": {image_id: 850703190, option1: "Purple"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_11', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const variant = new Variant({session: test_session}); + variant.product_id = 632910392; + variant.option1 = "Blue"; + variant.metafields = [ + { + key: "new", + value: "newvalue", + type: "single_line_text_field", + namespace: "global" + } + ]; + await variant.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/products/632910392/variants.json', + query: '', + headers, + data: { "variant": {option1: "Blue", metafields: [{key: "new", value: "newvalue", type: "single_line_text_field", namespace: "global"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_12', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Variant.delete({ + session: test_session, + product_id: 632910392, + id: 808950810, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-10/products/632910392/variants/808950810.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2021-10/webhook.test.ts b/src/rest-resources/__tests__/2021-10/webhook.test.ts new file mode 100644 index 000000000..6148c5174 --- /dev/null +++ b/src/rest-resources/__tests__/2021-10/webhook.test.ts @@ -0,0 +1,202 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Webhook} from '../../2021-10'; + +describe('Webhook resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.October21; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Webhook.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/webhooks.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Webhook.all({ + session: test_session, + since_id: "901431826", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/webhooks.json', + query: 'since_id=901431826', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const webhook = new Webhook({session: test_session}); + webhook.topic = "orders/create"; + webhook.address = "https://example.hostname.com/"; + webhook.format = "json"; + webhook.fields = [ + "id", + "note" + ]; + await webhook.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/webhooks.json', + query: '', + headers, + data: { "webhook": {topic: "orders/create", address: "https://example.hostname.com/", format: "json", fields: ["id", "note"]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const webhook = new Webhook({session: test_session}); + webhook.address = "arn:aws:events:us-east-1::event-source/aws.partner/shopify.com/755357713/example-event-source"; + webhook.topic = "customers/update"; + webhook.format = "json"; + await webhook.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/webhooks.json', + query: '', + headers, + data: { "webhook": {address: "arn:aws:events:us-east-1::event-source/aws.partner/shopify.com/755357713/example-event-source", topic: "customers/update", format: "json"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const webhook = new Webhook({session: test_session}); + webhook.address = "pubsub://projectName:topicName"; + webhook.topic = "customers/update"; + webhook.format = "json"; + await webhook.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2021-10/webhooks.json', + query: '', + headers, + data: { "webhook": {address: "pubsub://projectName:topicName", topic: "customers/update", format: "json"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Webhook.count({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/webhooks/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Webhook.count({ + session: test_session, + topic: "orders/create", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/webhooks/count.json', + query: 'topic=orders%2Fcreate', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Webhook.find({ + session: test_session, + id: 4759306, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2021-10/webhooks/4759306.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const webhook = new Webhook({session: test_session}); + webhook.id = 4759306; + webhook.address = "https://somewhere-else.com/"; + await webhook.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2021-10/webhooks/4759306.json', + query: '', + headers, + data: { "webhook": {id: 4759306, address: "https://somewhere-else.com/"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_10', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Webhook.delete({ + session: test_session, + id: 4759306, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2021-10/webhooks/4759306.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2022-01/abandoned_checkout.test.ts b/src/rest-resources/__tests__/2022-01/abandoned_checkout.test.ts new file mode 100644 index 000000000..4c0fe8cac --- /dev/null +++ b/src/rest-resources/__tests__/2022-01/abandoned_checkout.test.ts @@ -0,0 +1,141 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {AbandonedCheckout} from '../../2022-01'; + +describe('AbandonedCheckout resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.January22; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await AbandonedCheckout.checkouts({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/checkouts.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await AbandonedCheckout.checkouts({ + session: test_session, + status: "closed", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/checkouts.json', + query: 'status=closed', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await AbandonedCheckout.checkouts({ + session: test_session, + created_at_max: "2013-10-12T07:05:27-02:00", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/checkouts.json', + query: 'created_at_max=2013-10-12T07%3A05%3A27-02%3A00', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await AbandonedCheckout.checkouts({ + session: test_session, + limit: "1", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/checkouts.json', + query: 'limit=1', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await AbandonedCheckout.checkouts({ + session: test_session, + status: "closed", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/checkouts.json', + query: 'status=closed', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await AbandonedCheckout.checkouts({ + session: test_session, + created_at_max: "2013-10-12T07:05:27-02:00", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/checkouts.json', + query: 'created_at_max=2013-10-12T07%3A05%3A27-02%3A00', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await AbandonedCheckout.checkouts({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/checkouts.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2022-01/access_scope.test.ts b/src/rest-resources/__tests__/2022-01/access_scope.test.ts new file mode 100644 index 000000000..7df4eb3c5 --- /dev/null +++ b/src/rest-resources/__tests__/2022-01/access_scope.test.ts @@ -0,0 +1,34 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {AccessScope} from '../../2022-01'; + +describe('AccessScope resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.January22; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await AccessScope.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/oauth/access_scopes.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2022-01/android_pay_key.test.ts b/src/rest-resources/__tests__/2022-01/android_pay_key.test.ts new file mode 100644 index 000000000..e024da807 --- /dev/null +++ b/src/rest-resources/__tests__/2022-01/android_pay_key.test.ts @@ -0,0 +1,70 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {AndroidPayKey} from '../../2022-01'; + +describe('AndroidPayKey resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.January22; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const android_pay_key = new AndroidPayKey({session: test_session}); + + await android_pay_key.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/android_pay_keys.json', + query: '', + headers, + data: { "android_pay_key": {} } + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await AndroidPayKey.find({ + session: test_session, + id: 964811897, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/android_pay_keys/964811897.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await AndroidPayKey.delete({ + session: test_session, + id: 964811898, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2022-01/android_pay_keys/964811898.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2022-01/apple_pay_certificate.test.ts b/src/rest-resources/__tests__/2022-01/apple_pay_certificate.test.ts new file mode 100644 index 000000000..a53250dfe --- /dev/null +++ b/src/rest-resources/__tests__/2022-01/apple_pay_certificate.test.ts @@ -0,0 +1,108 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {ApplePayCertificate} from '../../2022-01'; + +describe('ApplePayCertificate resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.January22; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const apple_pay_certificate = new ApplePayCertificate({session: test_session}); + + await apple_pay_certificate.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/apple_pay_certificates.json', + query: '', + headers, + data: { "apple_pay_certificate": {} } + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await ApplePayCertificate.find({ + session: test_session, + id: 1068938280, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/apple_pay_certificates/1068938280.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const apple_pay_certificate = new ApplePayCertificate({session: test_session}); + apple_pay_certificate.id = 1068938282; + apple_pay_certificate.status = "completed"; + apple_pay_certificate.merchant_id = "merchant.something"; + apple_pay_certificate.encoded_signed_certificate = "MIIEZzCCBA6gAwIBAgIIWGMideLkDJAwCgYIKoZIzj0EAwIwgYAxNDAyBgNV\nBAMMK0FwcGxlIFdvcmxkd2lkZSBEZXZlbG9wZXIgUmVsYXRpb25zIENBIC0g\nRzIxJjAkBgNVBAsMHUFwcGxlIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MRMw\nEQYDVQQKDApBcHBsZSBJbmMuMQswCQYDVQQGEwJVUzAeFw0xNDEyMDgyMTMy\nMDBaFw0xNzAxMDYyMTMyMDBaMIGZMSowKAYKCZImiZPyLGQBAQwabWVyY2hh\nbnQuY29tLm5vcm1vcmUuamFzb24xMDAuBgNVBAMMJ01lcmNoYW50IElEOiBt\nZXJjaGFudC5jb20ubm9ybW9yZS5qYXNvbjETMBEGA1UECw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WL2\nCecFQrIgzHr/fZd8qcy3Be8CIEQCaAPpmvQrXEX0hFexoYMHtOHY9dgN2D8L\nNKpVyn3t\n"; + await apple_pay_certificate.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/apple_pay_certificates/1068938282.json', + query: '', + headers, + data: { "apple_pay_certificate": {id: 1068938282, status: "completed", merchant_id: "merchant.something", encoded_signed_certificate: "MIIEZzCCBA6gAwIBAgIIWGMideLkDJAwCgYIKoZIzj0EAwIwgYAxNDAyBgNV\nBAMMK0FwcGxlIFdvcmxkd2lkZSBEZXZlbG9wZXIgUmVsYXRpb25zIENBIC0g\nRzIxJjAkBgNVBAsMHUFwcGxlIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MRMw\nEQYDVQQKDApBcHBsZSBJbmMuMQswCQYDVQQGEwJVUzAeFw0xNDEyMDgyMTMy\nMDBaFw0xNzAxMDYyMTMyMDBaMIGZMSowKAYKCZImiZPyLGQBAQwabWVyY2hh\nbnQuY29tLm5vcm1vcmUuamFzb24xMDAuBgNVBAMMJ01lcmNoYW50IElEOiBt\nZXJjaGFudC5jb20ubm9ybW9yZS5qYXNvbjETMBEGA1UECwwKNVVZMzJOTE5O\nOTEXMBUGA1UECgwOSm9zaHVhIFRlc3NpZXIxCzAJBgNVBAYTAkNBMFkwEwYH\nKoZIzj0CAQYIKoZIzj0DAQcDQgAEAxDDCvzG6MnsZSJOtbr0hr3MRq 4HzTZ\nx8J4FD34E3kU5CallEnZLBmnzfqmjP8644SO28LLJxvWBnrg7lHFtaOCAlUw\nggJRMEcGCCsGAQUFBwEBBDswOTA3BggrBgEFBQcwAYYraHR0cDovL29jc3Au\nYXBwbGUuY29tL29jc3AwNC1hcHBsZXd3ZHJjYTIwMTAdBgNVHQ4EFgQUkPsO\nKEKvhL/takKomy5GWXtCd8wwDAYDVR0TAQH/BAIwADAfBgNVHSMEGDAWgBSE\ntoTMOoZichZZlOgao71I3zrfCzCCAR0GA1UdIASCARQwggEQMIIBDAYJKoZI\nhvdjZAUBMIH MIHDBggrBgEFBQcCAjCBtgyBs1JlbGlhbmNlIG9uIHRoaXMg\nY2VydGlmaWNhdGUgYnkgYW55IHBhcnR5IGFzc3VtZXMgYWNjZXB0YW5jZSBv\nZiB0aGUgdGhlbiBhcHBsaWNhYmxlIHN0YW5kYXJkIHRlcm1zIGFuZCBjb25k\naXRpb25zIG9mIHVzZSwgY2VydGlmaWNhdGUgcG9saWN5IGFuZCBjZXJ0aWZp\nY2F0aW9uIHByYWN0aWNlIHN0YXRlbWVudHMuMDYGCCsGAQUFBwIBFipodHRw\nOi8vd3d3LmFwcGxlLmNvbS9jZXJ0aWZpY2F0ZWF1dGhvcml0eS8wNgYDVR0f\nBC8wLTAroCmgJ4YlaHR0cDovL2NybC5hcHBsZS5jb20vYXBwbGV3d2RyY2Ey\nLmNybDAOBgNVHQ8BAf8EBAMCAygwTwYJKoZIhvdjZAYgBEIMQDM0NTBBMjhB\nOTlGRjIyRkI5OTdDRERFODU1REREOTI5NTE4RjVGMDdBQUM4NzdDMzRCQjM3\nODFCQTg2MzkyNjIwCgYIKoZIzj0EAwIDRwAwRAIgZ/oNx0gCc/PM4pYhOWL2\nCecFQrIgzHr/fZd8qcy3Be8CIEQCaAPpmvQrXEX0hFexoYMHtOHY9dgN2D8L\nNKpVyn3t\n"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await ApplePayCertificate.delete({ + session: test_session, + id: 1068938283, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2022-01/apple_pay_certificates/1068938283.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await ApplePayCertificate.csr({ + session: test_session, + id: 1068938281, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/apple_pay_certificates/1068938281/csr.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2022-01/application_charge.test.ts b/src/rest-resources/__tests__/2022-01/application_charge.test.ts new file mode 100644 index 000000000..f911809a8 --- /dev/null +++ b/src/rest-resources/__tests__/2022-01/application_charge.test.ts @@ -0,0 +1,109 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {ApplicationCharge} from '../../2022-01'; + +describe('ApplicationCharge resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.January22; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const application_charge = new ApplicationCharge({session: test_session}); + application_charge.name = "Super Duper Expensive action"; + application_charge.price = 100.0; + application_charge.return_url = "http://super-duper.shopifyapps.com"; + await application_charge.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/application_charges.json', + query: '', + headers, + data: { "application_charge": {name: "Super Duper Expensive action", price: 100.0, return_url: "http://super-duper.shopifyapps.com"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const application_charge = new ApplicationCharge({session: test_session}); + application_charge.name = "Super Duper Expensive action"; + application_charge.price = 100.0; + application_charge.return_url = "http://super-duper.shopifyapps.com"; + application_charge.test = true; + await application_charge.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/application_charges.json', + query: '', + headers, + data: { "application_charge": {name: "Super Duper Expensive action", price: 100.0, return_url: "http://super-duper.shopifyapps.com", test: true} } + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await ApplicationCharge.find({ + session: test_session, + id: 675931192, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/application_charges/675931192.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await ApplicationCharge.all({ + session: test_session, + since_id: "556467234", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/application_charges.json', + query: 'since_id=556467234', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await ApplicationCharge.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/application_charges.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2022-01/application_credit.test.ts b/src/rest-resources/__tests__/2022-01/application_credit.test.ts new file mode 100644 index 000000000..7213dbf16 --- /dev/null +++ b/src/rest-resources/__tests__/2022-01/application_credit.test.ts @@ -0,0 +1,89 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {ApplicationCredit} from '../../2022-01'; + +describe('ApplicationCredit resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.January22; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const application_credit = new ApplicationCredit({session: test_session}); + application_credit.description = "application credit for refund"; + application_credit.amount = 5.0; + await application_credit.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/application_credits.json', + query: '', + headers, + data: { "application_credit": {description: "application credit for refund", amount: 5.0} } + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const application_credit = new ApplicationCredit({session: test_session}); + application_credit.description = "application credit for refund"; + application_credit.amount = 5.0; + application_credit.test = true; + await application_credit.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/application_credits.json', + query: '', + headers, + data: { "application_credit": {description: "application credit for refund", amount: 5.0, test: true} } + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await ApplicationCredit.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/application_credits.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await ApplicationCredit.find({ + session: test_session, + id: 140583599, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/application_credits/140583599.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2022-01/article.test.ts b/src/rest-resources/__tests__/2022-01/article.test.ts new file mode 100644 index 000000000..d09a7420d --- /dev/null +++ b/src/rest-resources/__tests__/2022-01/article.test.ts @@ -0,0 +1,484 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Article} from '../../2022-01'; + +describe('Article resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.January22; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Article.all({ + session: test_session, + blog_id: 241253187, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/blogs/241253187/articles.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Article.all({ + session: test_session, + blog_id: 241253187, + since_id: "134645308", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/blogs/241253187/articles.json', + query: 'since_id=134645308', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const article = new Article({session: test_session}); + article.blog_id = 241253187; + article.title = "My new Article title"; + article.author = "John Smith"; + article.tags = "This Post, Has Been Tagged"; + article.body_html = "

I like articles

\n

Yea, I like posting them through REST.

"; + article.published_at = "Thu Mar 24 15:45:47 UTC 2011"; + await article.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/blogs/241253187/articles.json', + query: '', + headers, + data: { "article": {title: "My new Article title", author: "John Smith", tags: "This Post, Has Been Tagged", body_html: "

I like articles

\n

Yea, I like posting them through REST.

", published_at: "Thu Mar 24 15:45:47 UTC 2011"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const article = new Article({session: test_session}); + article.blog_id = 241253187; + article.title = "My new Article title"; + article.author = "John Smith"; + article.tags = "This Post, Has Been Tagged"; + article.body_html = "

I like articles

\n

Yea, I like posting them through REST.

"; + article.published = false; + await article.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/blogs/241253187/articles.json', + query: '', + headers, + data: { "article": {title: "My new Article title", author: "John Smith", tags: "This Post, Has Been Tagged", body_html: "

I like articles

\n

Yea, I like posting them through REST.

", published: false} } + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const article = new Article({session: test_session}); + article.blog_id = 241253187; + article.title = "My new Article title"; + article.author = "John Smith"; + article.tags = "This Post, Has Been Tagged"; + article.body_html = "

I like articles

\n

Yea, I like posting them through REST.

"; + article.published_at = "Thu Mar 24 15:45:47 UTC 2011"; + article.image = { + attachment: "R0lGODlhAQABAIAAAAAAAAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==\n" + }; + await article.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/blogs/241253187/articles.json', + query: '', + headers, + data: { "article": {title: "My new Article title", author: "John Smith", tags: "This Post, Has Been Tagged", body_html: "

I like articles

\n

Yea, I like posting them through REST.

", published_at: "Thu Mar 24 15:45:47 UTC 2011", image: {attachment: "R0lGODlhAQABAIAAAAAAAAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==\n"}} } + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const article = new Article({session: test_session}); + article.blog_id = 241253187; + article.title = "My new Article title"; + article.author = "John Smith"; + article.tags = "This Post, Has Been Tagged"; + article.body_html = "

I like articles

\n

Yea, I like posting them through REST.

"; + article.published_at = "Thu Mar 24 15:45:47 UTC 2011"; + article.image = { + src: "http://example.com/rails_logo.gif", + alt: "Rails logo" + }; + await article.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/blogs/241253187/articles.json', + query: '', + headers, + data: { "article": {title: "My new Article title", author: "John Smith", tags: "This Post, Has Been Tagged", body_html: "

I like articles

\n

Yea, I like posting them through REST.

", published_at: "Thu Mar 24 15:45:47 UTC 2011", image: {src: "http://example.com/rails_logo.gif", alt: "Rails logo"}} } + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const article = new Article({session: test_session}); + article.blog_id = 241253187; + article.title = "My new Article title"; + article.author = "John Smith"; + article.tags = "This Post, Has Been Tagged"; + article.body_html = "

I like articles

\n

Yea, I like posting them through REST.

"; + article.published_at = "Thu Mar 24 15:45:47 UTC 2011"; + article.metafields = [ + { + key: "new", + value: "newvalue", + type: "single_line_text_field", + namespace: "global" + } + ]; + await article.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/blogs/241253187/articles.json', + query: '', + headers, + data: { "article": {title: "My new Article title", author: "John Smith", tags: "This Post, Has Been Tagged", body_html: "

I like articles

\n

Yea, I like posting them through REST.

", published_at: "Thu Mar 24 15:45:47 UTC 2011", metafields: [{key: "new", value: "newvalue", type: "single_line_text_field", namespace: "global"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Article.count({ + session: test_session, + blog_id: 241253187, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/blogs/241253187/articles/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Article.find({ + session: test_session, + blog_id: 241253187, + id: 134645308, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/blogs/241253187/articles/134645308.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_10', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const article = new Article({session: test_session}); + article.blog_id = 241253187; + article.id = 134645308; + article.title = "My new Title"; + article.author = "Your name"; + article.tags = "Tags, Will Be, Updated"; + article.body_html = "

Look, I can even update through a web service.

"; + article.published_at = "Thu Mar 24 15:45:47 UTC 2011"; + await article.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/blogs/241253187/articles/134645308.json', + query: '', + headers, + data: { "article": {id: 134645308, title: "My new Title", author: "Your name", tags: "Tags, Will Be, Updated", body_html: "

Look, I can even update through a web service.

", published_at: "Thu Mar 24 15:45:47 UTC 2011"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_11', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const article = new Article({session: test_session}); + article.blog_id = 241253187; + article.id = 134645308; + article.published = true; + await article.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/blogs/241253187/articles/134645308.json', + query: '', + headers, + data: { "article": {id: 134645308, published: true} } + }).toMatchMadeHttpRequest(); + }); + + it('test_12', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const article = new Article({session: test_session}); + article.blog_id = 241253187; + article.id = 134645308; + article.published = false; + await article.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/blogs/241253187/articles/134645308.json', + query: '', + headers, + data: { "article": {id: 134645308, published: false} } + }).toMatchMadeHttpRequest(); + }); + + it('test_13', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const article = new Article({session: test_session}); + article.blog_id = 241253187; + article.id = 134645308; + article.title = "My new Title"; + article.author = "Your name"; + article.tags = "Tags, Will Be, Updated"; + article.body_html = "

Look, I can even update through a web service.

"; + article.published_at = "Thu Mar 24 15:45:47 UTC 2011"; + article.image = { + attachment: "R0lGODlhbgCMAPf/APbr48VySrxTO7IgKt2qmKQdJeK8lsFjROG5p/nz7Zg3\nMNmnd7Q1MLNVS9GId71hSJMZIuzTu4UtKbeEeakhKMl8U8WYjfr18YQaIbAf\nKKwhKdKzqpQtLebFortOOejKrOjZ1Mt7aMNpVbAqLLV7bsNqR 3WwMqEWenN\nsZYxL/Ddy/Pm2e7ZxLlUQrIjNPXp3bU5MbhENbEtLtqhj5ZQTfHh0bMxL7Ip\nNsNyUYkZIrZJPcqGdYIUHb5aPKkeJnoUHd2yiJkiLKYiKLRFOsyJXKVDO8up\nosFaS TBnK4kKti5sNaYg/z49aqYl5kqLrljUtORfMOlo/36 H4ZH8yDYq0f\nKKFYTaU9MrY8MrZBNXwXHpgaIdGVYu/byLZNP9SaZLIyOuXCtHkpJst Wpcm\nLMyCa8BfP9GMb9KQdPDd1PPk1sd5VP79/L5dQZ0bI9 ymqssK9WcfIoXHdzG\nxdWWfteib79lSr1YP86MYurQxKdcUKdMQr5ZSfPs6YEZH8uhl4oWIenMuurQ\nttmejaqoqsqBVaAcJLlJN5kvMLlZRMNsSL5fRak0LbdQQMVvSPjw6cJnRpkf\nKtmjhvfu5cJtT7IuOMVvWLY/M/37 o0YH9ibhtSYdObErc6HarM9NnYSGNGR\navLi09unje3WyeO8rsVrT7tdRtK3uffu6NWeaL9pTJIjJrM4NPbx8cdyX7M7\nPYYVHu7j4KgoNJAYIKtkV5o9MsOcldicis RYNutfrhFOZ0hJbqinZ8bI8h5\nUObFuOfItJsfJrJfU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nqva7jz1EdZ97\n4qNe bonfvCfVXvly1762beOOdLBd Q7PCAAOw==\n" + }; + await article.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/blogs/241253187/articles/134645308.json', + query: '', + headers, + data: { "article": {id: 134645308, title: "My new Title", author: "Your name", tags: "Tags, Will Be, Updated", body_html: "

Look, I can even update through a web service.

", published_at: "Thu Mar 24 15:45:47 UTC 2011", image: {attachment: "R0lGODlhbgCMAPf/APbr48VySrxTO7IgKt2qmKQdJeK8lsFjROG5p/nz7Zg3\nMNmnd7Q1MLNVS9GId71hSJMZIuzTu4UtKbeEeakhKMl8U8WYjfr18YQaIbAf\nKKwhKdKzqpQtLebFortOOejKrOjZ1Mt7aMNpVbAqLLV7bsNqR 3WwMqEWenN\nsZYxL/Ddy/Pm2e7ZxLlUQrIjNPXp3bU5MbhENbEtLtqhj5ZQTfHh0bMxL7Ip\nNsNyUYkZIrZJPcqGdYIUHb5aPKkeJnoUHd2yiJkiLKYiKLRFOsyJXKVDO8up\nosFaS TBnK4kKti5sNaYg/z49aqYl5kqLrljUtORfMOlo/36 H4ZH8yDYq0f\nKKFYTaU9MrY8MrZBNXwXHpgaIdGVYu/byLZNP9SaZLIyOuXCtHkpJst Wpcm\nLMyCa8BfP9GMb9KQdPDd1PPk1sd5VP79/L5dQZ0bI9 ymqssK9WcfIoXHdzG\nxdWWfteib79lSr1YP86MYurQxKdcUKdMQr5ZSfPs6YEZH8uhl4oWIenMuurQ\nttmejaqoqsqBVaAcJLlJN5kvMLlZRMNsSL5fRak0LbdQQMVvSPjw6cJnRpkf\nKtmjhvfu5cJtT7IuOMVvWLY/M/37 o0YH9ibhtSYdObErc6HarM9NnYSGNGR\navLi09unje3WyeO8rsVrT7tdRtK3uffu6NWeaL9pTJIjJrM4NPbx8cdyX7M7\nPYYVHu7j4KgoNJAYIKtkV5o9MsOcldicis RYNutfrhFOZ0hJbqinZ8bI8h5\nUObFuOfItJsfJrJfUOfIqc PXqQtK8RnSbA4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bonfvCfVXvly1762beOOdLBd Q7PCAAOw==\n"}} } + }).toMatchMadeHttpRequest(); + }); + + it('test_14', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const article = new Article({session: test_session}); + article.blog_id = 241253187; + article.id = 134645308; + article.title = "My new Title"; + article.author = "Your name"; + article.tags = "Tags, Will Be, Updated"; + article.body_html = "

Look, I can even update through a web service.

"; + article.published_at = "Thu Mar 24 15:45:47 UTC 2011"; + article.image = { + alt: "Rails logo" + }; + await article.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/blogs/241253187/articles/134645308.json', + query: '', + headers, + data: { "article": {id: 134645308, title: "My new Title", author: "Your name", tags: "Tags, Will Be, Updated", body_html: "

Look, I can even update through a web service.

", published_at: "Thu Mar 24 15:45:47 UTC 2011", image: {alt: "Rails logo"}} } + }).toMatchMadeHttpRequest(); + }); + + it('test_15', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const article = new Article({session: test_session}); + article.blog_id = 241253187; + article.id = 134645308; + article.image = ""; + await article.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/blogs/241253187/articles/134645308.json', + query: '', + headers, + data: { "article": {id: 134645308, image: ""} } + }).toMatchMadeHttpRequest(); + }); + + it('test_16', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const article = new Article({session: test_session}); + article.blog_id = 241253187; + article.id = 134645308; + article.metafields = [ + { + key: "new", + value: "newvalue", + type: "single_line_text_field", + namespace: "global" + } + ]; + await article.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/blogs/241253187/articles/134645308.json', + query: '', + headers, + data: { "article": {id: 134645308, metafields: [{key: "new", value: "newvalue", type: "single_line_text_field", namespace: "global"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_17', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Article.delete({ + session: test_session, + blog_id: 241253187, + id: 134645308, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2022-01/blogs/241253187/articles/134645308.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_18', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Article.authors({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/articles/authors.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_19', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Article.tags({ + session: test_session, + blog_id: 241253187, + limit: "1", + popular: "1", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/blogs/241253187/articles/tags.json', + query: 'limit=1&popular=1', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_20', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Article.tags({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/articles/tags.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_21', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Article.tags({ + session: test_session, + blog_id: 241253187, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/blogs/241253187/articles/tags.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_22', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Article.tags({ + session: test_session, + limit: "1", + popular: "1", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/articles/tags.json', + query: 'limit=1&popular=1', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2022-01/asset.test.ts b/src/rest-resources/__tests__/2022-01/asset.test.ts new file mode 100644 index 000000000..7e71b6dd1 --- /dev/null +++ b/src/rest-resources/__tests__/2022-01/asset.test.ts @@ -0,0 +1,149 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Asset} from '../../2022-01'; + +describe('Asset resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.January22; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Asset.all({ + session: test_session, + theme_id: 828155753, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/themes/828155753/assets.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const asset = new Asset({session: test_session}); + asset.theme_id = 828155753; + asset.key = "templates/index.liquid"; + asset.value = "

We are busy updating the store for you and will be back within the hour.

"; + await asset.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/themes/828155753/assets.json', + query: '', + headers, + data: { "asset": {key: "templates/index.liquid", value: "

We are busy updating the store for you and will be back within the hour.

"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const asset = new Asset({session: test_session}); + asset.theme_id = 828155753; + asset.key = "assets/empty.gif"; + asset.attachment = "R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw==\n"; + await asset.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/themes/828155753/assets.json', + query: '', + headers, + data: { "asset": {key: "assets/empty.gif", attachment: "R0lGODlhAQABAPABAP///wAAACH5BAEKAAAALAAAAAABAAEAAAICRAEAOw==\n"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const asset = new Asset({session: test_session}); + asset.theme_id = 828155753; + asset.key = "assets/bg-body.gif"; + asset.src = "http://apple.com/new_bg.gif"; + await asset.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/themes/828155753/assets.json', + query: '', + headers, + data: { "asset": {key: "assets/bg-body.gif", src: "http://apple.com/new_bg.gif"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const asset = new Asset({session: test_session}); + asset.theme_id = 828155753; + asset.key = "layout/alternate.liquid"; + asset.source_key = "layout/theme.liquid"; + await asset.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/themes/828155753/assets.json', + query: '', + headers, + data: { "asset": {key: "layout/alternate.liquid", source_key: "layout/theme.liquid"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Asset.all({ + session: test_session, + theme_id: 828155753, + asset: {key: "templates/index.liquid"}, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/themes/828155753/assets.json', + query: 'asset%5Bkey%5D=templates%2Findex.liquid', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Asset.delete({ + session: test_session, + theme_id: 828155753, + asset: {key: "assets/bg-body.gif"}, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2022-01/themes/828155753/assets.json', + query: 'asset%5Bkey%5D=assets%2Fbg-body.gif', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2022-01/assigned_fulfillment_order.test.ts b/src/rest-resources/__tests__/2022-01/assigned_fulfillment_order.test.ts new file mode 100644 index 000000000..4763762a0 --- /dev/null +++ b/src/rest-resources/__tests__/2022-01/assigned_fulfillment_order.test.ts @@ -0,0 +1,36 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {AssignedFulfillmentOrder} from '../../2022-01'; + +describe('AssignedFulfillmentOrder resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.January22; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await AssignedFulfillmentOrder.all({ + session: test_session, + assignment_status: "cancellation_requested", + location_ids: ["24826418"], + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/assigned_fulfillment_orders.json', + query: 'assignment_status=cancellation_requested&location_ids%5B%5D=24826418', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2022-01/balance.test.ts b/src/rest-resources/__tests__/2022-01/balance.test.ts new file mode 100644 index 000000000..6a7254d8e --- /dev/null +++ b/src/rest-resources/__tests__/2022-01/balance.test.ts @@ -0,0 +1,34 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Balance} from '../../2022-01'; + +describe('Balance resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.January22; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Balance.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/shopify_payments/balance.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2022-01/blog.test.ts b/src/rest-resources/__tests__/2022-01/blog.test.ts new file mode 100644 index 000000000..82a948feb --- /dev/null +++ b/src/rest-resources/__tests__/2022-01/blog.test.ts @@ -0,0 +1,229 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Blog} from '../../2022-01'; + +describe('Blog resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.January22; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Blog.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/blogs.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Blog.all({ + session: test_session, + since_id: "241253187", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/blogs.json', + query: 'since_id=241253187', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const blog = new Blog({session: test_session}); + blog.title = "Apple main blog"; + await blog.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/blogs.json', + query: '', + headers, + data: { "blog": {title: "Apple main blog"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const blog = new Blog({session: test_session}); + blog.title = "Apple main blog"; + blog.metafields = [ + { + key: "sponsor", + value: "Shopify", + type: "single_line_text_field", + namespace: "global" + } + ]; + await blog.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/blogs.json', + query: '', + headers, + data: { "blog": {title: "Apple main blog", metafields: [{key: "sponsor", value: "Shopify", type: "single_line_text_field", namespace: "global"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Blog.count({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/blogs/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Blog.find({ + session: test_session, + id: 241253187, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/blogs/241253187.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Blog.find({ + session: test_session, + id: 241253187, + fields: "id,title", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/blogs/241253187.json', + query: 'fields=id%2Ctitle', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const blog = new Blog({session: test_session}); + blog.id = 241253187; + blog.title = "IPod Updates"; + await blog.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/blogs/241253187.json', + query: '', + headers, + data: { "blog": {id: 241253187, title: "IPod Updates"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const blog = new Blog({session: test_session}); + blog.id = 241253187; + blog.title = "IPod Updates"; + blog.handle = "ipod-updates"; + blog.commentable = "moderate"; + await blog.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/blogs/241253187.json', + query: '', + headers, + data: { "blog": {id: 241253187, title: "IPod Updates", handle: "ipod-updates", commentable: "moderate"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_10', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const blog = new Blog({session: test_session}); + blog.id = 241253187; + blog.metafields = [ + { + key: "sponsor", + value: "Shopify", + type: "single_line_text_field", + namespace: "global" + } + ]; + await blog.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/blogs/241253187.json', + query: '', + headers, + data: { "blog": {id: 241253187, metafields: [{key: "sponsor", value: "Shopify", type: "single_line_text_field", namespace: "global"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_11', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Blog.delete({ + session: test_session, + id: 241253187, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2022-01/blogs/241253187.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2022-01/cancellation_request.test.ts b/src/rest-resources/__tests__/2022-01/cancellation_request.test.ts new file mode 100644 index 000000000..711bfbb1b --- /dev/null +++ b/src/rest-resources/__tests__/2022-01/cancellation_request.test.ts @@ -0,0 +1,73 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {CancellationRequest} from '../../2022-01'; + +describe('CancellationRequest resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.January22; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const cancellation_request = new CancellationRequest({session: test_session}); + cancellation_request.fulfillment_order_id = 1046000837; + cancellation_request.message = "The customer changed his mind."; + await cancellation_request.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/fulfillment_orders/1046000837/cancellation_request.json', + query: '', + headers, + data: { "cancellation_request": {message: "The customer changed his mind."} } + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const cancellation_request = new CancellationRequest({session: test_session}); + cancellation_request.fulfillment_order_id = 1046000838; + await cancellation_request.accept({ + body: {cancellation_request: {message: "We had not started any processing yet."}}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/fulfillment_orders/1046000838/cancellation_request/accept.json', + query: '', + headers, + data: { "cancellation_request": {message: "We had not started any processing yet."} } + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const cancellation_request = new CancellationRequest({session: test_session}); + cancellation_request.fulfillment_order_id = 1046000839; + await cancellation_request.reject({ + body: {cancellation_request: {message: "We have already send the shipment out."}}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/fulfillment_orders/1046000839/cancellation_request/reject.json', + query: '', + headers, + data: { "cancellation_request": {message: "We have already send the shipment out."} } + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2022-01/carrier_service.test.ts b/src/rest-resources/__tests__/2022-01/carrier_service.test.ts new file mode 100644 index 000000000..d8f7cbe9a --- /dev/null +++ b/src/rest-resources/__tests__/2022-01/carrier_service.test.ts @@ -0,0 +1,108 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {CarrierService} from '../../2022-01'; + +describe('CarrierService resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.January22; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const carrier_service = new CarrierService({session: test_session}); + carrier_service.name = "Shipping Rate Provider"; + carrier_service.callback_url = "http://shippingrateprovider.com"; + carrier_service.service_discovery = true; + await carrier_service.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/carrier_services.json', + query: '', + headers, + data: { "carrier_service": {name: "Shipping Rate Provider", callback_url: "http://shippingrateprovider.com", service_discovery: true} } + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CarrierService.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/carrier_services.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const carrier_service = new CarrierService({session: test_session}); + carrier_service.id = 1036894964; + carrier_service.name = "Some new name"; + carrier_service.active = false; + await carrier_service.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/carrier_services/1036894964.json', + query: '', + headers, + data: { "carrier_service": {id: 1036894964, name: "Some new name", active: false} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CarrierService.find({ + session: test_session, + id: 1036894966, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/carrier_services/1036894966.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CarrierService.delete({ + session: test_session, + id: 1036894967, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2022-01/carrier_services/1036894967.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2022-01/checkout.test.ts b/src/rest-resources/__tests__/2022-01/checkout.test.ts new file mode 100644 index 000000000..6b28812fe --- /dev/null +++ b/src/rest-resources/__tests__/2022-01/checkout.test.ts @@ -0,0 +1,229 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Checkout} from '../../2022-01'; + +describe('Checkout resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.January22; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const checkout = new Checkout({session: test_session}); + checkout.line_items = [ + { + variant_id: 39072856, + quantity: 5 + } + ]; + await checkout.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/checkouts.json', + query: '', + headers, + data: { "checkout": {line_items: [{variant_id: 39072856, quantity: 5}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const checkout = new Checkout({session: test_session}); + checkout.email = "me@example.com"; + await checkout.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/checkouts.json', + query: '', + headers, + data: { "checkout": {email: "me@example.com"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const checkout = new Checkout({session: test_session}); + checkout.token = "b490a9220cd14d7344024f4874f640a6"; + await checkout.complete({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/checkouts/b490a9220cd14d7344024f4874f640a6/complete.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Checkout.find({ + session: test_session, + token: "bd5a8aa1ecd019dd3520ff791ee3a24c", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/checkouts/bd5a8aa1ecd019dd3520ff791ee3a24c.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Checkout.find({ + session: test_session, + token: "7yjf4v2we7gamku6a6h7tvm8h3mmvs4x", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/checkouts/7yjf4v2we7gamku6a6h7tvm8h3mmvs4x.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Checkout.find({ + session: test_session, + token: "exuw7apwoycchjuwtiqg8nytfhphr62a", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/checkouts/exuw7apwoycchjuwtiqg8nytfhphr62a.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const checkout = new Checkout({session: test_session}); + checkout.token = "exuw7apwoycchjuwtiqg8nytfhphr62a"; + checkout.email = "john.smith@example.com"; + checkout.shipping_address = { + first_name: "John", + last_name: "Smith", + address1: "126 York St.", + city: "Los Angeles", + province_code: "CA", + country_code: "US", + phone: "(123)456-7890", + zip: "90002" + }; + await checkout.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/checkouts/exuw7apwoycchjuwtiqg8nytfhphr62a.json', + query: '', + headers, + data: { "checkout": {token: "exuw7apwoycchjuwtiqg8nytfhphr62a", email: "john.smith@example.com", shipping_address: {first_name: "John", last_name: "Smith", address1: "126 York St.", city: "Los Angeles", province_code: "CA", country_code: "US", phone: "(123)456-7890", zip: "90002"}} } + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const checkout = new Checkout({session: test_session}); + checkout.token = "exuw7apwoycchjuwtiqg8nytfhphr62a"; + checkout.shipping_line = { + handle: "shopify-Free Shipping-0.00" + }; + await checkout.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/checkouts/exuw7apwoycchjuwtiqg8nytfhphr62a.json', + query: '', + headers, + data: { "checkout": {token: "exuw7apwoycchjuwtiqg8nytfhphr62a", shipping_line: {handle: "shopify-Free Shipping-0.00"}} } + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Checkout.shipping_rates({ + session: test_session, + token: "exuw7apwoycchjuwtiqg8nytfhphr62a", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/checkouts/exuw7apwoycchjuwtiqg8nytfhphr62a/shipping_rates.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_10', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Checkout.shipping_rates({ + session: test_session, + token: "exuw7apwoycchjuwtiqg8nytfhphr62a", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/checkouts/exuw7apwoycchjuwtiqg8nytfhphr62a/shipping_rates.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_11', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Checkout.shipping_rates({ + session: test_session, + token: "zs9ru89kuqcdagk8bz4r9hnxt22wwd42", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/checkouts/zs9ru89kuqcdagk8bz4r9hnxt22wwd42/shipping_rates.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2022-01/collect.test.ts b/src/rest-resources/__tests__/2022-01/collect.test.ts new file mode 100644 index 000000000..09a5e56df --- /dev/null +++ b/src/rest-resources/__tests__/2022-01/collect.test.ts @@ -0,0 +1,177 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Collect} from '../../2022-01'; + +describe('Collect resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.January22; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const collect = new Collect({session: test_session}); + collect.product_id = 921728736; + collect.collection_id = 841564295; + await collect.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/collects.json', + query: '', + headers, + data: { "collect": {product_id: 921728736, collection_id: 841564295} } + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Collect.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/collects.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Collect.all({ + session: test_session, + product_id: "632910392", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/collects.json', + query: 'product_id=632910392', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Collect.all({ + session: test_session, + collection_id: "841564295", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/collects.json', + query: 'collection_id=841564295', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Collect.delete({ + session: test_session, + id: 455204334, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2022-01/collects/455204334.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Collect.find({ + session: test_session, + id: 455204334, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/collects/455204334.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Collect.count({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/collects/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Collect.count({ + session: test_session, + product_id: "632910392", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/collects/count.json', + query: 'product_id=632910392', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Collect.count({ + session: test_session, + collection_id: "841564295", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/collects/count.json', + query: 'collection_id=841564295', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2022-01/collection.test.ts b/src/rest-resources/__tests__/2022-01/collection.test.ts new file mode 100644 index 000000000..46219f9f6 --- /dev/null +++ b/src/rest-resources/__tests__/2022-01/collection.test.ts @@ -0,0 +1,53 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Collection} from '../../2022-01'; + +describe('Collection resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.January22; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Collection.find({ + session: test_session, + id: 841564295, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/collections/841564295.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Collection.products({ + session: test_session, + id: 841564295, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/collections/841564295/products.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2022-01/collection_listing.test.ts b/src/rest-resources/__tests__/2022-01/collection_listing.test.ts new file mode 100644 index 000000000..04830ca9e --- /dev/null +++ b/src/rest-resources/__tests__/2022-01/collection_listing.test.ts @@ -0,0 +1,105 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {CollectionListing} from '../../2022-01'; + +describe('CollectionListing resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.January22; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CollectionListing.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/collection_listings.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CollectionListing.product_ids({ + session: test_session, + collection_id: 841564295, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/collection_listings/841564295/product_ids.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CollectionListing.find({ + session: test_session, + collection_id: 482865238, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/collection_listings/482865238.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const collection_listing = new CollectionListing({session: test_session}); + collection_listing.collection_id = 482865238; + await collection_listing.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/collection_listings/482865238.json', + query: '', + headers, + data: { "collection_listing": {collection_id: 482865238} } + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CollectionListing.delete({ + session: test_session, + collection_id: 482865238, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2022-01/collection_listings/482865238.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2022-01/comment.test.ts b/src/rest-resources/__tests__/2022-01/comment.test.ts new file mode 100644 index 000000000..72a841258 --- /dev/null +++ b/src/rest-resources/__tests__/2022-01/comment.test.ts @@ -0,0 +1,289 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Comment} from '../../2022-01'; + +describe('Comment resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.January22; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Comment.all({ + session: test_session, + article_id: "134645308", + blog_id: "241253187", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/comments.json', + query: 'article_id=134645308&blog_id=241253187', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Comment.all({ + session: test_session, + blog_id: "241253187", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/comments.json', + query: 'blog_id=241253187', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Comment.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/comments.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Comment.all({ + session: test_session, + since_id: "118373535", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/comments.json', + query: 'since_id=118373535', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Comment.count({ + session: test_session, + article_id: "134645308", + blog_id: "241253187", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/comments/count.json', + query: 'article_id=134645308&blog_id=241253187', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Comment.count({ + session: test_session, + blog_id: "241253187", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/comments/count.json', + query: 'blog_id=241253187', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Comment.count({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/comments/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Comment.find({ + session: test_session, + id: 118373535, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/comments/118373535.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const comment = new Comment({session: test_session}); + comment.id = 118373535; + comment.body = "You can even update through a web service."; + comment.author = "Your new name"; + comment.email = "your@updated-email.com"; + comment.published_at = "2022-02-03T22:13:53.233Z"; + await comment.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/comments/118373535.json', + query: '', + headers, + data: { "comment": {id: 118373535, body: "You can even update through a web service.", author: "Your new name", email: "your@updated-email.com", published_at: "2022-02-03T22:13:53.233Z"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_10', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const comment = new Comment({session: test_session}); + comment.body = "I like comments\nAnd I like posting them *RESTfully*."; + comment.author = "Your name"; + comment.email = "your@email.com"; + comment.ip = "107.20.160.121"; + comment.blog_id = 241253187; + comment.article_id = 134645308; + await comment.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/comments.json', + query: '', + headers, + data: { "comment": {body: "I like comments\nAnd I like posting them *RESTfully*.", author: "Your name", email: "your@email.com", ip: "107.20.160.121", blog_id: 241253187, article_id: 134645308} } + }).toMatchMadeHttpRequest(); + }); + + it('test_11', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const comment = new Comment({session: test_session}); + comment.id = 653537639; + await comment.spam({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/comments/653537639/spam.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_12', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const comment = new Comment({session: test_session}); + comment.id = 653537639; + await comment.not_spam({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/comments/653537639/not_spam.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_13', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const comment = new Comment({session: test_session}); + comment.id = 653537639; + await comment.approve({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/comments/653537639/approve.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_14', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const comment = new Comment({session: test_session}); + comment.id = 653537639; + await comment.remove({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/comments/653537639/remove.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_15', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const comment = new Comment({session: test_session}); + comment.id = 653537639; + await comment.restore({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/comments/653537639/restore.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2022-01/country.test.ts b/src/rest-resources/__tests__/2022-01/country.test.ts new file mode 100644 index 000000000..b16677d85 --- /dev/null +++ b/src/rest-resources/__tests__/2022-01/country.test.ts @@ -0,0 +1,158 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Country} from '../../2022-01'; + +describe('Country resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.January22; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Country.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/countries.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Country.all({ + session: test_session, + since_id: "359115488", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/countries.json', + query: 'since_id=359115488', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const country = new Country({session: test_session}); + country.code = "FR"; + await country.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/countries.json', + query: '', + headers, + data: { "country": {code: "FR"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const country = new Country({session: test_session}); + country.code = "FR"; + country.tax = 0.2; + await country.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/countries.json', + query: '', + headers, + data: { "country": {code: "FR", tax: 0.2} } + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Country.count({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/countries/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Country.find({ + session: test_session, + id: 879921427, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/countries/879921427.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const country = new Country({session: test_session}); + country.id = 879921427; + country.tax = 0.05; + await country.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/countries/879921427.json', + query: '', + headers, + data: { "country": {id: 879921427, tax: 0.05} } + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Country.delete({ + session: test_session, + id: 879921427, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2022-01/countries/879921427.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2022-01/currency.test.ts b/src/rest-resources/__tests__/2022-01/currency.test.ts new file mode 100644 index 000000000..5f07e4e96 --- /dev/null +++ b/src/rest-resources/__tests__/2022-01/currency.test.ts @@ -0,0 +1,34 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Currency} from '../../2022-01'; + +describe('Currency resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.January22; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Currency.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/currencies.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2022-01/custom_collection.test.ts b/src/rest-resources/__tests__/2022-01/custom_collection.test.ts new file mode 100644 index 000000000..4ae7a2cad --- /dev/null +++ b/src/rest-resources/__tests__/2022-01/custom_collection.test.ts @@ -0,0 +1,436 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {CustomCollection} from '../../2022-01'; + +describe('CustomCollection resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.January22; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CustomCollection.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/custom_collections.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CustomCollection.all({ + session: test_session, + since_id: "841564295", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/custom_collections.json', + query: 'since_id=841564295', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CustomCollection.all({ + session: test_session, + product_id: "632910392", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/custom_collections.json', + query: 'product_id=632910392', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CustomCollection.all({ + session: test_session, + ids: "395646240,691652237,841564295", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/custom_collections.json', + query: 'ids=395646240%2C691652237%2C841564295', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const custom_collection = new CustomCollection({session: test_session}); + custom_collection.title = "Macbooks"; + await custom_collection.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/custom_collections.json', + query: '', + headers, + data: { "custom_collection": {title: "Macbooks"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const custom_collection = new CustomCollection({session: test_session}); + custom_collection.title = "Macbooks"; + custom_collection.published = false; + await custom_collection.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/custom_collections.json', + query: '', + headers, + data: { "custom_collection": {title: "Macbooks", published: false} } + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const custom_collection = new CustomCollection({session: test_session}); + custom_collection.title = "Macbooks"; + custom_collection.image = { + src: "http://example.com/rails_logo.gif", + alt: "Rails Logo" + }; + await custom_collection.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/custom_collections.json', + query: '', + headers, + data: { "custom_collection": {title: "Macbooks", image: {src: "http://example.com/rails_logo.gif", alt: "Rails Logo"}} } + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const custom_collection = new CustomCollection({session: test_session}); + custom_collection.title = "IPods"; + custom_collection.collects = [ + { + product_id: 921728736 + } + ]; + await custom_collection.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/custom_collections.json', + query: '', + headers, + data: { "custom_collection": {title: "IPods", collects: [{product_id: 921728736}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const custom_collection = new CustomCollection({session: test_session}); + custom_collection.title = "Macbooks"; + custom_collection.metafields = [ + { + key: "new", + value: "newvalue", + type: "single_line_text_field", + namespace: "global" + } + ]; + await custom_collection.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/custom_collections.json', + query: '', + headers, + data: { "custom_collection": {title: "Macbooks", metafields: [{key: "new", value: "newvalue", type: "single_line_text_field", namespace: "global"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_10', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CustomCollection.count({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/custom_collections/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_11', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CustomCollection.count({ + session: test_session, + product_id: "632910392", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/custom_collections/count.json', + query: 'product_id=632910392', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_12', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CustomCollection.find({ + session: test_session, + id: 841564295, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/custom_collections/841564295.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_13', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const custom_collection = new CustomCollection({session: test_session}); + custom_collection.id = 841564295; + custom_collection.image = ""; + custom_collection.updated_at = "2022-02-03T17:11:24-05:00"; + custom_collection.title = "IPods"; + custom_collection.handle = "ipods"; + custom_collection.body_html = "

The best selling ipod ever

"; + custom_collection.published_at = "2008-02-01T19:00:00-05:00"; + custom_collection.sort_order = "manual"; + custom_collection.template_suffix = null; + custom_collection.published_scope = "web"; + custom_collection.admin_graphql_api_id = "gid://shopify/Collection/841564295"; + await custom_collection.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/custom_collections/841564295.json', + query: '', + headers, + data: { "custom_collection": {id: 841564295, image: "", updated_at: "2022-02-03T17:11:24-05:00", title: "IPods", handle: "ipods", body_html: "

The best selling ipod ever

", published_at: "2008-02-01T19:00:00-05:00", sort_order: "manual", template_suffix: null, published_scope: "web", admin_graphql_api_id: "gid://shopify/Collection/841564295"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_14', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const custom_collection = new CustomCollection({session: test_session}); + custom_collection.id = 841564295; + custom_collection.metafields = [ + { + key: "new", + value: "newvalue", + type: "single_line_text_field", + namespace: "global" + } + ]; + await custom_collection.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/custom_collections/841564295.json', + query: '', + headers, + data: { "custom_collection": {id: 841564295, metafields: [{key: "new", value: "newvalue", type: "single_line_text_field", namespace: "global"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_15', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const custom_collection = new CustomCollection({session: test_session}); + custom_collection.id = 841564295; + custom_collection.body_html = "

5000 songs in your pocket

"; + await custom_collection.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/custom_collections/841564295.json', + query: '', + headers, + data: { "custom_collection": {id: 841564295, body_html: "

5000 songs in your pocket

"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_16', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const custom_collection = new CustomCollection({session: test_session}); + custom_collection.id = 841564295; + custom_collection.collects = [ + { + product_id: 921728736, + position: 1 + }, + { + id: 455204334, + position: 2 + } + ]; + await custom_collection.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/custom_collections/841564295.json', + query: '', + headers, + data: { "custom_collection": {id: 841564295, collects: [{product_id: 921728736, position: 1}, {id: 455204334, position: 2}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_17', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const custom_collection = new CustomCollection({session: test_session}); + custom_collection.id = 841564295; + custom_collection.published = true; + await custom_collection.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/custom_collections/841564295.json', + query: '', + headers, + data: { "custom_collection": {id: 841564295, published: true} } + }).toMatchMadeHttpRequest(); + }); + + it('test_18', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const custom_collection = new CustomCollection({session: test_session}); + custom_collection.id = 841564295; + custom_collection.published = false; + await custom_collection.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/custom_collections/841564295.json', + query: '', + headers, + data: { "custom_collection": {id: 841564295, published: false} } + }).toMatchMadeHttpRequest(); + }); + + it('test_19', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const custom_collection = new CustomCollection({session: test_session}); + custom_collection.id = 841564295; + custom_collection.image = { + attachment: "R0lGODlhbgCMAPf/APbr48VySrxTO7IgKt2qmKQdJeK8lsFjROG5p/nz7Zg3\nMNmnd7Q1MLNVS9GId71hSJMZIuzTu4UtKbeEeakhKMl8U8WYjfr18YQaIbAf\nKKwhKdKzqpQtLebFortOOejKrOjZ1Mt7aMNpVbAqLLV7bsNqR 3WwMqEWenN\nsZYxL/Ddy/Pm2e7ZxLlUQrIjNPXp3bU5MbhENbEtLtqhj5ZQTfHh0bMxL7Ip\nNsNyUYkZIrZJPcqGdYIUHb5aPKkeJnoUH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AyIlyNYURcONaInrWs9ci4JyJOaFYawDzP8Q ZwAICLckbgd08i290eh9V\nCIadQw3qO5Oa1H1GNRlSjeorO2HLruZ2rLudAm Dm9Gxcx/GXmSIMbnjH5W2\nzy2RbOzM cENBRAWs0N9b3zXWdp8pra1r61tbXdb4N/2Nv8i5gzeIJd5Gjui\nwT AzQ9YVGrYnNO0Agm27GBkvNnNzje 921qf/ b1QEfuMDFPe5lk/lspUG3\nWKbQCofLBBBuwNEs3C3aikcrB2TTeM81HgmOd3zf/PZ3yFPNaqSXfODF0EDK\nE9e6liZmCvJwOLD7AQhU2efSbG6zm7VgiG1ofBc //nGgZ7vbYw67aVux4v/\nfXSSK53by/HVrzIwDZTBBANUrzpMeAAIWASeB4P/AQ9 cHjEJx7xWgDE5nLQ\neMdHXvKbg/zkMZ23H/1oFRjYPOc9v3nQ58Aw0xn9LACvO7HQAOZVf/jl0ii1\nHcXe9bPX3euftaPL5R71tIf97nsy7/o0WlP2r4/JOU7B r5nqva7jz1EdZ97\n4qNe bonfvCfVXvly1762beOOdLBd Q7PCAAOw==\n", + alt: "Rails logo" + }; + await custom_collection.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/custom_collections/841564295.json', + query: '', + headers, + data: { "custom_collection": {id: 841564295, image: {attachment: "R0lGODlhbgCMAPf/APbr48VySrxTO7IgKt2qmKQdJeK8lsFjROG5p/nz7Zg3\nMNmnd7Q1MLNVS9GId71hSJMZIuzTu4UtKbeEeakhKMl8U8WYjfr18YQaIbAf\nKKwhKdKzqpQtLebFortOOejKrOjZ1Mt7aMNpVbAqLLV7bsNqR 3WwMqEWenN\nsZYxL/Ddy/Pm2e7ZxLlUQrIjNPXp3bU5MbhENbEtLtqhj5ZQTfHh0bMxL7Ip\nNsNyUYkZIrZJPcqGdYIUHb5aPKkeJnoUHd2yiJkiLKYiKLRFOsyJXKVDO8up\nosFaS TBnK4kKti5sNaYg/z49aqYl5kqLrljUtORfMOlo/36 H4ZH8yDYq0f\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rLudAm Dm9Gxcx/GXmSIMbnjH5W2\nzy2RbOzM cENBRAWs0N9b3zXWdp8pra1r61tbXdb4N/2Nv8i5gzeIJd5Gjui\nwT AzQ9YVGrYnNO0Agm27GBkvNnNzje 921qf/ b1QEfuMDFPe5lk/lspUG3\nWKbQCofLBBBuwNEs3C3aikcrB2TTeM81HgmOd3zf/PZ3yFPNaqSXfODF0EDK\nE9e6liZmCvJwOLD7AQhU2efSbG6zm7VgiG1ofBc //nGgZ7vbYw67aVux4v/\nfXSSK53by/HVrzIwDZTBBANUrzpMeAAIWASeB4P/AQ9 cHjEJx7xWgDE5nLQ\neMdHXvKbg/zkMZ23H/1oFRjYPOc9v3nQ58Aw0xn9LACvO7HQAOZVf/jl0ii1\nHcXe9bPX3euftaPL5R71tIf97nsy7/o0WlP2r4/JOU7B r5nqva7jz1EdZ97\n4qNe bonfvCfVXvly1762beOOdLBd Q7PCAAOw==\n", alt: "Rails logo"}} } + }).toMatchMadeHttpRequest(); + }); + + it('test_20', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const custom_collection = new CustomCollection({session: test_session}); + custom_collection.id = 841564295; + custom_collection.image = { + alt: "Rails logo" + }; + await custom_collection.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/custom_collections/841564295.json', + query: '', + headers, + data: { "custom_collection": {id: 841564295, image: {alt: "Rails logo"}} } + }).toMatchMadeHttpRequest(); + }); + + it('test_21', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CustomCollection.delete({ + session: test_session, + id: 841564295, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2022-01/custom_collections/841564295.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2022-01/customer.test.ts b/src/rest-resources/__tests__/2022-01/customer.test.ts new file mode 100644 index 000000000..6471856d9 --- /dev/null +++ b/src/rest-resources/__tests__/2022-01/customer.test.ts @@ -0,0 +1,440 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Customer} from '../../2022-01'; + +describe('Customer resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.January22; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Customer.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/customers.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Customer.all({ + session: test_session, + since_id: "207119551", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/customers.json', + query: 'since_id=207119551', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Customer.all({ + session: test_session, + updated_at_min: "2022-02-02 21:51:21", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/customers.json', + query: 'updated_at_min=2022-02-02+21%3A51%3A21', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Customer.all({ + session: test_session, + ids: "207119551,1073339489", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/customers.json', + query: 'ids=207119551%2C1073339489', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const customer = new Customer({session: test_session}); + customer.first_name = "Steve"; + customer.last_name = "Lastnameson"; + customer.email = "steve.lastnameson@example.com"; + customer.phone = " 15142546011"; + customer.verified_email = true; + customer.addresses = [ + { + address1: "123 Oak St", + city: "Ottawa", + province: "ON", + phone: "555-1212", + zip: "123 ABC", + last_name: "Lastnameson", + first_name: "Mother", + country: "CA" + } + ]; + await customer.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/customers.json', + query: '', + headers, + data: { "customer": {first_name: "Steve", last_name: "Lastnameson", email: "steve.lastnameson@example.com", phone: " 15142546011", verified_email: true, addresses: [{address1: "123 Oak St", city: "Ottawa", province: "ON", phone: "555-1212", zip: "123 ABC", last_name: "Lastnameson", first_name: "Mother", country: "CA"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const customer = new Customer({session: test_session}); + customer.first_name = "Steve"; + customer.last_name = "Lastnameson"; + customer.email = "steve.lastnameson@example.com"; + customer.phone = " 15142546011"; + customer.verified_email = true; + customer.addresses = [ + { + address1: "123 Oak St", + city: "Ottawa", + province: "ON", + phone: "555-1212", + zip: "123 ABC", + last_name: "Lastnameson", + first_name: "Mother", + country: "CA" + } + ]; + customer.metafields = [ + { + key: "new", + value: "newvalue", + type: "single_line_text_field", + namespace: "global" + } + ]; + await customer.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/customers.json', + query: '', + headers, + data: { "customer": {first_name: "Steve", last_name: "Lastnameson", email: "steve.lastnameson@example.com", phone: " 15142546011", verified_email: true, addresses: [{address1: "123 Oak St", city: "Ottawa", province: "ON", phone: "555-1212", zip: "123 ABC", last_name: "Lastnameson", first_name: "Mother", country: "CA"}], metafields: [{key: "new", value: "newvalue", type: "single_line_text_field", namespace: "global"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const customer = new Customer({session: test_session}); + customer.first_name = "Steve"; + customer.last_name = "Lastnameson"; + customer.email = "steve.lastnameson@example.com"; + customer.phone = " 15142546011"; + customer.verified_email = true; + customer.addresses = [ + { + address1: "123 Oak St", + city: "Ottawa", + province: "ON", + phone: "555-1212", + zip: "123 ABC", + last_name: "Lastnameson", + first_name: "Mother", + country: "CA" + } + ]; + customer.send_email_invite = true; + await customer.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/customers.json', + query: '', + headers, + data: { "customer": {first_name: "Steve", last_name: "Lastnameson", email: "steve.lastnameson@example.com", phone: " 15142546011", verified_email: true, addresses: [{address1: "123 Oak St", city: "Ottawa", province: "ON", phone: "555-1212", zip: "123 ABC", last_name: "Lastnameson", first_name: "Mother", country: "CA"}], send_email_invite: true} } + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const customer = new Customer({session: test_session}); + customer.first_name = "Steve"; + customer.last_name = "Lastnameson"; + customer.email = "steve.lastnameson@example.com"; + customer.phone = " 15142546011"; + customer.verified_email = true; + customer.addresses = [ + { + address1: "123 Oak St", + city: "Ottawa", + province: "ON", + phone: "555-1212", + zip: "123 ABC", + last_name: "Lastnameson", + first_name: "Mother", + country: "CA" + } + ]; + customer.password = "newpass"; + customer.password_confirmation = "newpass"; + customer.send_email_welcome = false; + await customer.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/customers.json', + query: '', + headers, + data: { "customer": {first_name: "Steve", last_name: "Lastnameson", email: "steve.lastnameson@example.com", phone: " 15142546011", verified_email: true, addresses: [{address1: "123 Oak St", city: "Ottawa", province: "ON", phone: "555-1212", zip: "123 ABC", last_name: "Lastnameson", first_name: "Mother", country: "CA"}], password: "newpass", password_confirmation: "newpass", send_email_welcome: false} } + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Customer.search({ + session: test_session, + query: "Bob country:United States", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/customers/search.json', + query: 'query=Bob+country%3AUnited+States', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_10', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Customer.find({ + session: test_session, + id: 207119551, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/customers/207119551.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_11', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const customer = new Customer({session: test_session}); + customer.id = 207119551; + customer.email = "changed@email.address.com"; + customer.note = "Customer is a great guy"; + await customer.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/customers/207119551.json', + query: '', + headers, + data: { "customer": {id: 207119551, email: "changed@email.address.com", note: "Customer is a great guy"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_12', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const customer = new Customer({session: test_session}); + customer.id = 207119551; + customer.metafields = [ + { + key: "new", + value: "newvalue", + type: "single_line_text_field", + namespace: "global" + } + ]; + await customer.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/customers/207119551.json', + query: '', + headers, + data: { "customer": {id: 207119551, metafields: [{key: "new", value: "newvalue", type: "single_line_text_field", namespace: "global"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_13', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const customer = new Customer({session: test_session}); + customer.id = 207119551; + customer.tags = "New Customer, Repeat Customer"; + await customer.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/customers/207119551.json', + query: '', + headers, + data: { "customer": {id: 207119551, tags: "New Customer, Repeat Customer"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_14', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const customer = new Customer({session: test_session}); + customer.id = 207119551; + customer.accepts_marketing = true; + customer.accepts_marketing_updated_at = "2022-01-31T16:46:47-05:00"; + customer.marketing_opt_in_level = "confirmed_opt_in"; + await customer.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/customers/207119551.json', + query: '', + headers, + data: { "customer": {id: 207119551, accepts_marketing: true, accepts_marketing_updated_at: "2022-01-31T16:46:47-05:00", marketing_opt_in_level: "confirmed_opt_in"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_15', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const customer = new Customer({session: test_session}); + customer.id = 207119551; + await customer.account_activation_url({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/customers/207119551/account_activation_url.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_16', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const customer = new Customer({session: test_session}); + customer.id = 207119551; + await customer.send_invite({ + body: {customer_invite: {}}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/customers/207119551/send_invite.json', + query: '', + headers, + data: {customer_invite: {}} + }).toMatchMadeHttpRequest(); + }); + + it('test_17', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const customer = new Customer({session: test_session}); + customer.id = 207119551; + await customer.send_invite({ + body: {customer_invite: {to: "new_test_email@shopify.com", from: "j.limited@example.com", bcc: ["j.limited@example.com"], subject: "Welcome to my new shop", custom_message: "My awesome new store"}}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/customers/207119551/send_invite.json', + query: '', + headers, + data: {customer_invite: {to: "new_test_email@shopify.com", from: "j.limited@example.com", bcc: ["j.limited@example.com"], subject: "Welcome to my new shop", custom_message: "My awesome new store"}} + }).toMatchMadeHttpRequest(); + }); + + it('test_18', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Customer.count({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/customers/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_19', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Customer.orders({ + session: test_session, + id: 207119551, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/customers/207119551/orders.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2022-01/customer_address.test.ts b/src/rest-resources/__tests__/2022-01/customer_address.test.ts new file mode 100644 index 000000000..63274edf7 --- /dev/null +++ b/src/rest-resources/__tests__/2022-01/customer_address.test.ts @@ -0,0 +1,180 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {CustomerAddress} from '../../2022-01'; + +describe('CustomerAddress resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.January22; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CustomerAddress.all({ + session: test_session, + customer_id: 207119551, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/customers/207119551/addresses.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CustomerAddress.all({ + session: test_session, + customer_id: 207119551, + limit: "1", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/customers/207119551/addresses.json', + query: 'limit=1', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const customer_address = new CustomerAddress({session: test_session}); + customer_address.customer_id = 207119551; + customer_address.address1 = "1 Rue des Carrieres"; + customer_address.address2 = "Suite 1234"; + customer_address.city = "Montreal"; + customer_address.company = "Fancy Co."; + customer_address.first_name = "Samuel"; + customer_address.last_name = "de Champlain"; + customer_address.phone = "819-555-5555"; + customer_address.province = "Quebec"; + customer_address.country = "Canada"; + customer_address.zip = "G1R 4P5"; + customer_address.name = "Samuel de Champlain"; + customer_address.province_code = "QC"; + customer_address.country_code = "CA"; + customer_address.country_name = "Canada"; + await customer_address.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/customers/207119551/addresses.json', + query: '', + headers, + data: { "address": {address1: "1 Rue des Carrieres", address2: "Suite 1234", city: "Montreal", company: "Fancy Co.", first_name: "Samuel", last_name: "de Champlain", phone: "819-555-5555", province: "Quebec", country: "Canada", zip: "G1R 4P5", name: "Samuel de Champlain", province_code: "QC", country_code: "CA", country_name: "Canada"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CustomerAddress.find({ + session: test_session, + customer_id: 207119551, + id: 207119551, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/customers/207119551/addresses/207119551.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const customer_address = new CustomerAddress({session: test_session}); + customer_address.customer_id = 207119551; + customer_address.id = 207119551; + customer_address.zip = "90210"; + await customer_address.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/customers/207119551/addresses/207119551.json', + query: '', + headers, + data: { "address": {id: 207119551, zip: "90210"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CustomerAddress.delete({ + session: test_session, + customer_id: 207119551, + id: 1053317335, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2022-01/customers/207119551/addresses/1053317335.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const customer_address = new CustomerAddress({session: test_session}); + customer_address.customer_id = 207119551; + await customer_address.set({ + address_ids: ["1053317336"], + operation: "destroy", + }); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/customers/207119551/addresses/set.json', + query: 'address_ids%5B%5D=1053317336&operation=destroy', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const customer_address = new CustomerAddress({session: test_session}); + customer_address.customer_id = 207119551; + customer_address.id = 1053317337; + await customer_address.default({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/customers/207119551/addresses/1053317337/default.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2022-01/customer_saved_search.test.ts b/src/rest-resources/__tests__/2022-01/customer_saved_search.test.ts new file mode 100644 index 000000000..2887f8d9a --- /dev/null +++ b/src/rest-resources/__tests__/2022-01/customer_saved_search.test.ts @@ -0,0 +1,195 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {CustomerSavedSearch} from '../../2022-01'; + +describe('CustomerSavedSearch resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.January22; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CustomerSavedSearch.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/customer_saved_searches.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CustomerSavedSearch.all({ + session: test_session, + since_id: "20610973", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/customer_saved_searches.json', + query: 'since_id=20610973', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const customer_saved_search = new CustomerSavedSearch({session: test_session}); + customer_saved_search.name = "Spent more than $50"; + customer_saved_search.query = "total_spent:>50"; + await customer_saved_search.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/customer_saved_searches.json', + query: '', + headers, + data: { "customer_saved_search": {name: "Spent more than $50", query: "total_spent:>50"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const customer_saved_search = new CustomerSavedSearch({session: test_session}); + customer_saved_search.name = "Spent more than $50 and after 2013"; + customer_saved_search.query = "total_spent:>50 order_date:>=2013-01-01"; + await customer_saved_search.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/customer_saved_searches.json', + query: '', + headers, + data: { "customer_saved_search": {name: "Spent more than $50 and after 2013", query: "total_spent:>50 order_date:>=2013-01-01"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CustomerSavedSearch.count({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/customer_saved_searches/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CustomerSavedSearch.count({ + session: test_session, + since_id: "20610973", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/customer_saved_searches/count.json', + query: 'since_id=20610973', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CustomerSavedSearch.find({ + session: test_session, + id: 789629109, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/customer_saved_searches/789629109.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const customer_saved_search = new CustomerSavedSearch({session: test_session}); + customer_saved_search.id = 789629109; + customer_saved_search.name = "This Name Has Been Changed"; + await customer_saved_search.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/customer_saved_searches/789629109.json', + query: '', + headers, + data: { "customer_saved_search": {id: 789629109, name: "This Name Has Been Changed"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CustomerSavedSearch.delete({ + session: test_session, + id: 789629109, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2022-01/customer_saved_searches/789629109.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_10', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await CustomerSavedSearch.customers({ + session: test_session, + id: 789629109, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/customer_saved_searches/789629109/customers.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2022-01/deprecated_api_call.test.ts b/src/rest-resources/__tests__/2022-01/deprecated_api_call.test.ts new file mode 100644 index 000000000..adc6dc1f8 --- /dev/null +++ b/src/rest-resources/__tests__/2022-01/deprecated_api_call.test.ts @@ -0,0 +1,34 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {DeprecatedApiCall} from '../../2022-01'; + +describe('DeprecatedApiCall resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.January22; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await DeprecatedApiCall.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/deprecated_api_calls.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2022-01/discount_code.test.ts b/src/rest-resources/__tests__/2022-01/discount_code.test.ts new file mode 100644 index 000000000..0b3eec65f --- /dev/null +++ b/src/rest-resources/__tests__/2022-01/discount_code.test.ts @@ -0,0 +1,184 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {DiscountCode} from '../../2022-01'; + +describe('DiscountCode resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.January22; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const discount_code = new DiscountCode({session: test_session}); + discount_code.price_rule_id = 507328175; + discount_code.code = "SUMMERSALE10OFF"; + await discount_code.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/price_rules/507328175/discount_codes.json', + query: '', + headers, + data: { "discount_code": {code: "SUMMERSALE10OFF"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await DiscountCode.all({ + session: test_session, + price_rule_id: 507328175, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/price_rules/507328175/discount_codes.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const discount_code = new DiscountCode({session: test_session}); + discount_code.price_rule_id = 507328175; + discount_code.id = 507328175; + discount_code.code = "WINTERSALE20OFF"; + await discount_code.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/price_rules/507328175/discount_codes/507328175.json', + query: '', + headers, + data: { "discount_code": {id: 507328175, code: "WINTERSALE20OFF"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await DiscountCode.find({ + session: test_session, + price_rule_id: 507328175, + id: 507328175, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/price_rules/507328175/discount_codes/507328175.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await DiscountCode.delete({ + session: test_session, + price_rule_id: 507328175, + id: 507328175, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2022-01/price_rules/507328175/discount_codes/507328175.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await DiscountCode.count({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/discount_codes/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const discount_code = new DiscountCode({session: test_session}); + discount_code.price_rule_id = 507328175; + await discount_code.batch({ + body: {discount_codes: [{code: "SUMMER1"}, {code: "SUMMER2"}, {code: "SUMMER3"}]}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/price_rules/507328175/batch.json', + query: '', + headers, + data: {discount_codes: [{code: "SUMMER1"}, {code: "SUMMER2"}, {code: "SUMMER3"}]} + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await DiscountCode.get_all({ + session: test_session, + price_rule_id: 507328175, + batch_id: 173232803, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/price_rules/507328175/batch/173232803.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await DiscountCode.all({ + session: test_session, + price_rule_id: 507328175, + batch_id: 173232803, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/price_rules/507328175/batch/173232803/discount_codes.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2022-01/dispute.test.ts b/src/rest-resources/__tests__/2022-01/dispute.test.ts new file mode 100644 index 000000000..f923fbc6c --- /dev/null +++ b/src/rest-resources/__tests__/2022-01/dispute.test.ts @@ -0,0 +1,88 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Dispute} from '../../2022-01'; + +describe('Dispute resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.January22; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Dispute.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/shopify_payments/disputes.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Dispute.all({ + session: test_session, + status: "won", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/shopify_payments/disputes.json', + query: 'status=won', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Dispute.all({ + session: test_session, + initiated_at: "2013-05-03", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/shopify_payments/disputes.json', + query: 'initiated_at=2013-05-03', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Dispute.find({ + session: test_session, + id: 598735659, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/shopify_payments/disputes/598735659.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2022-01/draft_order.test.ts b/src/rest-resources/__tests__/2022-01/draft_order.test.ts new file mode 100644 index 000000000..228470aea --- /dev/null +++ b/src/rest-resources/__tests__/2022-01/draft_order.test.ts @@ -0,0 +1,346 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {DraftOrder} from '../../2022-01'; + +describe('DraftOrder resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.January22; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const draft_order = new DraftOrder({session: test_session}); + draft_order.line_items = [ + { + variant_id: 447654529, + quantity: 1 + } + ]; + await draft_order.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/draft_orders.json', + query: '', + headers, + data: { "draft_order": {line_items: [{variant_id: 447654529, quantity: 1}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const draft_order = new DraftOrder({session: test_session}); + draft_order.line_items = [ + { + title: "Custom Tee", + price: "20.00", + quantity: 2 + } + ]; + draft_order.applied_discount = { + description: "Custom discount", + value_type: "fixed_amount", + value: "10.0", + amount: "10.00", + title: "Custom" + }; + draft_order.customer = { + id: 207119551 + }; + draft_order.use_customer_default_address = true; + await draft_order.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/draft_orders.json', + query: '', + headers, + data: { "draft_order": {line_items: [{title: "Custom Tee", price: "20.00", quantity: 2}], applied_discount: {description: "Custom discount", value_type: "fixed_amount", value: "10.0", amount: "10.00", title: "Custom"}, customer: {id: 207119551}, use_customer_default_address: true} } + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const draft_order = new DraftOrder({session: test_session}); + draft_order.line_items = [ + { + title: "Custom Tee", + price: "20.00", + quantity: 1, + applied_discount: { + description: "Custom discount", + value_type: "fixed_amount", + value: "10.0", + amount: "10.0", + title: "Custom" + } + } + ]; + await draft_order.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/draft_orders.json', + query: '', + headers, + data: { "draft_order": {line_items: [{title: "Custom Tee", price: "20.00", quantity: 1, applied_discount: {description: "Custom discount", value_type: "fixed_amount", value: "10.0", amount: "10.0", title: "Custom"}}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const draft_order = new DraftOrder({session: test_session}); + draft_order.line_items = [ + { + title: "Custom Tee", + price: "20.00", + quantity: 1, + applied_discount: { + description: "Custom discount", + value_type: "percentage", + value: "10.0", + amount: "2.0", + title: "Custom" + } + } + ]; + await draft_order.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/draft_orders.json', + query: '', + headers, + data: { "draft_order": {line_items: [{title: "Custom Tee", price: "20.00", quantity: 1, applied_discount: {description: "Custom discount", value_type: "percentage", value: "10.0", amount: "2.0", title: "Custom"}}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const draft_order = new DraftOrder({session: test_session}); + draft_order.line_items = [ + { + title: "Custom Tee", + price: "20.00", + quantity: 2 + } + ]; + draft_order.customer = { + id: 207119551 + }; + draft_order.use_customer_default_address = true; + await draft_order.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/draft_orders.json', + query: '', + headers, + data: { "draft_order": {line_items: [{title: "Custom Tee", price: "20.00", quantity: 2}], customer: {id: 207119551}, use_customer_default_address: true} } + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await DraftOrder.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/draft_orders.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const draft_order = new DraftOrder({session: test_session}); + draft_order.id = 994118539; + draft_order.note = "Customer contacted us about a custom engraving on this iPod"; + await draft_order.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/draft_orders/994118539.json', + query: '', + headers, + data: { "draft_order": {id: 994118539, note: "Customer contacted us about a custom engraving on this iPod"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const draft_order = new DraftOrder({session: test_session}); + draft_order.id = 994118539; + draft_order.applied_discount = { + description: "Custom discount", + value_type: "percentage", + value: "10.0", + amount: "19.90", + title: "Custom" + }; + await draft_order.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/draft_orders/994118539.json', + query: '', + headers, + data: { "draft_order": {id: 994118539, applied_discount: {description: "Custom discount", value_type: "percentage", value: "10.0", amount: "19.90", title: "Custom"}} } + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await DraftOrder.find({ + session: test_session, + id: 994118539, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/draft_orders/994118539.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_10', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await DraftOrder.delete({ + session: test_session, + id: 994118539, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2022-01/draft_orders/994118539.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_11', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await DraftOrder.count({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/draft_orders/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_12', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const draft_order = new DraftOrder({session: test_session}); + draft_order.id = 994118539; + await draft_order.send_invoice({ + body: {draft_order_invoice: {to: "first@example.com", from: "j.smith@example.com", bcc: ["j.smith@example.com"], subject: "Apple Computer Invoice", custom_message: "Thank you for ordering!"}}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/draft_orders/994118539/send_invoice.json', + query: '', + headers, + data: {draft_order_invoice: {to: "first@example.com", from: "j.smith@example.com", bcc: ["j.smith@example.com"], subject: "Apple Computer Invoice", custom_message: "Thank you for ordering!"}} + }).toMatchMadeHttpRequest(); + }); + + it('test_13', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const draft_order = new DraftOrder({session: test_session}); + draft_order.id = 994118539; + await draft_order.send_invoice({ + body: {draft_order_invoice: {}}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/draft_orders/994118539/send_invoice.json', + query: '', + headers, + data: {draft_order_invoice: {}} + }).toMatchMadeHttpRequest(); + }); + + it('test_14', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const draft_order = new DraftOrder({session: test_session}); + draft_order.id = 994118539; + await draft_order.complete({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/draft_orders/994118539/complete.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_15', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const draft_order = new DraftOrder({session: test_session}); + draft_order.id = 994118539; + await draft_order.complete({ + payment_pending: "true", + }); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/draft_orders/994118539/complete.json', + query: 'payment_pending=true', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2022-01/event.test.ts b/src/rest-resources/__tests__/2022-01/event.test.ts new file mode 100644 index 000000000..7ba3ecc52 --- /dev/null +++ b/src/rest-resources/__tests__/2022-01/event.test.ts @@ -0,0 +1,216 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Event} from '../../2022-01'; + +describe('Event resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.January22; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Event.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/events.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Event.all({ + session: test_session, + created_at_min: "2008-01-10 12:30:00+00:00", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/events.json', + query: 'created_at_min=2008-01-10+12%3A30%3A00%2B00%3A00', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Event.all({ + session: test_session, + order_id: 450789469, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/orders/450789469/events.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Event.all({ + session: test_session, + order_id: 450789469, + limit: "1", + since_id: "164748010", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/orders/450789469/events.json', + query: 'limit=1&since_id=164748010', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Event.all({ + session: test_session, + product_id: 921728736, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/products/921728736/events.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Event.all({ + session: test_session, + since_id: "164748010", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/events.json', + query: 'since_id=164748010', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Event.all({ + session: test_session, + filter: "Product,Order", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/events.json', + query: 'filter=Product%2COrder', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Event.all({ + session: test_session, + filter: "Product", + verb: "destroy", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/events.json', + query: 'filter=Product&verb=destroy', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Event.find({ + session: test_session, + id: 677313116, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/events/677313116.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_10', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Event.count({ + session: test_session, + created_at_min: "2008-01-10T13:00:00+00:00", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/events/count.json', + query: 'created_at_min=2008-01-10T13%3A00%3A00%2B00%3A00', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_11', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Event.count({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/events/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2022-01/fulfillment.test.ts b/src/rest-resources/__tests__/2022-01/fulfillment.test.ts new file mode 100644 index 000000000..760117af3 --- /dev/null +++ b/src/rest-resources/__tests__/2022-01/fulfillment.test.ts @@ -0,0 +1,581 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Fulfillment} from '../../2022-01'; + +describe('Fulfillment resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.January22; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Fulfillment.all({ + session: test_session, + order_id: 450789469, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/orders/450789469/fulfillments.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Fulfillment.all({ + session: test_session, + order_id: 450789469, + since_id: "255858046", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/orders/450789469/fulfillments.json', + query: 'since_id=255858046', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment = new Fulfillment({session: test_session}); + fulfillment.order_id = 450789469; + fulfillment.location_id = 487838322; + fulfillment.tracking_number = "123456789"; + fulfillment.tracking_urls = [ + "https://shipping.xyz/track.php?num=123456789", + "https://anothershipper.corp/track.php?code=abc" + ]; + fulfillment.notify_customer = true; + await fulfillment.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/orders/450789469/fulfillments.json', + query: '', + headers, + data: { "fulfillment": {location_id: 487838322, tracking_number: "123456789", tracking_urls: ["https://shipping.xyz/track.php?num=123456789", "https://anothershipper.corp/track.php?code=abc"], notify_customer: true} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment = new Fulfillment({session: test_session}); + fulfillment.order_id = 450789469; + fulfillment.location_id = 655441491; + fulfillment.tracking_number = null; + fulfillment.line_items = [ + { + id: 518995019 + } + ]; + await fulfillment.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/orders/450789469/fulfillments.json', + query: '', + headers, + data: { "fulfillment": {location_id: 655441491, tracking_number: null, line_items: [{id: 518995019}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment = new Fulfillment({session: test_session}); + fulfillment.order_id = 450789469; + fulfillment.location_id = 655441491; + fulfillment.tracking_numbers = [ + "88b451840563b72cc15d3fcb6179f302", + "aee587edbd98ad725d27974c808ec7d6", + "94e71192ecf091ea5c25b69c385c2b1b" + ]; + fulfillment.line_items = [ + { + id: 518995019 + } + ]; + await fulfillment.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/orders/450789469/fulfillments.json', + query: '', + headers, + data: { "fulfillment": {location_id: 655441491, tracking_numbers: ["88b451840563b72cc15d3fcb6179f302", "aee587edbd98ad725d27974c808ec7d6", "94e71192ecf091ea5c25b69c385c2b1b"], line_items: [{id: 518995019}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment = new Fulfillment({session: test_session}); + fulfillment.order_id = 450789469; + fulfillment.location_id = 655441491; + fulfillment.tracking_url = "http://www.packagetrackr.com/track/somecarrier/1234567"; + fulfillment.tracking_company = "Jack Black's Pack, Stack and Track"; + fulfillment.line_items = [ + { + id: 518995019 + } + ]; + await fulfillment.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/orders/450789469/fulfillments.json', + query: '', + headers, + data: { "fulfillment": {location_id: 655441491, tracking_url: "http://www.packagetrackr.com/track/somecarrier/1234567", tracking_company: "Jack Black's Pack, Stack and Track", line_items: [{id: 518995019}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment = new Fulfillment({session: test_session}); + fulfillment.order_id = 450789469; + fulfillment.location_id = 655441491; + fulfillment.tracking_number = "123456789"; + fulfillment.tracking_company = "4PX"; + fulfillment.line_items = [ + { + id: 518995019 + } + ]; + await fulfillment.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/orders/450789469/fulfillments.json', + query: '', + headers, + data: { "fulfillment": {location_id: 655441491, tracking_number: "123456789", tracking_company: "4PX", line_items: [{id: 518995019}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment = new Fulfillment({session: test_session}); + fulfillment.order_id = 450789469; + fulfillment.location_id = 655441491; + fulfillment.tracking_number = "123456789010"; + fulfillment.tracking_company = "fed ex"; + fulfillment.line_items = [ + { + id: 518995019 + } + ]; + await fulfillment.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/orders/450789469/fulfillments.json', + query: '', + headers, + data: { "fulfillment": {location_id: 655441491, tracking_number: "123456789010", tracking_company: "fed ex", line_items: [{id: 518995019}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment = new Fulfillment({session: test_session}); + fulfillment.order_id = 450789469; + fulfillment.location_id = 655441491; + fulfillment.tracking_number = "123456789010"; + fulfillment.tracking_company = "fed ex"; + fulfillment.tracking_url = "https://www.new-fedex-tracking.com/?number=123456789010"; + fulfillment.line_items = [ + { + id: 518995019 + } + ]; + await fulfillment.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/orders/450789469/fulfillments.json', + query: '', + headers, + data: { "fulfillment": {location_id: 655441491, tracking_number: "123456789010", tracking_company: "fed ex", tracking_url: "https://www.new-fedex-tracking.com/?number=123456789010", line_items: [{id: 518995019}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_10', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment = new Fulfillment({session: test_session}); + fulfillment.order_id = 450789469; + fulfillment.location_id = 655441491; + fulfillment.tracking_number = "RR123456789CN"; + fulfillment.tracking_company = "Chinese Post"; + fulfillment.line_items = [ + { + id: 518995019 + } + ]; + await fulfillment.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/orders/450789469/fulfillments.json', + query: '', + headers, + data: { "fulfillment": {location_id: 655441491, tracking_number: "RR123456789CN", tracking_company: "Chinese Post", line_items: [{id: 518995019}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_11', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment = new Fulfillment({session: test_session}); + fulfillment.order_id = 450789469; + fulfillment.location_id = 655441491; + fulfillment.tracking_number = "1234567"; + fulfillment.tracking_company = "Custom Tracking Company"; + fulfillment.line_items = [ + { + id: 518995019 + } + ]; + await fulfillment.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/orders/450789469/fulfillments.json', + query: '', + headers, + data: { "fulfillment": {location_id: 655441491, tracking_number: "1234567", tracking_company: "Custom Tracking Company", line_items: [{id: 518995019}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_12', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment = new Fulfillment({session: test_session}); + fulfillment.order_id = 450789469; + fulfillment.location_id = 655441491; + fulfillment.tracking_number = "CJ274101086US"; + fulfillment.tracking_url = "http://www.custom-tracking.com/?tracking_number=CJ274101086US"; + fulfillment.line_items = [ + { + id: 518995019 + } + ]; + await fulfillment.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/orders/450789469/fulfillments.json', + query: '', + headers, + data: { "fulfillment": {location_id: 655441491, tracking_number: "CJ274101086US", tracking_url: "http://www.custom-tracking.com/?tracking_number=CJ274101086US", line_items: [{id: 518995019}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_13', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment = new Fulfillment({session: test_session}); + fulfillment.order_id = 450789469; + fulfillment.location_id = 655441491; + fulfillment.tracking_number = null; + fulfillment.line_items = [ + { + id: 518995019 + } + ]; + await fulfillment.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/orders/450789469/fulfillments.json', + query: '', + headers, + data: { "fulfillment": {location_id: 655441491, tracking_number: null, line_items: [{id: 518995019}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_14', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment = new Fulfillment({session: test_session}); + fulfillment.order_id = 450789469; + fulfillment.location_id = 655441491; + fulfillment.tracking_number = null; + fulfillment.line_items = [ + { + id: 518995019, + quantity: 1 + } + ]; + await fulfillment.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/orders/450789469/fulfillments.json', + query: '', + headers, + data: { "fulfillment": {location_id: 655441491, tracking_number: null, line_items: [{id: 518995019, quantity: 1}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_15', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Fulfillment.all({ + session: test_session, + fulfillment_order_id: 1046000859, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/fulfillment_orders/1046000859/fulfillments.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_16', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Fulfillment.count({ + session: test_session, + order_id: 450789469, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/orders/450789469/fulfillments/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_17', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Fulfillment.find({ + session: test_session, + order_id: 450789469, + id: 255858046, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/orders/450789469/fulfillments/255858046.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_18', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment = new Fulfillment({session: test_session}); + fulfillment.order_id = 450789469; + fulfillment.id = 255858046; + fulfillment.tracking_number = "987654321"; + await fulfillment.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/orders/450789469/fulfillments/255858046.json', + query: '', + headers, + data: { "fulfillment": {tracking_number: "987654321", id: 255858046} } + }).toMatchMadeHttpRequest(); + }); + + it('test_19', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment = new Fulfillment({session: test_session}); + fulfillment.message = "The package was shipped this morning."; + fulfillment.notify_customer = false; + fulfillment.tracking_info = { + number: 1562678, + url: "https://www.my-shipping-company.com", + company: "my-shipping-company" + }; + fulfillment.line_items_by_fulfillment_order = [ + { + fulfillment_order_id: 1046000873, + fulfillment_order_line_items: [ + { + id: 1058737644, + quantity: 1 + } + ] + } + ]; + await fulfillment.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/fulfillments.json', + query: '', + headers, + data: { "fulfillment": {message: "The package was shipped this morning.", notify_customer: false, tracking_info: {number: 1562678, url: "https://www.my-shipping-company.com", company: "my-shipping-company"}, line_items_by_fulfillment_order: [{fulfillment_order_id: 1046000873, fulfillment_order_line_items: [{id: 1058737644, quantity: 1}]}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_20', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment = new Fulfillment({session: test_session}); + fulfillment.message = "The package was shipped this morning."; + fulfillment.notify_customer = false; + fulfillment.tracking_info = { + number: 1562678, + url: "https://www.my-shipping-company.com", + company: "my-shipping-company" + }; + fulfillment.line_items_by_fulfillment_order = [ + { + fulfillment_order_id: 1046000874 + } + ]; + await fulfillment.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/fulfillments.json', + query: '', + headers, + data: { "fulfillment": {message: "The package was shipped this morning.", notify_customer: false, tracking_info: {number: 1562678, url: "https://www.my-shipping-company.com", company: "my-shipping-company"}, line_items_by_fulfillment_order: [{fulfillment_order_id: 1046000874}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_21', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment = new Fulfillment({session: test_session}); + fulfillment.id = 1069019908; + await fulfillment.update_tracking({ + body: {fulfillment: {notify_customer: true, tracking_info: {number: "1111", url: "http://www.my-url.com", company: "my-company"}}}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/fulfillments/1069019908/update_tracking.json', + query: '', + headers, + data: { "fulfillment": {notify_customer: true, tracking_info: {number: "1111", url: "http://www.my-url.com", company: "my-company"}} } + }).toMatchMadeHttpRequest(); + }); + + it('test_22', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment = new Fulfillment({session: test_session}); + fulfillment.order_id = 450789469; + fulfillment.id = 255858046; + await fulfillment.complete({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/orders/450789469/fulfillments/255858046/complete.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_23', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment = new Fulfillment({session: test_session}); + fulfillment.order_id = 450789469; + fulfillment.id = 255858046; + await fulfillment.open({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/orders/450789469/fulfillments/255858046/open.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_24', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment = new Fulfillment({session: test_session}); + fulfillment.order_id = 450789469; + fulfillment.id = 255858046; + await fulfillment.cancel({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/orders/450789469/fulfillments/255858046/cancel.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_25', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment = new Fulfillment({session: test_session}); + fulfillment.id = 1069019909; + await fulfillment.cancel({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/fulfillments/1069019909/cancel.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2022-01/fulfillment_event.test.ts b/src/rest-resources/__tests__/2022-01/fulfillment_event.test.ts new file mode 100644 index 000000000..cf24bc21e --- /dev/null +++ b/src/rest-resources/__tests__/2022-01/fulfillment_event.test.ts @@ -0,0 +1,95 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {FulfillmentEvent} from '../../2022-01'; + +describe('FulfillmentEvent resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.January22; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await FulfillmentEvent.all({ + session: test_session, + order_id: 450789469, + fulfillment_id: 255858046, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/orders/450789469/fulfillments/255858046/events.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment_event = new FulfillmentEvent({session: test_session}); + fulfillment_event.order_id = 450789469; + fulfillment_event.fulfillment_id = 255858046; + fulfillment_event.status = "in_transit"; + await fulfillment_event.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/orders/450789469/fulfillments/255858046/events.json', + query: '', + headers, + data: { "event": {status: "in_transit"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await FulfillmentEvent.find({ + session: test_session, + order_id: 450789469, + fulfillment_id: 255858046, + id: 944956395, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/orders/450789469/fulfillments/255858046/events/944956395.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await FulfillmentEvent.delete({ + session: test_session, + order_id: 450789469, + fulfillment_id: 255858046, + id: 944956397, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2022-01/orders/450789469/fulfillments/255858046/events/944956397.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2022-01/fulfillment_order.test.ts b/src/rest-resources/__tests__/2022-01/fulfillment_order.test.ts new file mode 100644 index 000000000..7613a27b4 --- /dev/null +++ b/src/rest-resources/__tests__/2022-01/fulfillment_order.test.ts @@ -0,0 +1,180 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {FulfillmentOrder} from '../../2022-01'; + +describe('FulfillmentOrder resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.January22; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await FulfillmentOrder.all({ + session: test_session, + order_id: 450789469, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/orders/450789469/fulfillment_orders.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await FulfillmentOrder.find({ + session: test_session, + id: 1046000847, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/fulfillment_orders/1046000847.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment_order = new FulfillmentOrder({session: test_session}); + fulfillment_order.id = 1046000848; + await fulfillment_order.cancel({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/fulfillment_orders/1046000848/cancel.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment_order = new FulfillmentOrder({session: test_session}); + fulfillment_order.id = 1046000851; + await fulfillment_order.close({ + body: {fulfillment_order: {message: "Not enough inventory to complete this work."}}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/fulfillment_orders/1046000851/close.json', + query: '', + headers, + data: { "fulfillment_order": {message: "Not enough inventory to complete this work."} } + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment_order = new FulfillmentOrder({session: test_session}); + fulfillment_order.id = 1046000852; + await fulfillment_order.move({ + body: {fulfillment_order: {new_location_id: 655441491}}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/fulfillment_orders/1046000852/move.json', + query: '', + headers, + data: { "fulfillment_order": {new_location_id: 655441491} } + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment_order = new FulfillmentOrder({session: test_session}); + fulfillment_order.id = 1046000854; + await fulfillment_order.open({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/fulfillment_orders/1046000854/open.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment_order = new FulfillmentOrder({session: test_session}); + fulfillment_order.id = 1046000855; + await fulfillment_order.reschedule({ + body: {fulfillment_order: {new_fulfill_at: "2023-03-03"}}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/fulfillment_orders/1046000855/reschedule.json', + query: '', + headers, + data: { "fulfillment_order": {new_fulfill_at: "2023-03-03"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment_order = new FulfillmentOrder({session: test_session}); + fulfillment_order.id = 1046000856; + await fulfillment_order.hold({ + body: {fulfillment_hold: {reason: "inventory_out_of_stock", reason_notes: "Not enough inventory to complete this work."}}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/fulfillment_orders/1046000856/hold.json', + query: '', + headers, + data: {fulfillment_hold: {reason: "inventory_out_of_stock", reason_notes: "Not enough inventory to complete this work."}} + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment_order = new FulfillmentOrder({session: test_session}); + fulfillment_order.id = 1046000858; + await fulfillment_order.release_hold({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/fulfillment_orders/1046000858/release_hold.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2022-01/fulfillment_request.test.ts b/src/rest-resources/__tests__/2022-01/fulfillment_request.test.ts new file mode 100644 index 000000000..af8bf89b6 --- /dev/null +++ b/src/rest-resources/__tests__/2022-01/fulfillment_request.test.ts @@ -0,0 +1,101 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {FulfillmentRequest} from '../../2022-01'; + +describe('FulfillmentRequest resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.January22; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment_request = new FulfillmentRequest({session: test_session}); + fulfillment_request.fulfillment_order_id = 1046000840; + fulfillment_request.message = "Fulfill this ASAP please."; + fulfillment_request.fulfillment_order_line_items = [ + { + id: 1058737578, + quantity: 1 + }, + { + id: 1058737579, + quantity: 1 + } + ]; + await fulfillment_request.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/fulfillment_orders/1046000840/fulfillment_request.json', + query: '', + headers, + data: { "fulfillment_request": {message: "Fulfill this ASAP please.", fulfillment_order_line_items: [{id: 1058737578, quantity: 1}, {id: 1058737579, quantity: 1}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment_request = new FulfillmentRequest({session: test_session}); + fulfillment_request.fulfillment_order_id = 1046000843; + fulfillment_request.message = "Fulfill this ASAP please."; + await fulfillment_request.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/fulfillment_orders/1046000843/fulfillment_request.json', + query: '', + headers, + data: { "fulfillment_request": {message: "Fulfill this ASAP please."} } + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment_request = new FulfillmentRequest({session: test_session}); + fulfillment_request.fulfillment_order_id = 1046000844; + await fulfillment_request.accept({ + body: {fulfillment_request: {message: "We will start processing your fulfillment on the next business day."}}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/fulfillment_orders/1046000844/fulfillment_request/accept.json', + query: '', + headers, + data: { "fulfillment_request": {message: "We will start processing your fulfillment on the next business day."} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment_request = new FulfillmentRequest({session: test_session}); + fulfillment_request.fulfillment_order_id = 1046000845; + await fulfillment_request.reject({ + body: {fulfillment_request: {message: "Not enough inventory on hand to complete the work."}}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/fulfillment_orders/1046000845/fulfillment_request/reject.json', + query: '', + headers, + data: { "fulfillment_request": {message: "Not enough inventory on hand to complete the work."} } + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2022-01/fulfillment_service.test.ts b/src/rest-resources/__tests__/2022-01/fulfillment_service.test.ts new file mode 100644 index 000000000..618ef35c2 --- /dev/null +++ b/src/rest-resources/__tests__/2022-01/fulfillment_service.test.ts @@ -0,0 +1,128 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {FulfillmentService} from '../../2022-01'; + +describe('FulfillmentService resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.January22; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await FulfillmentService.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/fulfillment_services.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await FulfillmentService.all({ + session: test_session, + scope: "all", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/fulfillment_services.json', + query: 'scope=all', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment_service = new FulfillmentService({session: test_session}); + fulfillment_service.name = "Jupiter Fulfillment"; + fulfillment_service.callback_url = "http://google.com"; + fulfillment_service.inventory_management = true; + fulfillment_service.tracking_support = true; + fulfillment_service.requires_shipping_method = true; + fulfillment_service.format = "json"; + await fulfillment_service.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/fulfillment_services.json', + query: '', + headers, + data: { "fulfillment_service": {name: "Jupiter Fulfillment", callback_url: "http://google.com", inventory_management: true, tracking_support: true, requires_shipping_method: true, format: "json"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await FulfillmentService.find({ + session: test_session, + id: 755357713, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/fulfillment_services/755357713.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const fulfillment_service = new FulfillmentService({session: test_session}); + fulfillment_service.id = 755357713; + fulfillment_service.name = "New Fulfillment Service Name"; + await fulfillment_service.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/fulfillment_services/755357713.json', + query: '', + headers, + data: { "fulfillment_service": {id: 755357713, name: "New Fulfillment Service Name"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await FulfillmentService.delete({ + session: test_session, + id: 755357713, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2022-01/fulfillment_services/755357713.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2022-01/gift_card.test.ts b/src/rest-resources/__tests__/2022-01/gift_card.test.ts new file mode 100644 index 000000000..55746a00a --- /dev/null +++ b/src/rest-resources/__tests__/2022-01/gift_card.test.ts @@ -0,0 +1,215 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {GiftCard} from '../../2022-01'; + +describe('GiftCard resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.January22; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await GiftCard.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/gift_cards.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await GiftCard.all({ + session: test_session, + status: "enabled", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/gift_cards.json', + query: 'status=enabled', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const gift_card = new GiftCard({session: test_session}); + gift_card.note = "This is a note"; + gift_card.initial_value = 100.0; + gift_card.code = "ABCD EFGH IJKL MNOP"; + gift_card.template_suffix = "gift_cards.birthday.liquid"; + await gift_card.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/gift_cards.json', + query: '', + headers, + data: { "gift_card": {note: "This is a note", initial_value: 100.0, code: "ABCD EFGH IJKL MNOP", template_suffix: "gift_cards.birthday.liquid"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const gift_card = new GiftCard({session: test_session}); + gift_card.initial_value = 25.0; + await gift_card.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/gift_cards.json', + query: '', + headers, + data: { "gift_card": {initial_value: 25.0} } + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await GiftCard.find({ + session: test_session, + id: 1035197676, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/gift_cards/1035197676.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const gift_card = new GiftCard({session: test_session}); + gift_card.id = 1035197676; + gift_card.note = "Updating with a new note"; + await gift_card.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/gift_cards/1035197676.json', + query: '', + headers, + data: { "gift_card": {id: 1035197676, note: "Updating with a new note"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const gift_card = new GiftCard({session: test_session}); + gift_card.id = 1035197676; + gift_card.expires_on = "2020-01-01"; + await gift_card.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/gift_cards/1035197676.json', + query: '', + headers, + data: { "gift_card": {id: 1035197676, expires_on: "2020-01-01"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await GiftCard.count({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/gift_cards/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await GiftCard.count({ + session: test_session, + status: "enabled", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/gift_cards/count.json', + query: 'status=enabled', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_10', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const gift_card = new GiftCard({session: test_session}); + gift_card.id = 1035197676; + await gift_card.disable({ + body: {gift_card: {id: 1035197676}}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/gift_cards/1035197676/disable.json', + query: '', + headers, + data: { "gift_card": {id: 1035197676} } + }).toMatchMadeHttpRequest(); + }); + + it('test_11', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await GiftCard.search({ + session: test_session, + query: "last_characters:mnop", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/gift_cards/search.json', + query: 'query=last_characters%3Amnop', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2022-01/gift_card_adjustment.test.ts b/src/rest-resources/__tests__/2022-01/gift_card_adjustment.test.ts new file mode 100644 index 000000000..451396cd9 --- /dev/null +++ b/src/rest-resources/__tests__/2022-01/gift_card_adjustment.test.ts @@ -0,0 +1,131 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {GiftCardAdjustment} from '../../2022-01'; + +describe('GiftCardAdjustment resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.January22; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await GiftCardAdjustment.all({ + session: test_session, + gift_card_id: 1035197676, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/gift_cards/1035197676/adjustments.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const gift_card_adjustment = new GiftCardAdjustment({session: test_session}); + gift_card_adjustment.gift_card_id = 1035197676; + gift_card_adjustment.amount = 10.0; + gift_card_adjustment.note = "Customer refilled gift card by $10"; + await gift_card_adjustment.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/gift_cards/1035197676/adjustments.json', + query: '', + headers, + data: { "adjustment": {amount: 10.0, note: "Customer refilled gift card by $10"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const gift_card_adjustment = new GiftCardAdjustment({session: test_session}); + gift_card_adjustment.gift_card_id = 1035197676; + gift_card_adjustment.amount = -20.0; + gift_card_adjustment.note = "Customer spent $20 via external service"; + await gift_card_adjustment.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/gift_cards/1035197676/adjustments.json', + query: '', + headers, + data: { "adjustment": {amount: -20.0, note: "Customer spent $20 via external service"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const gift_card_adjustment = new GiftCardAdjustment({session: test_session}); + gift_card_adjustment.gift_card_id = 1035197676; + gift_card_adjustment.amount = 10.0; + gift_card_adjustment.remote_transaction_ref = "gift_card_app_transaction_193402"; + gift_card_adjustment.remote_transaction_url = "http://example.com/my-gift-card-app/gift_card_adjustments/193402"; + await gift_card_adjustment.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/gift_cards/1035197676/adjustments.json', + query: '', + headers, + data: { "adjustment": {amount: 10.0, remote_transaction_ref: "gift_card_app_transaction_193402", remote_transaction_url: "http://example.com/my-gift-card-app/gift_card_adjustments/193402"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const gift_card_adjustment = new GiftCardAdjustment({session: test_session}); + gift_card_adjustment.gift_card_id = 1035197676; + gift_card_adjustment.amount = 10.0; + gift_card_adjustment.processed_at = "2021-08-03T16:57:35-04:00"; + await gift_card_adjustment.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/gift_cards/1035197676/adjustments.json', + query: '', + headers, + data: { "adjustment": {amount: 10.0, processed_at: "2021-08-03T16:57:35-04:00"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await GiftCardAdjustment.find({ + session: test_session, + gift_card_id: 1035197676, + id: 9, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/gift_cards/1035197676/adjustments/9.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2022-01/image.test.ts b/src/rest-resources/__tests__/2022-01/image.test.ts new file mode 100644 index 000000000..ed64e0fe2 --- /dev/null +++ b/src/rest-resources/__tests__/2022-01/image.test.ts @@ -0,0 +1,305 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Image} from '../../2022-01'; + +describe('Image resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.January22; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Image.all({ + session: test_session, + product_id: 632910392, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/products/632910392/images.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Image.all({ + session: test_session, + product_id: 632910392, + since_id: "850703190", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/products/632910392/images.json', + query: 'since_id=850703190', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const image = new Image({session: test_session}); + image.product_id = 632910392; + image.attachment = "R0lGODlhbgCMAPf/APbr48VySrxTO7IgKt2qmKQdJeK8lsFjROG5p/nz7Zg3\nMNmnd7Q1MLNVS9GId71hSJMZIuzTu4UtKbeEeakhKMl8U8WYjfr18YQaIbAf\nKKwhKdKzqpQtLebFortOOejKrOjZ1Mt7aMNpVbAqLLV7bsNqR 3WwMqEWenN\nsZYxL/Ddy/Pm2e7ZxLlUQrIjNPXp3bU5MbhENbEtLtqhj5ZQTfHh0bMxL7Ip\nNsNyUYkZIrZJPcqGdYIUHb5aPKkeJnoUHd2yiJkiLKYiKLRFOsyJXKVDO8up\nosFaS TBnK4kKti5sNaYg/z49aqYl5kqLrljUtORfMOlo/36 H4ZH8yDYq0f\nKKFYTaU9MrY8MrZBNXwXHpgaIdGVYu/byLZNP9SaZLIyOuXCtHkpJst Wpcm\nLMyCa8BfP9GMb9KQdPDd1PPk1sd5VP79/L5dQZ0bI9 ymqssK9WcfIoXHdzG\nxdWWfteib79lSr1YP86MYurQxKdcUKdMQr5ZSfPs6YEZH8uhl4oWIenMuurQ\nttmejaqoqsqBVaAcJLlJN5kvMLlZRMNsSL5fRak0LbdQQMVvSPjw6cJnRpkf\nKtmjhvfu5cJtT7IuOMVvWLY/M/37 o0YH9ibhtSYdObErc6HarM9NnYSGNGR\navLi09unje3WyeO8rsVrT7tdRtK3uffu6NWeaL9pTJIjJrM4NPbx8cdyX7M7\nPYYVHu7j4KgoNJAYIKtkV5o9MsOcldicis RYNutfrhFOZ0hJbqinZ8bI8h5\nUObFuOfItJsfJrJfUOfIqc PXqQtK8RnSbA4Mcd3Tm0SGbpXQ8aqp7RLNs s\novHfzpVhV9iggMd1TLtbRKUdKXEQFsd4XrZRPLIgMZUeJ jKvrAlK6AhJ65A\nMpMpKuC3j5obIsRwS7hAN8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C6862KKRgHGY6K9zlEPdyP8AJcteo\n3ClsQCHq0AF0QdkN HbjlxygL31hO13tMrW7lwkB0BiUoR3x4EfmrYlCNjAF\nCRAoIWmwQexQqQcyxHe 9eXAfVOQAg7k16v7jQsAHGi2Bv0gUzyQQ05Ga Cy\n0MBEDsZgN8gQ4QnXt7oJ0QOGOZACDTeEu0aTCwC80EKhDcAHMDGHWATMsuMC\nFsVl/9GnP0Jg0kw24MUv/qUTOGDlCj8WETfGsVx2vI UzsATIFZUaTIRk3QY\n ZYlFq0Ce5QJHBXgdU MRCSwEYlVBCHPQZhyn7vhhD9fWdAc2DKhKXxhRCc6\n0Yi4LOPcl6hGVUFqc4gJLGaxufKO1s2VkrOj63znOkciCKMedZ n7ARUp1rQ\niLAyIlyNYURcONaInrWs9ci4JyJOaFYawDzP8Q ZwAICLckbgd08i290eh9V\nCIadQw3qO5Oa1H1GNRlSjeorO2HLruZ2rLudAm Dm9Gxcx/GXmSIMbnjH5W2\nzy2RbOzM cENBRAWs0N9b3zXWdp8pra1r61tbXdb4N/2Nv8i5gzeIJd5Gjui\nwT AzQ9YVGrYnNO0Agm27GBkvNnNzje 921qf/ b1QEfuMDFPe5lk/lspUG3\nWKbQCofLBBBuwNEs3C3aikcrB2TTeM81HgmOd3zf/PZ3yFPNaqSXfODF0EDK\nE9e6liZmCvJwOLD7AQhU2efSbG6zm7VgiG1ofBc //nGgZ7vbYw67aVux4v/\nfXSSK53by/HVrzIwDZTBBANUrzpMeAAIWASeB4P/AQ9 cHjEJx7xWgDE5nLQ\neMdHXvKbg/zkMZ23H/1oFRjYPOc9v3nQ58Aw0xn9LACvO7HQAOZVf/jl0ii1\nHcXe9bPX3euftaPL5R71tIf97nsy7/o0WlP2r4/JOU7B r5nqva7jz1EdZ97\n4qNe bonfvCfVXvly1762beOOdLBd Q7PCAAOw==\n"; + image.filename = "rails_logo.gif"; + await image.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/products/632910392/images.json', + query: '', + head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yxHe 9eXAfVOQAg7k16v7jQsAHGi2Bv0gUzyQQ05Ga Cy\n0MBEDsZgN8gQ4QnXt7oJ0QOGOZACDTeEu0aTCwC80EKhDcAHMDGHWATMsuMC\nFsVl/9GnP0Jg0kw24MUv/qUTOGDlCj8WETfGsVx2vI UzsATIFZUaTIRk3QY\n ZYlFq0Ce5QJHBXgdU MRCSwEYlVBCHPQZhyn7vhhD9fWdAc2DKhKXxhRCc6\n0Yi4LOPcl6hGVUFqc4gJLGaxufKO1s2VkrOj63znOkciCKMedZ n7ARUp1rQ\niLAyIlyNYURcONaInrWs9ci4JyJOaFYawDzP8Q ZwAICLckbgd08i290eh9V\nCIadQw3qO5Oa1H1GNRlSjeorO2HLruZ2rLudAm Dm9Gxcx/GXmSIMbnjH5W2\nzy2RbOzM cENBRAWs0N9b3zXWdp8pra1r61tbXdb4N/2Nv8i5gzeIJd5Gjui\nwT AzQ9YVGrYnNO0Agm27GBkvNnNzje 921qf/ b1QEfuMDFPe5lk/lspUG3\nWKbQCofLBBBuwNEs3C3aikcrB2TTeM81HgmOd3zf/PZ3yFPNaqSXfODF0EDK\nE9e6liZmCvJwOLD7AQhU2efSbG6zm7VgiG1ofBc //nGgZ7vbYw67aVux4v/\nfXSSK53by/HVrzIwDZTBBANUrzpMeAAIWASeB4P/AQ9 cHjEJx7xWgDE5nLQ\neMdHXvKbg/zkMZ23H/1oFRjYPOc9v3nQ58Aw0xn9LACvO7HQAOZVf/jl0ii1\nHcXe9bPX3euftaPL5R71tIf97nsy7/o0WlP2r4/JOU7B r5nqva7jz1EdZ97\n4qNe bonfvCfVXvly1762beOOdLBd Q7PCAAOw==\n", filename: "rails_logo.gif"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const image = new Image({session: test_session}); + image.product_id = 632910392; + image.src = "http://example.com/rails_logo.gif"; + await image.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/products/632910392/images.json', + query: '', + headers, + data: { "image": {src: "http://example.com/rails_logo.gif"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const image = new Image({session: test_session}); + image.product_id = 632910392; + image.position = 1; + image.attachment = "R0lGODlhbgCMAPf/APbr48VySrxTO7IgKt2qmKQdJeK8lsFjROG5p/nz7Zg3\nMNmnd7Q1MLNVS9GId71hSJMZIuzTu4UtKbeEeakhKMl8U8WYjfr18YQaIbAf\nKKwhKdKzqpQtLebFortOOejKrOjZ1Mt7aMNpVbAqLLV7bsNqR 3WwMqEWenN\nsZYxL/Ddy/Pm2e7ZxLlUQrIjNPXp3bU5MbhENbEtLtqhj5ZQTfHh0bMxL7Ip\nNsNyUYkZIrZJPcqGdYIUHb5aPKkeJnoUHd2yiJkiLKYiKLRFOsyJXKVDO8up\nosFaS TBnK4kKti5sNaYg/z49aqYl5kqLrljUtORfMOlo/36 H4ZH8yDYq0f\nKKFYTaU9MrY8MrZBNXwXHpgaIdGVYu/byLZNP9SaZLIyOuXCtHkpJst Wpcm\nLMyCa8BfP9GMb9KQdPDd1PPk1sd5VP79/L5dQZ0bI9 ymqssK9WcfIoXHdzG\nxdWWfteib79lSr1YP86MYurQxKdcUKdMQr5ZSfPs6YEZH8uhl4oWIenMuurQ\nttmejaqoqsqBVaAcJLlJN5kvMLlZRMNsSL5fRak0LbdQQMVvSPjw6cJnRpkf\nKtmjhvfu5cJtT7IuOMVvWLY/M/37 o0YH9ibhtSYdObErc6HarM9NnYSGNGR\navLi09unje3WyeO8rsVrT7tdRtK3uffu6NWeaL9pTJIjJrM4NPbx8cdyX7M7\nPYYVHu7j4KgoNJAYIKtkV5o9MsOcldicis RYNutfrhFOZ0hJbqinZ8bI8h5\nUObFuOfItJsfJrJfUOfIqc PXqQtK8RnSbA4Mcd3Tm0SGbpXQ8aqp7RLNs s\novHfzpVhV9iggMd1TLtbRKUdKXEQFsd4XrZRPLIgMZUeJ jKvrAlK6AhJ65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DHvUHLQyhWsy01rXs2MFj2ZGC6862KKRgHGY6K9zlEPdyP8AJcteo\n3ClsQCHq0AF0QdkN HbjlxygL31hO13tMrW7lwkB0BiUoR3x4EfmrYlCNjAF\nCRAoIWmwQexQqQcyxHe 9eXAfVOQAg7k16v7jQsAHGi2Bv0gUzyQQ05Ga Cy\n0MBEDsZgN8gQ4QnXt7oJ0QOGOZACDTeEu0aTCwC80EKhDcAHMDGHWATMsuMC\nFsVl/9GnP0Jg0kw24MUv/qUTOGDlCj8WETfGsVx2vI UzsATIFZUaTIRk3QY\n ZYlFq0Ce5QJHBXgdU MRCSwEYlVBCHPQZhyn7vhhD9fWdAc2DKhKXxhRCc6\n0Yi4LOPcl6hGVUFqc4gJLGaxufKO1s2VkrOj63znOkciCKMedZ n7ARUp1rQ\niLAyIlyNYURcONaInrWs9ci4JyJOaFYawDzP8Q ZwAICLckbgd08i290eh9V\nCIadQw3qO5Oa1H1GNRlSjeorO2HLruZ2rLudAm Dm9Gxcx/GXmSIMbnjH5W2\nzy2RbOzM cENBRAWs0N9b3zXWdp8pra1r61tbXdb4N/2Nv8i5gzeIJd5Gjui\nwT AzQ9YVGrYnNO0Agm27GBkvNnNzje 921qf/ b1QEfuMDFPe5lk/lspUG3\nWKbQCofLBBBuwNEs3C3aikcrB2TTeM81HgmOd3zf/PZ3yFPNaqSXfODF0EDK\nE9e6liZmCvJwOLD7AQhU2efSbG6zm7VgiG1ofBc //nGgZ7vbYw67aVux4v/\nfXSSK53by/HVrzIwDZTBBANUrzpMeAAIWASeB4P/AQ9 cHjEJx7xWgDE5nLQ\neMdHXvKbg/zkMZ23H/1oFRjYPOc9v3nQ58Aw0xn9LACvO7HQAOZVf/jl0ii1\nHcXe9bPX3euftaPL5R71tIf97nsy7/o0WlP2r4/JOU7B r5nqva7jz1EdZ97\n4qNe bonfvCfVXvly1762beOOdLBd Q7PCAAOw==\n"; + image.filename = "rails_logo.gif"; + await image.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/products/632910392/images.json', + query: '', + headers, + data: { "image": {position: 1, attachment: "R0lGODlhbgCMAPf/APbr48VySrxTO7IgKt2qmKQdJeK8lsFjROG5p/nz7Zg3\nMNmnd7Q1MLNVS9GId71hSJMZIuzTu4UtKbeEeakhKMl8U8WYjfr18YQaIbAf\nKKwhKdKzqpQtLebFortOOejKrOjZ1Mt7aMNpVbAqLLV7bsNqR 3WwMqEWenN\nsZYxL/Ddy/Pm2e7ZxLlUQrIjNPXp3bU5MbhENbEtLtqhj5ZQTfHh0bMxL7Ip\nNsNyUYkZIrZJPcqGdYIUHb5aPKkeJnoUHd2yiJkiLKYiKLRFOsyJXKVDO8up\nosFaS TBnK4kKti5sNaYg/z49aqYl5kqLrljUtORfMOlo/36 H4ZH8yDYq0f\nKKFYTaU9MrY8MrZBNXwXHpgaIdGVYu/byLZNP9SaZLIyOuXCtHkpJst Wpcm\nLMyCa8BfP9GMb9KQdPDd1PPk1sd5VP79/L5dQZ0bI9 ymqssK9WcfIoXHdzG\nxdWWfteib79lSr1YP86MYurQxKdcUKdMQr5ZSfPs6YEZH8uhl4oWIenMuurQ\nttmejaqoqsqBVaAcJLlJN5kvMLlZRMNsSL5fRak0LbdQQMVvSPjw6cJnRpkf\nKtmjhvfu5cJtT7IuOMVvWLY/M/37 o0YH9ibhtSYdObErc6HarM9NnYSGNGR\navLi09unje3WyeO8rsVrT7tdRtK3uffu6NWeaL9pTJIjJrM4NPbx8cdyX7M7\nPYYVHu7j4KgoNJAYIKtkV5o9MsOcldicis RYNutfrhFOZ0hJbqinZ8bI8h5\nUObFuOfItJsfJrJfUOfIqc PXqQtK8RnSbA4Mcd3Tm0SGbpXQ8aqp7RLNs s\novHfzpVhV9iggMd1TLtbRKUdKXEQFsd4XrZRPLIgMZUeJ jKvrAlK6AhJ65A\nMpMpKuC3j5obIsRwS7hAN8l/YtvDvnYXHbAoLI47SIUsOMenorF4gO/m4 fH\npo4vLZ8oKMukqp0cJbhVSMV2UuPR0bAfMLI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x4EfmrYlCNjAF\nCRAoIWmwQexQqQcyxHe 9eXAfVOQAg7k16v7jQsAHGi2Bv0gUzyQQ05Ga Cy\n0MBEDsZgN8gQ4QnXt7oJ0QOGOZACDTeEu0aTCwC80EKhDcAHMDGHWATMsuMC\nFsVl/9GnP0Jg0kw24MUv/qUTOGDlCj8WETfGsVx2vI UzsATIFZUaTIRk3QY\n ZYlFq0Ce5QJHBXgdU MRCSwEYlVBCHPQZhyn7vhhD9fWdAc2DKhKXxhRCc6\n0Yi4LOPcl6hGVUFqc4gJLGaxufKO1s2VkrOj63znOkciCKMedZ n7ARUp1rQ\niLAyIlyNYURcONaInrWs9ci4JyJOaFYawDzP8Q ZwAICLckbgd08i290eh9V\nCIadQw3qO5Oa1H1GNRlSjeorO2HLruZ2rLudAm Dm9Gxcx/GXmSIMbnjH5W2\nzy2RbOzM cENBRAWs0N9b3zXWdp8pra1r61tbXdb4N/2Nv8i5gzeIJd5Gjui\nwT AzQ9YVGrYnNO0Agm27GBkvNnNzje 921qf/ b1QEfuMDFPe5lk/lspUG3\nWKbQCofLBBBuwNEs3C3aikcrB2TTeM81HgmOd3zf/PZ3yFPNaqSXfODF0EDK\nE9e6liZmCvJwOLD7AQhU2efSbG6zm7VgiG1ofBc //nGgZ7vbYw67aVux4v/\nfXSSK53by/HVrzIwDZTBBANUrzpMeAAIWASeB4P/AQ9 cHjEJx7xWgDE5nLQ\neMdHXvKbg/zkMZ23H/1oFRjYPOc9v3nQ58Aw0xn9LACvO7HQAOZVf/jl0ii1\nHcXe9bPX3euftaPL5R71tIf97nsy7/o0WlP2r4/JOU7B r5nqva7jz1EdZ97\n4qNe bonfvCfVXvly1762beOOdLBd Q7PCAAOw==\n", filename: "rails_logo.gif"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const image = new Image({session: test_session}); + image.product_id = 632910392; + image.variant_ids = [ + 808950810, + 457924702 + ]; + image.attachment = "R0lGODlhbgC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Gi2Bv0gUzyQQ05Ga Cy\n0MBEDsZgN8gQ4QnXt7oJ0QOGOZACDTeEu0aTCwC80EKhDcAHMDGHWATMsuMC\nFsVl/9GnP0Jg0kw24MUv/qUTOGDlCj8WETfGsVx2vI UzsATIFZUaTIRk3QY\n ZYlFq0Ce5QJHBXgdU MRCSwEYlVBCHPQZhyn7vhhD9fWdAc2DKhKXxhRCc6\n0Yi4LOPcl6hGVUFqc4gJLGaxufKO1s2VkrOj63znOkciCKMedZ n7ARUp1rQ\niLAyIlyNYURcONaInrWs9ci4JyJOaFYawDzP8Q ZwAICLckbgd08i290eh9V\nCIadQw3qO5Oa1H1GNRlSjeorO2HLruZ2rLudAm Dm9Gxcx/GXmSIMbnjH5W2\nzy2RbOzM cENBRAWs0N9b3zXWdp8pra1r61tbXdb4N/2Nv8i5gzeIJd5Gjui\nwT AzQ9YVGrYnNO0Agm27GBkvNnNzje 921qf/ b1QEfuMDFPe5lk/lspUG3\nWKbQCofLBBBuwNEs3C3aikcrB2TTeM81HgmOd3zf/PZ3yFPNaqSXfODF0EDK\nE9e6liZmCvJwOLD7AQhU2efSbG6zm7VgiG1ofBc //nGgZ7vbYw67aVux4v/\nfXSSK53by/HVrzIwDZTBBANUrzpMeAAIWASeB4P/AQ9 cHjEJx7xWgDE5nLQ\neMdHXvKbg/zkMZ23H/1oFRjYPOc9v3nQ58Aw0xn9LACvO7HQAOZVf/jl0ii1\nHcXe9bPX3euftaPL5R71tIf97nsy7/o0WlP2r4/JOU7B r5nqva7jz1EdZ97\n4qNe bonfvCfVXvly1762beOOdLBd Q7PCAAOw==\n"; + image.filename = "rails_logo.gif"; + await image.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/products/632910392/images.json', + query: '', + headers, + data: { "image": {variant_ids: [808950810, 457924702], attachment: "R0lGODlhbgCMAPf/APbr48VySrxTO7IgKt2qmKQdJeK8lsFjROG5p/nz7Zg3\nMNmnd7Q1MLNVS9GId71hSJMZIuzTu4UtKbeEe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FsVl/9GnP0Jg0kw24MUv/qUTOGDlCj8WETfGsVx2vI UzsATIFZUaTIRk3QY\n ZYlFq0Ce5QJHBXgdU MRCSwEYlVBCHPQZhyn7vhhD9fWdAc2DKhKXxhRCc6\n0Yi4LOPcl6hGVUFqc4gJLGaxufKO1s2VkrOj63znOkciCKMedZ n7ARUp1rQ\niLAyIlyNYURcONaInrWs9ci4JyJOaFYawDzP8Q ZwAICLckbgd08i290eh9V\nCIadQw3qO5Oa1H1GNRlSjeorO2HLruZ2rLudAm Dm9Gxcx/GXmSIMbnjH5W2\nzy2RbOzM cENBRAWs0N9b3zXWdp8pra1r61tbXdb4N/2Nv8i5gzeIJd5Gjui\nwT AzQ9YVGrYnNO0Agm27GBkvNnNzje 921qf/ b1QEfuMDFPe5lk/lspUG3\nWKbQCofLBBBuwNEs3C3aikcrB2TTeM81HgmOd3zf/PZ3yFPNaqSXfODF0EDK\nE9e6liZmCvJwOLD7AQhU2efSbG6zm7VgiG1ofBc //nGgZ7vbYw67aVux4v/\nfXSSK53by/HVrzIwDZTBBANUrzpMeAAIWASeB4P/AQ9 cHjEJx7xWgDE5nLQ\neMdHXvKbg/zkMZ23H/1oFRjYPOc9v3nQ58Aw0xn9LACvO7HQAOZVf/jl0ii1\nHcXe9bPX3euftaPL5R71tIf97nsy7/o0WlP2r4/JOU7B r5nqva7jz1EdZ97\n4qNe bonfvCfVXvly1762beOOdLBd Q7PCAAOw==\n", filename: "rails_logo.gif"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const image = new Image({session: test_session}); + image.product_id = 632910392; + image.position = 1; + image.metafields = [ + { + key: "new", + value: "newvalue", + type: "single_line_text_field", + namespace: "global" + } + ]; + image.attachment = "R0lGODlhbgCMAPf/APbr48VySrxTO7IgKt2qmKQdJeK8lsFjROG5p/nz7Zg3\nMNmnd7Q1MLNVS9GId71hSJMZIuzTu4UtKbeEeakhKMl8U8WYjfr18YQaIbAf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qUTOGDlCj8WETfGsVx2vI UzsATIFZUaTIRk3QY\n ZYlFq0Ce5QJHBXgdU MRCSwEYlVBCHPQZhyn7vhhD9fWdAc2DKhKXxhRCc6\n0Yi4LOPcl6hGVUFqc4gJLGaxufKO1s2VkrOj63znOkciCKMedZ n7ARUp1rQ\niLAyIlyNYURcONaInrWs9ci4JyJOaFYawDzP8Q ZwAICLckbgd08i290eh9V\nCIadQw3qO5Oa1H1GNRlSjeorO2HLruZ2rLudAm Dm9Gxcx/GXmSIMbnjH5W2\nzy2RbOzM cENBRAWs0N9b3zXWdp8pra1r61tbXdb4N/2Nv8i5gzeIJd5Gjui\nwT AzQ9YVGrYnNO0Agm27GBkvNnNzje 921qf/ b1QEfuMDFPe5lk/lspUG3\nWKbQCofLBBBuwNEs3C3aikcrB2TTeM81HgmOd3zf/PZ3yFPNaqSXfODF0EDK\nE9e6liZmCvJwOLD7AQhU2efSbG6zm7VgiG1ofBc //nGgZ7vbYw67aVux4v/\nfXSSK53by/HVrzIwDZTBBANUrzpMeAAIWASeB4P/AQ9 cHjEJx7xWgDE5nLQ\neMdHXvKbg/zkMZ23H/1oFRjYPOc9v3nQ58Aw0xn9LACvO7HQAOZVf/jl0ii1\nHcXe9bPX3euftaPL5R71tIf97nsy7/o0WlP2r4/JOU7B r5nqva7jz1EdZ97\n4qNe bonfvCfVXvly1762beOOdLBd Q7PCAAOw==\n"; + image.filename = "rails_logo.gif"; + await image.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/products/632910392/images.json', + query: '', + headers, + data: { "image": {position: 1, metafields: [{key: "new", value: "newvalue", type: "single_line_text_field", namespace: "global"}], attachment: "R0lGODlhbgCMAPf/APbr48VySrxTO7IgKt2qmKQdJeK8lsFjROG5p/nz7Zg3\nMNmnd7Q1MLNVS9GId71hSJMZIuzTu4UtKbeEeakhKMl8U8WYjfr18YQaIbAf\nKKwhKdKzqpQtLebFortOOejKrOjZ1Mt7aMNpVbAqLLV7bsNqR 3WwMqE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U MRCSwEYlVBCHPQZhyn7vhhD9fWdAc2DKhKXxhRCc6\n0Yi4LOPcl6hGVUFqc4gJLGaxufKO1s2VkrOj63znOkciCKMedZ n7ARUp1rQ\niLAyIlyNYURcONaInrWs9ci4JyJOaFYawDzP8Q ZwAICLckbgd08i290eh9V\nCIadQw3qO5Oa1H1GNRlSjeorO2HLruZ2rLudAm Dm9Gxcx/GXmSIMbnjH5W2\nzy2RbOzM cENBRAWs0N9b3zXWdp8pra1r61tbXdb4N/2Nv8i5gzeIJd5Gjui\nwT AzQ9YVGrYnNO0Agm27GBkvNnNzje 921qf/ b1QEfuMDFPe5lk/lspUG3\nWKbQCofLBBBuwNEs3C3aikcrB2TTeM81HgmOd3zf/PZ3yFPNaqSXfODF0EDK\nE9e6liZmCvJwOLD7AQhU2efSbG6zm7VgiG1ofBc //nGgZ7vbYw67aVux4v/\nfXSSK53by/HVrzIwDZTBBANUrzpMeAAIWASeB4P/AQ9 cHjEJx7xWgDE5nLQ\neMdHXvKbg/zkMZ23H/1oFRjYPOc9v3nQ58Aw0xn9LACvO7HQAOZVf/jl0ii1\nHcXe9bPX3euftaPL5R71tIf97nsy7/o0WlP2r4/JOU7B r5nqva7jz1EdZ97\n4qNe bonfvCfVXvly1762beOOdLBd Q7PCAAOw==\n", filename: "rails_logo.gif"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Image.count({ + session: test_session, + product_id: 632910392, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/products/632910392/images/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Image.count({ + session: test_session, + product_id: 632910392, + since_id: "850703190", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/products/632910392/images/count.json', + query: 'since_id=850703190', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_10', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Image.find({ + session: test_session, + product_id: 632910392, + id: 850703190, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/products/632910392/images/850703190.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_11', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const image = new Image({session: test_session}); + image.product_id = 632910392; + image.id = 850703190; + image.position = 2; + image.alt = "new alt tag content"; + await image.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/products/632910392/images/850703190.json', + query: '', + headers, + data: { "image": {id: 850703190, position: 2, alt: "new alt tag content"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_12', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const image = new Image({session: test_session}); + image.product_id = 632910392; + image.id = 850703190; + image.variant_ids = [ + 808950810, + 457924702 + ]; + await image.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/products/632910392/images/850703190.json', + query: '', + headers, + data: { "image": {id: 850703190, variant_ids: [808950810, 457924702]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_13', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const image = new Image({session: test_session}); + image.product_id = 632910392; + image.id = 850703190; + image.metafields = [ + { + key: "my_new_metafield", + value: "my_new_value", + type: "single_line_text_field", + namespace: "tags" + } + ]; + await image.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/products/632910392/images/850703190.json', + query: '', + headers, + data: { "image": {id: 850703190, metafields: [{key: "my_new_metafield", value: "my_new_value", type: "single_line_text_field", namespace: "tags"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_14', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Image.delete({ + session: test_session, + product_id: 632910392, + id: 850703190, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2022-01/products/632910392/images/850703190.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2022-01/inventory_item.test.ts b/src/rest-resources/__tests__/2022-01/inventory_item.test.ts new file mode 100644 index 000000000..9687e900d --- /dev/null +++ b/src/rest-resources/__tests__/2022-01/inventory_item.test.ts @@ -0,0 +1,89 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {InventoryItem} from '../../2022-01'; + +describe('InventoryItem resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.January22; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await InventoryItem.all({ + session: test_session, + ids: "808950810,39072856,457924702", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/inventory_items.json', + query: 'ids=808950810%2C39072856%2C457924702', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await InventoryItem.find({ + session: test_session, + id: 808950810, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/inventory_items/808950810.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const inventory_item = new InventoryItem({session: test_session}); + inventory_item.id = 808950810; + inventory_item.sku = "new sku"; + await inventory_item.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/inventory_items/808950810.json', + query: '', + headers, + data: { "inventory_item": {id: 808950810, sku: "new sku"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const inventory_item = new InventoryItem({session: test_session}); + inventory_item.id = 808950810; + inventory_item.cost = "25.00"; + await inventory_item.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/inventory_items/808950810.json', + query: '', + headers, + data: { "inventory_item": {id: 808950810, cost: "25.00"} } + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2022-01/inventory_level.test.ts b/src/rest-resources/__tests__/2022-01/inventory_level.test.ts new file mode 100644 index 000000000..49ad618b2 --- /dev/null +++ b/src/rest-resources/__tests__/2022-01/inventory_level.test.ts @@ -0,0 +1,148 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {InventoryLevel} from '../../2022-01'; + +describe('InventoryLevel resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.January22; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await InventoryLevel.all({ + session: test_session, + inventory_item_ids: "808950810,39072856", + location_ids: "655441491,487838322", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/inventory_levels.json', + query: 'inventory_item_ids=808950810%2C39072856&location_ids=655441491%2C487838322', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await InventoryLevel.all({ + session: test_session, + inventory_item_ids: "808950810", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/inventory_levels.json', + query: 'inventory_item_ids=808950810', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await InventoryLevel.all({ + session: test_session, + location_ids: "655441491", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/inventory_levels.json', + query: 'location_ids=655441491', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const inventory_level = new InventoryLevel({session: test_session}); + + await inventory_level.adjust({ + body: {location_id: 655441491, inventory_item_id: 808950810, available_adjustment: 5}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/inventory_levels/adjust.json', + query: '', + headers, + data: {location_id: 655441491, inventory_item_id: 808950810, available_adjustment: 5} + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await InventoryLevel.delete({ + session: test_session, + inventory_item_id: "808950810", + location_id: "655441491", + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2022-01/inventory_levels.json', + query: 'inventory_item_id=808950810&location_id=655441491', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const inventory_level = new InventoryLevel({session: test_session}); + + await inventory_level.connect({ + body: {location_id: 844681632, inventory_item_id: 457924702}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/inventory_levels/connect.json', + query: '', + headers, + data: {location_id: 844681632, inventory_item_id: 457924702} + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const inventory_level = new InventoryLevel({session: test_session}); + + await inventory_level.set({ + body: {location_id: 655441491, inventory_item_id: 808950810, available: 42}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/inventory_levels/set.json', + query: '', + headers, + data: {location_id: 655441491, inventory_item_id: 808950810, available: 42} + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2022-01/location.test.ts b/src/rest-resources/__tests__/2022-01/location.test.ts new file mode 100644 index 000000000..dc115f629 --- /dev/null +++ b/src/rest-resources/__tests__/2022-01/location.test.ts @@ -0,0 +1,87 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Location} from '../../2022-01'; + +describe('Location resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.January22; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Location.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/locations.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Location.find({ + session: test_session, + id: 487838322, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/locations/487838322.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Location.count({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/locations/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Location.inventory_levels({ + session: test_session, + id: 487838322, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/locations/487838322/inventory_levels.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2022-01/locations_for_move.test.ts b/src/rest-resources/__tests__/2022-01/locations_for_move.test.ts new file mode 100644 index 000000000..785996f46 --- /dev/null +++ b/src/rest-resources/__tests__/2022-01/locations_for_move.test.ts @@ -0,0 +1,35 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {LocationsForMove} from '../../2022-01'; + +describe('LocationsForMove resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.January22; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await LocationsForMove.all({ + session: test_session, + fulfillment_order_id: 1046000833, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/fulfillment_orders/1046000833/locations_for_move.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2022-01/marketing_event.test.ts b/src/rest-resources/__tests__/2022-01/marketing_event.test.ts new file mode 100644 index 000000000..b3bec9bba --- /dev/null +++ b/src/rest-resources/__tests__/2022-01/marketing_event.test.ts @@ -0,0 +1,159 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {MarketingEvent} from '../../2022-01'; + +describe('MarketingEvent resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.January22; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await MarketingEvent.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/marketing_events.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const marketing_event = new MarketingEvent({session: test_session}); + marketing_event.started_at = "2022-12-15"; + marketing_event.utm_campaign = "Christmas2022"; + marketing_event.utm_source = "facebook"; + marketing_event.utm_medium = "cpc"; + marketing_event.event_type = "ad"; + marketing_event.referring_domain = "facebook.com"; + marketing_event.marketing_channel = "social"; + marketing_event.paid = true; + await marketing_event.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/marketing_events.json', + query: '', + headers, + data: { "marketing_event": {started_at: "2022-12-15", utm_campaign: "Christmas2022", utm_source: "facebook", utm_medium: "cpc", event_type: "ad", referring_domain: "facebook.com", marketing_channel: "social", paid: true} } + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await MarketingEvent.count({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/marketing_events/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await MarketingEvent.find({ + session: test_session, + id: 998730532, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/marketing_events/998730532.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const marketing_event = new MarketingEvent({session: test_session}); + marketing_event.id = 998730532; + marketing_event.remote_id = "1000:2000"; + marketing_event.started_at = "2022-02-02T00:00 00:00"; + marketing_event.ended_at = "2022-02-03T00:00 00:00"; + marketing_event.scheduled_to_end_at = "2022-02-04T00:00 00:00"; + marketing_event.budget = "11.1"; + marketing_event.budget_type = "daily"; + marketing_event.currency = "CAD"; + marketing_event.utm_campaign = "other"; + marketing_event.utm_source = "other"; + marketing_event.utm_medium = "other"; + marketing_event.event_type = "ad"; + marketing_event.referring_domain = "instagram.com"; + await marketing_event.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/marketing_events/998730532.json', + query: '', + headers, + data: { "marketing_event": {id: 998730532, remote_id: "1000:2000", started_at: "2022-02-02T00:00 00:00", ended_at: "2022-02-03T00:00 00:00", scheduled_to_end_at: "2022-02-04T00:00 00:00", budget: "11.1", budget_type: "daily", currency: "CAD", utm_campaign: "other", utm_source: "other", utm_medium: "other", event_type: "ad", referring_domain: "instagram.com"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await MarketingEvent.delete({ + session: test_session, + id: 998730532, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2022-01/marketing_events/998730532.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const marketing_event = new MarketingEvent({session: test_session}); + marketing_event.id = 998730532; + await marketing_event.engagements({ + body: {engagements: [{occurred_on: "2022-01-15", views_count: 0, clicks_count: 0, favorites_count: 0, ad_spend: 10.0, is_cumulative: true}, {occurred_on: "2022-01-16", views_count: 100, clicks_count: 50, is_cumulative: true}, {occurred_on: "2022-01-17", views_count: 200, clicks_count: 100, is_cumulative: true}]}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/marketing_events/998730532/engagements.json', + query: '', + headers, + data: {engagements: [{occurred_on: "2022-01-15", views_count: 0, clicks_count: 0, favorites_count: 0, ad_spend: 10.0, is_cumulative: true}, {occurred_on: "2022-01-16", views_count: 100, clicks_count: 50, is_cumulative: true}, {occurred_on: "2022-01-17", views_count: 200, clicks_count: 100, is_cumulative: true}]} + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2022-01/metafield.test.ts b/src/rest-resources/__tests__/2022-01/metafield.test.ts new file mode 100644 index 000000000..520b11932 --- /dev/null +++ b/src/rest-resources/__tests__/2022-01/metafield.test.ts @@ -0,0 +1,162 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Metafield} from '../../2022-01'; + +describe('Metafield resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.January22; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Metafield.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/metafields.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Metafield.all({ + session: test_session, + since_id: "721389482", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/metafields.json', + query: 'since_id=721389482', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const metafield = new Metafield({session: test_session}); + metafield.namespace = "inventory"; + metafield.key = "warehouse"; + metafield.value = 25; + metafield.type = "number_integer"; + await metafield.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/metafields.json', + query: '', + headers, + data: { "metafield": {namespace: "inventory", key: "warehouse", value: 25, type: "number_integer"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Metafield.all({ + session: test_session, + metafield: {owner_id: "850703190", owner_resource: "product_image"}, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/metafields.json', + query: 'metafield%5Bowner_id%5D=850703190&metafield%5Bowner_resource%5D=product_image', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Metafield.count({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/metafields/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Metafield.find({ + session: test_session, + id: 721389482, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/metafields/721389482.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const metafield = new Metafield({session: test_session}); + metafield.id = 721389482; + metafield.value = "something new"; + metafield.type = "single_line_text_field"; + await metafield.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/metafields/721389482.json', + query: '', + headers, + data: { "metafield": {id: 721389482, value: "something new", type: "single_line_text_field"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Metafield.delete({ + session: test_session, + id: 721389482, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2022-01/metafields/721389482.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2022-01/mobile_platform_application.test.ts b/src/rest-resources/__tests__/2022-01/mobile_platform_application.test.ts new file mode 100644 index 000000000..3d3dd2153 --- /dev/null +++ b/src/rest-resources/__tests__/2022-01/mobile_platform_application.test.ts @@ -0,0 +1,162 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {MobilePlatformApplication} from '../../2022-01'; + +describe('MobilePlatformApplication resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.January22; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await MobilePlatformApplication.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/mobile_platform_applications.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const mobile_platform_application = new MobilePlatformApplication({session: test_session}); + mobile_platform_application.platform = "ios"; + mobile_platform_application.application_id = "X1Y2.ca.domain.app"; + mobile_platform_application.enabled_universal_or_app_links = true; + mobile_platform_application.enabled_shared_webcredentials = true; + await mobile_platform_application.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/mobile_platform_applications.json', + query: '', + headers, + data: { "mobile_platform_application": {platform: "ios", application_id: "X1Y2.ca.domain.app", enabled_universal_or_app_links: true, enabled_shared_webcredentials: true} } + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const mobile_platform_application = new MobilePlatformApplication({session: test_session}); + mobile_platform_application.platform = "android"; + mobile_platform_application.application_id = "com.example"; + mobile_platform_application.sha256_cert_fingerprints = [ + "14:6D:E9:83:C5:73:06:50:D8:EE:B9:95:2F:34:FC:64:16:A0:83:42:E6:1D:BE:A8:8A:04:96:B2:3F:CF:44:E5" + ]; + mobile_platform_application.enabled_universal_or_app_links = true; + await mobile_platform_application.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/mobile_platform_applications.json', + query: '', + headers, + data: { "mobile_platform_application": {platform: "android", application_id: "com.example", sha256_cert_fingerprints: ["14:6D:E9:83:C5:73:06:50:D8:EE:B9:95:2F:34:FC:64:16:A0:83:42:E6:1D:BE:A8:8A:04:96:B2:3F:CF:44:E5"], enabled_universal_or_app_links: true} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await MobilePlatformApplication.find({ + session: test_session, + id: 1066176008, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/mobile_platform_applications/1066176008.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const mobile_platform_application = new MobilePlatformApplication({session: test_session}); + mobile_platform_application.id = 1066176009; + mobile_platform_application.application_id = "A1B2.ca.domain.app"; + mobile_platform_application.platform = "ios"; + mobile_platform_application.created_at = "2022-02-03T16:41:55-05:00"; + mobile_platform_application.updated_at = "2022-02-03T16:41:55-05:00"; + mobile_platform_application.sha256_cert_fingerprints = []; + mobile_platform_application.enabled_universal_or_app_links = true; + mobile_platform_application.enabled_shared_webcredentials = true; + await mobile_platform_application.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/mobile_platform_applications/1066176009.json', + query: '', + headers, + data: { "mobile_platform_application": {id: 1066176009, application_id: "A1B2.ca.domain.app", platform: "ios", created_at: "2022-02-03T16:41:55-05:00", updated_at: "2022-02-03T16:41:55-05:00", sha256_cert_fingerprints: [], enabled_universal_or_app_links: true, enabled_shared_webcredentials: true} } + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const mobile_platform_application = new MobilePlatformApplication({session: test_session}); + mobile_platform_application.id = 1066176010; + mobile_platform_application.application_id = "com.example.news.app"; + mobile_platform_application.platform = "android"; + mobile_platform_application.created_at = "2022-02-03T16:41:57-05:00"; + mobile_platform_application.updated_at = "2022-02-03T16:41:57-05:00"; + mobile_platform_application.sha256_cert_fingerprints = [ + "14:6D:E9:83:C5:73:06:50:D8:EE:B9:95:2F:34:FC:64:16:A0:83:42:E6:1D:BE:A8:8A:04:96:B2:3F:CF:44:E5" + ]; + mobile_platform_application.enabled_universal_or_app_links = true; + mobile_platform_application.enabled_shared_webcredentials = false; + await mobile_platform_application.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/mobile_platform_applications/1066176010.json', + query: '', + headers, + data: { "mobile_platform_application": {id: 1066176010, application_id: "com.example.news.app", platform: "android", created_at: "2022-02-03T16:41:57-05:00", updated_at: "2022-02-03T16:41:57-05:00", sha256_cert_fingerprints: ["14:6D:E9:83:C5:73:06:50:D8:EE:B9:95:2F:34:FC:64:16:A0:83:42:E6:1D:BE:A8:8A:04:96:B2:3F:CF:44:E5"], enabled_universal_or_app_links: true, enabled_shared_webcredentials: false} } + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await MobilePlatformApplication.delete({ + session: test_session, + id: 1066176011, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2022-01/mobile_platform_applications/1066176011.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2022-01/order.test.ts b/src/rest-resources/__tests__/2022-01/order.test.ts new file mode 100644 index 000000000..626bf2fc2 --- /dev/null +++ b/src/rest-resources/__tests__/2022-01/order.test.ts @@ -0,0 +1,814 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Order} from '../../2022-01'; + +describe('Order resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.January22; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Order.all({ + session: test_session, + status: "any", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/orders.json', + query: 'status=any', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Order.all({ + session: test_session, + ids: "1073459980", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/orders.json', + query: 'ids=1073459980', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Order.all({ + session: test_session, + financial_status: "authorized", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/orders.json', + query: 'financial_status=authorized', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Order.all({ + session: test_session, + updated_at_min: "2005-07-31T15:57:11-04:00", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/orders.json', + query: 'updated_at_min=2005-07-31T15%3A57%3A11-04%3A00', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Order.all({ + session: test_session, + fields: "created_at,id,name,total-price", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/orders.json', + query: 'fields=created_at%2Cid%2Cname%2Ctotal-price', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Order.all({ + session: test_session, + since_id: "123", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/orders.json', + query: 'since_id=123', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Order.find({ + session: test_session, + id: 450789469, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/orders/450789469.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Order.find({ + session: test_session, + id: 450789469, + fields: "id,line_items,name,total_price", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/orders/450789469.json', + query: 'fields=id%2Cline_items%2Cname%2Ctotal_price', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order = new Order({session: test_session}); + order.id = 450789469; + order.note = "Customer contacted us about a custom engraving on this iPod"; + await order.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/orders/450789469.json', + query: '', + headers, + data: { "order": {id: 450789469, note: "Customer contacted us about a custom engraving on this iPod"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_10', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order = new Order({session: test_session}); + order.id = 450789469; + order.note_attributes = [ + { + name: "colour", + value: "red" + } + ]; + await order.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/orders/450789469.json', + query: '', + headers, + data: { "order": {id: 450789469, note_attributes: [{name: "colour", value: "red"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_11', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order = new Order({session: test_session}); + order.id = 450789469; + order.email = "a-different@email.com"; + await order.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/orders/450789469.json', + query: '', + headers, + data: { "order": {id: 450789469, email: "a-different@email.com"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_12', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order = new Order({session: test_session}); + order.id = 450789469; + order.phone = " 15145556677"; + await order.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/orders/450789469.json', + query: '', + headers, + data: { "order": {id: 450789469, phone: " 15145556677"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_13', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order = new Order({session: test_session}); + order.id = 450789469; + order.buyer_accepts_marketing = true; + await order.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/orders/450789469.json', + query: '', + headers, + data: { "order": {id: 450789469, buyer_accepts_marketing: true} } + }).toMatchMadeHttpRequest(); + }); + + it('test_14', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order = new Order({session: test_session}); + order.id = 450789469; + order.shipping_address = { + address1: "123 Ship Street", + city: "Shipsville" + }; + await order.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/orders/450789469.json', + query: '', + headers, + data: { "order": {id: 450789469, shipping_address: {address1: "123 Ship Street", city: "Shipsville"}} } + }).toMatchMadeHttpRequest(); + }); + + it('test_15', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order = new Order({session: test_session}); + order.id = 450789469; + order.customer = null; + await order.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/orders/450789469.json', + query: '', + headers, + data: { "order": {id: 450789469, customer: null} } + }).toMatchMadeHttpRequest(); + }); + + it('test_16', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order = new Order({session: test_session}); + order.id = 450789469; + order.tags = "External, Inbound, Outbound"; + await order.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/orders/450789469.json', + query: '', + headers, + data: { "order": {id: 450789469, tags: "External, Inbound, Outbound"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_17', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order = new Order({session: test_session}); + order.id = 450789469; + order.metafields = [ + { + key: "new", + value: "newvalue", + type: "single_line_text_field", + namespace: "global" + } + ]; + await order.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/orders/450789469.json', + query: '', + headers, + data: { "order": {id: 450789469, metafields: [{key: "new", value: "newvalue", type: "single_line_text_field", namespace: "global"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_18', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Order.delete({ + session: test_session, + id: 450789469, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2022-01/orders/450789469.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_19', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Order.count({ + session: test_session, + status: "any", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/orders/count.json', + query: 'status=any', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_20', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Order.count({ + session: test_session, + financial_status: "authorized", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/orders/count.json', + query: 'financial_status=authorized', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_21', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order = new Order({session: test_session}); + order.id = 450789469; + await order.close({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/orders/450789469/close.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_22', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order = new Order({session: test_session}); + order.id = 450789469; + await order.open({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/orders/450789469/open.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_23', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order = new Order({session: test_session}); + order.id = 450789469; + await order.cancel({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/orders/450789469/cancel.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_24', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order = new Order({session: test_session}); + order.id = 450789469; + await order.cancel({ + body: {amount: "10.00", currency: "USD"}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/orders/450789469/cancel.json', + query: '', + headers, + data: {amount: "10.00", currency: "USD"} + }).toMatchMadeHttpRequest(); + }); + + it('test_25', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order = new Order({session: test_session}); + order.id = 450789469; + await order.cancel({ + body: {refund: {note: "Customer made a mistake", shipping: {full_refund: true}, refund_line_items: [{line_item_id: 466157049, quantity: 1, restock_type: "cancel", location_id: 24826418}], transactions: [{parent_id: 1068278509, amount: "10.00", kind: "refund", gateway: "bogus"}, {parent_id: 1068278510, amount: "100.00", kind: "refund", gateway: "gift_card"}]}}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/orders/450789469/cancel.json', + query: '', + headers, + data: {refund: {note: "Customer made a mistake", shipping: {full_refund: true}, refund_line_items: [{line_item_id: 466157049, quantity: 1, restock_type: "cancel", location_id: 24826418}], transactions: [{parent_id: 1068278509, amount: "10.00", kind: "refund", gateway: "bogus"}, {parent_id: 1068278510, amount: "100.00", kind: "refund", gateway: "gift_card"}]}} + }).toMatchMadeHttpRequest(); + }); + + it('test_26', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order = new Order({session: test_session}); + order.line_items = [ + { + variant_id: 447654529, + quantity: 1 + } + ]; + await order.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/orders.json', + query: '', + headers, + data: { "order": {line_items: [{variant_id: 447654529, quantity: 1}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_27', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order = new Order({session: test_session}); + order.email = "foo@example.com"; + order.fulfillment_status = "fulfilled"; + order.send_receipt = true; + order.send_fulfillment_receipt = true; + order.line_items = [ + { + variant_id: 457924702, + quantity: 1 + } + ]; + await order.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/orders.json', + query: '', + headers, + data: { "order": {email: "foo@example.com", fulfillment_status: "fulfilled", send_receipt: true, send_fulfillment_receipt: true, line_items: [{variant_id: 457924702, quantity: 1}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_28', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order = new Order({session: test_session}); + order.email = "foo@example.com"; + order.fulfillment_status = "fulfilled"; + order.line_items = [ + { + variant_id: 447654529, + quantity: 1 + } + ]; + await order.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/orders.json', + query: '', + headers, + data: { "order": {email: "foo@example.com", fulfillment_status: "fulfilled", line_items: [{variant_id: 447654529, quantity: 1}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_29', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order = new Order({session: test_session}); + order.email = "foo@example.com"; + order.fulfillment_status = "fulfilled"; + order.fulfillments = [ + { + location_id: 24826418 + } + ]; + order.line_items = [ + { + variant_id: 447654529, + quantity: 1 + } + ]; + await order.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/orders.json', + query: '', + headers, + data: { "order": {email: "foo@example.com", fulfillment_status: "fulfilled", fulfillments: [{location_id: 24826418}], line_items: [{variant_id: 447654529, quantity: 1}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_30', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order = new Order({session: test_session}); + order.line_items = [ + { + title: "Big Brown Bear Boots", + price: 74.99, + grams: "1300", + quantity: 3, + tax_lines: [ + { + price: 13.5, + rate: 0.06, + title: "State tax" + } + ] + } + ]; + order.transactions = [ + { + kind: "sale", + status: "success", + amount: 238.47 + } + ]; + order.total_tax = 13.5; + order.currency = "EUR"; + await order.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/orders.json', + query: '', + headers, + data: { "order": {line_items: [{title: "Big Brown Bear Boots", price: 74.99, grams: "1300", quantity: 3, tax_lines: [{price: 13.5, rate: 0.06, title: "State tax"}]}], transactions: [{kind: "sale", status: "success", amount: 238.47}], total_tax: 13.5, currency: "EUR"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_31', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order = new Order({session: test_session}); + order.line_items = [ + { + title: "Red Leather Coat", + price: 129.99, + grams: "1700", + quantity: 1 + }, + { + title: "Blue Suede Shoes", + price: 85.95, + grams: "750", + quantity: 1, + taxable: false + }, + { + title: "Raspberry Beret", + price: 19.99, + grams: "320", + quantity: 2 + } + ]; + order.tax_lines = [ + { + price: 10.2, + rate: 0.06, + title: "State tax" + }, + { + price: 4.25, + rate: 0.025, + title: "County tax" + } + ]; + order.total_tax = 14.45; + await order.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/orders.json', + query: '', + headers, + data: { "order": {line_items: [{title: "Red Leather Coat", price: 129.99, grams: "1700", quantity: 1}, {title: "Blue Suede Shoes", price: 85.95, grams: "750", quantity: 1, taxable: false}, {title: "Raspberry Beret", price: 19.99, grams: "320", quantity: 2}], tax_lines: [{price: 10.2, rate: 0.06, title: "State tax"}, {price: 4.25, rate: 0.025, title: "County tax"}], total_tax: 14.45} } + }).toMatchMadeHttpRequest(); + }); + + it('test_32', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order = new Order({session: test_session}); + order.line_items = [ + { + variant_id: 447654529, + quantity: 1 + } + ]; + order.customer = { + id: 207119551 + }; + order.financial_status = "pending"; + await order.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/orders.json', + query: '', + headers, + data: { "order": {line_items: [{variant_id: 447654529, quantity: 1}], customer: {id: 207119551}, financial_status: "pending"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_33', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order = new Order({session: test_session}); + order.line_items = [ + { + variant_id: 447654529, + quantity: 1 + } + ]; + order.customer = { + first_name: "Paul", + last_name: "Norman", + email: "paul.norman@example.com" + }; + order.billing_address = { + first_name: "John", + last_name: "Smith", + address1: "123 Fake Street", + phone: "555-555-5555", + city: "Fakecity", + province: "Ontario", + country: "Canada", + zip: "K2P 1L4" + }; + order.shipping_address = { + first_name: "Jane", + last_name: "Smith", + address1: "123 Fake Street", + phone: "777-777-7777", + city: "Fakecity", + province: "Ontario", + country: "Canada", + zip: "K2P 1L4" + }; + order.email = "jane@example.com"; + order.transactions = [ + { + kind: "authorization", + status: "success", + amount: 50.0 + } + ]; + order.financial_status = "partially_paid"; + await order.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/orders.json', + query: '', + headers, + data: { "order": {line_items: [{variant_id: 447654529, quantity: 1}], customer: {first_name: "Paul", last_name: "Norman", email: "paul.norman@example.com"}, billing_address: {first_name: "John", last_name: "Smith", address1: "123 Fake Street", phone: "555-555-5555", city: "Fakecity", province: "Ontario", country: "Canada", zip: "K2P 1L4"}, shipping_address: {first_name: "Jane", last_name: "Smith", address1: "123 Fake Street", phone: "777-777-7777", city: "Fakecity", province: "Ontario", country: "Canada", zip: "K2P 1L4"}, email: "jane@example.com", transactions: [{kind: "authorization", status: "success", amount: 50.0}], financial_status: "partially_paid"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_34', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order = new Order({session: test_session}); + order.line_items = [ + { + variant_id: 447654529, + quantity: 1 + } + ]; + order.email = "jane@example.com"; + order.phone = "18885551234"; + order.billing_address = { + first_name: "John", + last_name: "Smith", + address1: "123 Fake Street", + phone: "555-555-5555", + city: "Fakecity", + province: "Ontario", + country: "Canada", + zip: "K2P 1L4" + }; + order.shipping_address = { + first_name: "Jane", + last_name: "Smith", + address1: "123 Fake Street", + phone: "777-777-7777", + city: "Fakecity", + province: "Ontario", + country: "Canada", + zip: "K2P 1L4" + }; + order.transactions = [ + { + kind: "sale", + status: "success", + amount: 50.0 + } + ]; + order.financial_status = "paid"; + order.discount_codes = [ + { + code: "FAKE30", + amount: "9.00", + type: "percentage" + } + ]; + await order.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/orders.json', + query: '', + headers, + data: { "order": {line_items: [{variant_id: 447654529, quantity: 1}], email: "jane@example.com", phone: "18885551234", billing_address: {first_name: "John", last_name: "Smith", address1: "123 Fake Street", phone: "555-555-5555", city: "Fakecity", province: "Ontario", country: "Canada", zip: "K2P 1L4"}, shipping_address: {first_name: "Jane", last_name: "Smith", address1: "123 Fake Street", phone: "777-777-7777", city: "Fakecity", province: "Ontario", country: "Canada", zip: "K2P 1L4"}, transactions: [{kind: "sale", status: "success", amount: 50.0}], financial_status: "paid", discount_codes: [{code: "FAKE30", amount: "9.00", type: "percentage"}]} } + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2022-01/order_risk.test.ts b/src/rest-resources/__tests__/2022-01/order_risk.test.ts new file mode 100644 index 000000000..70a7d4f52 --- /dev/null +++ b/src/rest-resources/__tests__/2022-01/order_risk.test.ts @@ -0,0 +1,119 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {OrderRisk} from '../../2022-01'; + +describe('OrderRisk resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.January22; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order_risk = new OrderRisk({session: test_session}); + order_risk.order_id = 450789469; + order_risk.message = "This order came from an anonymous proxy"; + order_risk.recommendation = "cancel"; + order_risk.score = 1.0; + order_risk.source = "External"; + order_risk.cause_cancel = true; + order_risk.display = true; + await order_risk.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/orders/450789469/risks.json', + query: '', + headers, + data: { "risk": {message: "This order came from an anonymous proxy", recommendation: "cancel", score: 1.0, source: "External", cause_cancel: true, display: true} } + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await OrderRisk.all({ + session: test_session, + order_id: 450789469, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/orders/450789469/risks.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await OrderRisk.find({ + session: test_session, + order_id: 450789469, + id: 284138680, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/orders/450789469/risks/284138680.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const order_risk = new OrderRisk({session: test_session}); + order_risk.order_id = 450789469; + order_risk.id = 284138680; + order_risk.message = "After further review, this is a legitimate order"; + order_risk.recommendation = "accept"; + order_risk.source = "External"; + order_risk.cause_cancel = false; + order_risk.score = 0.0; + await order_risk.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/orders/450789469/risks/284138680.json', + query: '', + headers, + data: { "risk": {id: 284138680, message: "After further review, this is a legitimate order", recommendation: "accept", source: "External", cause_cancel: false, score: 0.0} } + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await OrderRisk.delete({ + session: test_session, + order_id: 450789469, + id: 284138680, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2022-01/orders/450789469/risks/284138680.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2022-01/page.test.ts b/src/rest-resources/__tests__/2022-01/page.test.ts new file mode 100644 index 000000000..4cfcbeea9 --- /dev/null +++ b/src/rest-resources/__tests__/2022-01/page.test.ts @@ -0,0 +1,268 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Page} from '../../2022-01'; + +describe('Page resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.January22; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Page.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/pages.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Page.all({ + session: test_session, + since_id: "108828309", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/pages.json', + query: 'since_id=108828309', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const page = new Page({session: test_session}); + page.title = "Warranty information"; + page.body_html = "

Warranty

\n

Returns accepted if we receive items 30 days after purchase.

"; + await page.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/pages.json', + query: '', + headers, + data: { "page": {title: "Warranty information", body_html: "

Warranty

\n

Returns accepted if we receive items 30 days after purchase.

"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const page = new Page({session: test_session}); + page.title = "Warranty information"; + page.body_html = "

Warranty

\n

Returns accepted if we receive items 30 days after purchase.

"; + page.published = false; + await page.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/pages.json', + query: '', + headers, + data: { "page": {title: "Warranty information", body_html: "

Warranty

\n

Returns accepted if we receive items 30 days after purchase.

", published: false} } + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const page = new Page({session: test_session}); + page.title = "Warranty information"; + page.body_html = "

Warranty

\n

Returns accepted if we receive items 30 days after purchase.

"; + page.metafields = [ + { + key: "new", + value: "new value", + type: "single_line_text_field", + namespace: "global" + } + ]; + await page.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/pages.json', + query: '', + headers, + data: { "page": {title: "Warranty information", body_html: "

Warranty

\n

Returns accepted if we receive items 30 days after purchase.

", metafields: [{key: "new", value: "new value", type: "single_line_text_field", namespace: "global"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Page.count({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/pages/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Page.find({ + session: test_session, + id: 131092082, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/pages/131092082.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const page = new Page({session: test_session}); + page.id = 131092082; + page.body_html = "

Returns accepted if we receive the items 14 days after purchase.

"; + await page.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/pages/131092082.json', + query: '', + headers, + data: { "page": {id: 131092082, body_html: "

Returns accepted if we receive the items 14 days after purchase.

"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const page = new Page({session: test_session}); + page.id = 131092082; + page.body_html = "

Returns accepted if we receive the items 14 days after purchase.

"; + page.author = "Christopher Gorski"; + page.title = "New warranty"; + page.handle = "new-warranty"; + await page.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/pages/131092082.json', + query: '', + headers, + data: { "page": {id: 131092082, body_html: "

Returns accepted if we receive the items 14 days after purchase.

", author: "Christopher Gorski", title: "New warranty", handle: "new-warranty"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_10', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const page = new Page({session: test_session}); + page.id = 131092082; + page.published = true; + await page.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/pages/131092082.json', + query: '', + headers, + data: { "page": {id: 131092082, published: true} } + }).toMatchMadeHttpRequest(); + }); + + it('test_11', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const page = new Page({session: test_session}); + page.id = 131092082; + page.published = false; + await page.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/pages/131092082.json', + query: '', + headers, + data: { "page": {id: 131092082, published: false} } + }).toMatchMadeHttpRequest(); + }); + + it('test_12', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const page = new Page({session: test_session}); + page.id = 131092082; + page.metafields = [ + { + key: "new", + value: "new value", + type: "single_line_text_field", + namespace: "global" + } + ]; + await page.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/pages/131092082.json', + query: '', + headers, + data: { "page": {id: 131092082, metafields: [{key: "new", value: "new value", type: "single_line_text_field", namespace: "global"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_13', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Page.delete({ + session: test_session, + id: 131092082, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2022-01/pages/131092082.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2022-01/payment.test.ts b/src/rest-resources/__tests__/2022-01/payment.test.ts new file mode 100644 index 000000000..2333a67e7 --- /dev/null +++ b/src/rest-resources/__tests__/2022-01/payment.test.ts @@ -0,0 +1,116 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Payment} from '../../2022-01'; + +describe('Payment resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.January22; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const payment = new Payment({session: test_session}); + payment.checkout_id = "7yjf4v2we7gamku6a6h7tvm8h3mmvs4x"; + payment.request_details = { + ip_address: "123.1.1.1", + accept_language: "en-US,en;q=0.8,fr;q=0.6", + user_agent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.98 Safari/537.36" + }; + payment.amount = "398.00"; + payment.session_id = "global-4f10a3a42a3b4d41"; + payment.unique_token = "client-side-idempotency-token"; + await payment.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/checkouts/7yjf4v2we7gamku6a6h7tvm8h3mmvs4x/payments.json', + query: '', + headers, + data: { "payment": {request_details: {ip_address: "123.1.1.1", accept_language: "en-US,en;q=0.8,fr;q=0.6", user_agent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.98 Safari/537.36"}, amount: "398.00", session_id: "global-4f10a3a42a3b4d41", unique_token: "client-side-idempotency-token"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Payment.all({ + session: test_session, + checkout_id: "7yjf4v2we7gamku6a6h7tvm8h3mmvs4x", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/checkouts/7yjf4v2we7gamku6a6h7tvm8h3mmvs4x/payments.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Payment.find({ + session: test_session, + checkout_id: "7yjf4v2we7gamku6a6h7tvm8h3mmvs4x", + id: 25428999, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/checkouts/7yjf4v2we7gamku6a6h7tvm8h3mmvs4x/payments/25428999.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Payment.find({ + session: test_session, + checkout_id: "7yjf4v2we7gamku6a6h7tvm8h3mmvs4x", + id: 25428999, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/checkouts/7yjf4v2we7gamku6a6h7tvm8h3mmvs4x/payments/25428999.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Payment.count({ + session: test_session, + checkout_id: "7yjf4v2we7gamku6a6h7tvm8h3mmvs4x", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/checkouts/7yjf4v2we7gamku6a6h7tvm8h3mmvs4x/payments/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2022-01/payment_gateway.test.ts b/src/rest-resources/__tests__/2022-01/payment_gateway.test.ts new file mode 100644 index 000000000..d32b9a0a3 --- /dev/null +++ b/src/rest-resources/__tests__/2022-01/payment_gateway.test.ts @@ -0,0 +1,124 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {PaymentGateway} from '../../2022-01'; + +describe('PaymentGateway resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.January22; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await PaymentGateway.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/payment_gateways.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await PaymentGateway.all({ + session: test_session, + disabled: "false", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/payment_gateways.json', + query: 'disabled=false', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const payment_gateway = new PaymentGateway({session: test_session}); + payment_gateway.credential1 = "someone@example.com"; + payment_gateway.provider_id = 7; + await payment_gateway.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/payment_gateways.json', + query: '', + headers, + data: { "payment_gateway": {credential1: "someone@example.com", provider_id: 7} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await PaymentGateway.find({ + session: test_session, + id: 431363653, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/payment_gateways/431363653.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const payment_gateway = new PaymentGateway({session: test_session}); + payment_gateway.id = 170508070; + payment_gateway.sandbox = true; + await payment_gateway.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/payment_gateways/170508070.json', + query: '', + headers, + data: { "payment_gateway": {id: 170508070, sandbox: true} } + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await PaymentGateway.delete({ + session: test_session, + id: 170508070, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2022-01/payment_gateways/170508070.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2022-01/payment_transaction.test.ts b/src/rest-resources/__tests__/2022-01/payment_transaction.test.ts new file mode 100644 index 000000000..7aea22dbf --- /dev/null +++ b/src/rest-resources/__tests__/2022-01/payment_transaction.test.ts @@ -0,0 +1,35 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {PaymentTransaction} from '../../2022-01'; + +describe('PaymentTransaction resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.January22; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await PaymentTransaction.transactions({ + session: test_session, + payout_id: "623721858", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/shopify_payments/balance/transactions.json', + query: 'payout_id=623721858', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2022-01/payout.test.ts b/src/rest-resources/__tests__/2022-01/payout.test.ts new file mode 100644 index 000000000..3c47639b4 --- /dev/null +++ b/src/rest-resources/__tests__/2022-01/payout.test.ts @@ -0,0 +1,70 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Payout} from '../../2022-01'; + +describe('Payout resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.January22; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Payout.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/shopify_payments/payouts.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Payout.all({ + session: test_session, + date_max: "2012-11-12", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/shopify_payments/payouts.json', + query: 'date_max=2012-11-12', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Payout.find({ + session: test_session, + id: 623721858, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/shopify_payments/payouts/623721858.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2022-01/policy.test.ts b/src/rest-resources/__tests__/2022-01/policy.test.ts new file mode 100644 index 000000000..9b8651de0 --- /dev/null +++ b/src/rest-resources/__tests__/2022-01/policy.test.ts @@ -0,0 +1,34 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Policy} from '../../2022-01'; + +describe('Policy resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.January22; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Policy.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/policies.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2022-01/price_rule.test.ts b/src/rest-resources/__tests__/2022-01/price_rule.test.ts new file mode 100644 index 000000000..20c65949e --- /dev/null +++ b/src/rest-resources/__tests__/2022-01/price_rule.test.ts @@ -0,0 +1,246 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {PriceRule} from '../../2022-01'; + +describe('PriceRule resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.January22; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const price_rule = new PriceRule({session: test_session}); + price_rule.title = "SUMMERSALE10OFF"; + price_rule.target_type = "line_item"; + price_rule.target_selection = "all"; + price_rule.allocation_method = "across"; + price_rule.value_type = "fixed_amount"; + price_rule.value = "-10.0"; + price_rule.customer_selection = "all"; + price_rule.starts_at = "2017-01-19T17:59:10Z"; + await price_rule.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/price_rules.json', + query: '', + headers, + data: { "price_rule": {title: "SUMMERSALE10OFF", target_type: "line_item", target_selection: "all", allocation_method: "across", value_type: "fixed_amount", value: "-10.0", customer_selection: "all", starts_at: "2017-01-19T17:59:10Z"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const price_rule = new PriceRule({session: test_session}); + price_rule.title = "15OFFCOLLECTION"; + price_rule.target_type = "line_item"; + price_rule.target_selection = "entitled"; + price_rule.allocation_method = "across"; + price_rule.value_type = "percentage"; + price_rule.value = "-15.0"; + price_rule.customer_selection = "all"; + price_rule.entitled_collection_ids = [ + 841564295 + ]; + price_rule.starts_at = "2017-01-19T17:59:10Z"; + await price_rule.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/price_rules.json', + query: '', + headers, + data: { "price_rule": {title: "15OFFCOLLECTION", target_type: "line_item", target_selection: "entitled", allocation_method: "across", value_type: "percentage", value: "-15.0", customer_selection: "all", entitled_collection_ids: [841564295], starts_at: "2017-01-19T17:59:10Z"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const price_rule = new PriceRule({session: test_session}); + price_rule.title = "FREESHIPPING"; + price_rule.target_type = "shipping_line"; + price_rule.target_selection = "all"; + price_rule.allocation_method = "each"; + price_rule.value_type = "percentage"; + price_rule.value = "-100.0"; + price_rule.usage_limit = 20; + price_rule.customer_selection = "all"; + price_rule.prerequisite_subtotal_range = { + greater_than_or_equal_to: "50.0" + }; + price_rule.starts_at = "2017-01-19T17:59:10Z"; + await price_rule.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/price_rules.json', + query: '', + headers, + data: { "price_rule": {title: "FREESHIPPING", target_type: "shipping_line", target_selection: "all", allocation_method: "each", value_type: "percentage", value: "-100.0", usage_limit: 20, customer_selection: "all", prerequisite_subtotal_range: {greater_than_or_equal_to: "50.0"}, starts_at: "2017-01-19T17:59:10Z"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const price_rule = new PriceRule({session: test_session}); + price_rule.title = "5OFFCUSTOMERGROUP"; + price_rule.target_type = "line_item"; + price_rule.target_selection = "all"; + price_rule.allocation_method = "across"; + price_rule.value_type = "fixed_amount"; + price_rule.value = "-5.0"; + price_rule.customer_selection = "prerequisite"; + price_rule.prerequisite_saved_search_ids = [ + 789629109 + ]; + price_rule.starts_at = "2017-01-19T17:59:10Z"; + await price_rule.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/price_rules.json', + query: '', + headers, + data: { "price_rule": {title: "5OFFCUSTOMERGROUP", target_type: "line_item", target_selection: "all", allocation_method: "across", value_type: "fixed_amount", value: "-5.0", customer_selection: "prerequisite", prerequisite_saved_search_ids: [789629109], starts_at: "2017-01-19T17:59:10Z"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const price_rule = new PriceRule({session: test_session}); + price_rule.title = "Buy2iPodsGetiPodTouchForFree"; + price_rule.value_type = "percentage"; + price_rule.value = "-100.0"; + price_rule.customer_selection = "all"; + price_rule.target_type = "line_item"; + price_rule.target_selection = "entitled"; + price_rule.allocation_method = "each"; + price_rule.starts_at = "2018-03-22T00:00:00-00:00"; + price_rule.prerequisite_collection_ids = [ + 841564295 + ]; + price_rule.entitled_product_ids = [ + 921728736 + ]; + price_rule.prerequisite_to_entitlement_quantity_ratio = { + prerequisite_quantity: 2, + entitled_quantity: 1 + }; + price_rule.allocation_limit = 3; + await price_rule.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/price_rules.json', + query: '', + headers, + data: { "price_rule": {title: "Buy2iPodsGetiPodTouchForFree", value_type: "percentage", value: "-100.0", customer_selection: "all", target_type: "line_item", target_selection: "entitled", allocation_method: "each", starts_at: "2018-03-22T00:00:00-00:00", prerequisite_collection_ids: [841564295], entitled_product_ids: [921728736], prerequisite_to_entitlement_quantity_ratio: {prerequisite_quantity: 2, entitled_quantity: 1}, allocation_limit: 3} } + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await PriceRule.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/price_rules.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const price_rule = new PriceRule({session: test_session}); + price_rule.id = 507328175; + price_rule.title = "WINTER SALE"; + await price_rule.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/price_rules/507328175.json', + query: '', + headers, + data: { "price_rule": {id: 507328175, title: "WINTER SALE"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await PriceRule.find({ + session: test_session, + id: 507328175, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/price_rules/507328175.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await PriceRule.delete({ + session: test_session, + id: 507328175, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2022-01/price_rules/507328175.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_10', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await PriceRule.count({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/price_rules/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2022-01/product.test.ts b/src/rest-resources/__tests__/2022-01/product.test.ts new file mode 100644 index 000000000..aa7d36d13 --- /dev/null +++ b/src/rest-resources/__tests__/2022-01/product.test.ts @@ -0,0 +1,738 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Product} from '../../2022-01'; + +describe('Product resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.January22; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Product.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/products.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Product.all({ + session: test_session, + ids: "632910392,921728736", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/products.json', + query: 'ids=632910392%2C921728736', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Product.all({ + session: test_session, + fields: "id,images,title", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/products.json', + query: 'fields=id%2Cimages%2Ctitle', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Product.all({ + session: test_session, + collection_id: "841564295", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/products.json', + query: 'collection_id=841564295', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Product.all({ + session: test_session, + since_id: "632910392", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/products.json', + query: 'since_id=632910392', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Product.all({ + session: test_session, + presentment_currencies: "USD", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/products.json', + query: 'presentment_currencies=USD', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product = new Product({session: test_session}); + product.title = "Burton Custom Freestyle 151"; + product.body_html = "Good snowboard!"; + product.vendor = "Burton"; + product.product_type = "Snowboard"; + product.tags = [ + "Barnes & Noble", + "Big Air", + "John's Fav" + ]; + await product.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/products.json', + query: '', + headers, + data: { "product": {title: "Burton Custom Freestyle 151", body_html: "Good snowboard!", vendor: "Burton", product_type: "Snowboard", tags: ["Barnes & Noble", "Big Air", "John's Fav"]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product = new Product({session: test_session}); + product.title = "Burton Custom Freestyle 151"; + product.body_html = "Good snowboard!"; + product.vendor = "Burton"; + product.product_type = "Snowboard"; + product.published = false; + await product.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/products.json', + query: '', + headers, + data: { "product": {title: "Burton Custom Freestyle 151", body_html: "Good snowboard!", vendor: "Burton", product_type: "Snowboard", published: false} } + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product = new Product({session: test_session}); + product.title = "Burton Custom Freestyle 151"; + product.body_html = "Good snowboard!"; + product.vendor = "Burton"; + product.product_type = "Snowboard"; + product.status = "draft"; + await product.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/products.json', + query: '', + headers, + data: { "product": {title: "Burton Custom Freestyle 151", body_html: "Good snowboard!", vendor: "Burton", product_type: "Snowboard", status: "draft"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_10', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product = new Product({session: test_session}); + product.title = "Burton Custom Freestyle 151"; + product.body_html = "Good snowboard!"; + product.vendor = "Burton"; + product.product_type = "Snowboard"; + product.variants = [ + { + option1: "First", + price: "10.00", + sku: "123" + }, + { + option1: "Second", + price: "20.00", + sku: "123" + } + ]; + await product.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/products.json', + query: '', + headers, + data: { "product": {title: "Burton Custom Freestyle 151", body_html: "Good snowboard!", vendor: "Burton", product_type: "Snowboard", variants: [{option1: "First", price: "10.00", sku: "123"}, {option1: "Second", price: "20.00", sku: "123"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_11', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product = new Product({session: test_session}); + product.title = "Burton Custom Freestyle 151"; + product.body_html = "Good snowboard!"; + product.vendor = "Burton"; + product.product_type = "Snowboard"; + product.variants = [ + { + option1: "Blue", + option2: "155" + }, + { + option1: "Black", + option2: "159" + } + ]; + product.options = [ + { + name: "Color", + values: [ + "Blue", + "Black" + ] + }, + { + name: "Size", + values: [ + "155", + "159" + ] + } + ]; + await product.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/products.json', + query: '', + headers, + data: { "product": {title: "Burton Custom Freestyle 151", body_html: "Good snowboard!", vendor: "Burton", product_type: "Snowboard", variants: [{option1: "Blue", option2: "155"}, {option1: "Black", option2: "159"}], options: [{name: "Color", values: ["Blue", "Black"]}, {name: "Size", values: ["155", "159"]}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_12', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product = new Product({session: test_session}); + product.title = "Burton Custom Freestyle 151"; + product.body_html = "Good snowboard!"; + product.vendor = "Burton"; + product.product_type = "Snowboard"; + product.images = [ + { + attachment: "R0lGODlhAQABAIAAAAAAAAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==\n" + } + ]; + await product.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/products.json', + query: '', + headers, + data: { "product": {title: "Burton Custom Freestyle 151", body_html: "Good snowboard!", vendor: "Burton", product_type: "Snowboard", images: [{attachment: "R0lGODlhAQABAIAAAAAAAAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==\n"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_13', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product = new Product({session: test_session}); + product.title = "Burton Custom Freestyle 151"; + product.body_html = "Good snowboard!"; + product.vendor = "Burton"; + product.product_type = "Snowboard"; + product.images = [ + { + src: "http://example.com/rails_logo.gif" + } + ]; + await product.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/products.json', + query: '', + headers, + data: { "product": {title: "Burton Custom Freestyle 151", body_html: "Good snowboard!", vendor: "Burton", product_type: "Snowboard", images: [{src: "http://example.com/rails_logo.gif"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_14', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product = new Product({session: test_session}); + product.title = "Burton Custom Freestyle 151"; + product.body_html = "Good snowboard!"; + product.vendor = "Burton"; + product.product_type = "Snowboard"; + product.metafields_global_title_tag = "Product SEO Title"; + product.metafields_global_description_tag = "Product SEO Description"; + await product.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/products.json', + query: '', + headers, + data: { "product": {title: "Burton Custom Freestyle 151", body_html: "Good snowboard!", vendor: "Burton", product_type: "Snowboard", metafields_global_title_tag: "Product SEO Title", metafields_global_description_tag: "Product SEO Description"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_15', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product = new Product({session: test_session}); + product.title = "Burton Custom Freestyle 151"; + product.body_html = "Good snowboard!"; + product.vendor = "Burton"; + product.product_type = "Snowboard"; + product.metafields = [ + { + key: "new", + value: "newvalue", + type: "single_line_text_field", + namespace: "global" + } + ]; + await product.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/products.json', + query: '', + headers, + data: { "product": {title: "Burton Custom Freestyle 151", body_html: "Good snowboard!", vendor: "Burton", product_type: "Snowboard", metafields: [{key: "new", value: "newvalue", type: "single_line_text_field", namespace: "global"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_16', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Product.count({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/products/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_17', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Product.count({ + session: test_session, + collection_id: "841564295", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/products/count.json', + query: 'collection_id=841564295', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_18', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Product.find({ + session: test_session, + id: 632910392, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/products/632910392.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_19', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Product.find({ + session: test_session, + id: 632910392, + fields: "id,images,title", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/products/632910392.json', + query: 'fields=id%2Cimages%2Ctitle', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_20', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product = new Product({session: test_session}); + product.id = 632910392; + product.title = "New product title"; + await product.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/products/632910392.json', + query: '', + headers, + data: { "product": {id: 632910392, title: "New product title"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_21', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product = new Product({session: test_session}); + product.id = 632910392; + product.status = "draft"; + await product.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/products/632910392.json', + query: '', + headers, + data: { "product": {id: 632910392, status: "draft"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_22', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product = new Product({session: test_session}); + product.id = 632910392; + product.tags = "Barnes & Noble, John's Fav"; + await product.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/products/632910392.json', + query: '', + headers, + data: { "product": {id: 632910392, tags: "Barnes & Noble, John's Fav"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_23', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product = new Product({session: test_session}); + product.id = 632910392; + product.images = []; + await product.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/products/632910392.json', + query: '', + headers, + data: { "product": {id: 632910392, images: []} } + }).toMatchMadeHttpRequest(); + }); + + it('test_24', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product = new Product({session: test_session}); + product.id = 632910392; + product.images = [ + { + id: 850703190 + }, + { + id: 562641783 + }, + { + id: 378407906 + }, + { + src: "http://example.com/rails_logo.gif" + } + ]; + await product.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/products/632910392.json', + query: '', + headers, + data: { "product": {id: 632910392, images: [{id: 850703190}, {id: 562641783}, {id: 378407906}, {src: "http://example.com/rails_logo.gif"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_25', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product = new Product({session: test_session}); + product.id = 632910392; + product.images = [ + { + id: 850703190, + position: 3 + }, + { + id: 562641783, + position: 2 + }, + { + id: 378407906, + position: 1 + } + ]; + await product.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/products/632910392.json', + query: '', + headers, + data: { "product": {id: 632910392, images: [{id: 850703190, position: 3}, {id: 562641783, position: 2}, {id: 378407906, position: 1}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_26', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product = new Product({session: test_session}); + product.id = 632910392; + product.variants = [ + { + id: 457924702 + }, + { + id: 39072856 + }, + { + id: 49148385 + }, + { + id: 808950810 + } + ]; + await product.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/products/632910392.json', + query: '', + headers, + data: { "product": {id: 632910392, variants: [{id: 457924702}, {id: 39072856}, {id: 49148385}, {id: 808950810}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_27', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product = new Product({session: test_session}); + product.id = 632910392; + product.title = "Updated Product Title"; + product.variants = [ + { + id: 808950810, + price: "2000.00", + sku: "Updating the Product SKU" + }, + { + id: 49148385 + }, + { + id: 39072856 + }, + { + id: 457924702 + } + ]; + await product.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/products/632910392.json', + query: '', + headers, + data: { "product": {id: 632910392, title: "Updated Product Title", variants: [{id: 808950810, price: "2000.00", sku: "Updating the Product SKU"}, {id: 49148385}, {id: 39072856}, {id: 457924702}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_28', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product = new Product({session: test_session}); + product.id = 632910392; + product.metafields_global_title_tag = "Brand new title"; + product.metafields_global_description_tag = "Brand new description"; + await product.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/products/632910392.json', + query: '', + headers, + data: { "product": {id: 632910392, metafields_global_title_tag: "Brand new title", metafields_global_description_tag: "Brand new description"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_29', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product = new Product({session: test_session}); + product.id = 632910392; + product.published = true; + await product.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/products/632910392.json', + query: '', + headers, + data: { "product": {id: 632910392, published: true} } + }).toMatchMadeHttpRequest(); + }); + + it('test_30', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product = new Product({session: test_session}); + product.id = 632910392; + product.published = false; + await product.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/products/632910392.json', + query: '', + headers, + data: { "product": {id: 632910392, published: false} } + }).toMatchMadeHttpRequest(); + }); + + it('test_31', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product = new Product({session: test_session}); + product.id = 632910392; + product.metafields = [ + { + key: "new", + value: "newvalue", + type: "single_line_text_field", + namespace: "global" + } + ]; + await product.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/products/632910392.json', + query: '', + headers, + data: { "product": {id: 632910392, metafields: [{key: "new", value: "newvalue", type: "single_line_text_field", namespace: "global"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_32', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Product.delete({ + session: test_session, + id: 632910392, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2022-01/products/632910392.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2022-01/product_listing.test.ts b/src/rest-resources/__tests__/2022-01/product_listing.test.ts new file mode 100644 index 000000000..19deeb96c --- /dev/null +++ b/src/rest-resources/__tests__/2022-01/product_listing.test.ts @@ -0,0 +1,121 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {ProductListing} from '../../2022-01'; + +describe('ProductListing resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.January22; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await ProductListing.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/product_listings.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await ProductListing.product_ids({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/product_listings/product_ids.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await ProductListing.count({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/product_listings/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await ProductListing.find({ + session: test_session, + product_id: 921728736, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/product_listings/921728736.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product_listing = new ProductListing({session: test_session}); + product_listing.product_id = 921728736; + await product_listing.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/product_listings/921728736.json', + query: '', + headers, + data: { "product_listing": {product_id: 921728736} } + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await ProductListing.delete({ + session: test_session, + product_id: 921728736, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2022-01/product_listings/921728736.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2022-01/product_resource_feedback.test.ts b/src/rest-resources/__tests__/2022-01/product_resource_feedback.test.ts new file mode 100644 index 000000000..3b774c9e1 --- /dev/null +++ b/src/rest-resources/__tests__/2022-01/product_resource_feedback.test.ts @@ -0,0 +1,78 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {ProductResourceFeedback} from '../../2022-01'; + +describe('ProductResourceFeedback resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.January22; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product_resource_feedback = new ProductResourceFeedback({session: test_session}); + product_resource_feedback.product_id = 632910392; + product_resource_feedback.state = "requires_action"; + product_resource_feedback.messages = [ + "Needs at least one image." + ]; + product_resource_feedback.resource_updated_at = "2022-02-03T16:53:36-05:00"; + product_resource_feedback.feedback_generated_at = "2022-02-03T22:11:14.477009Z"; + await product_resource_feedback.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/products/632910392/resource_feedback.json', + query: '', + headers, + data: { "resource_feedback": {state: "requires_action", messages: ["Needs at least one image."], resource_updated_at: "2022-02-03T16:53:36-05:00", feedback_generated_at: "2022-02-03T22:11:14.477009Z"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const product_resource_feedback = new ProductResourceFeedback({session: test_session}); + product_resource_feedback.product_id = 632910392; + product_resource_feedback.state = "success"; + product_resource_feedback.resource_updated_at = "2022-02-03T16:53:36-05:00"; + product_resource_feedback.feedback_generated_at = "2022-02-03T22:11:15.898793Z"; + await product_resource_feedback.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/products/632910392/resource_feedback.json', + query: '', + headers, + data: { "resource_feedback": {state: "success", resource_updated_at: "2022-02-03T16:53:36-05:00", feedback_generated_at: "2022-02-03T22:11:15.898793Z"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await ProductResourceFeedback.all({ + session: test_session, + product_id: 632910392, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/products/632910392/resource_feedback.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2022-01/province.test.ts b/src/rest-resources/__tests__/2022-01/province.test.ts new file mode 100644 index 000000000..08d6cf839 --- /dev/null +++ b/src/rest-resources/__tests__/2022-01/province.test.ts @@ -0,0 +1,110 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Province} from '../../2022-01'; + +describe('Province resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.January22; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Province.all({ + session: test_session, + country_id: 879921427, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/countries/879921427/provinces.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Province.all({ + session: test_session, + country_id: 879921427, + since_id: "536137098", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/countries/879921427/provinces.json', + query: 'since_id=536137098', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Province.count({ + session: test_session, + country_id: 879921427, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/countries/879921427/provinces/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Province.find({ + session: test_session, + country_id: 879921427, + id: 224293623, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/countries/879921427/provinces/224293623.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const province = new Province({session: test_session}); + province.country_id = 879921427; + province.id = 224293623; + province.tax = 0.09; + await province.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/countries/879921427/provinces/224293623.json', + query: '', + headers, + data: { "province": {id: 224293623, tax: 0.09} } + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2022-01/recurring_application_charge.test.ts b/src/rest-resources/__tests__/2022-01/recurring_application_charge.test.ts new file mode 100644 index 000000000..44df34bbc --- /dev/null +++ b/src/rest-resources/__tests__/2022-01/recurring_application_charge.test.ts @@ -0,0 +1,187 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {RecurringApplicationCharge} from '../../2022-01'; + +describe('RecurringApplicationCharge resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.January22; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const recurring_application_charge = new RecurringApplicationCharge({session: test_session}); + recurring_application_charge.name = "Super Duper Plan"; + recurring_application_charge.price = 10.0; + recurring_application_charge.return_url = "http://super-duper.shopifyapps.com"; + await recurring_application_charge.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/recurring_application_charges.json', + query: '', + headers, + data: { "recurring_application_charge": {name: "Super Duper Plan", price: 10.0, return_url: "http://super-duper.shopifyapps.com"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const recurring_application_charge = new RecurringApplicationCharge({session: test_session}); + recurring_application_charge.name = "Super Duper Plan"; + recurring_application_charge.price = 10.0; + recurring_application_charge.return_url = "http://super-duper.shopifyapps.com"; + recurring_application_charge.capped_amount = 100; + recurring_application_charge.terms = "$1 for 1000 emails"; + await recurring_application_charge.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/recurring_application_charges.json', + query: '', + headers, + data: { "recurring_application_charge": {name: "Super Duper Plan", price: 10.0, return_url: "http://super-duper.shopifyapps.com", capped_amount: 100, terms: "$1 for 1000 emails"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const recurring_application_charge = new RecurringApplicationCharge({session: test_session}); + recurring_application_charge.name = "Super Duper Plan"; + recurring_application_charge.price = 10.0; + recurring_application_charge.return_url = "http://super-duper.shopifyapps.com"; + recurring_application_charge.trial_days = 5; + await recurring_application_charge.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/recurring_application_charges.json', + query: '', + headers, + data: { "recurring_application_charge": {name: "Super Duper Plan", price: 10.0, return_url: "http://super-duper.shopifyapps.com", trial_days: 5} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const recurring_application_charge = new RecurringApplicationCharge({session: test_session}); + recurring_application_charge.name = "Super Duper Plan"; + recurring_application_charge.price = 10.0; + recurring_application_charge.return_url = "http://super-duper.shopifyapps.com"; + recurring_application_charge.test = true; + await recurring_application_charge.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/recurring_application_charges.json', + query: '', + headers, + data: { "recurring_application_charge": {name: "Super Duper Plan", price: 10.0, return_url: "http://super-duper.shopifyapps.com", test: true} } + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await RecurringApplicationCharge.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/recurring_application_charges.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await RecurringApplicationCharge.all({ + session: test_session, + since_id: "455696195", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/recurring_application_charges.json', + query: 'since_id=455696195', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await RecurringApplicationCharge.find({ + session: test_session, + id: 455696195, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/recurring_application_charges/455696195.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await RecurringApplicationCharge.delete({ + session: test_session, + id: 455696195, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2022-01/recurring_application_charges/455696195.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const recurring_application_charge = new RecurringApplicationCharge({session: test_session}); + recurring_application_charge.id = 455696195; + await recurring_application_charge.customize({ + recurring_application_charge: {capped_amount: "200"}, + }); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/recurring_application_charges/455696195/customize.json', + query: 'recurring_application_charge%5Bcapped_amount%5D=200', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2022-01/redirect.test.ts b/src/rest-resources/__tests__/2022-01/redirect.test.ts new file mode 100644 index 000000000..5d01916f7 --- /dev/null +++ b/src/rest-resources/__tests__/2022-01/redirect.test.ts @@ -0,0 +1,196 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Redirect} from '../../2022-01'; + +describe('Redirect resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.January22; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Redirect.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/redirects.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Redirect.all({ + session: test_session, + since_id: "668809255", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/redirects.json', + query: 'since_id=668809255', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const redirect = new Redirect({session: test_session}); + redirect.path = "/ipod"; + redirect.target = "/pages/itunes"; + await redirect.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/redirects.json', + query: '', + headers, + data: { "redirect": {path: "/ipod", target: "/pages/itunes"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const redirect = new Redirect({session: test_session}); + redirect.path = "http://www.apple.com/forums"; + redirect.target = "http://forums.apple.com"; + await redirect.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/redirects.json', + query: '', + headers, + data: { "redirect": {path: "http://www.apple.com/forums", target: "http://forums.apple.com"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Redirect.count({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/redirects/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Redirect.find({ + session: test_session, + id: 668809255, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/redirects/668809255.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const redirect = new Redirect({session: test_session}); + redirect.id = 668809255; + redirect.path = "/tiger"; + await redirect.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/redirects/668809255.json', + query: '', + headers, + data: { "redirect": {id: 668809255, path: "/tiger"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const redirect = new Redirect({session: test_session}); + redirect.id = 668809255; + redirect.target = "/pages/macpro"; + await redirect.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/redirects/668809255.json', + query: '', + headers, + data: { "redirect": {id: 668809255, target: "/pages/macpro"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const redirect = new Redirect({session: test_session}); + redirect.id = 950115854; + redirect.path = "/powermac"; + redirect.target = "/pages/macpro"; + await redirect.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/redirects/950115854.json', + query: '', + headers, + data: { "redirect": {id: 950115854, path: "/powermac", target: "/pages/macpro"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_10', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Redirect.delete({ + session: test_session, + id: 668809255, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2022-01/redirects/668809255.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2022-01/refund.test.ts b/src/rest-resources/__tests__/2022-01/refund.test.ts new file mode 100644 index 000000000..9d8e64ac2 --- /dev/null +++ b/src/rest-resources/__tests__/2022-01/refund.test.ts @@ -0,0 +1,179 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Refund} from '../../2022-01'; + +describe('Refund resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.January22; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Refund.all({ + session: test_session, + order_id: 450789469, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/orders/450789469/refunds.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const refund = new Refund({session: test_session}); + refund.order_id = 450789469; + refund.currency = "USD"; + refund.notify = true; + refund.note = "wrong size"; + refund.shipping = { + full_refund: true + }; + refund.refund_line_items = [ + { + line_item_id: 518995019, + quantity: 1, + restock_type: "return", + location_id: 487838322 + } + ]; + refund.transactions = [ + { + parent_id: 801038806, + amount: 41.94, + kind: "refund", + gateway: "bogus" + } + ]; + await refund.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/orders/450789469/refunds.json', + query: '', + headers, + data: { "refund": {currency: "USD", notify: true, note: "wrong size", shipping: {full_refund: true}, refund_line_items: [{line_item_id: 518995019, quantity: 1, restock_type: "return", location_id: 487838322}], transactions: [{parent_id: 801038806, amount: 41.94, kind: "refund", gateway: "bogus"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const refund = new Refund({session: test_session}); + refund.order_id = 450789469; + refund.currency = "USD"; + refund.shipping = { + amount: 5.0 + }; + refund.transactions = [ + { + parent_id: 801038806, + amount: 5.0, + kind: "refund", + gateway: "bogus" + } + ]; + await refund.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/orders/450789469/refunds.json', + query: '', + headers, + data: { "refund": {currency: "USD", shipping: {amount: 5.0}, transactions: [{parent_id: 801038806, amount: 5.0, kind: "refund", gateway: "bogus"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Refund.find({ + session: test_session, + order_id: 450789469, + id: 509562969, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/orders/450789469/refunds/509562969.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const refund = new Refund({session: test_session}); + refund.order_id = 450789469; + await refund.calculate({ + body: {refund: {shipping: {full_refund: true}, refund_line_items: [{line_item_id: 518995019, quantity: 1, restock_type: "no_restock"}]}}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/orders/450789469/refunds/calculate.json', + query: '', + headers, + data: { "refund": {shipping: {full_refund: true}, refund_line_items: [{line_item_id: 518995019, quantity: 1, restock_type: "no_restock"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const refund = new Refund({session: test_session}); + refund.order_id = 450789469; + await refund.calculate({ + body: {refund: {currency: "USD", shipping: {full_refund: true}, refund_line_items: [{line_item_id: 518995019, quantity: 1, restock_type: "no_restock"}]}}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/orders/450789469/refunds/calculate.json', + query: '', + headers, + data: { "refund": {currency: "USD", shipping: {full_refund: true}, refund_line_items: [{line_item_id: 518995019, quantity: 1, restock_type: "no_restock"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const refund = new Refund({session: test_session}); + refund.order_id = 450789469; + await refund.calculate({ + body: {refund: {currency: "USD", shipping: {amount: 2.0}}}, + }); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/orders/450789469/refunds/calculate.json', + query: '', + headers, + data: { "refund": {currency: "USD", shipping: {amount: 2.0}} } + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2022-01/report.test.ts b/src/rest-resources/__tests__/2022-01/report.test.ts new file mode 100644 index 000000000..26b749ee4 --- /dev/null +++ b/src/rest-resources/__tests__/2022-01/report.test.ts @@ -0,0 +1,198 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Report} from '../../2022-01'; + +describe('Report resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.January22; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Report.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/reports.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Report.all({ + session: test_session, + ids: "517154478", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/reports.json', + query: 'ids=517154478', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Report.all({ + session: test_session, + updated_at_min: "2005-07-31 15:57:11 EDT -04:00", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/reports.json', + query: 'updated_at_min=2005-07-31+15%3A57%3A11+EDT+-04%3A00', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Report.all({ + session: test_session, + fields: "id,shopify_ql", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/reports.json', + query: 'fields=id%2Cshopify_ql', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Report.all({ + session: test_session, + since_id: "123", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/reports.json', + query: 'since_id=123', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const report = new Report({session: test_session}); + report.name = "A new app report"; + report.shopify_ql = "SHOW total_sales BY order_id FROM sales SINCE -1m UNTIL today ORDER BY total_sales"; + await report.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/reports.json', + query: '', + headers, + data: { "report": {name: "A new app report", shopify_ql: "SHOW total_sales BY order_id FROM sales SINCE -1m UNTIL today ORDER BY total_sales"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Report.find({ + session: test_session, + id: 517154478, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/reports/517154478.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Report.find({ + session: test_session, + id: 517154478, + fields: "id,shopify_ql", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/reports/517154478.json', + query: 'fields=id%2Cshopify_ql', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const report = new Report({session: test_session}); + report.id = 517154478; + report.name = "Changed Report Name"; + report.shopify_ql = "SHOW total_sales BY order_id FROM sales SINCE -12m UNTIL today ORDER BY total_sales"; + await report.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/reports/517154478.json', + query: '', + headers, + data: { "report": {id: 517154478, name: "Changed Report Name", shopify_ql: "SHOW total_sales BY order_id FROM sales SINCE -12m UNTIL today ORDER BY total_sales"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_10', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Report.delete({ + session: test_session, + id: 517154478, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2022-01/reports/517154478.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2022-01/resource_feedback.test.ts b/src/rest-resources/__tests__/2022-01/resource_feedback.test.ts new file mode 100644 index 000000000..e498abac7 --- /dev/null +++ b/src/rest-resources/__tests__/2022-01/resource_feedback.test.ts @@ -0,0 +1,73 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {ResourceFeedback} from '../../2022-01'; + +describe('ResourceFeedback resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.January22; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const resource_feedback = new ResourceFeedback({session: test_session}); + resource_feedback.state = "requires_action"; + resource_feedback.messages = [ + "is not connected. Connect your account to use this sales channel." + ]; + resource_feedback.feedback_generated_at = "2022-02-03T22:00:23.179942Z"; + await resource_feedback.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/resource_feedback.json', + query: '', + headers, + data: { "resource_feedback": {state: "requires_action", messages: ["is not connected. Connect your account to use this sales channel."], feedback_generated_at: "2022-02-03T22:00:23.179942Z"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const resource_feedback = new ResourceFeedback({session: test_session}); + resource_feedback.state = "success"; + resource_feedback.feedback_generated_at = "2022-02-03T22:00:24.490026Z"; + await resource_feedback.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/resource_feedback.json', + query: '', + headers, + data: { "resource_feedback": {state: "success", feedback_generated_at: "2022-02-03T22:00:24.490026Z"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await ResourceFeedback.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/resource_feedback.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2022-01/script_tag.test.ts b/src/rest-resources/__tests__/2022-01/script_tag.test.ts new file mode 100644 index 000000000..0a5645d8a --- /dev/null +++ b/src/rest-resources/__tests__/2022-01/script_tag.test.ts @@ -0,0 +1,159 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {ScriptTag} from '../../2022-01'; + +describe('ScriptTag resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.January22; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await ScriptTag.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/script_tags.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await ScriptTag.all({ + session: test_session, + src: "https://js-aplenty.com/foo.js", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/script_tags.json', + query: 'src=https%3A%2F%2Fjs-aplenty.com%2Ffoo.js', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await ScriptTag.all({ + session: test_session, + since_id: "421379493", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/script_tags.json', + query: 'since_id=421379493', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const script_tag = new ScriptTag({session: test_session}); + script_tag.event = "onload"; + script_tag.src = "https://djavaskripped.org/fancy.js"; + await script_tag.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/script_tags.json', + query: '', + headers, + data: { "script_tag": {event: "onload", src: "https://djavaskripped.org/fancy.js"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await ScriptTag.count({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/script_tags/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await ScriptTag.find({ + session: test_session, + id: 596726825, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/script_tags/596726825.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const script_tag = new ScriptTag({session: test_session}); + script_tag.id = 596726825; + script_tag.src = "https://somewhere-else.com/another.js"; + await script_tag.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/script_tags/596726825.json', + query: '', + headers, + data: { "script_tag": {id: 596726825, src: "https://somewhere-else.com/another.js"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await ScriptTag.delete({ + session: test_session, + id: 596726825, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2022-01/script_tags/596726825.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2022-01/shipping_zone.test.ts b/src/rest-resources/__tests__/2022-01/shipping_zone.test.ts new file mode 100644 index 000000000..b519a9ac8 --- /dev/null +++ b/src/rest-resources/__tests__/2022-01/shipping_zone.test.ts @@ -0,0 +1,34 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {ShippingZone} from '../../2022-01'; + +describe('ShippingZone resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.January22; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await ShippingZone.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/shipping_zones.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2022-01/shop.test.ts b/src/rest-resources/__tests__/2022-01/shop.test.ts new file mode 100644 index 000000000..59db6c125 --- /dev/null +++ b/src/rest-resources/__tests__/2022-01/shop.test.ts @@ -0,0 +1,52 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Shop} from '../../2022-01'; + +describe('Shop resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.January22; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Shop.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/shop.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Shop.all({ + session: test_session, + fields: "address1,address2,city,province,country", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/shop.json', + query: 'fields=address1%2Caddress2%2Ccity%2Cprovince%2Ccountry', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2022-01/smart_collection.test.ts b/src/rest-resources/__tests__/2022-01/smart_collection.test.ts new file mode 100644 index 000000000..593bc54ae --- /dev/null +++ b/src/rest-resources/__tests__/2022-01/smart_collection.test.ts @@ -0,0 +1,456 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {SmartCollection} from '../../2022-01'; + +describe('SmartCollection resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.January22; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await SmartCollection.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/smart_collections.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await SmartCollection.all({ + session: test_session, + since_id: "482865238", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/smart_collections.json', + query: 'since_id=482865238', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await SmartCollection.all({ + session: test_session, + product_id: "632910392", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/smart_collections.json', + query: 'product_id=632910392', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await SmartCollection.all({ + session: test_session, + ids: "482865238,1063001375", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/smart_collections.json', + query: 'ids=482865238%2C1063001375', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const smart_collection = new SmartCollection({session: test_session}); + smart_collection.title = "IPods"; + smart_collection.rules = [ + { + column: "title", + relation: "starts_with", + condition: "iPod" + } + ]; + await smart_collection.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/smart_collections.json', + query: '', + headers, + data: { "smart_collection": {title: "IPods", rules: [{column: "title", relation: "starts_with", condition: "iPod"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const smart_collection = new SmartCollection({session: test_session}); + smart_collection.title = "Macbooks"; + smart_collection.rules = [ + { + column: "vendor", + relation: "equals", + condition: "Apple" + } + ]; + await smart_collection.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/smart_collections.json', + query: '', + headers, + data: { "smart_collection": {title: "Macbooks", rules: [{column: "vendor", relation: "equals", condition: "Apple"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const smart_collection = new SmartCollection({session: test_session}); + smart_collection.title = "Macbooks"; + smart_collection.rules = [ + { + column: "vendor", + relation: "equals", + condition: "Apple" + } + ]; + smart_collection.published = false; + await smart_collection.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/smart_collections.json', + query: '', + headers, + data: { "smart_collection": {title: "Macbooks", rules: [{column: "vendor", relation: "equals", condition: "Apple"}], published: false} } + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const smart_collection = new SmartCollection({session: test_session}); + smart_collection.title = "Macbooks"; + smart_collection.rules = [ + { + column: "vendor", + relation: "equals", + condition: "Apple" + } + ]; + smart_collection.image = { + attachment: "R0lGODlhAQABAIAAAAAAAAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==\n", + alt: "iPod" + }; + await smart_collection.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/smart_collections.json', + query: '', + headers, + data: { "smart_collection": {title: "Macbooks", rules: [{column: "vendor", relation: "equals", condition: "Apple"}], image: {attachment: "R0lGODlhAQABAIAAAAAAAAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==\n", alt: "iPod"}} } + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const smart_collection = new SmartCollection({session: test_session}); + smart_collection.title = "Macbooks"; + smart_collection.rules = [ + { + column: "vendor", + relation: "equals", + condition: "Apple" + } + ]; + smart_collection.image = { + src: "http://example.com/rails_logo.gif", + alt: "Rails Logo" + }; + await smart_collection.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/smart_collections.json', + query: '', + headers, + data: { "smart_collection": {title: "Macbooks", rules: [{column: "vendor", relation: "equals", condition: "Apple"}], image: {src: "http://example.com/rails_logo.gif", alt: "Rails Logo"}} } + }).toMatchMadeHttpRequest(); + }); + + it('test_10', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await SmartCollection.count({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/smart_collections/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_11', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await SmartCollection.count({ + session: test_session, + product_id: "632910392", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/smart_collections/count.json', + query: 'product_id=632910392', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_12', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await SmartCollection.find({ + session: test_session, + id: 482865238, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/smart_collections/482865238.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_13', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const smart_collection = new SmartCollection({session: test_session}); + smart_collection.id = 482865238; + smart_collection.body_html = "

5000 songs in your pocket

"; + await smart_collection.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/smart_collections/482865238.json', + query: '', + headers, + data: { "smart_collection": {id: 482865238, body_html: "

5000 songs in your pocket

"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_14', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const smart_collection = new SmartCollection({session: test_session}); + smart_collection.id = 482865238; + smart_collection.published = true; + await smart_collection.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/smart_collections/482865238.json', + query: '', + headers, + data: { "smart_collection": {id: 482865238, published: true} } + }).toMatchMadeHttpRequest(); + }); + + it('test_15', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const smart_collection = new SmartCollection({session: test_session}); + smart_collection.id = 482865238; + smart_collection.published = false; + await smart_collection.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/smart_collections/482865238.json', + query: '', + headers, + data: { "smart_collection": {id: 482865238, published: false} } + }).toMatchMadeHttpRequest(); + }); + + it('test_16', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const smart_collection = new SmartCollection({session: test_session}); + smart_collection.id = 482865238; + smart_collection.image = { + attachment: "R0lGODlhbgCMAPf/APbr48VySrxTO7IgKt2qmKQdJeK8lsFjROG5p/nz7Zg3\nMNmnd7Q1MLNVS9GId71hSJMZIuzTu4UtKbeEeakhKMl8U8WYjfr18YQaIbAf\nKKwhKdKzqpQtLebFortOOejKrOjZ1Mt7aMNpVbAqLLV7bsNqR 3WwMqEWenN\nsZYxL/Ddy/Pm2e7ZxLlUQrIjNPXp3bU5MbhENbEtLtqhj5ZQTfHh0bMx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JLGaxufKO1s2VkrOj63znOkciCKMedZ n7ARUp1rQ\niLAyIlyNYURcONaInrWs9ci4JyJOaFYawDzP8Q ZwAICLckbgd08i290eh9V\nCIadQw3qO5Oa1H1GNRlSjeorO2HLruZ2rLudAm Dm9Gxcx/GXmSIMbnjH5W2\nzy2RbOzM cENBRAWs0N9b3zXWdp8pra1r61tbXdb4N/2Nv8i5gzeIJd5Gjui\nwT AzQ9YVGrYnNO0Agm27GBkvNnNzje 921qf/ b1QEfuMDFPe5lk/lspUG3\nWKbQCofLBBBuwNEs3C3aikcrB2TTeM81HgmOd3zf/PZ3yFPNaqSXfODF0EDK\nE9e6liZmCvJwOLD7AQhU2efSbG6zm7VgiG1ofBc //nGgZ7vbYw67aVux4v/\nfXSSK53by/HVrzIwDZTBBANUrzpMeAAIWASeB4P/AQ9 cHjEJx7xWgDE5nLQ\neMdHXvKbg/zkMZ23H/1oFRjYPOc9v3nQ58Aw0xn9LACvO7HQAOZVf/jl0ii1\nHcXe9bPX3euftaPL5R71tIf97nsy7/o0WlP2r4/JOU7B r5nqva7jz1EdZ97\n4qNe bonfvCfVXvly1762beOOdLBd Q7PCAAOw==\n", + alt: "Rails logo" + }; + await smart_collection.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/smart_collections/482865238.json', + query: '', + headers, + data: { "smart_collection": {id: 482865238, image: {attachment: "R0lGODlhbgCMAPf/APbr48VySrxTO7IgKt2qmKQdJeK8lsFjROG5p/nz7Zg3\nMNmnd7Q1MLNVS9GId71hSJMZIuzTu4UtKbeEeakhKMl8U8WYjfr18YQaIbAf\nKKwhKdKzqpQtLebFortOOejKrOjZ1Mt7aMNpVbAqLLV7bsNqR 3WwMqEWenN\nsZYxL/Ddy/Pm2e7ZxLlUQrIjNPXp3bU5MbhENbEtLtqhj5ZQTfHh0bMxL7Ip\nNsNyUYkZIrZJPcqGdYIUHb5aPKkeJnoUHd2yiJkiLKYiKLRFOsyJXKVDO8up\nosFaS TBnK4kKti5sN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08i290eh9V\nCIadQw3qO5Oa1H1GNRlSjeorO2HLruZ2rLudAm Dm9Gxcx/GXmSIMbnjH5W2\nzy2RbOzM cENBRAWs0N9b3zXWdp8pra1r61tbXdb4N/2Nv8i5gzeIJd5Gjui\nwT AzQ9YVGrYnNO0Agm27GBkvNnNzje 921qf/ b1QEfuMDFPe5lk/lspUG3\nWKbQCofLBBBuwNEs3C3aikcrB2TTeM81HgmOd3zf/PZ3yFPNaqSXfODF0EDK\nE9e6liZmCvJwOLD7AQhU2efSbG6zm7VgiG1ofBc //nGgZ7vbYw67aVux4v/\nfXSSK53by/HVrzIwDZTBBANUrzpMeAAIWASeB4P/AQ9 cHjEJx7xWgDE5nLQ\neMdHXvKbg/zkMZ23H/1oFRjYPOc9v3nQ58Aw0xn9LACvO7HQAOZVf/jl0ii1\nHcXe9bPX3euftaPL5R71tIf97nsy7/o0WlP2r4/JOU7B r5nqva7jz1EdZ97\n4qNe bonfvCfVXvly1762beOOdLBd Q7PCAAOw==\n", alt: "Rails logo"}} } + }).toMatchMadeHttpRequest(); + }); + + it('test_17', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const smart_collection = new SmartCollection({session: test_session}); + smart_collection.id = 482865238; + smart_collection.image = { + alt: "Rails logo" + }; + await smart_collection.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/smart_collections/482865238.json', + query: '', + headers, + data: { "smart_collection": {id: 482865238, image: {alt: "Rails logo"}} } + }).toMatchMadeHttpRequest(); + }); + + it('test_18', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const smart_collection = new SmartCollection({session: test_session}); + smart_collection.id = 482865238; + smart_collection.image = ""; + smart_collection.updated_at = "2022-02-03T17:04:39-05:00"; + smart_collection.title = "Smart iPods"; + smart_collection.handle = "smart-ipods"; + smart_collection.body_html = "

The best selling ipod ever

"; + smart_collection.published_at = "2008-02-01T19:00:00-05:00"; + smart_collection.sort_order = "manual"; + smart_collection.template_suffix = null; + smart_collection.disjunctive = false; + smart_collection.rules = [ + { + column: "type", + relation: "equals", + condition: "Cult Products" + } + ]; + smart_collection.published_scope = "web"; + smart_collection.admin_graphql_api_id = "gid://shopify/Collection/482865238"; + await smart_collection.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/smart_collections/482865238.json', + query: '', + headers, + data: { "smart_collection": {id: 482865238, image: "", updated_at: "2022-02-03T17:04:39-05:00", title: "Smart iPods", handle: "smart-ipods", body_html: "

The best selling ipod ever

", published_at: "2008-02-01T19:00:00-05:00", sort_order: "manual", template_suffix: null, disjunctive: false, rules: [{column: "type", relation: "equals", condition: "Cult Products"}], published_scope: "web", admin_graphql_api_id: "gid://shopify/Collection/482865238"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_19', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await SmartCollection.delete({ + session: test_session, + id: 482865238, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2022-01/smart_collections/482865238.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_20', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const smart_collection = new SmartCollection({session: test_session}); + smart_collection.id = 482865238; + await smart_collection.order({ + products: ["921728736", "632910392"], + }); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/smart_collections/482865238/order.json', + query: 'products%5B%5D=921728736&products%5B%5D=632910392', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_21', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const smart_collection = new SmartCollection({session: test_session}); + smart_collection.id = 482865238; + await smart_collection.order({ + sort_order: "alpha-desc", + }); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/smart_collections/482865238/order.json', + query: 'sort_order=alpha-desc', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2022-01/storefront_access_token.test.ts b/src/rest-resources/__tests__/2022-01/storefront_access_token.test.ts new file mode 100644 index 000000000..57c3057cc --- /dev/null +++ b/src/rest-resources/__tests__/2022-01/storefront_access_token.test.ts @@ -0,0 +1,69 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {StorefrontAccessToken} from '../../2022-01'; + +describe('StorefrontAccessToken resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.January22; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const storefront_access_token = new StorefrontAccessToken({session: test_session}); + storefront_access_token.title = "Test"; + await storefront_access_token.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/storefront_access_tokens.json', + query: '', + headers, + data: { "storefront_access_token": {title: "Test"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await StorefrontAccessToken.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/storefront_access_tokens.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await StorefrontAccessToken.delete({ + session: test_session, + id: 755357713, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2022-01/storefront_access_tokens/755357713.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2022-01/tender_transaction.test.ts b/src/rest-resources/__tests__/2022-01/tender_transaction.test.ts new file mode 100644 index 000000000..47a14c346 --- /dev/null +++ b/src/rest-resources/__tests__/2022-01/tender_transaction.test.ts @@ -0,0 +1,124 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {TenderTransaction} from '../../2022-01'; + +describe('TenderTransaction resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.January22; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await TenderTransaction.all({ + session: test_session, + processed_at_max: "2005-08-05 10:22:51 -0400", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/tender_transactions.json', + query: 'processed_at_max=2005-08-05+10%3A22%3A51+-0400', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await TenderTransaction.all({ + session: test_session, + order: "processed_at ASC", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/tender_transactions.json', + query: 'order=processed_at+ASC', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await TenderTransaction.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/tender_transactions.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await TenderTransaction.all({ + session: test_session, + since_id: "1011222896", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/tender_transactions.json', + query: 'since_id=1011222896', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await TenderTransaction.all({ + session: test_session, + processed_at_min: "2005-08-06 10:22:51 -0400", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/tender_transactions.json', + query: 'processed_at_min=2005-08-06+10%3A22%3A51+-0400', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await TenderTransaction.all({ + session: test_session, + processed_at_max: "2005-08-06 10:22:51 -0400", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/tender_transactions.json', + query: 'processed_at_max=2005-08-06+10%3A22%3A51+-0400', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2022-01/theme.test.ts b/src/rest-resources/__tests__/2022-01/theme.test.ts new file mode 100644 index 000000000..f0e8407ff --- /dev/null +++ b/src/rest-resources/__tests__/2022-01/theme.test.ts @@ -0,0 +1,125 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Theme} from '../../2022-01'; + +describe('Theme resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.January22; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Theme.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/themes.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const theme = new Theme({session: test_session}); + theme.name = "Lemongrass"; + theme.src = "http://themes.shopify.com/theme.zip"; + theme.role = "main"; + await theme.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/themes.json', + query: '', + headers, + data: { "theme": {name: "Lemongrass", src: "http://themes.shopify.com/theme.zip", role: "main"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Theme.find({ + session: test_session, + id: 828155753, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/themes/828155753.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const theme = new Theme({session: test_session}); + theme.id = 752253240; + theme.name = "Experimental"; + await theme.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/themes/752253240.json', + query: '', + headers, + data: { "theme": {id: 752253240, name: "Experimental"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const theme = new Theme({session: test_session}); + theme.id = 752253240; + theme.role = "main"; + await theme.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/themes/752253240.json', + query: '', + headers, + data: { "theme": {id: 752253240, role: "main"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Theme.delete({ + session: test_session, + id: 752253240, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2022-01/themes/752253240.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2022-01/transaction.test.ts b/src/rest-resources/__tests__/2022-01/transaction.test.ts new file mode 100644 index 000000000..371e98ccf --- /dev/null +++ b/src/rest-resources/__tests__/2022-01/transaction.test.ts @@ -0,0 +1,174 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Transaction} from '../../2022-01'; + +describe('Transaction resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.January22; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Transaction.all({ + session: test_session, + order_id: 450789469, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/orders/450789469/transactions.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Transaction.all({ + session: test_session, + order_id: 450789469, + since_id: "801038806", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/orders/450789469/transactions.json', + query: 'since_id=801038806', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const transaction = new Transaction({session: test_session}); + transaction.order_id = 450789469; + transaction.currency = "USD"; + transaction.amount = "10.00"; + transaction.kind = "capture"; + transaction.parent_id = 389404469; + await transaction.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/orders/450789469/transactions.json', + query: '', + headers, + data: { "transaction": {currency: "USD", amount: "10.00", kind: "capture", parent_id: 389404469} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const transaction = new Transaction({session: test_session}); + transaction.order_id = 450789469; + transaction.currency = "USD"; + transaction.amount = "10.00"; + transaction.kind = "void"; + transaction.parent_id = 389404469; + await transaction.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/orders/450789469/transactions.json', + query: '', + headers, + data: { "transaction": {currency: "USD", amount: "10.00", kind: "void", parent_id: 389404469} } + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const transaction = new Transaction({session: test_session}); + transaction.order_id = 450789469; + transaction.currency = "USD"; + transaction.amount = "10.00"; + transaction.kind = "capture"; + transaction.parent_id = 389404469; + transaction.test = true; + await transaction.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/orders/450789469/transactions.json', + query: '', + headers, + data: { "transaction": {currency: "USD", amount: "10.00", kind: "capture", parent_id: 389404469, test: true} } + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const transaction = new Transaction({session: test_session}); + transaction.order_id = 450789469; + transaction.kind = "capture"; + transaction.authorization = "authorization-key"; + await transaction.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/orders/450789469/transactions.json', + query: '', + headers, + data: { "transaction": {kind: "capture", authorization: "authorization-key"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Transaction.count({ + session: test_session, + order_id: 450789469, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/orders/450789469/transactions/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Transaction.find({ + session: test_session, + order_id: 450789469, + id: 389404469, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/orders/450789469/transactions/389404469.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2022-01/usage_charge.test.ts b/src/rest-resources/__tests__/2022-01/usage_charge.test.ts new file mode 100644 index 000000000..02069370d --- /dev/null +++ b/src/rest-resources/__tests__/2022-01/usage_charge.test.ts @@ -0,0 +1,73 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {UsageCharge} from '../../2022-01'; + +describe('UsageCharge resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.January22; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const usage_charge = new UsageCharge({session: test_session}); + usage_charge.recurring_application_charge_id = 455696195; + usage_charge.description = "Super Mega Plan 1000 emails"; + usage_charge.price = 1.0; + await usage_charge.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/recurring_application_charges/455696195/usage_charges.json', + query: '', + headers, + data: { "usage_charge": {description: "Super Mega Plan 1000 emails", price: 1.0} } + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await UsageCharge.all({ + session: test_session, + recurring_application_charge_id: 455696195, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/recurring_application_charges/455696195/usage_charges.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await UsageCharge.find({ + session: test_session, + recurring_application_charge_id: 455696195, + id: 1034618217, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/recurring_application_charges/455696195/usage_charges/1034618217.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2022-01/user.test.ts b/src/rest-resources/__tests__/2022-01/user.test.ts new file mode 100644 index 000000000..f2c860aae --- /dev/null +++ b/src/rest-resources/__tests__/2022-01/user.test.ts @@ -0,0 +1,69 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {User} from '../../2022-01'; + +describe('User resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.January22; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await User.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/users.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await User.find({ + session: test_session, + id: 548380009, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/users/548380009.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await User.current({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/users/current.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2022-01/variant.test.ts b/src/rest-resources/__tests__/2022-01/variant.test.ts new file mode 100644 index 000000000..f77493bc9 --- /dev/null +++ b/src/rest-resources/__tests__/2022-01/variant.test.ts @@ -0,0 +1,254 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Variant} from '../../2022-01'; + +describe('Variant resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.January22; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Variant.all({ + session: test_session, + product_id: 632910392, + since_id: "49148385", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/products/632910392/variants.json', + query: 'since_id=49148385', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Variant.all({ + session: test_session, + product_id: 632910392, + presentment_currencies: "USD,CAD", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/products/632910392/variants.json', + query: 'presentment_currencies=USD%2CCAD', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Variant.all({ + session: test_session, + product_id: 632910392, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/products/632910392/variants.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Variant.count({ + session: test_session, + product_id: 632910392, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/products/632910392/variants/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Variant.find({ + session: test_session, + id: 808950810, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/variants/808950810.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const variant = new Variant({session: test_session}); + variant.id = 808950810; + variant.option1 = "Not Pink"; + variant.price = "99.00"; + await variant.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/variants/808950810.json', + query: '', + headers, + data: { "variant": {id: 808950810, option1: "Not Pink", price: "99.00"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const variant = new Variant({session: test_session}); + variant.id = 808950810; + variant.image_id = 562641783; + await variant.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/variants/808950810.json', + query: '', + headers, + data: { "variant": {id: 808950810, image_id: 562641783} } + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const variant = new Variant({session: test_session}); + variant.id = 808950810; + variant.metafields = [ + { + key: "new", + value: "newvalue", + type: "single_line_text_field", + namespace: "global" + } + ]; + await variant.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/variants/808950810.json', + query: '', + headers, + data: { "variant": {id: 808950810, metafields: [{key: "new", value: "newvalue", type: "single_line_text_field", namespace: "global"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const variant = new Variant({session: test_session}); + variant.product_id = 632910392; + variant.option1 = "Yellow"; + variant.price = "1.00"; + await variant.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/products/632910392/variants.json', + query: '', + headers, + data: { "variant": {option1: "Yellow", price: "1.00"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_10', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const variant = new Variant({session: test_session}); + variant.product_id = 632910392; + variant.image_id = 850703190; + variant.option1 = "Purple"; + await variant.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/products/632910392/variants.json', + query: '', + headers, + data: { "variant": {image_id: 850703190, option1: "Purple"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_11', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const variant = new Variant({session: test_session}); + variant.product_id = 632910392; + variant.option1 = "Blue"; + variant.metafields = [ + { + key: "new", + value: "newvalue", + type: "single_line_text_field", + namespace: "global" + } + ]; + await variant.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/products/632910392/variants.json', + query: '', + headers, + data: { "variant": {option1: "Blue", metafields: [{key: "new", value: "newvalue", type: "single_line_text_field", namespace: "global"}]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_12', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Variant.delete({ + session: test_session, + product_id: 632910392, + id: 808950810, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2022-01/products/632910392/variants/808950810.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/rest-resources/__tests__/2022-01/webhook.test.ts b/src/rest-resources/__tests__/2022-01/webhook.test.ts new file mode 100644 index 000000000..8cd49f1e6 --- /dev/null +++ b/src/rest-resources/__tests__/2022-01/webhook.test.ts @@ -0,0 +1,202 @@ +import {Session} from '../../../auth/session'; +import {Context} from '../../../context'; +import {ApiVersion} from '../../../base-types'; + +import {Webhook} from '../../2022-01'; + +describe('Webhook resource', () => { + const domain = 'test-shop.myshopify.io'; + const headers = {'X-Shopify-Access-Token': 'this_is_a_test_token'}; + const test_session = new Session('1234', domain, '1234', true); + test_session.accessToken = 'this_is_a_test_token'; + + beforeEach(() => { + Context.API_VERSION = ApiVersion.January22; + }); + + it('test_1', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Webhook.all({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/webhooks.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_2', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Webhook.all({ + session: test_session, + since_id: "901431826", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/webhooks.json', + query: 'since_id=901431826', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_3', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const webhook = new Webhook({session: test_session}); + webhook.topic = "orders/create"; + webhook.address = "https://example.hostname.com/"; + webhook.format = "json"; + webhook.fields = [ + "id", + "note" + ]; + await webhook.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/webhooks.json', + query: '', + headers, + data: { "webhook": {topic: "orders/create", address: "https://example.hostname.com/", format: "json", fields: ["id", "note"]} } + }).toMatchMadeHttpRequest(); + }); + + it('test_4', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const webhook = new Webhook({session: test_session}); + webhook.address = "arn:aws:events:us-east-1::event-source/aws.partner/shopify.com/755357713/example-event-source"; + webhook.topic = "customers/update"; + webhook.format = "json"; + await webhook.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/webhooks.json', + query: '', + headers, + data: { "webhook": {address: "arn:aws:events:us-east-1::event-source/aws.partner/shopify.com/755357713/example-event-source", topic: "customers/update", format: "json"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_5', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const webhook = new Webhook({session: test_session}); + webhook.address = "pubsub://projectName:topicName"; + webhook.topic = "customers/update"; + webhook.format = "json"; + await webhook.save({}); + + expect({ + method: 'POST', + domain, + path: '/admin/api/2022-01/webhooks.json', + query: '', + headers, + data: { "webhook": {address: "pubsub://projectName:topicName", topic: "customers/update", format: "json"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_6', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Webhook.count({ + session: test_session, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/webhooks/count.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_7', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Webhook.count({ + session: test_session, + topic: "orders/create", + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/webhooks/count.json', + query: 'topic=orders%2Fcreate', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_8', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Webhook.find({ + session: test_session, + id: 4759306, + }); + + expect({ + method: 'GET', + domain, + path: '/admin/api/2022-01/webhooks/4759306.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + + it('test_9', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + const webhook = new Webhook({session: test_session}); + webhook.id = 4759306; + webhook.address = "https://somewhere-else.com/"; + await webhook.save({}); + + expect({ + method: 'PUT', + domain, + path: '/admin/api/2022-01/webhooks/4759306.json', + query: '', + headers, + data: { "webhook": {id: 4759306, address: "https://somewhere-else.com/"} } + }).toMatchMadeHttpRequest(); + }); + + it('test_10', async () => { + fetchMock.mockResponseOnce(JSON.stringify({})); + + await Webhook.delete({ + session: test_session, + id: 4759306, + }); + + expect({ + method: 'DELETE', + domain, + path: '/admin/api/2022-01/webhooks/4759306.json', + query: '', + headers, + data: null + }).toMatchMadeHttpRequest(); + }); + +}); diff --git a/src/types.ts b/src/types.ts index 17ffebe52..d40776c99 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,4 +1,4 @@ -export * from './base_types'; +export * from './base-types'; export * from './auth/types'; export * from './clients/types'; export * from './utils/types'; diff --git a/src/utils/setup-jest.ts b/src/utils/setup-jest.ts index a3a3b1549..4411947a7 100644 --- a/src/utils/setup-jest.ts +++ b/src/utils/setup-jest.ts @@ -1,10 +1,10 @@ -import {enableFetchMocks} from 'jest-fetch-mock'; +import fetchMock from 'jest-fetch-mock'; import {Context} from '../context'; -import {ApiVersion} from '../base_types'; +import {ApiVersion} from '../base-types'; import {MemorySessionStorage} from '../auth/session'; -enableFetchMocks(); +fetchMock.enableMocks(); let currentCall = 0; beforeEach(() => { diff --git a/src/utils/version-compatible.ts b/src/utils/version-compatible.ts index 9d2d33e87..8aabcbb59 100644 --- a/src/utils/version-compatible.ts +++ b/src/utils/version-compatible.ts @@ -1,5 +1,5 @@ import {Context} from '../context'; -import {ApiVersion} from '../base_types'; +import {ApiVersion} from '../base-types'; /** * Check if the current or optionally supplied version is compatible with a given version diff --git a/src/webhooks/__tests__/registry.test.ts b/src/webhooks/__tests__/registry.test.ts index 56f16e140..eebccdc4a 100644 --- a/src/webhooks/__tests__/registry.test.ts +++ b/src/webhooks/__tests__/registry.test.ts @@ -5,7 +5,7 @@ import request from 'supertest'; import {Method, Header, StatusCode} from '@shopify/network'; import {DeliveryMethod, RegisterOptions, RegisterReturn} from '../types'; -import {ApiVersion, ShopifyHeader} from '../../base_types'; +import {ApiVersion, ShopifyHeader} from '../../base-types'; import {Context} from '../../context'; import {DataType} from '../../clients/types'; import ShopifyWebhooks from '..'; diff --git a/src/webhooks/registry.ts b/src/webhooks/registry.ts index 64ee6ce67..a6dced38b 100644 --- a/src/webhooks/registry.ts +++ b/src/webhooks/registry.ts @@ -4,7 +4,7 @@ import http from 'http'; import {StatusCode} from '@shopify/network'; import {GraphqlClient} from '../clients/graphql/graphql_client'; -import {ApiVersion, ShopifyHeader} from '../base_types'; +import {ApiVersion, ShopifyHeader} from '../base-types'; import ShopifyUtilities from '../utils'; import {Context} from '../context'; import * as ShopifyErrors from '../error';