diff --git a/gen/generator.ts b/gen/generator.ts index 37b835e0..16d8f3d2 100644 --- a/gen/generator.ts +++ b/gen/generator.ts @@ -1,9 +1,9 @@ /* eslint-disable no-console */ import apiSchema, { Resource, Operation, Component, Cardinality } from './schema' -import fs from 'fs' -import path from 'path' -import _ from 'lodash' +import { readFileSync, writeFileSync, existsSync, mkdirSync, readdirSync, rmSync } from 'fs' +import { basename } from 'path' +import { capitalize, snakeCase } from 'lodash' import { inspect } from 'util' // eslint-disable-next-line @typescript-eslint/no-var-requires @@ -28,10 +28,10 @@ const global: { const loadTemplates = (): void => { const tplDir = './gen/templates' - const tplList = fs.readdirSync(tplDir, { encoding: 'utf-8' }).filter(f => f.endsWith('.tpl')) + const tplList = readdirSync(tplDir, { encoding: 'utf-8' }).filter(f => f.endsWith('.tpl')) tplList.forEach(t => { - const tplName = path.basename(t).replace('.tpl', '') - const tpl = fs.readFileSync(`${tplDir}/${tplName}.tpl`, { encoding: 'utf-8' }) + const tplName = basename(t).replace('.tpl', '') + const tpl = readFileSync(`${tplDir}/${tplName}.tpl`, { encoding: 'utf-8' }) templates[tplName] = tpl }) } @@ -42,7 +42,7 @@ const generate = async (localSchema?: boolean) => { console.log('>> Local schema: ' + (localSchema || false) + '\n') const schemaPath = localSchema ? 'gen/openapi.json' : await apiSchema.download() - if (!fs.existsSync(schemaPath)) { + if (!existsSync(schemaPath)) { console.log('Cannot find schema file: ' + schemaPath) return } @@ -56,13 +56,13 @@ const generate = async (localSchema?: boolean) => { // Initialize source dir const resDir = 'src/resources' - if (fs.existsSync(resDir)) fs.rmSync(resDir, { recursive: true }) - fs.mkdirSync(resDir, { recursive: true }) + if (existsSync(resDir)) rmSync(resDir, { recursive: true }) + mkdirSync(resDir, { recursive: true }) // Initialize test dir const testDir = 'specs/resources' - if (fs.existsSync(testDir)) fs.rmSync(testDir, { recursive: true }) - fs.mkdirSync(testDir, { recursive: true }) + if (existsSync(testDir)) rmSync(testDir, { recursive: true }) + mkdirSync(testDir, { recursive: true }) const resources: { [key: string]: ApiRes } = {} @@ -72,11 +72,11 @@ const generate = async (localSchema?: boolean) => { const name = Inflector.pluralize(Inflector.camelize(type)) as string const tplRes = generateResource(type, name, res) - fs.writeFileSync(`${resDir}/${type}.ts`, tplRes) + writeFileSync(`${resDir}/${type}.ts`, tplRes) console.log('Generated resource ' + name) const tplSpec = generateSpec(type, name, res) - fs.writeFileSync(`${testDir}/${type}.spec.ts`, tplSpec) + writeFileSync(`${testDir}/${type}.spec.ts`, tplSpec) console.log('Generated spec ' + name) resources[type] = { @@ -122,7 +122,7 @@ const tabsString = (num: number): string => { const updateSdkInterfaces = (resources: { [key: string]: ApiRes }): void => { - const cl = fs.readFileSync('src/commercelayer.ts', { encoding: 'utf-8' }) + const cl = readFileSync('src/commercelayer.ts', { encoding: 'utf-8' }) const lines = cl.split('\n') @@ -173,7 +173,7 @@ const updateSdkInterfaces = (resources: { [key: string]: ApiRes }): void => { // console.log(definitions) // console.log(initializations) - fs.writeFileSync('src/commercelayer.ts', lines.join('\n'), { encoding: 'utf-8' }) + writeFileSync('src/commercelayer.ts', lines.join('\n'), { encoding: 'utf-8' }) console.log('API interfaces generated.') @@ -182,7 +182,7 @@ const updateSdkInterfaces = (resources: { [key: string]: ApiRes }): void => { const updateModelTypes = (resources: { [key: string]: ApiRes }): void => { - const cl = fs.readFileSync('src/model.ts', { encoding: 'utf-8' }) + const cl = readFileSync('src/model.ts', { encoding: 'utf-8' }) const lines = cl.split('\n') @@ -207,7 +207,7 @@ const updateModelTypes = (resources: { [key: string]: ApiRes }): void => { lines.splice(expStartIdx, expStopIdx - expStartIdx, ...exports) - fs.writeFileSync('src/model.ts', lines.join('\n'), { encoding: 'utf-8' }) + writeFileSync('src/model.ts', lines.join('\n'), { encoding: 'utf-8' }) console.log('Model types generated.') @@ -216,7 +216,7 @@ const updateModelTypes = (resources: { [key: string]: ApiRes }): void => { const updateApiResources = (resources: { [key: string]: ApiRes }): void => { - const cl = fs.readFileSync('src/api.ts', { encoding: 'utf-8' }) + const cl = readFileSync('src/api.ts', { encoding: 'utf-8' }) const lines = cl.split('\n') @@ -257,7 +257,7 @@ const updateApiResources = (resources: { [key: string]: ApiRes }): void => { */ - fs.writeFileSync('src/api.ts', lines.join('\n'), { encoding: 'utf-8' }) + writeFileSync('src/api.ts', lines.join('\n'), { encoding: 'utf-8' }) console.log('API resources generated.') @@ -308,6 +308,8 @@ const generateSpec = (type: string, name: string, resource: Resource): string => const lines = spec.split('\n') const allOperations = ['list', 'create', 'retrieve', 'update', 'delete', 'singleton'] + + // Generate CRUD operations specs allOperations.forEach(op => { if (!Object.values(resource.operations).map(o => { if ((o.name === 'list') && o.singleton) return 'singleton' @@ -321,11 +323,27 @@ const generateSpec = (type: string, name: string, resource: Resource): string => spec = lines.join('\n') + // Generate relationships operations specs + Object.keys(resource.operations).filter(o => !allOperations.includes(o)).forEach(o => { + const op = resource.operations[o] + if (op.relationship) { + + let specRel = templates.spec_relationship.split('\n').join('\n\t') + + specRel = specRel.replace(/##__OPERATION_NAME__##/g, op.name) + specRel = specRel.replace(/##__RELATIONSHIP_TYPE__##/g, op.relationship.type) + console.log(specRel) + spec = spec.replace(/##__RELATIONSHIP_SPECS__##/g, '\n\n\t' + specRel + '\n\t##__RELATIONSHIP_SPECS__##') + + } + }) + // Header spec = copyrightHeader(spec) spec = spec.replace(/##__RESOURCE_CLASS__##/g, name) spec = spec.replace(/##__RESOURCE_TYPE__##/g, type) + spec = spec.replace(/##__RELATIONSHIP_SPECS__##/g, '') if (resource.operations.create) { @@ -386,8 +404,8 @@ const generateResource = (type: string, name: string, resource: Resource): strin const resName = name - const types: Set = new Set() - const imports: Set = new Set() + const declaredTypes: Set = new Set() + const declaredImports: Set = new Set() // Header res = copyrightHeader(res) @@ -400,14 +418,20 @@ const generateResource = (type: string, name: string, resource: Resource): strin const tpl = op.singleton ? templates['singleton'] : templates[opName] if (tpl) { if (['retrieve', 'list'].includes(opName)) { - qryMod.push('QueryParams' + _.capitalize(op.singleton ? 'retrieve' : opName)) + qryMod.push('QueryParams' + capitalize(op.singleton ? 'retrieve' : opName)) if ((opName === 'list') && !op.singleton) resMod.push('ListResponse') } const tplOp = templatedOperation(resName, opName, op, tpl) operations.push(tplOp.operation) - tplOp.types.forEach(t => { types.add(t) }) + tplOp.types.forEach(t => { declaredTypes.add(t) }) + } + else { + if (op.relationship) { + const tplr = templates[`relationship_${op.relationship.cardinality.replace('to_', '')}`] + const tplrOp = templatedOperation('', opName, op, tplr) + operations.push(tplrOp.operation) + } else console.log('Unknown operation: ' + opName) } - else console.log('Unknown operation: ' + opName) }) res = res.replace(/##__QUERY_MODELS__##/g, qryMod.join(', ')) res = res.replace(/##__RESPONSE_MODELS__##/g, (resMod.length > 0) ? `, ${resMod.join(', ')}`: '') @@ -420,18 +444,19 @@ const generateResource = (type: string, name: string, resource: Resource): strin if (operations && (operations.length > 0)) res = res.replace(/##__RESOURCE_OPERATIONS__##/g, operations.join('\n\n\t')) // Interfaces export - const typesArray = Array.from(types) + const typesArray = Array.from(declaredTypes) res = res.replace(/##__EXPORT_RESOURCE_TYPES__##/g, typesArray.join(', ')) // Interfaces definition const modIntf: string[] = [] const resIntf: string[] = [] const relTypes: Set = new Set() + typesArray.forEach(t => { const cudSuffix = getCUDSuffix(t) resIntf.push(`Resource${cudSuffix}`) const tplCmp = templatedComponent(resName, t, resource.components[t]) - tplCmp.models.forEach(m => imports.add(m)) + tplCmp.models.forEach(m => declaredImports.add(m)) modIntf.push(tplCmp.component) if (cudSuffix) tplCmp.models.forEach(t => relTypes.add(t)) }) @@ -440,13 +465,13 @@ const generateResource = (type: string, name: string, resource: Resource): strin // Relationships definition - const relTypesArray = Array.from(relTypes).map(i => `type ${i}Rel = ResourceRel & { type: '${_.snakeCase(Inflector.pluralize(i))}' }`) + const relTypesArray = Array.from(relTypes).map(i => `type ${i}Rel = ResourceRel & { type: '${snakeCase(Inflector.pluralize(i))}' }`) res = res.replace(/##__RELATIONSHIP_TYPES__##/g, relTypesArray.length ? (relTypesArray.join('\n') + '\n') : '') // Resources import - const impResMod: string[] = Array.from(imports) + const impResMod: string[] = Array.from(declaredImports) .filter(i => !typesArray.includes(i)) // exludes resource self reference - .map(i => `import { ${i} } from './${_.snakeCase(Inflector.pluralize(i))}'`) + .map(i => `import { ${i} } from './${snakeCase(Inflector.pluralize(i))}'`) const importStr = impResMod.join('\n') + (impResMod.length ? '\n' : '') res = res.replace(/##__IMPORT_RESOURCE_MODELS__##/g, importStr) @@ -466,13 +491,18 @@ const templatedOperation = (res: string, name: string, op: Operation, tpl: strin if (op.requestType) { const requestType = op.requestType - operation = operation.replace(/##__RESOURCE_REQUEST_TYPE__##/g, requestType) - types.push(requestType) + operation = operation.replace(/##__RESOURCE_REQUEST_CLASS__##/g, requestType) + if (!types.includes(requestType)) types.push(requestType) } if (op.responseType || ['list', 'update', 'create'].includes(name)) { const responseType = op.responseType ? op.responseType : Inflector.singularize(res) - operation = operation.replace(/##__RESOURCE_RESPONSE_TYPE__##/g, responseType) - types.push(responseType) + operation = operation.replace(/##__RESOURCE_RESPONSE_CLASS__##/g, responseType) + if (!types.includes(responseType)) types.push(responseType) + } + if (op.relationship) { + operation = operation.replace(/##__RELATIONSHIP_TYPE__##/g, op.relationship.type) + operation = operation.replace(/##__RELATIONSHIP_PATH__##/g, op.path.substring(1).replace('{', '${')) + operation = operation.replace(/##__RESOURCE_ID__##/g, op.id || 'id') } operation = operation.replace(/\n/g, '\n\t') diff --git a/gen/schema.ts b/gen/schema.ts index 721f2ea6..4316320b 100644 --- a/gen/schema.ts +++ b/gen/schema.ts @@ -1,8 +1,10 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ /* eslint-disable no-console */ -import fs from 'fs' -import _ from 'lodash' +import { readFileSync, writeFileSync } from 'fs' +import { camelCase, capitalize, snakeCase } from 'lodash' import axios from 'axios' +import { inspect } from 'util' + // eslint-disable-next-line @typescript-eslint/no-var-requires const Inflector = require('inflector-js') @@ -19,7 +21,7 @@ const downloadSchema = async (url?: string): Promise => { const response = await axios.get(schemaUrl) const schema = await response.data - if (schema) fs.writeFileSync(schemaOutPath, JSON.stringify(schema, null, 4)) + if (schema) writeFileSync(schemaOutPath, JSON.stringify(schema, null, 4)) else console.log ('OpenAPI schema is empty!') console.log('OpenAPI schema downloaded: ' + schema.info.version) @@ -36,7 +38,7 @@ const parseSchema = (path: string): { version: string, resources: ResourceMap, c const apiSchema: any = {} const schemaFile = path - const openApi = fs.readFileSync(schemaFile, { encoding: 'utf-8' }) as any + const openApi = readFileSync(schemaFile, { encoding: 'utf-8' }) as any const schema = JSON.parse(openApi) @@ -54,7 +56,7 @@ const parseSchema = (path: string): { version: string, resources: ResourceMap, c components: {} } Object.keys(apiSchema.components).forEach(c => { - const resName = _.snakeCase(c.replace('Update', '').replace('Create', '')) + const resName = snakeCase(c.replace('Update', '').replace('Create', '')) if (!c.endsWith('Update') && !c.endsWith('Create')) components[c] = apiSchema.components[c] if (resName === Inflector.singularize(p)) resources[p].components[c] = apiSchema.components[c] }) @@ -68,9 +70,9 @@ const parseSchema = (path: string): { version: string, resources: ResourceMap, c } -const basicOperationName = (op: string, id?: string): string => { +const operationName = (op: string, id?: string, relationship?: string): string => { switch (op) { - case 'get': return id ? 'retrieve' : 'list' + case 'get': return id ? (relationship || 'retrieve') : 'list' case 'patch': return 'update' case 'delete': return 'delete' case 'post': return 'create' @@ -97,16 +99,20 @@ const parsePaths = (schemaPaths: any[]): PathMap => { for (const p of Object.entries(schemaPaths)) { const [pKey, pValue] = p - if (pKey.indexOf('}/') > -1) continue + const relIdx = pKey.indexOf('}/') + 2 + const relationship = (relIdx > 1) ? pKey.substring(relIdx) : undefined const id = pKey.substring(pKey.indexOf('{') + 1, pKey.indexOf('}')) - const path = pKey.replace(/\/{.*}/g, '') - const res = path.substr(1) - + const path = pKey.replace(/\/{.*}/g, '').substring(1) + const slIdx = path.lastIndexOf('/') + const res = (slIdx === -1) ? path : path.substring(0, slIdx) + const operations: OperationMap = paths[res] || {} Object.entries(pValue as object).forEach(o => { + let skip = false + const [oKey, oValue] = o const singleton = oValue.tags.includes('singleton') @@ -114,8 +120,8 @@ const parsePaths = (schemaPaths: any[]): PathMap => { const op: Operation = { path: pKey, type: oKey, - name: basicOperationName(oKey, id), - singleton + name: operationName(oKey, id, relationship), + singleton, } if (id) op.id = id @@ -130,7 +136,31 @@ const parsePaths = (schemaPaths: any[]): PathMap => { op.responseType = referenceContent(oValue.responses['200'].content) } - operations[op.name] = op + + if (relationship) { + + const relCard = oValue.tags[0] as string + if (!relCard) console.log(`Relationship without cardinality: ${op.name} [${op.path}]`) + const relType = oValue.tags[1] as string + if (!relType) console.log(`Relationship without type: ${op.name} [${op.path}]`) + if (!relCard || ! relType) skip = true + + if (!skip) { + op.relationship = { + name: relationship || '', + type: relType, + polymorphic: false, + cardinality: (relCard === 'has_many') ? Cardinality.to_many : Cardinality.to_one, + required: false, + deprecated: false + } + op.responseType = Inflector.camelize(Inflector.singularize(op.relationship.type)) + } + } + + + if (skip) console.log(`Operation skipped: ${op.name} [${op.path}]`) + else operations[op.name] = op }) @@ -248,8 +278,9 @@ type Operation = { id?: string name: string requestType?: any - responseType?: any, + responseType?: any singleton: boolean + relationship?: Relationship } diff --git a/gen/templates/create.tpl b/gen/templates/create.tpl index c2716708..25e47024 100644 --- a/gen/templates/create.tpl +++ b/gen/templates/create.tpl @@ -1,3 +1,3 @@ -async create(resource: ##__RESOURCE_REQUEST_TYPE__##, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<##__RESOURCE_RESPONSE_TYPE__##> { +async create(resource: ##__RESOURCE_REQUEST_CLASS__##, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<##__RESOURCE_RESPONSE_CLASS__##> { return this.resources.create({ ...resource, type: ##__RESOURCE_CLASS__##.TYPE }, params, options) } \ No newline at end of file diff --git a/gen/templates/delete.tpl b/gen/templates/delete.tpl index 36605993..3d62d173 100644 --- a/gen/templates/delete.tpl +++ b/gen/templates/delete.tpl @@ -1,3 +1,3 @@ async delete(id: string, options?: ResourcesConfig): Promise { await this.resources.delete({ type: ##__RESOURCE_CLASS__##.TYPE, id }, options) -} +} \ No newline at end of file diff --git a/gen/templates/list.tpl b/gen/templates/list.tpl index 4f0ab250..666b1c7c 100644 --- a/gen/templates/list.tpl +++ b/gen/templates/list.tpl @@ -1,3 +1,3 @@ -async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: ##__RESOURCE_CLASS__##.TYPE }, params, options) +async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.list<##__RESOURCE_RESPONSE_CLASS__##>({ type: ##__RESOURCE_CLASS__##.TYPE }, params, options) } \ No newline at end of file diff --git a/gen/templates/relationship_many.tpl b/gen/templates/relationship_many.tpl new file mode 100644 index 00000000..aeea0e6f --- /dev/null +++ b/gen/templates/relationship_many.tpl @@ -0,0 +1,3 @@ +async ##__OPERATION_NAME__##(##__RESOURCE_ID__##: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch<##__RESOURCE_RESPONSE_CLASS__##>({ type: '##__RELATIONSHIP_TYPE__##' }, `##__RELATIONSHIP_PATH__##`, params, options) as unknown as ListResponse<##__RESOURCE_RESPONSE_CLASS__##> +} \ No newline at end of file diff --git a/gen/templates/relationship_one.tpl b/gen/templates/relationship_one.tpl new file mode 100644 index 00000000..c749674d --- /dev/null +++ b/gen/templates/relationship_one.tpl @@ -0,0 +1,3 @@ +async ##__OPERATION_NAME__##(##__RESOURCE_ID__##: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<##__RESOURCE_RESPONSE_CLASS__##> { + return this.resources.fetch<##__RESOURCE_RESPONSE_CLASS__##>({ type: '##__RELATIONSHIP_TYPE__##' }, `##__RELATIONSHIP_PATH__##`, params, options) as unknown as ##__RESOURCE_RESPONSE_CLASS__## +} \ No newline at end of file diff --git a/gen/templates/retrieve.tpl b/gen/templates/retrieve.tpl index 914ccb5c..98f67177 100644 --- a/gen/templates/retrieve.tpl +++ b/gen/templates/retrieve.tpl @@ -1,3 +1,3 @@ -async retrieve(id: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<##__RESOURCE_RESPONSE_TYPE__##> { - return this.resources.retrieve<##__RESOURCE_RESPONSE_TYPE__##>({ type: ##__RESOURCE_CLASS__##.TYPE, id }, params, options) +async retrieve(id: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<##__RESOURCE_RESPONSE_CLASS__##> { + return this.resources.retrieve<##__RESOURCE_RESPONSE_CLASS__##>({ type: ##__RESOURCE_CLASS__##.TYPE, id }, params, options) } \ No newline at end of file diff --git a/gen/templates/singleton.tpl b/gen/templates/singleton.tpl index e5621622..c6387324 100644 --- a/gen/templates/singleton.tpl +++ b/gen/templates/singleton.tpl @@ -1,3 +1,3 @@ -async retrieve(params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<##__RESOURCE_RESPONSE_TYPE__##> { - return this.resources.singleton<##__RESOURCE_RESPONSE_TYPE__##>({ type: ##__RESOURCE_CLASS__##.TYPE }, params, options) +async retrieve(params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<##__RESOURCE_RESPONSE_CLASS__##> { + return this.resources.singleton<##__RESOURCE_RESPONSE_CLASS__##>({ type: ##__RESOURCE_CLASS__##.TYPE }, params, options) } \ No newline at end of file diff --git a/gen/templates/spec.tpl b/gen/templates/spec.tpl index 5bfe7f49..7020d3bd 100644 --- a/gen/templates/spec.tpl +++ b/gen/templates/spec.tpl @@ -165,4 +165,5 @@ describe('##__RESOURCE_CLASS__## resource', () => { }) /* spec.type.stop */ + ##__RELATIONSHIP_SPECS__## }) diff --git a/gen/templates/spec_relationship.tpl b/gen/templates/spec_relationship.tpl new file mode 100644 index 00000000..bd136ed2 --- /dev/null +++ b/gen/templates/spec_relationship.tpl @@ -0,0 +1,17 @@ +it(resourceType + '.##__OPERATION_NAME__##', async () => { + + const id = TestData.id + const params = { fields: { ##__RELATIONSHIP_TYPE__##: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, '##__OPERATION_NAME__##') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].##__OPERATION_NAME__##(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + +}) \ No newline at end of file diff --git a/gen/templates/update.tpl b/gen/templates/update.tpl index 585fcef7..76a4f862 100644 --- a/gen/templates/update.tpl +++ b/gen/templates/update.tpl @@ -1,3 +1,3 @@ -async update(resource: ##__RESOURCE_REQUEST_TYPE__##, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<##__RESOURCE_RESPONSE_TYPE__##> { +async update(resource: ##__RESOURCE_REQUEST_CLASS__##, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise<##__RESOURCE_RESPONSE_CLASS__##> { return this.resources.update({ ...resource, type: ##__RESOURCE_CLASS__##.TYPE }, params, options) } \ No newline at end of file diff --git a/specs/resources/addresses.spec.ts b/specs/resources/addresses.spec.ts index 01290d3c..ac27c4a0 100644 --- a/specs/resources/addresses.spec.ts +++ b/specs/resources/addresses.spec.ts @@ -25,11 +25,11 @@ describe('Addresses resource', () => { it(resourceType + '.create', async () => { const createAttributes = { - line_1: 'omega_68', - city: 'epsilon_22', - state_code: 'kappa_82', - country_code: 'sigma_69', - phone: 'alfa_10', + line_1: 'gamma_69', + city: 'alfa_29', + state_code: 'lambda_32', + country_code: 'lambda_65', + phone: 'beta_0', geocoder: cl.geocoders.relationship(TestData.id), } @@ -153,4 +153,24 @@ describe('Addresses resource', () => { }) /* spec.type.stop */ + + + it(resourceType + '.geocoder', async () => { + + const id = TestData.id + const params = { fields: { geocoders: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'geocoder') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].geocoder(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + }) diff --git a/specs/resources/adjustments.spec.ts b/specs/resources/adjustments.spec.ts index 57a118a6..0ee65362 100644 --- a/specs/resources/adjustments.spec.ts +++ b/specs/resources/adjustments.spec.ts @@ -25,9 +25,9 @@ describe('Adjustments resource', () => { it(resourceType + '.create', async () => { const createAttributes = { - name: 'delta_79', - currency_code: 'kappa_7', - amount_cents: 555, + name: 'sigma_35', + currency_code: 'delta_59', + amount_cents: 12345, } const attributes = { ...createAttributes, reference: TestData.reference } @@ -150,4 +150,5 @@ describe('Adjustments resource', () => { }) /* spec.type.stop */ + }) diff --git a/specs/resources/adyen_gateways.spec.ts b/specs/resources/adyen_gateways.spec.ts index ea9db7d3..84ddc4a9 100644 --- a/specs/resources/adyen_gateways.spec.ts +++ b/specs/resources/adyen_gateways.spec.ts @@ -25,10 +25,10 @@ describe('AdyenGateways resource', () => { it(resourceType + '.create', async () => { const createAttributes = { - name: 'epsilon_33', - merchant_account: 'delta_20', - api_key: 'gamma_82', - live_url_prefix: 'lambda_10', + name: 'sigma_9', + merchant_account: 'lambda_28', + api_key: 'lambda_97', + live_url_prefix: 'epsilon_20', adyen_payments: [ cl.adyen_payments.relationship(TestData.id) ], } @@ -152,4 +152,43 @@ describe('AdyenGateways resource', () => { }) /* spec.type.stop */ + + + it(resourceType + '.payment_methods', async () => { + + const id = TestData.id + const params = { fields: { payment_methods: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'payment_methods') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].payment_methods(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.adyen_payments', async () => { + + const id = TestData.id + const params = { fields: { adyen_payments: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'adyen_payments') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].adyen_payments(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + }) diff --git a/specs/resources/adyen_payments.spec.ts b/specs/resources/adyen_payments.spec.ts index c55c32de..f531c0c3 100644 --- a/specs/resources/adyen_payments.spec.ts +++ b/specs/resources/adyen_payments.spec.ts @@ -148,4 +148,43 @@ describe('AdyenPayments resource', () => { }) /* spec.type.stop */ + + + it(resourceType + '.order', async () => { + + const id = TestData.id + const params = { fields: { orders: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'order') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].order(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.payment_gateway', async () => { + + const id = TestData.id + const params = { fields: { payment_gateways: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'payment_gateway') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].payment_gateway(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + }) diff --git a/specs/resources/application.spec.ts b/specs/resources/application.spec.ts index 1c78d4ed..74e44988 100644 --- a/specs/resources/application.spec.ts +++ b/specs/resources/application.spec.ts @@ -59,4 +59,5 @@ describe('Applications resource', () => { }) /* spec.type.stop */ + }) diff --git a/specs/resources/attachments.spec.ts b/specs/resources/attachments.spec.ts index 66d34b91..29f66b14 100644 --- a/specs/resources/attachments.spec.ts +++ b/specs/resources/attachments.spec.ts @@ -25,7 +25,7 @@ describe('Attachments resource', () => { it(resourceType + '.create', async () => { const createAttributes = { - name: 'gamma_25', + name: 'lambda_88', attachable: cl.bundles.relationship(TestData.id), } @@ -149,4 +149,5 @@ describe('Attachments resource', () => { }) /* spec.type.stop */ + }) diff --git a/specs/resources/authorizations.spec.ts b/specs/resources/authorizations.spec.ts index d32110a3..9be0d287 100644 --- a/specs/resources/authorizations.spec.ts +++ b/specs/resources/authorizations.spec.ts @@ -102,4 +102,62 @@ describe('Authorizations resource', () => { }) /* spec.type.stop */ + + + it(resourceType + '.order', async () => { + + const id = TestData.id + const params = { fields: { orders: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'order') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].order(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.captures', async () => { + + const id = TestData.id + const params = { fields: { captures: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'captures') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].captures(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.voids', async () => { + + const id = TestData.id + const params = { fields: { voids: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'voids') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].voids(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + }) diff --git a/specs/resources/avalara_accounts.spec.ts b/specs/resources/avalara_accounts.spec.ts index 6fef7905..6cb2cb96 100644 --- a/specs/resources/avalara_accounts.spec.ts +++ b/specs/resources/avalara_accounts.spec.ts @@ -25,10 +25,10 @@ describe('AvalaraAccounts resource', () => { it(resourceType + '.create', async () => { const createAttributes = { - name: 'delta_63', - username: 'sigma_23', - password: 'kappa_14', - company_code: 'lambda_74', + name: 'alfa_55', + username: 'lambda_52', + password: 'gamma_51', + company_code: 'epsilon_91', tax_categories: [ cl.tax_categories.relationship(TestData.id) ], } @@ -152,4 +152,62 @@ describe('AvalaraAccounts resource', () => { }) /* spec.type.stop */ + + + it(resourceType + '.tax_categories', async () => { + + const id = TestData.id + const params = { fields: { tax_categories: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'tax_categories') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].tax_categories(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.markets', async () => { + + const id = TestData.id + const params = { fields: { markets: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'markets') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].markets(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.attachments', async () => { + + const id = TestData.id + const params = { fields: { attachments: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'attachments') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].attachments(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + }) diff --git a/specs/resources/billing_info_validation_rules.spec.ts b/specs/resources/billing_info_validation_rules.spec.ts index 6dad7108..749641f2 100644 --- a/specs/resources/billing_info_validation_rules.spec.ts +++ b/specs/resources/billing_info_validation_rules.spec.ts @@ -148,4 +148,24 @@ describe('BillingInfoValidationRules resource', () => { }) /* spec.type.stop */ + + + it(resourceType + '.market', async () => { + + const id = TestData.id + const params = { fields: { markets: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'market') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].market(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + }) diff --git a/specs/resources/bing_geocoders.spec.ts b/specs/resources/bing_geocoders.spec.ts index 7e21ea6d..0cb70394 100644 --- a/specs/resources/bing_geocoders.spec.ts +++ b/specs/resources/bing_geocoders.spec.ts @@ -25,8 +25,8 @@ describe('BingGeocoders resource', () => { it(resourceType + '.create', async () => { const createAttributes = { - name: 'kappa_68', - key: 'epsilon_53', + name: 'omega_14', + key: 'kappa_72', } const attributes = { ...createAttributes, reference: TestData.reference } @@ -149,4 +149,43 @@ describe('BingGeocoders resource', () => { }) /* spec.type.stop */ + + + it(resourceType + '.addresses', async () => { + + const id = TestData.id + const params = { fields: { addresses: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'addresses') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].addresses(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.attachments', async () => { + + const id = TestData.id + const params = { fields: { attachments: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'attachments') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].attachments(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + }) diff --git a/specs/resources/braintree_gateways.spec.ts b/specs/resources/braintree_gateways.spec.ts index 6cd96a47..730489fc 100644 --- a/specs/resources/braintree_gateways.spec.ts +++ b/specs/resources/braintree_gateways.spec.ts @@ -25,11 +25,11 @@ describe('BraintreeGateways resource', () => { it(resourceType + '.create', async () => { const createAttributes = { - name: 'alfa_27', - merchant_account_id: 'epsilon_45', - merchant_id: 'kappa_54', - public_key: 'gamma_64', - private_key: 'epsilon_38', + name: 'lambda_22', + merchant_account_id: 'epsilon_93', + merchant_id: 'beta_73', + public_key: 'omega_43', + private_key: 'alfa_48', braintree_payments: [ cl.braintree_payments.relationship(TestData.id) ], } @@ -153,4 +153,43 @@ describe('BraintreeGateways resource', () => { }) /* spec.type.stop */ + + + it(resourceType + '.payment_methods', async () => { + + const id = TestData.id + const params = { fields: { payment_methods: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'payment_methods') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].payment_methods(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.braintree_payments', async () => { + + const id = TestData.id + const params = { fields: { braintree_payments: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'braintree_payments') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].braintree_payments(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + }) diff --git a/specs/resources/braintree_payments.spec.ts b/specs/resources/braintree_payments.spec.ts index 15213f76..9d5e17d0 100644 --- a/specs/resources/braintree_payments.spec.ts +++ b/specs/resources/braintree_payments.spec.ts @@ -148,4 +148,43 @@ describe('BraintreePayments resource', () => { }) /* spec.type.stop */ + + + it(resourceType + '.order', async () => { + + const id = TestData.id + const params = { fields: { orders: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'order') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].order(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.payment_gateway', async () => { + + const id = TestData.id + const params = { fields: { payment_gateways: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'payment_gateway') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].payment_gateway(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + }) diff --git a/specs/resources/bundles.spec.ts b/specs/resources/bundles.spec.ts index 0dfdfcf7..1880dab1 100644 --- a/specs/resources/bundles.spec.ts +++ b/specs/resources/bundles.spec.ts @@ -25,10 +25,10 @@ describe('Bundles resource', () => { it(resourceType + '.create', async () => { const createAttributes = { - code: 'kappa_58', - name: 'beta_4', - price_amount_cents: 55, - compare_at_amount_cents: 1, + code: 'delta_90', + name: 'omega_39', + price_amount_cents: 0, + compare_at_amount_cents: 555, market: cl.markets.relationship(TestData.id), sku_list: cl.sku_lists.relationship(TestData.id), } @@ -153,4 +153,81 @@ describe('Bundles resource', () => { }) /* spec.type.stop */ + + + it(resourceType + '.market', async () => { + + const id = TestData.id + const params = { fields: { markets: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'market') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].market(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.sku_list', async () => { + + const id = TestData.id + const params = { fields: { sku_lists: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'sku_list') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].sku_list(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.skus', async () => { + + const id = TestData.id + const params = { fields: { skus: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'skus') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].skus(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.attachments', async () => { + + const id = TestData.id + const params = { fields: { attachments: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'attachments') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].attachments(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + }) diff --git a/specs/resources/captures.spec.ts b/specs/resources/captures.spec.ts index a5ee6dd9..64c2f7fc 100644 --- a/specs/resources/captures.spec.ts +++ b/specs/resources/captures.spec.ts @@ -102,4 +102,62 @@ describe('Captures resource', () => { }) /* spec.type.stop */ + + + it(resourceType + '.order', async () => { + + const id = TestData.id + const params = { fields: { orders: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'order') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].order(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.reference_authorization', async () => { + + const id = TestData.id + const params = { fields: { authorizations: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'reference_authorization') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].reference_authorization(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.refunds', async () => { + + const id = TestData.id + const params = { fields: { refunds: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'refunds') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].refunds(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + }) diff --git a/specs/resources/carrier_accounts.spec.ts b/specs/resources/carrier_accounts.spec.ts index 649ce2a7..19402dc8 100644 --- a/specs/resources/carrier_accounts.spec.ts +++ b/specs/resources/carrier_accounts.spec.ts @@ -80,4 +80,43 @@ describe('CarrierAccounts resource', () => { }) /* spec.type.stop */ + + + it(resourceType + '.market', async () => { + + const id = TestData.id + const params = { fields: { markets: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'market') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].market(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.attachments', async () => { + + const id = TestData.id + const params = { fields: { attachments: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'attachments') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].attachments(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + }) diff --git a/specs/resources/checkout_com_gateways.spec.ts b/specs/resources/checkout_com_gateways.spec.ts index 9a2ae050..b086b631 100644 --- a/specs/resources/checkout_com_gateways.spec.ts +++ b/specs/resources/checkout_com_gateways.spec.ts @@ -25,9 +25,9 @@ describe('CheckoutComGateways resource', () => { it(resourceType + '.create', async () => { const createAttributes = { - name: 'delta_57', - secret_key: 'sigma_37', - public_key: 'kappa_58', + name: 'delta_96', + secret_key: 'gamma_62', + public_key: 'lambda_62', checkout_com_payments: [ cl.checkout_com_payments.relationship(TestData.id) ], } @@ -151,4 +151,43 @@ describe('CheckoutComGateways resource', () => { }) /* spec.type.stop */ + + + it(resourceType + '.payment_methods', async () => { + + const id = TestData.id + const params = { fields: { payment_methods: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'payment_methods') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].payment_methods(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.checkout_com_payments', async () => { + + const id = TestData.id + const params = { fields: { checkout_com_payments: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'checkout_com_payments') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].checkout_com_payments(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + }) diff --git a/specs/resources/checkout_com_payments.spec.ts b/specs/resources/checkout_com_payments.spec.ts index ee297e37..86d63538 100644 --- a/specs/resources/checkout_com_payments.spec.ts +++ b/specs/resources/checkout_com_payments.spec.ts @@ -25,8 +25,8 @@ describe('CheckoutComPayments resource', () => { it(resourceType + '.create', async () => { const createAttributes = { - payment_type: 'epsilon_80', - token: 'epsilon_3', + payment_type: 'kappa_2', + token: 'delta_34', order: cl.orders.relationship(TestData.id), } @@ -150,4 +150,43 @@ describe('CheckoutComPayments resource', () => { }) /* spec.type.stop */ + + + it(resourceType + '.order', async () => { + + const id = TestData.id + const params = { fields: { orders: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'order') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].order(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.payment_gateway', async () => { + + const id = TestData.id + const params = { fields: { payment_gateways: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'payment_gateway') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].payment_gateway(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + }) diff --git a/specs/resources/coupon_codes_promotion_rules.spec.ts b/specs/resources/coupon_codes_promotion_rules.spec.ts index 2171a624..bdfb0cd0 100644 --- a/specs/resources/coupon_codes_promotion_rules.spec.ts +++ b/specs/resources/coupon_codes_promotion_rules.spec.ts @@ -149,4 +149,24 @@ describe('CouponCodesPromotionRules resource', () => { }) /* spec.type.stop */ + + + it(resourceType + '.coupons', async () => { + + const id = TestData.id + const params = { fields: { coupons: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'coupons') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].coupons(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + }) diff --git a/specs/resources/coupon_recipients.spec.ts b/specs/resources/coupon_recipients.spec.ts index 0780ed92..e191a9a1 100644 --- a/specs/resources/coupon_recipients.spec.ts +++ b/specs/resources/coupon_recipients.spec.ts @@ -25,7 +25,7 @@ describe('CouponRecipients resource', () => { it(resourceType + '.create', async () => { const createAttributes = { - email: 'lambda_47', + email: 'epsilon_90', customer: cl.customers.relationship(TestData.id), } @@ -149,4 +149,43 @@ describe('CouponRecipients resource', () => { }) /* spec.type.stop */ + + + it(resourceType + '.customer', async () => { + + const id = TestData.id + const params = { fields: { customers: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'customer') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].customer(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.attachments', async () => { + + const id = TestData.id + const params = { fields: { attachments: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'attachments') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].attachments(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + }) diff --git a/specs/resources/coupons.spec.ts b/specs/resources/coupons.spec.ts index f2e47d3c..fee95377 100644 --- a/specs/resources/coupons.spec.ts +++ b/specs/resources/coupons.spec.ts @@ -25,8 +25,8 @@ describe('Coupons resource', () => { it(resourceType + '.create', async () => { const createAttributes = { - code: 'epsilon_46', - usage_limit: 100, + code: 'gamma_21', + usage_limit: 12345, promotion_rule: cl.coupon_codes_promotion_rules.relationship(TestData.id), } @@ -150,4 +150,24 @@ describe('Coupons resource', () => { }) /* spec.type.stop */ + + + it(resourceType + '.promotion_rule', async () => { + + const id = TestData.id + const params = { fields: { coupon_codes_promotion_rules: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'promotion_rule') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].promotion_rule(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + }) diff --git a/specs/resources/customer_addresses.spec.ts b/specs/resources/customer_addresses.spec.ts index 344c9aa4..d77b6a9e 100644 --- a/specs/resources/customer_addresses.spec.ts +++ b/specs/resources/customer_addresses.spec.ts @@ -149,4 +149,43 @@ describe('CustomerAddresses resource', () => { }) /* spec.type.stop */ + + + it(resourceType + '.customer', async () => { + + const id = TestData.id + const params = { fields: { customers: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'customer') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].customer(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.address', async () => { + + const id = TestData.id + const params = { fields: { addresses: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'address') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].address(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + }) diff --git a/specs/resources/customer_groups.spec.ts b/specs/resources/customer_groups.spec.ts index 0a4e74eb..0f04798b 100644 --- a/specs/resources/customer_groups.spec.ts +++ b/specs/resources/customer_groups.spec.ts @@ -25,7 +25,7 @@ describe('CustomerGroups resource', () => { it(resourceType + '.create', async () => { const createAttributes = { - name: 'beta_78', + name: 'sigma_38', } const attributes = { ...createAttributes, reference: TestData.reference } @@ -148,4 +148,62 @@ describe('CustomerGroups resource', () => { }) /* spec.type.stop */ + + + it(resourceType + '.customers', async () => { + + const id = TestData.id + const params = { fields: { customers: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'customers') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].customers(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.markets', async () => { + + const id = TestData.id + const params = { fields: { markets: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'markets') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].markets(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.attachments', async () => { + + const id = TestData.id + const params = { fields: { attachments: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'attachments') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].attachments(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + }) diff --git a/specs/resources/customer_password_resets.spec.ts b/specs/resources/customer_password_resets.spec.ts index 8aa62fe4..b5e320b6 100644 --- a/specs/resources/customer_password_resets.spec.ts +++ b/specs/resources/customer_password_resets.spec.ts @@ -25,7 +25,7 @@ describe('CustomerPasswordResets resource', () => { it(resourceType + '.create', async () => { const createAttributes = { - customer_email: 'kappa_29', + customer_email: 'gamma_68', } const attributes = { ...createAttributes, reference: TestData.reference } @@ -148,4 +148,24 @@ describe('CustomerPasswordResets resource', () => { }) /* spec.type.stop */ + + + it(resourceType + '.customer', async () => { + + const id = TestData.id + const params = { fields: { customers: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'customer') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].customer(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + }) diff --git a/specs/resources/customer_payment_sources.spec.ts b/specs/resources/customer_payment_sources.spec.ts index 6e98ebba..abe70ae4 100644 --- a/specs/resources/customer_payment_sources.spec.ts +++ b/specs/resources/customer_payment_sources.spec.ts @@ -149,4 +149,24 @@ describe('CustomerPaymentSources resource', () => { }) /* spec.type.stop */ + + + it(resourceType + '.customer', async () => { + + const id = TestData.id + const params = { fields: { customers: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'customer') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].customer(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + }) diff --git a/specs/resources/customer_subscriptions.spec.ts b/specs/resources/customer_subscriptions.spec.ts index c28ae731..6caf6d7b 100644 --- a/specs/resources/customer_subscriptions.spec.ts +++ b/specs/resources/customer_subscriptions.spec.ts @@ -25,7 +25,7 @@ describe('CustomerSubscriptions resource', () => { it(resourceType + '.create', async () => { const createAttributes = { - customer_email: 'gamma_53', + customer_email: 'kappa_7', } const attributes = { ...createAttributes, reference: TestData.reference } @@ -148,4 +148,24 @@ describe('CustomerSubscriptions resource', () => { }) /* spec.type.stop */ + + + it(resourceType + '.customer', async () => { + + const id = TestData.id + const params = { fields: { customers: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'customer') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].customer(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + }) diff --git a/specs/resources/customers.spec.ts b/specs/resources/customers.spec.ts index 29c5c49f..aa1997cb 100644 --- a/specs/resources/customers.spec.ts +++ b/specs/resources/customers.spec.ts @@ -25,7 +25,7 @@ describe('Customers resource', () => { it(resourceType + '.create', async () => { const createAttributes = { - email: 'beta_2', + email: 'lambda_39', customer_group: cl.customer_groups.relationship(TestData.id), } @@ -149,4 +149,157 @@ describe('Customers resource', () => { }) /* spec.type.stop */ + + + it(resourceType + '.customer_group', async () => { + + const id = TestData.id + const params = { fields: { customer_groups: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'customer_group') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].customer_group(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.customer_addresses', async () => { + + const id = TestData.id + const params = { fields: { customer_addresses: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'customer_addresses') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].customer_addresses(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.customer_payment_sources', async () => { + + const id = TestData.id + const params = { fields: { customer_payment_sources: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'customer_payment_sources') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].customer_payment_sources(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.customer_subscriptions', async () => { + + const id = TestData.id + const params = { fields: { customer_subscriptions: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'customer_subscriptions') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].customer_subscriptions(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.orders', async () => { + + const id = TestData.id + const params = { fields: { orders: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'orders') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].orders(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.order_subscriptions', async () => { + + const id = TestData.id + const params = { fields: { order_subscriptions: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'order_subscriptions') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].order_subscriptions(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.returns', async () => { + + const id = TestData.id + const params = { fields: { returns: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'returns') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].returns(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.attachments', async () => { + + const id = TestData.id + const params = { fields: { attachments: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'attachments') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].attachments(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + }) diff --git a/specs/resources/delivery_lead_times.spec.ts b/specs/resources/delivery_lead_times.spec.ts index 8c44584b..1a4232e8 100644 --- a/specs/resources/delivery_lead_times.spec.ts +++ b/specs/resources/delivery_lead_times.spec.ts @@ -25,8 +25,8 @@ describe('DeliveryLeadTimes resource', () => { it(resourceType + '.create', async () => { const createAttributes = { - min_hours: 1, - max_hours: 100, + min_hours: 5, + max_hours: 12345, stock_location: cl.stock_locations.relationship(TestData.id), shipping_method: cl.shipping_methods.relationship(TestData.id), } @@ -151,4 +151,62 @@ describe('DeliveryLeadTimes resource', () => { }) /* spec.type.stop */ + + + it(resourceType + '.stock_location', async () => { + + const id = TestData.id + const params = { fields: { stock_locations: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'stock_location') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].stock_location(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.shipping_method', async () => { + + const id = TestData.id + const params = { fields: { shipping_methods: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'shipping_method') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].shipping_method(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.attachments', async () => { + + const id = TestData.id + const params = { fields: { attachments: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'attachments') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].attachments(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + }) diff --git a/specs/resources/event_callbacks.spec.ts b/specs/resources/event_callbacks.spec.ts index cc7637d8..b0504671 100644 --- a/specs/resources/event_callbacks.spec.ts +++ b/specs/resources/event_callbacks.spec.ts @@ -80,4 +80,24 @@ describe('EventCallbacks resource', () => { }) /* spec.type.stop */ + + + it(resourceType + '.webhook', async () => { + + const id = TestData.id + const params = { fields: { webhooks: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'webhook') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].webhook(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + }) diff --git a/specs/resources/external_gateways.spec.ts b/specs/resources/external_gateways.spec.ts index 598f0f22..d1993d7c 100644 --- a/specs/resources/external_gateways.spec.ts +++ b/specs/resources/external_gateways.spec.ts @@ -25,7 +25,7 @@ describe('ExternalGateways resource', () => { it(resourceType + '.create', async () => { const createAttributes = { - name: 'lambda_31', + name: 'epsilon_46', } const attributes = { ...createAttributes, reference: TestData.reference } @@ -148,4 +148,43 @@ describe('ExternalGateways resource', () => { }) /* spec.type.stop */ + + + it(resourceType + '.payment_methods', async () => { + + const id = TestData.id + const params = { fields: { payment_methods: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'payment_methods') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].payment_methods(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.external_payments', async () => { + + const id = TestData.id + const params = { fields: { external_payments: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'external_payments') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].external_payments(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + }) diff --git a/specs/resources/external_payments.spec.ts b/specs/resources/external_payments.spec.ts index e584eced..5500ad22 100644 --- a/specs/resources/external_payments.spec.ts +++ b/specs/resources/external_payments.spec.ts @@ -25,7 +25,7 @@ describe('ExternalPayments resource', () => { it(resourceType + '.create', async () => { const createAttributes = { - payment_source_token: 'sigma_2', + payment_source_token: 'epsilon_96', order: cl.orders.relationship(TestData.id), } @@ -149,4 +149,62 @@ describe('ExternalPayments resource', () => { }) /* spec.type.stop */ + + + it(resourceType + '.order', async () => { + + const id = TestData.id + const params = { fields: { orders: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'order') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].order(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.payment_gateway', async () => { + + const id = TestData.id + const params = { fields: { payment_gateways: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'payment_gateway') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].payment_gateway(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.wallet', async () => { + + const id = TestData.id + const params = { fields: { customer_payment_sources: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'wallet') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].wallet(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + }) diff --git a/specs/resources/external_promotions.spec.ts b/specs/resources/external_promotions.spec.ts index 1fd01f57..e3731a4e 100644 --- a/specs/resources/external_promotions.spec.ts +++ b/specs/resources/external_promotions.spec.ts @@ -25,11 +25,11 @@ describe('ExternalPromotions resource', () => { it(resourceType + '.create', async () => { const createAttributes = { - name: 'kappa_89', - starts_at: 'gamma_6', - expires_at: 'omega_97', - total_usage_limit: 5, - promotion_url: 'sigma_23', + name: 'lambda_15', + starts_at: 'epsilon_45', + expires_at: 'kappa_78', + total_usage_limit: 1000, + promotion_url: 'delta_83', market: cl.markets.relationship(TestData.id), promotion_rules: [ cl.promotion_rules.relationship(TestData.id) ], order_amount_promotion_rule: cl.order_amount_promotion_rules.relationship(TestData.id), @@ -157,4 +157,100 @@ describe('ExternalPromotions resource', () => { }) /* spec.type.stop */ + + + it(resourceType + '.market', async () => { + + const id = TestData.id + const params = { fields: { markets: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'market') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].market(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.order_amount_promotion_rule', async () => { + + const id = TestData.id + const params = { fields: { order_amount_promotion_rules: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'order_amount_promotion_rule') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].order_amount_promotion_rule(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.sku_list_promotion_rule', async () => { + + const id = TestData.id + const params = { fields: { sku_list_promotion_rules: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'sku_list_promotion_rule') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].sku_list_promotion_rule(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.coupon_codes_promotion_rule', async () => { + + const id = TestData.id + const params = { fields: { coupon_codes_promotion_rules: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'coupon_codes_promotion_rule') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].coupon_codes_promotion_rule(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.attachments', async () => { + + const id = TestData.id + const params = { fields: { attachments: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'attachments') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].attachments(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + }) diff --git a/specs/resources/external_tax_calculators.spec.ts b/specs/resources/external_tax_calculators.spec.ts index 4f042a6b..51bd7979 100644 --- a/specs/resources/external_tax_calculators.spec.ts +++ b/specs/resources/external_tax_calculators.spec.ts @@ -25,8 +25,8 @@ describe('ExternalTaxCalculators resource', () => { it(resourceType + '.create', async () => { const createAttributes = { - name: 'omega_18', - tax_calculator_url: 'delta_25', + name: 'gamma_82', + tax_calculator_url: 'sigma_60', tax_categories: [ cl.tax_categories.relationship(TestData.id) ], } @@ -150,4 +150,62 @@ describe('ExternalTaxCalculators resource', () => { }) /* spec.type.stop */ + + + it(resourceType + '.tax_categories', async () => { + + const id = TestData.id + const params = { fields: { tax_categories: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'tax_categories') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].tax_categories(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.markets', async () => { + + const id = TestData.id + const params = { fields: { markets: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'markets') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].markets(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.attachments', async () => { + + const id = TestData.id + const params = { fields: { attachments: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'attachments') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].attachments(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + }) diff --git a/specs/resources/fixed_amount_promotions.spec.ts b/specs/resources/fixed_amount_promotions.spec.ts index 8ba86880..63dd17db 100644 --- a/specs/resources/fixed_amount_promotions.spec.ts +++ b/specs/resources/fixed_amount_promotions.spec.ts @@ -25,11 +25,11 @@ describe('FixedAmountPromotions resource', () => { it(resourceType + '.create', async () => { const createAttributes = { - name: 'omega_54', - starts_at: 'delta_77', - expires_at: 'epsilon_44', - total_usage_limit: 1000, - fixed_amount_cents: 100, + name: 'beta_40', + starts_at: 'omega_89', + expires_at: 'beta_12', + total_usage_limit: 555, + fixed_amount_cents: 55, market: cl.markets.relationship(TestData.id), promotion_rules: [ cl.promotion_rules.relationship(TestData.id) ], order_amount_promotion_rule: cl.order_amount_promotion_rules.relationship(TestData.id), @@ -157,4 +157,100 @@ describe('FixedAmountPromotions resource', () => { }) /* spec.type.stop */ + + + it(resourceType + '.market', async () => { + + const id = TestData.id + const params = { fields: { markets: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'market') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].market(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.order_amount_promotion_rule', async () => { + + const id = TestData.id + const params = { fields: { order_amount_promotion_rules: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'order_amount_promotion_rule') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].order_amount_promotion_rule(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.sku_list_promotion_rule', async () => { + + const id = TestData.id + const params = { fields: { sku_list_promotion_rules: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'sku_list_promotion_rule') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].sku_list_promotion_rule(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.coupon_codes_promotion_rule', async () => { + + const id = TestData.id + const params = { fields: { coupon_codes_promotion_rules: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'coupon_codes_promotion_rule') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].coupon_codes_promotion_rule(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.attachments', async () => { + + const id = TestData.id + const params = { fields: { attachments: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'attachments') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].attachments(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + }) diff --git a/specs/resources/fixed_price_promotions.spec.ts b/specs/resources/fixed_price_promotions.spec.ts index 09d8e71b..3bd063b6 100644 --- a/specs/resources/fixed_price_promotions.spec.ts +++ b/specs/resources/fixed_price_promotions.spec.ts @@ -25,11 +25,11 @@ describe('FixedPricePromotions resource', () => { it(resourceType + '.create', async () => { const createAttributes = { - name: 'sigma_62', - starts_at: 'omega_52', - expires_at: 'lambda_6', - total_usage_limit: 555, - fixed_amount_cents: 0, + name: 'kappa_38', + starts_at: 'kappa_96', + expires_at: 'epsilon_68', + total_usage_limit: 12345, + fixed_amount_cents: 10, market: cl.markets.relationship(TestData.id), promotion_rules: [ cl.promotion_rules.relationship(TestData.id) ], order_amount_promotion_rule: cl.order_amount_promotion_rules.relationship(TestData.id), @@ -158,4 +158,138 @@ describe('FixedPricePromotions resource', () => { }) /* spec.type.stop */ + + + it(resourceType + '.market', async () => { + + const id = TestData.id + const params = { fields: { markets: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'market') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].market(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.order_amount_promotion_rule', async () => { + + const id = TestData.id + const params = { fields: { order_amount_promotion_rules: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'order_amount_promotion_rule') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].order_amount_promotion_rule(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.sku_list_promotion_rule', async () => { + + const id = TestData.id + const params = { fields: { sku_list_promotion_rules: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'sku_list_promotion_rule') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].sku_list_promotion_rule(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.coupon_codes_promotion_rule', async () => { + + const id = TestData.id + const params = { fields: { coupon_codes_promotion_rules: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'coupon_codes_promotion_rule') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].coupon_codes_promotion_rule(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.attachments', async () => { + + const id = TestData.id + const params = { fields: { attachments: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'attachments') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].attachments(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.sku_list', async () => { + + const id = TestData.id + const params = { fields: { sku_lists: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'sku_list') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].sku_list(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.skus', async () => { + + const id = TestData.id + const params = { fields: { skus: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'skus') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].skus(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + }) diff --git a/specs/resources/free_gift_promotions.spec.ts b/specs/resources/free_gift_promotions.spec.ts index 7c21a18f..e509e09c 100644 --- a/specs/resources/free_gift_promotions.spec.ts +++ b/specs/resources/free_gift_promotions.spec.ts @@ -25,10 +25,10 @@ describe('FreeGiftPromotions resource', () => { it(resourceType + '.create', async () => { const createAttributes = { - name: 'epsilon_94', - starts_at: 'epsilon_99', - expires_at: 'epsilon_68', - total_usage_limit: 1, + name: 'delta_14', + starts_at: 'omega_81', + expires_at: 'beta_42', + total_usage_limit: 5, market: cl.markets.relationship(TestData.id), promotion_rules: [ cl.promotion_rules.relationship(TestData.id) ], order_amount_promotion_rule: cl.order_amount_promotion_rules.relationship(TestData.id), @@ -157,4 +157,138 @@ describe('FreeGiftPromotions resource', () => { }) /* spec.type.stop */ + + + it(resourceType + '.market', async () => { + + const id = TestData.id + const params = { fields: { markets: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'market') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].market(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.order_amount_promotion_rule', async () => { + + const id = TestData.id + const params = { fields: { order_amount_promotion_rules: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'order_amount_promotion_rule') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].order_amount_promotion_rule(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.sku_list_promotion_rule', async () => { + + const id = TestData.id + const params = { fields: { sku_list_promotion_rules: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'sku_list_promotion_rule') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].sku_list_promotion_rule(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.coupon_codes_promotion_rule', async () => { + + const id = TestData.id + const params = { fields: { coupon_codes_promotion_rules: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'coupon_codes_promotion_rule') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].coupon_codes_promotion_rule(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.attachments', async () => { + + const id = TestData.id + const params = { fields: { attachments: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'attachments') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].attachments(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.sku_list', async () => { + + const id = TestData.id + const params = { fields: { sku_lists: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'sku_list') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].sku_list(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.skus', async () => { + + const id = TestData.id + const params = { fields: { skus: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'skus') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].skus(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + }) diff --git a/specs/resources/free_shipping_promotions.spec.ts b/specs/resources/free_shipping_promotions.spec.ts index da69de51..766053e2 100644 --- a/specs/resources/free_shipping_promotions.spec.ts +++ b/specs/resources/free_shipping_promotions.spec.ts @@ -25,10 +25,10 @@ describe('FreeShippingPromotions resource', () => { it(resourceType + '.create', async () => { const createAttributes = { - name: 'kappa_19', - starts_at: 'delta_1', - expires_at: 'kappa_55', - total_usage_limit: 10, + name: 'omega_86', + starts_at: 'gamma_57', + expires_at: 'epsilon_77', + total_usage_limit: 555, market: cl.markets.relationship(TestData.id), promotion_rules: [ cl.promotion_rules.relationship(TestData.id) ], order_amount_promotion_rule: cl.order_amount_promotion_rules.relationship(TestData.id), @@ -156,4 +156,100 @@ describe('FreeShippingPromotions resource', () => { }) /* spec.type.stop */ + + + it(resourceType + '.market', async () => { + + const id = TestData.id + const params = { fields: { markets: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'market') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].market(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.order_amount_promotion_rule', async () => { + + const id = TestData.id + const params = { fields: { order_amount_promotion_rules: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'order_amount_promotion_rule') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].order_amount_promotion_rule(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.sku_list_promotion_rule', async () => { + + const id = TestData.id + const params = { fields: { sku_list_promotion_rules: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'sku_list_promotion_rule') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].sku_list_promotion_rule(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.coupon_codes_promotion_rule', async () => { + + const id = TestData.id + const params = { fields: { coupon_codes_promotion_rules: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'coupon_codes_promotion_rule') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].coupon_codes_promotion_rule(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.attachments', async () => { + + const id = TestData.id + const params = { fields: { attachments: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'attachments') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].attachments(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + }) diff --git a/specs/resources/geocoders.spec.ts b/specs/resources/geocoders.spec.ts index 53f9fe81..99780922 100644 --- a/specs/resources/geocoders.spec.ts +++ b/specs/resources/geocoders.spec.ts @@ -80,4 +80,43 @@ describe('Geocoders resource', () => { }) /* spec.type.stop */ + + + it(resourceType + '.addresses', async () => { + + const id = TestData.id + const params = { fields: { addresses: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'addresses') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].addresses(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.attachments', async () => { + + const id = TestData.id + const params = { fields: { attachments: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'attachments') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].attachments(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + }) diff --git a/specs/resources/gift_card_recipients.spec.ts b/specs/resources/gift_card_recipients.spec.ts index 77be5de1..ff07d3ba 100644 --- a/specs/resources/gift_card_recipients.spec.ts +++ b/specs/resources/gift_card_recipients.spec.ts @@ -25,7 +25,7 @@ describe('GiftCardRecipients resource', () => { it(resourceType + '.create', async () => { const createAttributes = { - email: 'lambda_66', + email: 'gamma_42', customer: cl.customers.relationship(TestData.id), } @@ -149,4 +149,43 @@ describe('GiftCardRecipients resource', () => { }) /* spec.type.stop */ + + + it(resourceType + '.customer', async () => { + + const id = TestData.id + const params = { fields: { customers: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'customer') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].customer(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.attachments', async () => { + + const id = TestData.id + const params = { fields: { attachments: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'attachments') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].attachments(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + }) diff --git a/specs/resources/gift_cards.spec.ts b/specs/resources/gift_cards.spec.ts index c70f82aa..71ac607d 100644 --- a/specs/resources/gift_cards.spec.ts +++ b/specs/resources/gift_cards.spec.ts @@ -150,4 +150,62 @@ describe('GiftCards resource', () => { }) /* spec.type.stop */ + + + it(resourceType + '.market', async () => { + + const id = TestData.id + const params = { fields: { markets: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'market') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].market(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.gift_card_recipient', async () => { + + const id = TestData.id + const params = { fields: { gift_card_recipients: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'gift_card_recipient') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].gift_card_recipient(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.attachments', async () => { + + const id = TestData.id + const params = { fields: { attachments: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'attachments') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].attachments(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + }) diff --git a/specs/resources/google_geocoders.spec.ts b/specs/resources/google_geocoders.spec.ts index c45b2d3f..4ab9b888 100644 --- a/specs/resources/google_geocoders.spec.ts +++ b/specs/resources/google_geocoders.spec.ts @@ -25,8 +25,8 @@ describe('GoogleGeocoders resource', () => { it(resourceType + '.create', async () => { const createAttributes = { - name: 'omega_67', - api_key: 'delta_68', + name: 'beta_35', + api_key: 'lambda_38', } const attributes = { ...createAttributes, reference: TestData.reference } @@ -149,4 +149,43 @@ describe('GoogleGeocoders resource', () => { }) /* spec.type.stop */ + + + it(resourceType + '.addresses', async () => { + + const id = TestData.id + const params = { fields: { addresses: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'addresses') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].addresses(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.attachments', async () => { + + const id = TestData.id + const params = { fields: { attachments: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'attachments') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].attachments(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + }) diff --git a/specs/resources/imports.spec.ts b/specs/resources/imports.spec.ts index d364d9c3..79104042 100644 --- a/specs/resources/imports.spec.ts +++ b/specs/resources/imports.spec.ts @@ -25,7 +25,7 @@ describe('Imports resource', () => { it(resourceType + '.create', async () => { const createAttributes = { - resource_type: 'delta_39', + resource_type: 'gamma_61', inputs: [ { key21: 'val21' } ], } @@ -127,4 +127,5 @@ describe('Imports resource', () => { }) /* spec.type.stop */ + }) diff --git a/specs/resources/in_stock_subscriptions.spec.ts b/specs/resources/in_stock_subscriptions.spec.ts index 4421eea6..91cb9a75 100644 --- a/specs/resources/in_stock_subscriptions.spec.ts +++ b/specs/resources/in_stock_subscriptions.spec.ts @@ -150,4 +150,62 @@ describe('InStockSubscriptions resource', () => { }) /* spec.type.stop */ + + + it(resourceType + '.market', async () => { + + const id = TestData.id + const params = { fields: { markets: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'market') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].market(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.customer', async () => { + + const id = TestData.id + const params = { fields: { customers: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'customer') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].customer(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.sku', async () => { + + const id = TestData.id + const params = { fields: { skus: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'sku') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].sku(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + }) diff --git a/specs/resources/inventory_models.spec.ts b/specs/resources/inventory_models.spec.ts index 09f38523..ef7cc562 100644 --- a/specs/resources/inventory_models.spec.ts +++ b/specs/resources/inventory_models.spec.ts @@ -25,8 +25,8 @@ describe('InventoryModels resource', () => { it(resourceType + '.create', async () => { const createAttributes = { - name: 'sigma_9', - strategy: 'lambda_0', + name: 'kappa_4', + strategy: 'gamma_51', } const attributes = { ...createAttributes, reference: TestData.reference } @@ -149,4 +149,62 @@ describe('InventoryModels resource', () => { }) /* spec.type.stop */ + + + it(resourceType + '.inventory_stock_locations', async () => { + + const id = TestData.id + const params = { fields: { inventory_stock_locations: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'inventory_stock_locations') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].inventory_stock_locations(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.inventory_return_locations', async () => { + + const id = TestData.id + const params = { fields: { inventory_return_locations: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'inventory_return_locations') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].inventory_return_locations(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.attachments', async () => { + + const id = TestData.id + const params = { fields: { attachments: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'attachments') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].attachments(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + }) diff --git a/specs/resources/inventory_return_locations.spec.ts b/specs/resources/inventory_return_locations.spec.ts index 21df1e93..82c4205c 100644 --- a/specs/resources/inventory_return_locations.spec.ts +++ b/specs/resources/inventory_return_locations.spec.ts @@ -25,7 +25,7 @@ describe('InventoryReturnLocations resource', () => { it(resourceType + '.create', async () => { const createAttributes = { - priority: 100, + priority: 5, stock_location: cl.stock_locations.relationship(TestData.id), inventory_model: cl.inventory_models.relationship(TestData.id), } @@ -150,4 +150,43 @@ describe('InventoryReturnLocations resource', () => { }) /* spec.type.stop */ + + + it(resourceType + '.stock_location', async () => { + + const id = TestData.id + const params = { fields: { stock_locations: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'stock_location') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].stock_location(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.inventory_model', async () => { + + const id = TestData.id + const params = { fields: { inventory_models: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'inventory_model') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].inventory_model(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + }) diff --git a/specs/resources/inventory_stock_locations.spec.ts b/specs/resources/inventory_stock_locations.spec.ts index 1720c200..16b087c1 100644 --- a/specs/resources/inventory_stock_locations.spec.ts +++ b/specs/resources/inventory_stock_locations.spec.ts @@ -25,7 +25,7 @@ describe('InventoryStockLocations resource', () => { it(resourceType + '.create', async () => { const createAttributes = { - priority: 55, + priority: 10000, stock_location: cl.stock_locations.relationship(TestData.id), inventory_model: cl.inventory_models.relationship(TestData.id), } @@ -150,4 +150,43 @@ describe('InventoryStockLocations resource', () => { }) /* spec.type.stop */ + + + it(resourceType + '.stock_location', async () => { + + const id = TestData.id + const params = { fields: { stock_locations: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'stock_location') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].stock_location(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.inventory_model', async () => { + + const id = TestData.id + const params = { fields: { inventory_models: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'inventory_model') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].inventory_model(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + }) diff --git a/specs/resources/klarna_gateways.spec.ts b/specs/resources/klarna_gateways.spec.ts index 8fca8eeb..49b18820 100644 --- a/specs/resources/klarna_gateways.spec.ts +++ b/specs/resources/klarna_gateways.spec.ts @@ -25,10 +25,10 @@ describe('KlarnaGateways resource', () => { it(resourceType + '.create', async () => { const createAttributes = { - name: 'beta_56', - country_code: 'sigma_17', - api_key: 'sigma_56', - api_secret: 'alfa_89', + name: 'gamma_59', + country_code: 'sigma_95', + api_key: 'epsilon_69', + api_secret: 'lambda_42', klarna_payments: [ cl.klarna_payments.relationship(TestData.id) ], } @@ -152,4 +152,43 @@ describe('KlarnaGateways resource', () => { }) /* spec.type.stop */ + + + it(resourceType + '.payment_methods', async () => { + + const id = TestData.id + const params = { fields: { payment_methods: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'payment_methods') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].payment_methods(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.klarna_payments', async () => { + + const id = TestData.id + const params = { fields: { klarna_payments: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'klarna_payments') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].klarna_payments(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + }) diff --git a/specs/resources/klarna_payments.spec.ts b/specs/resources/klarna_payments.spec.ts index cdfaae3c..ded7b33b 100644 --- a/specs/resources/klarna_payments.spec.ts +++ b/specs/resources/klarna_payments.spec.ts @@ -148,4 +148,43 @@ describe('KlarnaPayments resource', () => { }) /* spec.type.stop */ + + + it(resourceType + '.order', async () => { + + const id = TestData.id + const params = { fields: { orders: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'order') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].order(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.payment_gateway', async () => { + + const id = TestData.id + const params = { fields: { payment_gateways: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'payment_gateway') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].payment_gateway(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + }) diff --git a/specs/resources/line_item_options.spec.ts b/specs/resources/line_item_options.spec.ts index ba669029..a7af45b9 100644 --- a/specs/resources/line_item_options.spec.ts +++ b/specs/resources/line_item_options.spec.ts @@ -25,8 +25,8 @@ describe('LineItemOptions resource', () => { it(resourceType + '.create', async () => { const createAttributes = { - quantity: 10000, - options: { key21: 'val21' }, + quantity: 0, + options: { key11: 'val11' }, line_item: cl.line_items.relationship(TestData.id), sku_option: cl.sku_options.relationship(TestData.id), } @@ -151,4 +151,43 @@ describe('LineItemOptions resource', () => { }) /* spec.type.stop */ + + + it(resourceType + '.line_item', async () => { + + const id = TestData.id + const params = { fields: { line_items: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'line_item') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].line_item(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.sku_option', async () => { + + const id = TestData.id + const params = { fields: { sku_options: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'sku_option') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].sku_option(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + }) diff --git a/specs/resources/line_items.spec.ts b/specs/resources/line_items.spec.ts index ed2afea4..d8553feb 100644 --- a/specs/resources/line_items.spec.ts +++ b/specs/resources/line_items.spec.ts @@ -150,4 +150,81 @@ describe('LineItems resource', () => { }) /* spec.type.stop */ + + + it(resourceType + '.order', async () => { + + const id = TestData.id + const params = { fields: { orders: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'order') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].order(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.line_item_options', async () => { + + const id = TestData.id + const params = { fields: { line_item_options: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'line_item_options') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].line_item_options(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.stock_line_items', async () => { + + const id = TestData.id + const params = { fields: { stock_line_items: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'stock_line_items') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].stock_line_items(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.stock_transfers', async () => { + + const id = TestData.id + const params = { fields: { stock_transfers: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'stock_transfers') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].stock_transfers(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + }) diff --git a/specs/resources/manual_gateways.spec.ts b/specs/resources/manual_gateways.spec.ts index ea8ea079..a03178dd 100644 --- a/specs/resources/manual_gateways.spec.ts +++ b/specs/resources/manual_gateways.spec.ts @@ -25,7 +25,7 @@ describe('ManualGateways resource', () => { it(resourceType + '.create', async () => { const createAttributes = { - name: 'epsilon_26', + name: 'kappa_27', } const attributes = { ...createAttributes, reference: TestData.reference } @@ -148,4 +148,24 @@ describe('ManualGateways resource', () => { }) /* spec.type.stop */ + + + it(resourceType + '.payment_methods', async () => { + + const id = TestData.id + const params = { fields: { payment_methods: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'payment_methods') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].payment_methods(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + }) diff --git a/specs/resources/manual_tax_calculators.spec.ts b/specs/resources/manual_tax_calculators.spec.ts index 948b6dba..31a80fe7 100644 --- a/specs/resources/manual_tax_calculators.spec.ts +++ b/specs/resources/manual_tax_calculators.spec.ts @@ -25,7 +25,7 @@ describe('ManualTaxCalculators resource', () => { it(resourceType + '.create', async () => { const createAttributes = { - name: 'gamma_47', + name: 'beta_67', tax_categories: [ cl.tax_categories.relationship(TestData.id) ], tax_rules: [ cl.tax_rules.relationship(TestData.id) ], } @@ -150,4 +150,81 @@ describe('ManualTaxCalculators resource', () => { }) /* spec.type.stop */ + + + it(resourceType + '.tax_categories', async () => { + + const id = TestData.id + const params = { fields: { tax_categories: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'tax_categories') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].tax_categories(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.markets', async () => { + + const id = TestData.id + const params = { fields: { markets: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'markets') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].markets(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.attachments', async () => { + + const id = TestData.id + const params = { fields: { attachments: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'attachments') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].attachments(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.tax_rules', async () => { + + const id = TestData.id + const params = { fields: { tax_rules: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'tax_rules') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].tax_rules(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + }) diff --git a/specs/resources/markets.spec.ts b/specs/resources/markets.spec.ts index 4fd9effc..867c100f 100644 --- a/specs/resources/markets.spec.ts +++ b/specs/resources/markets.spec.ts @@ -25,7 +25,7 @@ describe('Markets resource', () => { it(resourceType + '.create', async () => { const createAttributes = { - name: 'gamma_24', + name: 'omega_2', merchant: cl.merchants.relationship(TestData.id), price_list: cl.price_lists.relationship(TestData.id), inventory_model: cl.inventory_models.relationship(TestData.id), @@ -153,4 +153,119 @@ describe('Markets resource', () => { }) /* spec.type.stop */ + + + it(resourceType + '.merchant', async () => { + + const id = TestData.id + const params = { fields: { merchants: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'merchant') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].merchant(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.price_list', async () => { + + const id = TestData.id + const params = { fields: { price_lists: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'price_list') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].price_list(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.inventory_model', async () => { + + const id = TestData.id + const params = { fields: { inventory_models: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'inventory_model') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].inventory_model(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.tax_calculator', async () => { + + const id = TestData.id + const params = { fields: { tax_calculators: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'tax_calculator') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].tax_calculator(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.customer_group', async () => { + + const id = TestData.id + const params = { fields: { customer_groups: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'customer_group') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].customer_group(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.attachments', async () => { + + const id = TestData.id + const params = { fields: { attachments: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'attachments') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].attachments(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + }) diff --git a/specs/resources/merchants.spec.ts b/specs/resources/merchants.spec.ts index 8cb1b62c..c9ec79a9 100644 --- a/specs/resources/merchants.spec.ts +++ b/specs/resources/merchants.spec.ts @@ -25,7 +25,7 @@ describe('Merchants resource', () => { it(resourceType + '.create', async () => { const createAttributes = { - name: 'kappa_94', + name: 'delta_39', address: cl.addresses.relationship(TestData.id), } @@ -149,4 +149,43 @@ describe('Merchants resource', () => { }) /* spec.type.stop */ + + + it(resourceType + '.address', async () => { + + const id = TestData.id + const params = { fields: { addresses: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'address') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].address(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.attachments', async () => { + + const id = TestData.id + const params = { fields: { attachments: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'attachments') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].attachments(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + }) diff --git a/specs/resources/order_amount_promotion_rules.spec.ts b/specs/resources/order_amount_promotion_rules.spec.ts index f84fa632..d9323a70 100644 --- a/specs/resources/order_amount_promotion_rules.spec.ts +++ b/specs/resources/order_amount_promotion_rules.spec.ts @@ -148,4 +148,5 @@ describe('OrderAmountPromotionRules resource', () => { }) /* spec.type.stop */ + }) diff --git a/specs/resources/order_copies.spec.ts b/specs/resources/order_copies.spec.ts index 1b24e91f..a744bd3b 100644 --- a/specs/resources/order_copies.spec.ts +++ b/specs/resources/order_copies.spec.ts @@ -126,4 +126,62 @@ describe('OrderCopies resource', () => { }) /* spec.type.stop */ + + + it(resourceType + '.source_order', async () => { + + const id = TestData.id + const params = { fields: { orders: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'source_order') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].source_order(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.target_order', async () => { + + const id = TestData.id + const params = { fields: { orders: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'target_order') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].target_order(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.order_subscription', async () => { + + const id = TestData.id + const params = { fields: { order_subscriptions: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'order_subscription') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].order_subscription(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + }) diff --git a/specs/resources/order_subscriptions.spec.ts b/specs/resources/order_subscriptions.spec.ts index d8c56dc9..81f999fb 100644 --- a/specs/resources/order_subscriptions.spec.ts +++ b/specs/resources/order_subscriptions.spec.ts @@ -25,7 +25,7 @@ describe('OrderSubscriptions resource', () => { it(resourceType + '.create', async () => { const createAttributes = { - frequency: 'omega_68', + frequency: 'kappa_26', market: cl.markets.relationship(TestData.id), source_order: cl.orders.relationship(TestData.id), } @@ -150,4 +150,100 @@ describe('OrderSubscriptions resource', () => { }) /* spec.type.stop */ + + + it(resourceType + '.market', async () => { + + const id = TestData.id + const params = { fields: { markets: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'market') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].market(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.source_order', async () => { + + const id = TestData.id + const params = { fields: { orders: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'source_order') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].source_order(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.customer', async () => { + + const id = TestData.id + const params = { fields: { customers: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'customer') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].customer(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.order_copies', async () => { + + const id = TestData.id + const params = { fields: { order_copies: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'order_copies') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].order_copies(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.orders', async () => { + + const id = TestData.id + const params = { fields: { orders: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'orders') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].orders(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + }) diff --git a/specs/resources/order_validation_rules.spec.ts b/specs/resources/order_validation_rules.spec.ts index e3ce3053..1891eb4c 100644 --- a/specs/resources/order_validation_rules.spec.ts +++ b/specs/resources/order_validation_rules.spec.ts @@ -80,4 +80,24 @@ describe('OrderValidationRules resource', () => { }) /* spec.type.stop */ + + + it(resourceType + '.market', async () => { + + const id = TestData.id + const params = { fields: { markets: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'market') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].market(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + }) diff --git a/specs/resources/orders.spec.ts b/specs/resources/orders.spec.ts index 59703f80..091aeacd 100644 --- a/specs/resources/orders.spec.ts +++ b/specs/resources/orders.spec.ts @@ -153,4 +153,309 @@ describe('Orders resource', () => { }) /* spec.type.stop */ + + + it(resourceType + '.market', async () => { + + const id = TestData.id + const params = { fields: { markets: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'market') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].market(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.customer', async () => { + + const id = TestData.id + const params = { fields: { customers: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'customer') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].customer(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.shipping_address', async () => { + + const id = TestData.id + const params = { fields: { addresses: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'shipping_address') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].shipping_address(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.billing_address', async () => { + + const id = TestData.id + const params = { fields: { addresses: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'billing_address') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].billing_address(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.available_payment_methods', async () => { + + const id = TestData.id + const params = { fields: { payment_methods: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'available_payment_methods') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].available_payment_methods(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.available_customer_payment_sources', async () => { + + const id = TestData.id + const params = { fields: { customer_payment_sources: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'available_customer_payment_sources') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].available_customer_payment_sources(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.payment_method', async () => { + + const id = TestData.id + const params = { fields: { payment_methods: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'payment_method') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].payment_method(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.line_items', async () => { + + const id = TestData.id + const params = { fields: { line_items: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'line_items') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].line_items(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.shipments', async () => { + + const id = TestData.id + const params = { fields: { shipments: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'shipments') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].shipments(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.authorizations', async () => { + + const id = TestData.id + const params = { fields: { authorizations: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'authorizations') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].authorizations(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.captures', async () => { + + const id = TestData.id + const params = { fields: { captures: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'captures') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].captures(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.voids', async () => { + + const id = TestData.id + const params = { fields: { voids: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'voids') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].voids(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.refunds', async () => { + + const id = TestData.id + const params = { fields: { refunds: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'refunds') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].refunds(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.order_subscriptions', async () => { + + const id = TestData.id + const params = { fields: { order_subscriptions: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'order_subscriptions') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].order_subscriptions(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.order_copies', async () => { + + const id = TestData.id + const params = { fields: { order_copies: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'order_copies') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].order_copies(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.attachments', async () => { + + const id = TestData.id + const params = { fields: { attachments: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'attachments') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].attachments(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + }) diff --git a/specs/resources/organization.spec.ts b/specs/resources/organization.spec.ts index caebf6c1..1a1a545d 100644 --- a/specs/resources/organization.spec.ts +++ b/specs/resources/organization.spec.ts @@ -59,4 +59,5 @@ describe('Organizations resource', () => { }) /* spec.type.stop */ + }) diff --git a/specs/resources/packages.spec.ts b/specs/resources/packages.spec.ts index 8f962457..4f4ec8f2 100644 --- a/specs/resources/packages.spec.ts +++ b/specs/resources/packages.spec.ts @@ -25,11 +25,11 @@ describe('Packages resource', () => { it(resourceType + '.create', async () => { const createAttributes = { - name: 'delta_73', - length: 1000, - width: 55, - height: 10000, - unit_of_length: 'lambda_77', + name: 'sigma_30', + length: 100, + width: 5, + height: 100, + unit_of_length: 'gamma_96', stock_location: cl.stock_locations.relationship(TestData.id), } @@ -153,4 +153,62 @@ describe('Packages resource', () => { }) /* spec.type.stop */ + + + it(resourceType + '.stock_location', async () => { + + const id = TestData.id + const params = { fields: { stock_locations: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'stock_location') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].stock_location(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.parcels', async () => { + + const id = TestData.id + const params = { fields: { parcels: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'parcels') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].parcels(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.attachments', async () => { + + const id = TestData.id + const params = { fields: { attachments: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'attachments') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].attachments(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + }) diff --git a/specs/resources/parcel_line_items.spec.ts b/specs/resources/parcel_line_items.spec.ts index 65bc6271..71b42775 100644 --- a/specs/resources/parcel_line_items.spec.ts +++ b/specs/resources/parcel_line_items.spec.ts @@ -25,7 +25,7 @@ describe('ParcelLineItems resource', () => { it(resourceType + '.create', async () => { const createAttributes = { - quantity: 12345, + quantity: 555, parcel: cl.parcels.relationship(TestData.id), stock_line_item: cl.stock_line_items.relationship(TestData.id), } @@ -150,4 +150,43 @@ describe('ParcelLineItems resource', () => { }) /* spec.type.stop */ + + + it(resourceType + '.parcel', async () => { + + const id = TestData.id + const params = { fields: { parcels: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'parcel') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].parcel(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.stock_line_item', async () => { + + const id = TestData.id + const params = { fields: { stock_line_items: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'stock_line_item') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].stock_line_item(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + }) diff --git a/specs/resources/parcels.spec.ts b/specs/resources/parcels.spec.ts index 6fda6898..bd4b9a5c 100644 --- a/specs/resources/parcels.spec.ts +++ b/specs/resources/parcels.spec.ts @@ -149,4 +149,81 @@ describe('Parcels resource', () => { }) /* spec.type.stop */ + + + it(resourceType + '.shipment', async () => { + + const id = TestData.id + const params = { fields: { shipments: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'shipment') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].shipment(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.package', async () => { + + const id = TestData.id + const params = { fields: { packages: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'package') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].package(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.parcel_line_items', async () => { + + const id = TestData.id + const params = { fields: { parcel_line_items: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'parcel_line_items') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].parcel_line_items(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.attachments', async () => { + + const id = TestData.id + const params = { fields: { attachments: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'attachments') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].attachments(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + }) diff --git a/specs/resources/payment_gateways.spec.ts b/specs/resources/payment_gateways.spec.ts index 37f6407c..dcd620dc 100644 --- a/specs/resources/payment_gateways.spec.ts +++ b/specs/resources/payment_gateways.spec.ts @@ -80,4 +80,24 @@ describe('PaymentGateways resource', () => { }) /* spec.type.stop */ + + + it(resourceType + '.payment_methods', async () => { + + const id = TestData.id + const params = { fields: { payment_methods: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'payment_methods') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].payment_methods(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + }) diff --git a/specs/resources/payment_methods.spec.ts b/specs/resources/payment_methods.spec.ts index f64646e4..463f873d 100644 --- a/specs/resources/payment_methods.spec.ts +++ b/specs/resources/payment_methods.spec.ts @@ -25,8 +25,8 @@ describe('PaymentMethods resource', () => { it(resourceType + '.create', async () => { const createAttributes = { - payment_source_type: 'gamma_68', - price_amount_cents: 55, + payment_source_type: 'delta_82', + price_amount_cents: 555, market: cl.markets.relationship(TestData.id), payment_gateway: cl.payment_gateways.relationship(TestData.id), } @@ -151,4 +151,62 @@ describe('PaymentMethods resource', () => { }) /* spec.type.stop */ + + + it(resourceType + '.market', async () => { + + const id = TestData.id + const params = { fields: { markets: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'market') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].market(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.payment_gateway', async () => { + + const id = TestData.id + const params = { fields: { payment_gateways: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'payment_gateway') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].payment_gateway(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.attachments', async () => { + + const id = TestData.id + const params = { fields: { attachments: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'attachments') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].attachments(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + }) diff --git a/specs/resources/paypal_gateways.spec.ts b/specs/resources/paypal_gateways.spec.ts index c1e42c0d..7b16d260 100644 --- a/specs/resources/paypal_gateways.spec.ts +++ b/specs/resources/paypal_gateways.spec.ts @@ -25,10 +25,10 @@ describe('PaypalGateways resource', () => { it(resourceType + '.create', async () => { const createAttributes = { - name: 'epsilon_4', - client_id: 'sigma_57', - client_secret: 'omega_73', - mode: 'sigma_87', + name: 'delta_48', + client_id: 'kappa_97', + client_secret: 'lambda_54', + mode: 'omega_21', } const attributes = { ...createAttributes, reference: TestData.reference } @@ -151,4 +151,43 @@ describe('PaypalGateways resource', () => { }) /* spec.type.stop */ + + + it(resourceType + '.payment_methods', async () => { + + const id = TestData.id + const params = { fields: { payment_methods: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'payment_methods') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].payment_methods(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.paypal_payments', async () => { + + const id = TestData.id + const params = { fields: { paypal_payments: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'paypal_payments') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].paypal_payments(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + }) diff --git a/specs/resources/paypal_payments.spec.ts b/specs/resources/paypal_payments.spec.ts index 012065e6..a76e96bb 100644 --- a/specs/resources/paypal_payments.spec.ts +++ b/specs/resources/paypal_payments.spec.ts @@ -25,8 +25,8 @@ describe('PaypalPayments resource', () => { it(resourceType + '.create', async () => { const createAttributes = { - return_url: 'sigma_25', - cancel_url: 'lambda_92', + return_url: 'alfa_3', + cancel_url: 'omega_64', order: cl.orders.relationship(TestData.id), } @@ -150,4 +150,43 @@ describe('PaypalPayments resource', () => { }) /* spec.type.stop */ + + + it(resourceType + '.order', async () => { + + const id = TestData.id + const params = { fields: { orders: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'order') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].order(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.payment_gateway', async () => { + + const id = TestData.id + const params = { fields: { payment_gateways: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'payment_gateway') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].payment_gateway(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + }) diff --git a/specs/resources/percentage_discount_promotions.spec.ts b/specs/resources/percentage_discount_promotions.spec.ts index 9c3a3b38..0764a707 100644 --- a/specs/resources/percentage_discount_promotions.spec.ts +++ b/specs/resources/percentage_discount_promotions.spec.ts @@ -25,11 +25,11 @@ describe('PercentageDiscountPromotions resource', () => { it(resourceType + '.create', async () => { const createAttributes = { - name: 'sigma_20', - starts_at: 'beta_41', - expires_at: 'kappa_23', - total_usage_limit: 55, - percentage: 100, + name: 'sigma_2', + starts_at: 'kappa_47', + expires_at: 'kappa_40', + total_usage_limit: 555, + percentage: 10000, market: cl.markets.relationship(TestData.id), promotion_rules: [ cl.promotion_rules.relationship(TestData.id) ], order_amount_promotion_rule: cl.order_amount_promotion_rules.relationship(TestData.id), @@ -158,4 +158,138 @@ describe('PercentageDiscountPromotions resource', () => { }) /* spec.type.stop */ + + + it(resourceType + '.market', async () => { + + const id = TestData.id + const params = { fields: { markets: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'market') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].market(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.order_amount_promotion_rule', async () => { + + const id = TestData.id + const params = { fields: { order_amount_promotion_rules: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'order_amount_promotion_rule') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].order_amount_promotion_rule(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.sku_list_promotion_rule', async () => { + + const id = TestData.id + const params = { fields: { sku_list_promotion_rules: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'sku_list_promotion_rule') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].sku_list_promotion_rule(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.coupon_codes_promotion_rule', async () => { + + const id = TestData.id + const params = { fields: { coupon_codes_promotion_rules: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'coupon_codes_promotion_rule') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].coupon_codes_promotion_rule(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.attachments', async () => { + + const id = TestData.id + const params = { fields: { attachments: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'attachments') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].attachments(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.sku_list', async () => { + + const id = TestData.id + const params = { fields: { sku_lists: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'sku_list') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].sku_list(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.skus', async () => { + + const id = TestData.id + const params = { fields: { skus: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'skus') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].skus(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + }) diff --git a/specs/resources/price_lists.spec.ts b/specs/resources/price_lists.spec.ts index c21e5446..50765891 100644 --- a/specs/resources/price_lists.spec.ts +++ b/specs/resources/price_lists.spec.ts @@ -25,8 +25,8 @@ describe('PriceLists resource', () => { it(resourceType + '.create', async () => { const createAttributes = { - name: 'epsilon_33', - currency_code: 'alfa_67', + name: 'sigma_85', + currency_code: 'gamma_39', } const attributes = { ...createAttributes, reference: TestData.reference } @@ -149,4 +149,43 @@ describe('PriceLists resource', () => { }) /* spec.type.stop */ + + + it(resourceType + '.prices', async () => { + + const id = TestData.id + const params = { fields: { prices: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'prices') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].prices(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.attachments', async () => { + + const id = TestData.id + const params = { fields: { attachments: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'attachments') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].attachments(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + }) diff --git a/specs/resources/prices.spec.ts b/specs/resources/prices.spec.ts index 699b3c08..03087406 100644 --- a/specs/resources/prices.spec.ts +++ b/specs/resources/prices.spec.ts @@ -25,8 +25,8 @@ describe('Prices resource', () => { it(resourceType + '.create', async () => { const createAttributes = { - amount_cents: 10000, - compare_at_amount_cents: 100, + amount_cents: 5, + compare_at_amount_cents: 10, price_list: cl.price_lists.relationship(TestData.id), sku: cl.skus.relationship(TestData.id), } @@ -151,4 +151,62 @@ describe('Prices resource', () => { }) /* spec.type.stop */ + + + it(resourceType + '.price_list', async () => { + + const id = TestData.id + const params = { fields: { price_lists: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'price_list') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].price_list(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.sku', async () => { + + const id = TestData.id + const params = { fields: { skus: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'sku') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].sku(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.attachments', async () => { + + const id = TestData.id + const params = { fields: { attachments: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'attachments') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].attachments(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + }) diff --git a/specs/resources/promotion_rules.spec.ts b/specs/resources/promotion_rules.spec.ts index a6ec2906..1ec4580c 100644 --- a/specs/resources/promotion_rules.spec.ts +++ b/specs/resources/promotion_rules.spec.ts @@ -80,4 +80,5 @@ describe('PromotionRules resource', () => { }) /* spec.type.stop */ + }) diff --git a/specs/resources/promotions.spec.ts b/specs/resources/promotions.spec.ts index 36550d94..964b1d60 100644 --- a/specs/resources/promotions.spec.ts +++ b/specs/resources/promotions.spec.ts @@ -80,4 +80,100 @@ describe('Promotions resource', () => { }) /* spec.type.stop */ + + + it(resourceType + '.market', async () => { + + const id = TestData.id + const params = { fields: { markets: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'market') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].market(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.order_amount_promotion_rule', async () => { + + const id = TestData.id + const params = { fields: { order_amount_promotion_rules: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'order_amount_promotion_rule') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].order_amount_promotion_rule(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.sku_list_promotion_rule', async () => { + + const id = TestData.id + const params = { fields: { sku_list_promotion_rules: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'sku_list_promotion_rule') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].sku_list_promotion_rule(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.coupon_codes_promotion_rule', async () => { + + const id = TestData.id + const params = { fields: { coupon_codes_promotion_rules: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'coupon_codes_promotion_rule') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].coupon_codes_promotion_rule(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.attachments', async () => { + + const id = TestData.id + const params = { fields: { attachments: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'attachments') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].attachments(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + }) diff --git a/specs/resources/refunds.spec.ts b/specs/resources/refunds.spec.ts index b7e1ea24..ae20e4a1 100644 --- a/specs/resources/refunds.spec.ts +++ b/specs/resources/refunds.spec.ts @@ -80,4 +80,43 @@ describe('Refunds resource', () => { }) /* spec.type.stop */ + + + it(resourceType + '.order', async () => { + + const id = TestData.id + const params = { fields: { orders: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'order') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].order(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.reference_capture', async () => { + + const id = TestData.id + const params = { fields: { captures: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'reference_capture') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].reference_capture(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + }) diff --git a/specs/resources/return_line_items.spec.ts b/specs/resources/return_line_items.spec.ts index 2d42ade0..3aadf316 100644 --- a/specs/resources/return_line_items.spec.ts +++ b/specs/resources/return_line_items.spec.ts @@ -25,7 +25,7 @@ describe('ReturnLineItems resource', () => { it(resourceType + '.create', async () => { const createAttributes = { - quantity: 1000, + quantity: 0, return: cl.returns.relationship(TestData.id), line_item: cl.line_items.relationship(TestData.id), } @@ -150,4 +150,43 @@ describe('ReturnLineItems resource', () => { }) /* spec.type.stop */ + + + it(resourceType + '.return', async () => { + + const id = TestData.id + const params = { fields: { returns: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'return') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].return(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.line_item', async () => { + + const id = TestData.id + const params = { fields: { line_items: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'line_item') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].line_item(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + }) diff --git a/specs/resources/returns.spec.ts b/specs/resources/returns.spec.ts index 06bb1d42..56c5db3f 100644 --- a/specs/resources/returns.spec.ts +++ b/specs/resources/returns.spec.ts @@ -149,4 +149,138 @@ describe('Returns resource', () => { }) /* spec.type.stop */ + + + it(resourceType + '.order', async () => { + + const id = TestData.id + const params = { fields: { orders: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'order') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].order(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.customer', async () => { + + const id = TestData.id + const params = { fields: { customers: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'customer') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].customer(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.stock_location', async () => { + + const id = TestData.id + const params = { fields: { stock_locations: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'stock_location') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].stock_location(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.origin_address', async () => { + + const id = TestData.id + const params = { fields: { addresses: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'origin_address') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].origin_address(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.destination_address', async () => { + + const id = TestData.id + const params = { fields: { addresses: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'destination_address') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].destination_address(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.return_line_items', async () => { + + const id = TestData.id + const params = { fields: { return_line_items: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'return_line_items') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].return_line_items(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.attachments', async () => { + + const id = TestData.id + const params = { fields: { attachments: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'attachments') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].attachments(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + }) diff --git a/specs/resources/shipments.spec.ts b/specs/resources/shipments.spec.ts index 7c09efb2..6b91f909 100644 --- a/specs/resources/shipments.spec.ts +++ b/specs/resources/shipments.spec.ts @@ -102,4 +102,252 @@ describe('Shipments resource', () => { }) /* spec.type.stop */ + + + it(resourceType + '.order', async () => { + + const id = TestData.id + const params = { fields: { orders: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'order') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].order(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.shipping_category', async () => { + + const id = TestData.id + const params = { fields: { shipping_categories: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'shipping_category') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].shipping_category(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.stock_location', async () => { + + const id = TestData.id + const params = { fields: { stock_locations: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'stock_location') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].stock_location(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.origin_address', async () => { + + const id = TestData.id + const params = { fields: { addresses: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'origin_address') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].origin_address(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.shipping_address', async () => { + + const id = TestData.id + const params = { fields: { addresses: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'shipping_address') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].shipping_address(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.shipping_method', async () => { + + const id = TestData.id + const params = { fields: { shipping_methods: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'shipping_method') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].shipping_method(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.delivery_lead_time', async () => { + + const id = TestData.id + const params = { fields: { delivery_lead_times: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'delivery_lead_time') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].delivery_lead_time(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.stock_line_items', async () => { + + const id = TestData.id + const params = { fields: { stock_line_items: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'stock_line_items') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].stock_line_items(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.stock_transfers', async () => { + + const id = TestData.id + const params = { fields: { stock_transfers: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'stock_transfers') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].stock_transfers(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.available_shipping_methods', async () => { + + const id = TestData.id + const params = { fields: { shipping_methods: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'available_shipping_methods') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].available_shipping_methods(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.carrier_accounts', async () => { + + const id = TestData.id + const params = { fields: { carrier_accounts: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'carrier_accounts') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].carrier_accounts(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.parcels', async () => { + + const id = TestData.id + const params = { fields: { parcels: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'parcels') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].parcels(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.attachments', async () => { + + const id = TestData.id + const params = { fields: { attachments: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'attachments') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].attachments(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + }) diff --git a/specs/resources/shipping_categories.spec.ts b/specs/resources/shipping_categories.spec.ts index 5ce46a0f..c3294474 100644 --- a/specs/resources/shipping_categories.spec.ts +++ b/specs/resources/shipping_categories.spec.ts @@ -25,7 +25,7 @@ describe('ShippingCategories resource', () => { it(resourceType + '.create', async () => { const createAttributes = { - name: 'omega_73', + name: 'kappa_89', } const attributes = { ...createAttributes, reference: TestData.reference } @@ -148,4 +148,43 @@ describe('ShippingCategories resource', () => { }) /* spec.type.stop */ + + + it(resourceType + '.skus', async () => { + + const id = TestData.id + const params = { fields: { skus: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'skus') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].skus(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.attachments', async () => { + + const id = TestData.id + const params = { fields: { attachments: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'attachments') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].attachments(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + }) diff --git a/specs/resources/shipping_methods.spec.ts b/specs/resources/shipping_methods.spec.ts index 1a8fe388..5bd555de 100644 --- a/specs/resources/shipping_methods.spec.ts +++ b/specs/resources/shipping_methods.spec.ts @@ -25,7 +25,7 @@ describe('ShippingMethods resource', () => { it(resourceType + '.create', async () => { const createAttributes = { - name: 'gamma_13', + name: 'omega_96', price_amount_cents: 10000, market: cl.markets.relationship(TestData.id), shipping_zone: cl.shipping_zones.relationship(TestData.id), @@ -152,4 +152,100 @@ describe('ShippingMethods resource', () => { }) /* spec.type.stop */ + + + it(resourceType + '.market', async () => { + + const id = TestData.id + const params = { fields: { markets: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'market') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].market(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.shipping_zone', async () => { + + const id = TestData.id + const params = { fields: { shipping_zones: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'shipping_zone') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].shipping_zone(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.shipping_category', async () => { + + const id = TestData.id + const params = { fields: { shipping_categories: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'shipping_category') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].shipping_category(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.delivery_lead_time_for_shipment', async () => { + + const id = TestData.id + const params = { fields: { delivery_lead_times: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'delivery_lead_time_for_shipment') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].delivery_lead_time_for_shipment(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.attachments', async () => { + + const id = TestData.id + const params = { fields: { attachments: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'attachments') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].attachments(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + }) diff --git a/specs/resources/shipping_zones.spec.ts b/specs/resources/shipping_zones.spec.ts index 5adcc74f..7b92af04 100644 --- a/specs/resources/shipping_zones.spec.ts +++ b/specs/resources/shipping_zones.spec.ts @@ -25,7 +25,7 @@ describe('ShippingZones resource', () => { it(resourceType + '.create', async () => { const createAttributes = { - name: 'epsilon_96', + name: 'delta_14', } const attributes = { ...createAttributes, reference: TestData.reference } @@ -148,4 +148,24 @@ describe('ShippingZones resource', () => { }) /* spec.type.stop */ + + + it(resourceType + '.attachments', async () => { + + const id = TestData.id + const params = { fields: { attachments: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'attachments') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].attachments(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + }) diff --git a/specs/resources/sku_list_items.spec.ts b/specs/resources/sku_list_items.spec.ts index debc248c..2641bd78 100644 --- a/specs/resources/sku_list_items.spec.ts +++ b/specs/resources/sku_list_items.spec.ts @@ -149,4 +149,43 @@ describe('SkuListItems resource', () => { }) /* spec.type.stop */ + + + it(resourceType + '.sku_list', async () => { + + const id = TestData.id + const params = { fields: { sku_lists: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'sku_list') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].sku_list(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.sku', async () => { + + const id = TestData.id + const params = { fields: { skus: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'sku') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].sku(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + }) diff --git a/specs/resources/sku_list_promotion_rules.spec.ts b/specs/resources/sku_list_promotion_rules.spec.ts index 281773c8..0d0ad6db 100644 --- a/specs/resources/sku_list_promotion_rules.spec.ts +++ b/specs/resources/sku_list_promotion_rules.spec.ts @@ -149,4 +149,43 @@ describe('SkuListPromotionRules resource', () => { }) /* spec.type.stop */ + + + it(resourceType + '.sku_list', async () => { + + const id = TestData.id + const params = { fields: { sku_lists: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'sku_list') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].sku_list(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.skus', async () => { + + const id = TestData.id + const params = { fields: { skus: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'skus') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].skus(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + }) diff --git a/specs/resources/sku_lists.spec.ts b/specs/resources/sku_lists.spec.ts index ac32d346..fd98b453 100644 --- a/specs/resources/sku_lists.spec.ts +++ b/specs/resources/sku_lists.spec.ts @@ -25,7 +25,7 @@ describe('SkuLists resource', () => { it(resourceType + '.create', async () => { const createAttributes = { - name: 'kappa_10', + name: 'gamma_25', } const attributes = { ...createAttributes, reference: TestData.reference } @@ -148,4 +148,62 @@ describe('SkuLists resource', () => { }) /* spec.type.stop */ + + + it(resourceType + '.skus', async () => { + + const id = TestData.id + const params = { fields: { skus: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'skus') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].skus(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.sku_list_items', async () => { + + const id = TestData.id + const params = { fields: { sku_list_items: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'sku_list_items') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].sku_list_items(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.bundles', async () => { + + const id = TestData.id + const params = { fields: { bundles: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'bundles') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].bundles(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + }) diff --git a/specs/resources/sku_options.spec.ts b/specs/resources/sku_options.spec.ts index 0ecc6f86..baed188e 100644 --- a/specs/resources/sku_options.spec.ts +++ b/specs/resources/sku_options.spec.ts @@ -25,7 +25,7 @@ describe('SkuOptions resource', () => { it(resourceType + '.create', async () => { const createAttributes = { - name: 'gamma_84', + name: 'epsilon_6', market: cl.markets.relationship(TestData.id), } @@ -149,4 +149,43 @@ describe('SkuOptions resource', () => { }) /* spec.type.stop */ + + + it(resourceType + '.market', async () => { + + const id = TestData.id + const params = { fields: { markets: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'market') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].market(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.attachments', async () => { + + const id = TestData.id + const params = { fields: { attachments: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'attachments') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].attachments(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + }) diff --git a/specs/resources/skus.spec.ts b/specs/resources/skus.spec.ts index b03fd054..4628ae9d 100644 --- a/specs/resources/skus.spec.ts +++ b/specs/resources/skus.spec.ts @@ -25,8 +25,8 @@ describe('Skus resource', () => { it(resourceType + '.create', async () => { const createAttributes = { - code: 'lambda_70', - name: 'delta_98', + code: 'alfa_27', + name: 'lambda_53', shipping_category: cl.shipping_categories.relationship(TestData.id), } @@ -150,4 +150,119 @@ describe('Skus resource', () => { }) /* spec.type.stop */ + + + it(resourceType + '.shipping_category', async () => { + + const id = TestData.id + const params = { fields: { shipping_categories: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'shipping_category') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].shipping_category(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.prices', async () => { + + const id = TestData.id + const params = { fields: { prices: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'prices') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].prices(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.stock_items', async () => { + + const id = TestData.id + const params = { fields: { stock_items: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'stock_items') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].stock_items(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.delivery_lead_times', async () => { + + const id = TestData.id + const params = { fields: { delivery_lead_times: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'delivery_lead_times') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].delivery_lead_times(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.sku_options', async () => { + + const id = TestData.id + const params = { fields: { sku_options: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'sku_options') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].sku_options(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.attachments', async () => { + + const id = TestData.id + const params = { fields: { attachments: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'attachments') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].attachments(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + }) diff --git a/specs/resources/stock_items.spec.ts b/specs/resources/stock_items.spec.ts index 75fadca2..a12d857b 100644 --- a/specs/resources/stock_items.spec.ts +++ b/specs/resources/stock_items.spec.ts @@ -25,7 +25,7 @@ describe('StockItems resource', () => { it(resourceType + '.create', async () => { const createAttributes = { - quantity: 55, + quantity: 555, stock_location: cl.stock_locations.relationship(TestData.id), sku: cl.skus.relationship(TestData.id), } @@ -150,4 +150,62 @@ describe('StockItems resource', () => { }) /* spec.type.stop */ + + + it(resourceType + '.stock_location', async () => { + + const id = TestData.id + const params = { fields: { stock_locations: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'stock_location') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].stock_location(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.sku', async () => { + + const id = TestData.id + const params = { fields: { skus: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'sku') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].sku(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.attachments', async () => { + + const id = TestData.id + const params = { fields: { attachments: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'attachments') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].attachments(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + }) diff --git a/specs/resources/stock_line_items.spec.ts b/specs/resources/stock_line_items.spec.ts index c0ee6998..b1d39d0f 100644 --- a/specs/resources/stock_line_items.spec.ts +++ b/specs/resources/stock_line_items.spec.ts @@ -80,4 +80,62 @@ describe('StockLineItems resource', () => { }) /* spec.type.stop */ + + + it(resourceType + '.shipment', async () => { + + const id = TestData.id + const params = { fields: { shipments: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'shipment') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].shipment(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.line_item', async () => { + + const id = TestData.id + const params = { fields: { line_items: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'line_item') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].line_item(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.stock_item', async () => { + + const id = TestData.id + const params = { fields: { stock_items: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'stock_item') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].stock_item(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + }) diff --git a/specs/resources/stock_locations.spec.ts b/specs/resources/stock_locations.spec.ts index 7d47d4f6..9f8b57fb 100644 --- a/specs/resources/stock_locations.spec.ts +++ b/specs/resources/stock_locations.spec.ts @@ -25,7 +25,7 @@ describe('StockLocations resource', () => { it(resourceType + '.create', async () => { const createAttributes = { - name: 'gamma_67', + name: 'omega_62', address: cl.addresses.relationship(TestData.id), } @@ -149,4 +149,119 @@ describe('StockLocations resource', () => { }) /* spec.type.stop */ + + + it(resourceType + '.address', async () => { + + const id = TestData.id + const params = { fields: { addresses: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'address') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].address(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.inventory_stock_locations', async () => { + + const id = TestData.id + const params = { fields: { inventory_stock_locations: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'inventory_stock_locations') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].inventory_stock_locations(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.inventory_return_locations', async () => { + + const id = TestData.id + const params = { fields: { inventory_return_locations: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'inventory_return_locations') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].inventory_return_locations(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.stock_items', async () => { + + const id = TestData.id + const params = { fields: { stock_items: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'stock_items') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].stock_items(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.stock_transfers', async () => { + + const id = TestData.id + const params = { fields: { stock_transfers: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'stock_transfers') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].stock_transfers(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.attachments', async () => { + + const id = TestData.id + const params = { fields: { attachments: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'attachments') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].attachments(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + }) diff --git a/specs/resources/stock_transfers.spec.ts b/specs/resources/stock_transfers.spec.ts index d353cdfc..e890da11 100644 --- a/specs/resources/stock_transfers.spec.ts +++ b/specs/resources/stock_transfers.spec.ts @@ -25,7 +25,7 @@ describe('StockTransfers resource', () => { it(resourceType + '.create', async () => { const createAttributes = { - quantity: 1000, + quantity: 55, sku: cl.skus.relationship(TestData.id), origin_stock_location: cl.stock_locations.relationship(TestData.id), destination_stock_location: cl.stock_locations.relationship(TestData.id), @@ -153,4 +153,100 @@ describe('StockTransfers resource', () => { }) /* spec.type.stop */ + + + it(resourceType + '.sku', async () => { + + const id = TestData.id + const params = { fields: { skus: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'sku') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].sku(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.origin_stock_location', async () => { + + const id = TestData.id + const params = { fields: { stock_locations: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'origin_stock_location') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].origin_stock_location(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.destination_stock_location', async () => { + + const id = TestData.id + const params = { fields: { stock_locations: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'destination_stock_location') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].destination_stock_location(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.shipment', async () => { + + const id = TestData.id + const params = { fields: { shipments: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'shipment') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].shipment(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.line_item', async () => { + + const id = TestData.id + const params = { fields: { line_items: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'line_item') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].line_item(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + }) diff --git a/specs/resources/stripe_gateways.spec.ts b/specs/resources/stripe_gateways.spec.ts index 72a227ff..dab04e36 100644 --- a/specs/resources/stripe_gateways.spec.ts +++ b/specs/resources/stripe_gateways.spec.ts @@ -25,8 +25,8 @@ describe('StripeGateways resource', () => { it(resourceType + '.create', async () => { const createAttributes = { - name: 'alfa_52', - login: 'sigma_57', + name: 'kappa_86', + login: 'sigma_89', } const attributes = { ...createAttributes, reference: TestData.reference } @@ -149,4 +149,43 @@ describe('StripeGateways resource', () => { }) /* spec.type.stop */ + + + it(resourceType + '.payment_methods', async () => { + + const id = TestData.id + const params = { fields: { payment_methods: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'payment_methods') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].payment_methods(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.stripe_payments', async () => { + + const id = TestData.id + const params = { fields: { stripe_payments: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'stripe_payments') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].stripe_payments(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + }) diff --git a/specs/resources/stripe_payments.spec.ts b/specs/resources/stripe_payments.spec.ts index bb51d581..16944237 100644 --- a/specs/resources/stripe_payments.spec.ts +++ b/specs/resources/stripe_payments.spec.ts @@ -148,4 +148,43 @@ describe('StripePayments resource', () => { }) /* spec.type.stop */ + + + it(resourceType + '.order', async () => { + + const id = TestData.id + const params = { fields: { orders: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'order') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].order(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.payment_gateway', async () => { + + const id = TestData.id + const params = { fields: { payment_gateways: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'payment_gateway') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].payment_gateway(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + }) diff --git a/specs/resources/tax_calculators.spec.ts b/specs/resources/tax_calculators.spec.ts index 48e4632f..374759b1 100644 --- a/specs/resources/tax_calculators.spec.ts +++ b/specs/resources/tax_calculators.spec.ts @@ -80,4 +80,62 @@ describe('TaxCalculators resource', () => { }) /* spec.type.stop */ + + + it(resourceType + '.tax_categories', async () => { + + const id = TestData.id + const params = { fields: { tax_categories: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'tax_categories') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].tax_categories(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.markets', async () => { + + const id = TestData.id + const params = { fields: { markets: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'markets') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].markets(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.attachments', async () => { + + const id = TestData.id + const params = { fields: { attachments: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'attachments') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].attachments(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + }) diff --git a/specs/resources/tax_categories.spec.ts b/specs/resources/tax_categories.spec.ts index b9b567b3..98b19a4e 100644 --- a/specs/resources/tax_categories.spec.ts +++ b/specs/resources/tax_categories.spec.ts @@ -25,7 +25,7 @@ describe('TaxCategories resource', () => { it(resourceType + '.create', async () => { const createAttributes = { - code: 'sigma_88', + code: 'omega_92', sku: cl.skus.relationship(TestData.id), tax_calculator: cl.avalara_accounts.relationship(TestData.id), } @@ -150,4 +150,43 @@ describe('TaxCategories resource', () => { }) /* spec.type.stop */ + + + it(resourceType + '.sku', async () => { + + const id = TestData.id + const params = { fields: { skus: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'sku') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].sku(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.attachments', async () => { + + const id = TestData.id + const params = { fields: { attachments: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'attachments') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].attachments(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + }) diff --git a/specs/resources/tax_rules.spec.ts b/specs/resources/tax_rules.spec.ts index 7c50bd6d..93066cfb 100644 --- a/specs/resources/tax_rules.spec.ts +++ b/specs/resources/tax_rules.spec.ts @@ -25,7 +25,7 @@ describe('TaxRules resource', () => { it(resourceType + '.create', async () => { const createAttributes = { - name: 'delta_77', + name: 'delta_14', manual_tax_calculator: cl.manual_tax_calculators.relationship(TestData.id), } @@ -149,4 +149,24 @@ describe('TaxRules resource', () => { }) /* spec.type.stop */ + + + it(resourceType + '.manual_tax_calculator', async () => { + + const id = TestData.id + const params = { fields: { manual_tax_calculators: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'manual_tax_calculator') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].manual_tax_calculator(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + }) diff --git a/specs/resources/taxjar_accounts.spec.ts b/specs/resources/taxjar_accounts.spec.ts index a48f4f81..bcff494b 100644 --- a/specs/resources/taxjar_accounts.spec.ts +++ b/specs/resources/taxjar_accounts.spec.ts @@ -25,8 +25,8 @@ describe('TaxjarAccounts resource', () => { it(resourceType + '.create', async () => { const createAttributes = { - name: 'alfa_21', - api_key: 'delta_65', + name: 'delta_66', + api_key: 'gamma_38', tax_categories: [ cl.tax_categories.relationship(TestData.id) ], } @@ -150,4 +150,62 @@ describe('TaxjarAccounts resource', () => { }) /* spec.type.stop */ + + + it(resourceType + '.tax_categories', async () => { + + const id = TestData.id + const params = { fields: { tax_categories: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'tax_categories') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].tax_categories(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.markets', async () => { + + const id = TestData.id + const params = { fields: { markets: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'markets') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].markets(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.attachments', async () => { + + const id = TestData.id + const params = { fields: { attachments: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'attachments') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].attachments(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + }) diff --git a/specs/resources/transactions.spec.ts b/specs/resources/transactions.spec.ts index 41fb62e2..bbe48e19 100644 --- a/specs/resources/transactions.spec.ts +++ b/specs/resources/transactions.spec.ts @@ -80,4 +80,24 @@ describe('Transactions resource', () => { }) /* spec.type.stop */ + + + it(resourceType + '.order', async () => { + + const id = TestData.id + const params = { fields: { orders: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'order') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].order(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + }) diff --git a/specs/resources/voids.spec.ts b/specs/resources/voids.spec.ts index 63879eb4..12eb3c97 100644 --- a/specs/resources/voids.spec.ts +++ b/specs/resources/voids.spec.ts @@ -80,4 +80,43 @@ describe('Voids resource', () => { }) /* spec.type.stop */ + + + it(resourceType + '.order', async () => { + + const id = TestData.id + const params = { fields: { orders: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'order') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].order(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + + + it(resourceType + '.reference_authorization', async () => { + + const id = TestData.id + const params = { fields: { authorizations: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'reference_authorization') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].reference_authorization(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + }) diff --git a/specs/resources/webhooks.spec.ts b/specs/resources/webhooks.spec.ts index c76ba2a4..48eb6b0f 100644 --- a/specs/resources/webhooks.spec.ts +++ b/specs/resources/webhooks.spec.ts @@ -25,8 +25,8 @@ describe('Webhooks resource', () => { it(resourceType + '.create', async () => { const createAttributes = { - topic: 'alfa_57', - callback_url: 'alfa_45', + topic: 'beta_43', + callback_url: 'kappa_44', } const attributes = { ...createAttributes, reference: TestData.reference } @@ -149,4 +149,24 @@ describe('Webhooks resource', () => { }) /* spec.type.stop */ + + + it(resourceType + '.last_event_callbacks', async () => { + + const id = TestData.id + const params = { fields: { event_callbacks: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'last_event_callbacks') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].last_event_callbacks(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + }) diff --git a/specs/resources/wire_transfers.spec.ts b/specs/resources/wire_transfers.spec.ts index ed0f5bdd..835f2206 100644 --- a/specs/resources/wire_transfers.spec.ts +++ b/specs/resources/wire_transfers.spec.ts @@ -148,4 +148,24 @@ describe('WireTransfers resource', () => { }) /* spec.type.stop */ + + + it(resourceType + '.order', async () => { + + const id = TestData.id + const params = { fields: { orders: CommonData.paramsFields } } + + const intId = cl.addRequestInterceptor((config) => { + expect(config.method).toBe('get') + checkCommon(config, resourceType, id, currentAccessToken, 'order') + checkCommonParams(config, params) + return interceptRequest() + }) + + await cl[resourceType].order(id, params, CommonData.options) + .catch(handleError) + .finally(() => cl.removeInterceptor('request', intId)) + + }) + }) diff --git a/src/commercelayer.ts b/src/commercelayer.ts index 1087912a..3f4d4255 100644 --- a/src/commercelayer.ts +++ b/src/commercelayer.ts @@ -15,7 +15,7 @@ const OPEN_API_SCHEMA_VERSION = '2.8.1' type SdkConfig = {} type CommerceLayerInitConfig = SdkConfig & ResourcesInitConfig -type CommerceLayerConfig = SdkConfig & ResourcesConfig +type CommerceLayerConfig = Partial diff --git a/src/resource.ts b/src/resource.ts index 0f685370..0b92c073 100644 --- a/src/resource.ts +++ b/src/resource.ts @@ -7,6 +7,7 @@ import config from './config' import { InterceptorManager } from './interceptor' import Debug from './debug' +import { QueryParams } from '.' const debug = Debug() @@ -217,6 +218,31 @@ class ResourceAdapter { await this.#client.request('delete', `${resource.type}/${resource.id}`, undefined, options) } + + async fetch(resource: ResourceType, path: string, params?: QueryParams, options?: ResourcesConfig): Promise> { + + debug('fetch: %o, %O, %O', path, params || {}, options || {}) + + const queryParams = generateQueryStringParams(params, resource) + if (options?.params) Object.assign(queryParams, options?.params) + + const res = await this.#client.request('get', path, undefined, { ...options, params: queryParams }) + const r = denormalize(res) + + if (Array.isArray(r)) { + const p = params as QueryParamsList + const meta: ListMeta = { + pageCount: Number(res.meta?.page_count), + recordCount: Number(res.meta?.record_count), + currentPage: p?.pageNumber || config.default.pageNumber, + recordsPerPage: p?.pageSize || config.default.pageSize + } + return new ListResponse(meta, r) + } + else return r + + } + } diff --git a/src/resources/addresses.ts b/src/resources/addresses.ts index c72cd29e..a77cae77 100644 --- a/src/resources/addresses.ts +++ b/src/resources/addresses.ts @@ -94,7 +94,7 @@ class Addresses extends ApiResource { // static readonly PATH = 'addresses' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: Addresses.TYPE }, params, options) + return this.resources.list
({ type: Addresses.TYPE }, params, options) } async create(resource: AddressCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise
{ @@ -112,7 +112,10 @@ class Addresses extends ApiResource { async delete(id: string, options?: ResourcesConfig): Promise { await this.resources.delete({ type: Addresses.TYPE, id }, options) } - + + async geocoder(addressId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'geocoders' }, `addresses/${addressId}/geocoder`, params, options) as unknown as Geocoder + } // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any diff --git a/src/resources/adjustments.ts b/src/resources/adjustments.ts index 0bc71276..4ca9df76 100644 --- a/src/resources/adjustments.ts +++ b/src/resources/adjustments.ts @@ -41,7 +41,7 @@ class Adjustments extends ApiResource { // static readonly PATH = 'adjustments' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: Adjustments.TYPE }, params, options) + return this.resources.list({ type: Adjustments.TYPE }, params, options) } async create(resource: AdjustmentCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { @@ -59,7 +59,6 @@ class Adjustments extends ApiResource { async delete(id: string, options?: ResourcesConfig): Promise { await this.resources.delete({ type: Adjustments.TYPE, id }, options) } - // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any diff --git a/src/resources/adyen_gateways.ts b/src/resources/adyen_gateways.ts index 2cf24ef1..5af02743 100644 --- a/src/resources/adyen_gateways.ts +++ b/src/resources/adyen_gateways.ts @@ -52,7 +52,7 @@ class AdyenGateways extends ApiResource { // static readonly PATH = 'adyen_gateways' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: AdyenGateways.TYPE }, params, options) + return this.resources.list({ type: AdyenGateways.TYPE }, params, options) } async create(resource: AdyenGatewayCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { @@ -70,7 +70,14 @@ class AdyenGateways extends ApiResource { async delete(id: string, options?: ResourcesConfig): Promise { await this.resources.delete({ type: AdyenGateways.TYPE, id }, options) } - + + async payment_methods(adyenGatewayId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'payment_methods' }, `adyen_gateways/${adyenGatewayId}/payment_methods`, params, options) as unknown as ListResponse + } + + async adyen_payments(adyenGatewayId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'adyen_payments' }, `adyen_gateways/${adyenGatewayId}/adyen_payments`, params, options) as unknown as ListResponse + } // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any diff --git a/src/resources/adyen_payments.ts b/src/resources/adyen_payments.ts index ebae823b..abacd71d 100644 --- a/src/resources/adyen_payments.ts +++ b/src/resources/adyen_payments.ts @@ -48,7 +48,7 @@ class AdyenPayments extends ApiResource { // static readonly PATH = 'adyen_payments' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: AdyenPayments.TYPE }, params, options) + return this.resources.list({ type: AdyenPayments.TYPE }, params, options) } async create(resource: AdyenPaymentCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { @@ -66,7 +66,14 @@ class AdyenPayments extends ApiResource { async delete(id: string, options?: ResourcesConfig): Promise { await this.resources.delete({ type: AdyenPayments.TYPE, id }, options) } - + + async order(adyenPaymentId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'orders' }, `adyen_payments/${adyenPaymentId}/order`, params, options) as unknown as Order + } + + async payment_gateway(adyenPaymentId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'payment_gateways' }, `adyen_payments/${adyenPaymentId}/payment_gateway`, params, options) as unknown as PaymentGateway + } // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any diff --git a/src/resources/attachments.ts b/src/resources/attachments.ts index cc46caa0..05476b6f 100644 --- a/src/resources/attachments.ts +++ b/src/resources/attachments.ts @@ -105,7 +105,7 @@ class Attachments extends ApiResource { // static readonly PATH = 'attachments' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: Attachments.TYPE }, params, options) + return this.resources.list({ type: Attachments.TYPE }, params, options) } async create(resource: AttachmentCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { @@ -123,7 +123,6 @@ class Attachments extends ApiResource { async delete(id: string, options?: ResourcesConfig): Promise { await this.resources.delete({ type: Attachments.TYPE, id }, options) } - // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any diff --git a/src/resources/authorizations.ts b/src/resources/authorizations.ts index edc02f87..e56cd2ed 100644 --- a/src/resources/authorizations.ts +++ b/src/resources/authorizations.ts @@ -59,7 +59,7 @@ class Authorizations extends ApiResource { // static readonly PATH = 'authorizations' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: Authorizations.TYPE }, params, options) + return this.resources.list({ type: Authorizations.TYPE }, params, options) } async retrieve(id: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { @@ -70,6 +70,18 @@ class Authorizations extends ApiResource { return this.resources.update({ ...resource, type: Authorizations.TYPE }, params, options) } + async order(authorizationId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'orders' }, `authorizations/${authorizationId}/order`, params, options) as unknown as Order + } + + async captures(authorizationId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'captures' }, `authorizations/${authorizationId}/captures`, params, options) as unknown as ListResponse + } + + async voids(authorizationId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'voids' }, `authorizations/${authorizationId}/voids`, params, options) as unknown as ListResponse + } + // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any isAuthorization(resource: any): resource is Authorization { diff --git a/src/resources/avalara_accounts.ts b/src/resources/avalara_accounts.ts index cf8adf35..1a4bc591 100644 --- a/src/resources/avalara_accounts.ts +++ b/src/resources/avalara_accounts.ts @@ -56,7 +56,7 @@ class AvalaraAccounts extends ApiResource { // static readonly PATH = 'avalara_accounts' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: AvalaraAccounts.TYPE }, params, options) + return this.resources.list({ type: AvalaraAccounts.TYPE }, params, options) } async create(resource: AvalaraAccountCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { @@ -74,7 +74,18 @@ class AvalaraAccounts extends ApiResource { async delete(id: string, options?: ResourcesConfig): Promise { await this.resources.delete({ type: AvalaraAccounts.TYPE, id }, options) } - + + async tax_categories(avalaraAccountId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'tax_categories' }, `avalara_accounts/${avalaraAccountId}/tax_categories`, params, options) as unknown as ListResponse + } + + async markets(avalaraAccountId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'markets' }, `avalara_accounts/${avalaraAccountId}/markets`, params, options) as unknown as ListResponse + } + + async attachments(avalaraAccountId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'attachments' }, `avalara_accounts/${avalaraAccountId}/attachments`, params, options) as unknown as ListResponse + } // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any diff --git a/src/resources/billing_info_validation_rules.ts b/src/resources/billing_info_validation_rules.ts index d773ae21..f4f5e5b3 100644 --- a/src/resources/billing_info_validation_rules.ts +++ b/src/resources/billing_info_validation_rules.ts @@ -35,7 +35,7 @@ class BillingInfoValidationRules extends ApiResource { // static readonly PATH = 'billing_info_validation_rules' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: BillingInfoValidationRules.TYPE }, params, options) + return this.resources.list({ type: BillingInfoValidationRules.TYPE }, params, options) } async create(resource: BillingInfoValidationRuleCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { @@ -53,7 +53,10 @@ class BillingInfoValidationRules extends ApiResource { async delete(id: string, options?: ResourcesConfig): Promise { await this.resources.delete({ type: BillingInfoValidationRules.TYPE, id }, options) } - + + async market(billingInfoValidationRuleId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'markets' }, `billing_info_validation_rules/${billingInfoValidationRuleId}/market`, params, options) as unknown as Market + } // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any diff --git a/src/resources/bing_geocoders.ts b/src/resources/bing_geocoders.ts index da3d0b61..6134e5b1 100644 --- a/src/resources/bing_geocoders.ts +++ b/src/resources/bing_geocoders.ts @@ -40,7 +40,7 @@ class BingGeocoders extends ApiResource { // static readonly PATH = 'bing_geocoders' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: BingGeocoders.TYPE }, params, options) + return this.resources.list({ type: BingGeocoders.TYPE }, params, options) } async create(resource: BingGeocoderCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { @@ -58,7 +58,14 @@ class BingGeocoders extends ApiResource { async delete(id: string, options?: ResourcesConfig): Promise { await this.resources.delete({ type: BingGeocoders.TYPE, id }, options) } - + + async addresses(bingGeocoderId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch
({ type: 'addresses' }, `bing_geocoders/${bingGeocoderId}/addresses`, params, options) as unknown as ListResponse
+ } + + async attachments(bingGeocoderId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'attachments' }, `bing_geocoders/${bingGeocoderId}/attachments`, params, options) as unknown as ListResponse + } // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any diff --git a/src/resources/braintree_gateways.ts b/src/resources/braintree_gateways.ts index 82acc9a4..7153c356 100644 --- a/src/resources/braintree_gateways.ts +++ b/src/resources/braintree_gateways.ts @@ -61,7 +61,7 @@ class BraintreeGateways extends ApiResource { // static readonly PATH = 'braintree_gateways' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: BraintreeGateways.TYPE }, params, options) + return this.resources.list({ type: BraintreeGateways.TYPE }, params, options) } async create(resource: BraintreeGatewayCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { @@ -79,7 +79,14 @@ class BraintreeGateways extends ApiResource { async delete(id: string, options?: ResourcesConfig): Promise { await this.resources.delete({ type: BraintreeGateways.TYPE, id }, options) } - + + async payment_methods(braintreeGatewayId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'payment_methods' }, `braintree_gateways/${braintreeGatewayId}/payment_methods`, params, options) as unknown as ListResponse + } + + async braintree_payments(braintreeGatewayId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'braintree_payments' }, `braintree_gateways/${braintreeGatewayId}/braintree_payments`, params, options) as unknown as ListResponse + } // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any diff --git a/src/resources/braintree_payments.ts b/src/resources/braintree_payments.ts index 3fd6163a..fc681607 100644 --- a/src/resources/braintree_payments.ts +++ b/src/resources/braintree_payments.ts @@ -52,7 +52,7 @@ class BraintreePayments extends ApiResource { // static readonly PATH = 'braintree_payments' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: BraintreePayments.TYPE }, params, options) + return this.resources.list({ type: BraintreePayments.TYPE }, params, options) } async create(resource: BraintreePaymentCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { @@ -70,7 +70,14 @@ class BraintreePayments extends ApiResource { async delete(id: string, options?: ResourcesConfig): Promise { await this.resources.delete({ type: BraintreePayments.TYPE, id }, options) } - + + async order(braintreePaymentId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'orders' }, `braintree_payments/${braintreePaymentId}/order`, params, options) as unknown as Order + } + + async payment_gateway(braintreePaymentId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'payment_gateways' }, `braintree_payments/${braintreePaymentId}/payment_gateway`, params, options) as unknown as PaymentGateway + } // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any diff --git a/src/resources/bundles.ts b/src/resources/bundles.ts index d9b4f767..d83919eb 100644 --- a/src/resources/bundles.ts +++ b/src/resources/bundles.ts @@ -74,7 +74,7 @@ class Bundles extends ApiResource { // static readonly PATH = 'bundles' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: Bundles.TYPE }, params, options) + return this.resources.list({ type: Bundles.TYPE }, params, options) } async create(resource: BundleCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { @@ -92,7 +92,22 @@ class Bundles extends ApiResource { async delete(id: string, options?: ResourcesConfig): Promise { await this.resources.delete({ type: Bundles.TYPE, id }, options) } - + + async market(bundleId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'markets' }, `bundles/${bundleId}/market`, params, options) as unknown as Market + } + + async sku_list(bundleId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'sku_lists' }, `bundles/${bundleId}/sku_list`, params, options) as unknown as SkuList + } + + async skus(bundleId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'skus' }, `bundles/${bundleId}/skus`, params, options) as unknown as ListResponse + } + + async attachments(bundleId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'attachments' }, `bundles/${bundleId}/attachments`, params, options) as unknown as ListResponse + } // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any diff --git a/src/resources/captures.ts b/src/resources/captures.ts index 7698ec74..dad2b340 100644 --- a/src/resources/captures.ts +++ b/src/resources/captures.ts @@ -50,7 +50,7 @@ class Captures extends ApiResource { // static readonly PATH = 'captures' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: Captures.TYPE }, params, options) + return this.resources.list({ type: Captures.TYPE }, params, options) } async retrieve(id: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { @@ -61,6 +61,18 @@ class Captures extends ApiResource { return this.resources.update({ ...resource, type: Captures.TYPE }, params, options) } + async order(captureId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'orders' }, `captures/${captureId}/order`, params, options) as unknown as Order + } + + async reference_authorization(captureId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'authorizations' }, `captures/${captureId}/reference_authorization`, params, options) as unknown as Authorization + } + + async refunds(captureId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'refunds' }, `captures/${captureId}/refunds`, params, options) as unknown as ListResponse + } + // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any isCapture(resource: any): resource is Capture { diff --git a/src/resources/carrier_accounts.ts b/src/resources/carrier_accounts.ts index 232be70a..0668552f 100644 --- a/src/resources/carrier_accounts.ts +++ b/src/resources/carrier_accounts.ts @@ -26,13 +26,21 @@ class CarrierAccounts extends ApiResource { // static readonly PATH = 'carrier_accounts' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: CarrierAccounts.TYPE }, params, options) + return this.resources.list({ type: CarrierAccounts.TYPE }, params, options) } async retrieve(id: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { return this.resources.retrieve({ type: CarrierAccounts.TYPE, id }, params, options) } + async market(carrierAccountId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'markets' }, `carrier_accounts/${carrierAccountId}/market`, params, options) as unknown as Market + } + + async attachments(carrierAccountId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'attachments' }, `carrier_accounts/${carrierAccountId}/attachments`, params, options) as unknown as ListResponse + } + // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any isCarrierAccount(resource: any): resource is CarrierAccount { diff --git a/src/resources/checkout_com_gateways.ts b/src/resources/checkout_com_gateways.ts index beb622c7..7f413628 100644 --- a/src/resources/checkout_com_gateways.ts +++ b/src/resources/checkout_com_gateways.ts @@ -50,7 +50,7 @@ class CheckoutComGateways extends ApiResource { // static readonly PATH = 'checkout_com_gateways' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: CheckoutComGateways.TYPE }, params, options) + return this.resources.list({ type: CheckoutComGateways.TYPE }, params, options) } async create(resource: CheckoutComGatewayCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { @@ -68,7 +68,14 @@ class CheckoutComGateways extends ApiResource { async delete(id: string, options?: ResourcesConfig): Promise { await this.resources.delete({ type: CheckoutComGateways.TYPE, id }, options) } - + + async payment_methods(checkoutComGatewayId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'payment_methods' }, `checkout_com_gateways/${checkoutComGatewayId}/payment_methods`, params, options) as unknown as ListResponse + } + + async checkout_com_payments(checkoutComGatewayId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'checkout_com_payments' }, `checkout_com_gateways/${checkoutComGatewayId}/checkout_com_payments`, params, options) as unknown as ListResponse + } // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any diff --git a/src/resources/checkout_com_payments.ts b/src/resources/checkout_com_payments.ts index d0c2d36b..f9470c40 100644 --- a/src/resources/checkout_com_payments.ts +++ b/src/resources/checkout_com_payments.ts @@ -55,7 +55,7 @@ class CheckoutComPayments extends ApiResource { // static readonly PATH = 'checkout_com_payments' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: CheckoutComPayments.TYPE }, params, options) + return this.resources.list({ type: CheckoutComPayments.TYPE }, params, options) } async create(resource: CheckoutComPaymentCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { @@ -73,7 +73,14 @@ class CheckoutComPayments extends ApiResource { async delete(id: string, options?: ResourcesConfig): Promise { await this.resources.delete({ type: CheckoutComPayments.TYPE, id }, options) } - + + async order(checkoutComPaymentId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'orders' }, `checkout_com_payments/${checkoutComPaymentId}/order`, params, options) as unknown as Order + } + + async payment_gateway(checkoutComPaymentId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'payment_gateways' }, `checkout_com_payments/${checkoutComPaymentId}/payment_gateway`, params, options) as unknown as PaymentGateway + } // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any diff --git a/src/resources/coupon_codes_promotion_rules.ts b/src/resources/coupon_codes_promotion_rules.ts index 560f0075..0c6152b8 100644 --- a/src/resources/coupon_codes_promotion_rules.ts +++ b/src/resources/coupon_codes_promotion_rules.ts @@ -50,7 +50,7 @@ class CouponCodesPromotionRules extends ApiResource { // static readonly PATH = 'coupon_codes_promotion_rules' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: CouponCodesPromotionRules.TYPE }, params, options) + return this.resources.list({ type: CouponCodesPromotionRules.TYPE }, params, options) } async create(resource: CouponCodesPromotionRuleCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { @@ -68,7 +68,10 @@ class CouponCodesPromotionRules extends ApiResource { async delete(id: string, options?: ResourcesConfig): Promise { await this.resources.delete({ type: CouponCodesPromotionRules.TYPE, id }, options) } - + + async coupons(couponCodesPromotionRuleId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'coupons' }, `coupon_codes_promotion_rules/${couponCodesPromotionRuleId}/coupons`, params, options) as unknown as ListResponse + } // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any diff --git a/src/resources/coupon_recipients.ts b/src/resources/coupon_recipients.ts index 6e51b0b6..b5e71b30 100644 --- a/src/resources/coupon_recipients.ts +++ b/src/resources/coupon_recipients.ts @@ -49,7 +49,7 @@ class CouponRecipients extends ApiResource { // static readonly PATH = 'coupon_recipients' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: CouponRecipients.TYPE }, params, options) + return this.resources.list({ type: CouponRecipients.TYPE }, params, options) } async create(resource: CouponRecipientCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { @@ -67,7 +67,14 @@ class CouponRecipients extends ApiResource { async delete(id: string, options?: ResourcesConfig): Promise { await this.resources.delete({ type: CouponRecipients.TYPE, id }, options) } - + + async customer(couponRecipientId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'customers' }, `coupon_recipients/${couponRecipientId}/customer`, params, options) as unknown as Customer + } + + async attachments(couponRecipientId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'attachments' }, `coupon_recipients/${couponRecipientId}/attachments`, params, options) as unknown as ListResponse + } // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any diff --git a/src/resources/coupons.ts b/src/resources/coupons.ts index c54e8150..5695d08a 100644 --- a/src/resources/coupons.ts +++ b/src/resources/coupons.ts @@ -51,7 +51,7 @@ class Coupons extends ApiResource { // static readonly PATH = 'coupons' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: Coupons.TYPE }, params, options) + return this.resources.list({ type: Coupons.TYPE }, params, options) } async create(resource: CouponCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { @@ -69,7 +69,10 @@ class Coupons extends ApiResource { async delete(id: string, options?: ResourcesConfig): Promise { await this.resources.delete({ type: Coupons.TYPE, id }, options) } - + + async promotion_rule(couponId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'coupon_codes_promotion_rules' }, `coupons/${couponId}/promotion_rule`, params, options) as unknown as CouponCodesPromotionRule + } // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any diff --git a/src/resources/customer_addresses.ts b/src/resources/customer_addresses.ts index f57d8dc1..5c0e6e15 100644 --- a/src/resources/customer_addresses.ts +++ b/src/resources/customer_addresses.ts @@ -42,7 +42,7 @@ class CustomerAddresses extends ApiResource { // static readonly PATH = 'customer_addresses' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: CustomerAddresses.TYPE }, params, options) + return this.resources.list({ type: CustomerAddresses.TYPE }, params, options) } async create(resource: CustomerAddressCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { @@ -60,7 +60,14 @@ class CustomerAddresses extends ApiResource { async delete(id: string, options?: ResourcesConfig): Promise { await this.resources.delete({ type: CustomerAddresses.TYPE, id }, options) } - + + async customer(customerAddressId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'customers' }, `customer_addresses/${customerAddressId}/customer`, params, options) as unknown as Customer + } + + async address(customerAddressId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise
{ + return this.resources.fetch
({ type: 'addresses' }, `customer_addresses/${customerAddressId}/address`, params, options) as unknown as Address + } // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any diff --git a/src/resources/customer_groups.ts b/src/resources/customer_groups.ts index 96a9268d..2c8bb24a 100644 --- a/src/resources/customer_groups.ts +++ b/src/resources/customer_groups.ts @@ -40,7 +40,7 @@ class CustomerGroups extends ApiResource { // static readonly PATH = 'customer_groups' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: CustomerGroups.TYPE }, params, options) + return this.resources.list({ type: CustomerGroups.TYPE }, params, options) } async create(resource: CustomerGroupCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { @@ -58,7 +58,18 @@ class CustomerGroups extends ApiResource { async delete(id: string, options?: ResourcesConfig): Promise { await this.resources.delete({ type: CustomerGroups.TYPE, id }, options) } - + + async customers(customerGroupId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'customers' }, `customer_groups/${customerGroupId}/customers`, params, options) as unknown as ListResponse + } + + async markets(customerGroupId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'markets' }, `customer_groups/${customerGroupId}/markets`, params, options) as unknown as ListResponse + } + + async attachments(customerGroupId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'attachments' }, `customer_groups/${customerGroupId}/attachments`, params, options) as unknown as ListResponse + } // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any diff --git a/src/resources/customer_password_resets.ts b/src/resources/customer_password_resets.ts index 0e07a58a..ce64ac43 100644 --- a/src/resources/customer_password_resets.ts +++ b/src/resources/customer_password_resets.ts @@ -39,7 +39,7 @@ class CustomerPasswordResets extends ApiResource { // static readonly PATH = 'customer_password_resets' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: CustomerPasswordResets.TYPE }, params, options) + return this.resources.list({ type: CustomerPasswordResets.TYPE }, params, options) } async create(resource: CustomerPasswordResetCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { @@ -57,7 +57,10 @@ class CustomerPasswordResets extends ApiResource { async delete(id: string, options?: ResourcesConfig): Promise { await this.resources.delete({ type: CustomerPasswordResets.TYPE, id }, options) } - + + async customer(customerPasswordResetId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'customers' }, `customer_password_resets/${customerPasswordResetId}/customer`, params, options) as unknown as Customer + } // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any diff --git a/src/resources/customer_payment_sources.ts b/src/resources/customer_payment_sources.ts index 5ef6edcd..7119851c 100644 --- a/src/resources/customer_payment_sources.ts +++ b/src/resources/customer_payment_sources.ts @@ -58,7 +58,7 @@ class CustomerPaymentSources extends ApiResource { // static readonly PATH = 'customer_payment_sources' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: CustomerPaymentSources.TYPE }, params, options) + return this.resources.list({ type: CustomerPaymentSources.TYPE }, params, options) } async create(resource: CustomerPaymentSourceCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { @@ -76,7 +76,10 @@ class CustomerPaymentSources extends ApiResource { async delete(id: string, options?: ResourcesConfig): Promise { await this.resources.delete({ type: CustomerPaymentSources.TYPE, id }, options) } - + + async customer(customerPaymentSourceId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'customers' }, `customer_payment_sources/${customerPaymentSourceId}/customer`, params, options) as unknown as Customer + } // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any diff --git a/src/resources/customer_subscriptions.ts b/src/resources/customer_subscriptions.ts index 39d55635..500fa42d 100644 --- a/src/resources/customer_subscriptions.ts +++ b/src/resources/customer_subscriptions.ts @@ -32,7 +32,7 @@ class CustomerSubscriptions extends ApiResource { // static readonly PATH = 'customer_subscriptions' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: CustomerSubscriptions.TYPE }, params, options) + return this.resources.list({ type: CustomerSubscriptions.TYPE }, params, options) } async create(resource: CustomerSubscriptionCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { @@ -50,7 +50,10 @@ class CustomerSubscriptions extends ApiResource { async delete(id: string, options?: ResourcesConfig): Promise { await this.resources.delete({ type: CustomerSubscriptions.TYPE, id }, options) } - + + async customer(customerSubscriptionId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'customers' }, `customer_subscriptions/${customerSubscriptionId}/customer`, params, options) as unknown as Customer + } // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any diff --git a/src/resources/customers.ts b/src/resources/customers.ts index 81aceced..815dc2ac 100644 --- a/src/resources/customers.ts +++ b/src/resources/customers.ts @@ -59,7 +59,7 @@ class Customers extends ApiResource { // static readonly PATH = 'customers' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: Customers.TYPE }, params, options) + return this.resources.list({ type: Customers.TYPE }, params, options) } async create(resource: CustomerCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { @@ -77,7 +77,38 @@ class Customers extends ApiResource { async delete(id: string, options?: ResourcesConfig): Promise { await this.resources.delete({ type: Customers.TYPE, id }, options) } - + + async customer_group(customerId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'customer_groups' }, `customers/${customerId}/customer_group`, params, options) as unknown as CustomerGroup + } + + async customer_addresses(customerId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'customer_addresses' }, `customers/${customerId}/customer_addresses`, params, options) as unknown as ListResponse + } + + async customer_payment_sources(customerId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'customer_payment_sources' }, `customers/${customerId}/customer_payment_sources`, params, options) as unknown as ListResponse + } + + async customer_subscriptions(customerId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'customer_subscriptions' }, `customers/${customerId}/customer_subscriptions`, params, options) as unknown as ListResponse + } + + async orders(customerId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'orders' }, `customers/${customerId}/orders`, params, options) as unknown as ListResponse + } + + async order_subscriptions(customerId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'order_subscriptions' }, `customers/${customerId}/order_subscriptions`, params, options) as unknown as ListResponse + } + + async returns(customerId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'returns' }, `customers/${customerId}/returns`, params, options) as unknown as ListResponse + } + + async attachments(customerId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'attachments' }, `customers/${customerId}/attachments`, params, options) as unknown as ListResponse + } // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any diff --git a/src/resources/delivery_lead_times.ts b/src/resources/delivery_lead_times.ts index 4e7833da..28066fa5 100644 --- a/src/resources/delivery_lead_times.ts +++ b/src/resources/delivery_lead_times.ts @@ -53,7 +53,7 @@ class DeliveryLeadTimes extends ApiResource { // static readonly PATH = 'delivery_lead_times' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: DeliveryLeadTimes.TYPE }, params, options) + return this.resources.list({ type: DeliveryLeadTimes.TYPE }, params, options) } async create(resource: DeliveryLeadTimeCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { @@ -71,7 +71,18 @@ class DeliveryLeadTimes extends ApiResource { async delete(id: string, options?: ResourcesConfig): Promise { await this.resources.delete({ type: DeliveryLeadTimes.TYPE, id }, options) } - + + async stock_location(deliveryLeadTimeId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'stock_locations' }, `delivery_lead_times/${deliveryLeadTimeId}/stock_location`, params, options) as unknown as StockLocation + } + + async shipping_method(deliveryLeadTimeId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'shipping_methods' }, `delivery_lead_times/${deliveryLeadTimeId}/shipping_method`, params, options) as unknown as ShippingMethod + } + + async attachments(deliveryLeadTimeId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'attachments' }, `delivery_lead_times/${deliveryLeadTimeId}/attachments`, params, options) as unknown as ListResponse + } // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any diff --git a/src/resources/event_callbacks.ts b/src/resources/event_callbacks.ts index 67e2ebad..4b305e89 100644 --- a/src/resources/event_callbacks.ts +++ b/src/resources/event_callbacks.ts @@ -25,13 +25,17 @@ class EventCallbacks extends ApiResource { // static readonly PATH = 'event_callbacks' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: EventCallbacks.TYPE }, params, options) + return this.resources.list({ type: EventCallbacks.TYPE }, params, options) } async retrieve(id: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { return this.resources.retrieve({ type: EventCallbacks.TYPE, id }, params, options) } + async webhook(eventCallbackId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'webhooks' }, `event_callbacks/${eventCallbackId}/webhook`, params, options) as unknown as Webhook + } + // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any isEventCallback(resource: any): resource is EventCallback { diff --git a/src/resources/external_gateways.ts b/src/resources/external_gateways.ts index 31492ef4..ee6ab72e 100644 --- a/src/resources/external_gateways.ts +++ b/src/resources/external_gateways.ts @@ -54,7 +54,7 @@ class ExternalGateways extends ApiResource { // static readonly PATH = 'external_gateways' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: ExternalGateways.TYPE }, params, options) + return this.resources.list({ type: ExternalGateways.TYPE }, params, options) } async create(resource: ExternalGatewayCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { @@ -72,7 +72,14 @@ class ExternalGateways extends ApiResource { async delete(id: string, options?: ResourcesConfig): Promise { await this.resources.delete({ type: ExternalGateways.TYPE, id }, options) } - + + async payment_methods(externalGatewayId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'payment_methods' }, `external_gateways/${externalGatewayId}/payment_methods`, params, options) as unknown as ListResponse + } + + async external_payments(externalGatewayId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'external_payments' }, `external_gateways/${externalGatewayId}/external_payments`, params, options) as unknown as ListResponse + } // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any diff --git a/src/resources/external_payments.ts b/src/resources/external_payments.ts index d3b294ad..928e08b4 100644 --- a/src/resources/external_payments.ts +++ b/src/resources/external_payments.ts @@ -47,7 +47,7 @@ class ExternalPayments extends ApiResource { // static readonly PATH = 'external_payments' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: ExternalPayments.TYPE }, params, options) + return this.resources.list({ type: ExternalPayments.TYPE }, params, options) } async create(resource: ExternalPaymentCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { @@ -65,7 +65,18 @@ class ExternalPayments extends ApiResource { async delete(id: string, options?: ResourcesConfig): Promise { await this.resources.delete({ type: ExternalPayments.TYPE, id }, options) } - + + async order(externalPaymentId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'orders' }, `external_payments/${externalPaymentId}/order`, params, options) as unknown as Order + } + + async payment_gateway(externalPaymentId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'payment_gateways' }, `external_payments/${externalPaymentId}/payment_gateway`, params, options) as unknown as PaymentGateway + } + + async wallet(externalPaymentId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'customer_payment_sources' }, `external_payments/${externalPaymentId}/wallet`, params, options) as unknown as CustomerPaymentSource + } // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any diff --git a/src/resources/external_promotions.ts b/src/resources/external_promotions.ts index 6b433bbd..4d336a09 100644 --- a/src/resources/external_promotions.ts +++ b/src/resources/external_promotions.ts @@ -80,7 +80,7 @@ class ExternalPromotions extends ApiResource { // static readonly PATH = 'external_promotions' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: ExternalPromotions.TYPE }, params, options) + return this.resources.list({ type: ExternalPromotions.TYPE }, params, options) } async create(resource: ExternalPromotionCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { @@ -98,7 +98,26 @@ class ExternalPromotions extends ApiResource { async delete(id: string, options?: ResourcesConfig): Promise { await this.resources.delete({ type: ExternalPromotions.TYPE, id }, options) } - + + async market(externalPromotionId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'markets' }, `external_promotions/${externalPromotionId}/market`, params, options) as unknown as Market + } + + async order_amount_promotion_rule(externalPromotionId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'order_amount_promotion_rules' }, `external_promotions/${externalPromotionId}/order_amount_promotion_rule`, params, options) as unknown as OrderAmountPromotionRule + } + + async sku_list_promotion_rule(externalPromotionId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'sku_list_promotion_rules' }, `external_promotions/${externalPromotionId}/sku_list_promotion_rule`, params, options) as unknown as SkuListPromotionRule + } + + async coupon_codes_promotion_rule(externalPromotionId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'coupon_codes_promotion_rules' }, `external_promotions/${externalPromotionId}/coupon_codes_promotion_rule`, params, options) as unknown as CouponCodesPromotionRule + } + + async attachments(externalPromotionId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'attachments' }, `external_promotions/${externalPromotionId}/attachments`, params, options) as unknown as ListResponse + } // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any diff --git a/src/resources/external_tax_calculators.ts b/src/resources/external_tax_calculators.ts index 131db37c..84684bf1 100644 --- a/src/resources/external_tax_calculators.ts +++ b/src/resources/external_tax_calculators.ts @@ -48,7 +48,7 @@ class ExternalTaxCalculators extends ApiResource { // static readonly PATH = 'external_tax_calculators' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: ExternalTaxCalculators.TYPE }, params, options) + return this.resources.list({ type: ExternalTaxCalculators.TYPE }, params, options) } async create(resource: ExternalTaxCalculatorCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { @@ -66,7 +66,18 @@ class ExternalTaxCalculators extends ApiResource { async delete(id: string, options?: ResourcesConfig): Promise { await this.resources.delete({ type: ExternalTaxCalculators.TYPE, id }, options) } - + + async tax_categories(externalTaxCalculatorId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'tax_categories' }, `external_tax_calculators/${externalTaxCalculatorId}/tax_categories`, params, options) as unknown as ListResponse + } + + async markets(externalTaxCalculatorId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'markets' }, `external_tax_calculators/${externalTaxCalculatorId}/markets`, params, options) as unknown as ListResponse + } + + async attachments(externalTaxCalculatorId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'attachments' }, `external_tax_calculators/${externalTaxCalculatorId}/attachments`, params, options) as unknown as ListResponse + } // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any diff --git a/src/resources/fixed_amount_promotions.ts b/src/resources/fixed_amount_promotions.ts index 2277df50..0921b2fb 100644 --- a/src/resources/fixed_amount_promotions.ts +++ b/src/resources/fixed_amount_promotions.ts @@ -82,7 +82,7 @@ class FixedAmountPromotions extends ApiResource { // static readonly PATH = 'fixed_amount_promotions' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: FixedAmountPromotions.TYPE }, params, options) + return this.resources.list({ type: FixedAmountPromotions.TYPE }, params, options) } async create(resource: FixedAmountPromotionCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { @@ -100,7 +100,26 @@ class FixedAmountPromotions extends ApiResource { async delete(id: string, options?: ResourcesConfig): Promise { await this.resources.delete({ type: FixedAmountPromotions.TYPE, id }, options) } - + + async market(fixedAmountPromotionId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'markets' }, `fixed_amount_promotions/${fixedAmountPromotionId}/market`, params, options) as unknown as Market + } + + async order_amount_promotion_rule(fixedAmountPromotionId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'order_amount_promotion_rules' }, `fixed_amount_promotions/${fixedAmountPromotionId}/order_amount_promotion_rule`, params, options) as unknown as OrderAmountPromotionRule + } + + async sku_list_promotion_rule(fixedAmountPromotionId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'sku_list_promotion_rules' }, `fixed_amount_promotions/${fixedAmountPromotionId}/sku_list_promotion_rule`, params, options) as unknown as SkuListPromotionRule + } + + async coupon_codes_promotion_rule(fixedAmountPromotionId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'coupon_codes_promotion_rules' }, `fixed_amount_promotions/${fixedAmountPromotionId}/coupon_codes_promotion_rule`, params, options) as unknown as CouponCodesPromotionRule + } + + async attachments(fixedAmountPromotionId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'attachments' }, `fixed_amount_promotions/${fixedAmountPromotionId}/attachments`, params, options) as unknown as ListResponse + } // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any diff --git a/src/resources/fixed_price_promotions.ts b/src/resources/fixed_price_promotions.ts index a44fad2c..fcf30fcd 100644 --- a/src/resources/fixed_price_promotions.ts +++ b/src/resources/fixed_price_promotions.ts @@ -89,7 +89,7 @@ class FixedPricePromotions extends ApiResource { // static readonly PATH = 'fixed_price_promotions' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: FixedPricePromotions.TYPE }, params, options) + return this.resources.list({ type: FixedPricePromotions.TYPE }, params, options) } async create(resource: FixedPricePromotionCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { @@ -107,7 +107,34 @@ class FixedPricePromotions extends ApiResource { async delete(id: string, options?: ResourcesConfig): Promise { await this.resources.delete({ type: FixedPricePromotions.TYPE, id }, options) } - + + async market(fixedPricePromotionId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'markets' }, `fixed_price_promotions/${fixedPricePromotionId}/market`, params, options) as unknown as Market + } + + async order_amount_promotion_rule(fixedPricePromotionId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'order_amount_promotion_rules' }, `fixed_price_promotions/${fixedPricePromotionId}/order_amount_promotion_rule`, params, options) as unknown as OrderAmountPromotionRule + } + + async sku_list_promotion_rule(fixedPricePromotionId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'sku_list_promotion_rules' }, `fixed_price_promotions/${fixedPricePromotionId}/sku_list_promotion_rule`, params, options) as unknown as SkuListPromotionRule + } + + async coupon_codes_promotion_rule(fixedPricePromotionId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'coupon_codes_promotion_rules' }, `fixed_price_promotions/${fixedPricePromotionId}/coupon_codes_promotion_rule`, params, options) as unknown as CouponCodesPromotionRule + } + + async attachments(fixedPricePromotionId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'attachments' }, `fixed_price_promotions/${fixedPricePromotionId}/attachments`, params, options) as unknown as ListResponse + } + + async sku_list(fixedPricePromotionId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'sku_lists' }, `fixed_price_promotions/${fixedPricePromotionId}/sku_list`, params, options) as unknown as SkuList + } + + async skus(fixedPricePromotionId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'skus' }, `fixed_price_promotions/${fixedPricePromotionId}/skus`, params, options) as unknown as ListResponse + } // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any diff --git a/src/resources/free_gift_promotions.ts b/src/resources/free_gift_promotions.ts index b4f9d3b2..ba99fa31 100644 --- a/src/resources/free_gift_promotions.ts +++ b/src/resources/free_gift_promotions.ts @@ -87,7 +87,7 @@ class FreeGiftPromotions extends ApiResource { // static readonly PATH = 'free_gift_promotions' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: FreeGiftPromotions.TYPE }, params, options) + return this.resources.list({ type: FreeGiftPromotions.TYPE }, params, options) } async create(resource: FreeGiftPromotionCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { @@ -105,7 +105,34 @@ class FreeGiftPromotions extends ApiResource { async delete(id: string, options?: ResourcesConfig): Promise { await this.resources.delete({ type: FreeGiftPromotions.TYPE, id }, options) } - + + async market(freeGiftPromotionId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'markets' }, `free_gift_promotions/${freeGiftPromotionId}/market`, params, options) as unknown as Market + } + + async order_amount_promotion_rule(freeGiftPromotionId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'order_amount_promotion_rules' }, `free_gift_promotions/${freeGiftPromotionId}/order_amount_promotion_rule`, params, options) as unknown as OrderAmountPromotionRule + } + + async sku_list_promotion_rule(freeGiftPromotionId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'sku_list_promotion_rules' }, `free_gift_promotions/${freeGiftPromotionId}/sku_list_promotion_rule`, params, options) as unknown as SkuListPromotionRule + } + + async coupon_codes_promotion_rule(freeGiftPromotionId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'coupon_codes_promotion_rules' }, `free_gift_promotions/${freeGiftPromotionId}/coupon_codes_promotion_rule`, params, options) as unknown as CouponCodesPromotionRule + } + + async attachments(freeGiftPromotionId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'attachments' }, `free_gift_promotions/${freeGiftPromotionId}/attachments`, params, options) as unknown as ListResponse + } + + async sku_list(freeGiftPromotionId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'sku_lists' }, `free_gift_promotions/${freeGiftPromotionId}/sku_list`, params, options) as unknown as SkuList + } + + async skus(freeGiftPromotionId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'skus' }, `free_gift_promotions/${freeGiftPromotionId}/skus`, params, options) as unknown as ListResponse + } // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any diff --git a/src/resources/free_shipping_promotions.ts b/src/resources/free_shipping_promotions.ts index 0f5cc1c0..7974c625 100644 --- a/src/resources/free_shipping_promotions.ts +++ b/src/resources/free_shipping_promotions.ts @@ -77,7 +77,7 @@ class FreeShippingPromotions extends ApiResource { // static readonly PATH = 'free_shipping_promotions' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: FreeShippingPromotions.TYPE }, params, options) + return this.resources.list({ type: FreeShippingPromotions.TYPE }, params, options) } async create(resource: FreeShippingPromotionCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { @@ -95,7 +95,26 @@ class FreeShippingPromotions extends ApiResource { async delete(id: string, options?: ResourcesConfig): Promise { await this.resources.delete({ type: FreeShippingPromotions.TYPE, id }, options) } - + + async market(freeShippingPromotionId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'markets' }, `free_shipping_promotions/${freeShippingPromotionId}/market`, params, options) as unknown as Market + } + + async order_amount_promotion_rule(freeShippingPromotionId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'order_amount_promotion_rules' }, `free_shipping_promotions/${freeShippingPromotionId}/order_amount_promotion_rule`, params, options) as unknown as OrderAmountPromotionRule + } + + async sku_list_promotion_rule(freeShippingPromotionId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'sku_list_promotion_rules' }, `free_shipping_promotions/${freeShippingPromotionId}/sku_list_promotion_rule`, params, options) as unknown as SkuListPromotionRule + } + + async coupon_codes_promotion_rule(freeShippingPromotionId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'coupon_codes_promotion_rules' }, `free_shipping_promotions/${freeShippingPromotionId}/coupon_codes_promotion_rule`, params, options) as unknown as CouponCodesPromotionRule + } + + async attachments(freeShippingPromotionId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'attachments' }, `free_shipping_promotions/${freeShippingPromotionId}/attachments`, params, options) as unknown as ListResponse + } // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any diff --git a/src/resources/geocoders.ts b/src/resources/geocoders.ts index 34e93e7d..9583f87f 100644 --- a/src/resources/geocoders.ts +++ b/src/resources/geocoders.ts @@ -24,13 +24,21 @@ class Geocoders extends ApiResource { // static readonly PATH = 'geocoders' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: Geocoders.TYPE }, params, options) + return this.resources.list({ type: Geocoders.TYPE }, params, options) } async retrieve(id: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { return this.resources.retrieve({ type: Geocoders.TYPE, id }, params, options) } + async addresses(geocoderId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch
({ type: 'addresses' }, `geocoders/${geocoderId}/addresses`, params, options) as unknown as ListResponse
+ } + + async attachments(geocoderId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'attachments' }, `geocoders/${geocoderId}/attachments`, params, options) as unknown as ListResponse + } + // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any isGeocoder(resource: any): resource is Geocoder { diff --git a/src/resources/gift_card_recipients.ts b/src/resources/gift_card_recipients.ts index c95d25a0..fd48a0bf 100644 --- a/src/resources/gift_card_recipients.ts +++ b/src/resources/gift_card_recipients.ts @@ -49,7 +49,7 @@ class GiftCardRecipients extends ApiResource { // static readonly PATH = 'gift_card_recipients' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: GiftCardRecipients.TYPE }, params, options) + return this.resources.list({ type: GiftCardRecipients.TYPE }, params, options) } async create(resource: GiftCardRecipientCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { @@ -67,7 +67,14 @@ class GiftCardRecipients extends ApiResource { async delete(id: string, options?: ResourcesConfig): Promise { await this.resources.delete({ type: GiftCardRecipients.TYPE, id }, options) } - + + async customer(giftCardRecipientId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'customers' }, `gift_card_recipients/${giftCardRecipientId}/customer`, params, options) as unknown as Customer + } + + async attachments(giftCardRecipientId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'attachments' }, `gift_card_recipients/${giftCardRecipientId}/attachments`, params, options) as unknown as ListResponse + } // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any diff --git a/src/resources/gift_cards.ts b/src/resources/gift_cards.ts index ae021bb9..4aeaba42 100644 --- a/src/resources/gift_cards.ts +++ b/src/resources/gift_cards.ts @@ -84,7 +84,7 @@ class GiftCards extends ApiResource { // static readonly PATH = 'gift_cards' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: GiftCards.TYPE }, params, options) + return this.resources.list({ type: GiftCards.TYPE }, params, options) } async create(resource: GiftCardCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { @@ -102,7 +102,18 @@ class GiftCards extends ApiResource { async delete(id: string, options?: ResourcesConfig): Promise { await this.resources.delete({ type: GiftCards.TYPE, id }, options) } - + + async market(giftCardId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'markets' }, `gift_cards/${giftCardId}/market`, params, options) as unknown as Market + } + + async gift_card_recipient(giftCardId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'gift_card_recipients' }, `gift_cards/${giftCardId}/gift_card_recipient`, params, options) as unknown as GiftCardRecipient + } + + async attachments(giftCardId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'attachments' }, `gift_cards/${giftCardId}/attachments`, params, options) as unknown as ListResponse + } // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any diff --git a/src/resources/google_geocoders.ts b/src/resources/google_geocoders.ts index f0d9d4f1..11d8eaaa 100644 --- a/src/resources/google_geocoders.ts +++ b/src/resources/google_geocoders.ts @@ -40,7 +40,7 @@ class GoogleGeocoders extends ApiResource { // static readonly PATH = 'google_geocoders' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: GoogleGeocoders.TYPE }, params, options) + return this.resources.list({ type: GoogleGeocoders.TYPE }, params, options) } async create(resource: GoogleGeocoderCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { @@ -58,7 +58,14 @@ class GoogleGeocoders extends ApiResource { async delete(id: string, options?: ResourcesConfig): Promise { await this.resources.delete({ type: GoogleGeocoders.TYPE, id }, options) } - + + async addresses(googleGeocoderId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch
({ type: 'addresses' }, `google_geocoders/${googleGeocoderId}/addresses`, params, options) as unknown as ListResponse
+ } + + async attachments(googleGeocoderId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'attachments' }, `google_geocoders/${googleGeocoderId}/attachments`, params, options) as unknown as ListResponse + } // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any diff --git a/src/resources/imports.ts b/src/resources/imports.ts index 72d30729..895e55bd 100644 --- a/src/resources/imports.ts +++ b/src/resources/imports.ts @@ -43,7 +43,7 @@ class Imports extends ApiResource { // static readonly PATH = 'imports' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: Imports.TYPE }, params, options) + return this.resources.list({ type: Imports.TYPE }, params, options) } async create(resource: ImportCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { @@ -57,7 +57,6 @@ class Imports extends ApiResource { async delete(id: string, options?: ResourcesConfig): Promise { await this.resources.delete({ type: Imports.TYPE, id }, options) } - // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any diff --git a/src/resources/in_stock_subscriptions.ts b/src/resources/in_stock_subscriptions.ts index 5bf3ebac..6972877e 100644 --- a/src/resources/in_stock_subscriptions.ts +++ b/src/resources/in_stock_subscriptions.ts @@ -59,7 +59,7 @@ class InStockSubscriptions extends ApiResource { // static readonly PATH = 'in_stock_subscriptions' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: InStockSubscriptions.TYPE }, params, options) + return this.resources.list({ type: InStockSubscriptions.TYPE }, params, options) } async create(resource: InStockSubscriptionCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { @@ -77,7 +77,18 @@ class InStockSubscriptions extends ApiResource { async delete(id: string, options?: ResourcesConfig): Promise { await this.resources.delete({ type: InStockSubscriptions.TYPE, id }, options) } - + + async market(inStockSubscriptionId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'markets' }, `in_stock_subscriptions/${inStockSubscriptionId}/market`, params, options) as unknown as Market + } + + async customer(inStockSubscriptionId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'customers' }, `in_stock_subscriptions/${inStockSubscriptionId}/customer`, params, options) as unknown as Customer + } + + async sku(inStockSubscriptionId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'skus' }, `in_stock_subscriptions/${inStockSubscriptionId}/sku`, params, options) as unknown as Sku + } // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any diff --git a/src/resources/inventory_models.ts b/src/resources/inventory_models.ts index 7308177f..80824c0b 100644 --- a/src/resources/inventory_models.ts +++ b/src/resources/inventory_models.ts @@ -46,7 +46,7 @@ class InventoryModels extends ApiResource { // static readonly PATH = 'inventory_models' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: InventoryModels.TYPE }, params, options) + return this.resources.list({ type: InventoryModels.TYPE }, params, options) } async create(resource: InventoryModelCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { @@ -64,7 +64,18 @@ class InventoryModels extends ApiResource { async delete(id: string, options?: ResourcesConfig): Promise { await this.resources.delete({ type: InventoryModels.TYPE, id }, options) } - + + async inventory_stock_locations(inventoryModelId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'inventory_stock_locations' }, `inventory_models/${inventoryModelId}/inventory_stock_locations`, params, options) as unknown as ListResponse + } + + async inventory_return_locations(inventoryModelId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'inventory_return_locations' }, `inventory_models/${inventoryModelId}/inventory_return_locations`, params, options) as unknown as ListResponse + } + + async attachments(inventoryModelId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'attachments' }, `inventory_models/${inventoryModelId}/attachments`, params, options) as unknown as ListResponse + } // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any diff --git a/src/resources/inventory_return_locations.ts b/src/resources/inventory_return_locations.ts index 5cc13d04..6fc2a50e 100644 --- a/src/resources/inventory_return_locations.ts +++ b/src/resources/inventory_return_locations.ts @@ -46,7 +46,7 @@ class InventoryReturnLocations extends ApiResource { // static readonly PATH = 'inventory_return_locations' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: InventoryReturnLocations.TYPE }, params, options) + return this.resources.list({ type: InventoryReturnLocations.TYPE }, params, options) } async create(resource: InventoryReturnLocationCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { @@ -64,7 +64,14 @@ class InventoryReturnLocations extends ApiResource { async delete(id: string, options?: ResourcesConfig): Promise { await this.resources.delete({ type: InventoryReturnLocations.TYPE, id }, options) } - + + async stock_location(inventoryReturnLocationId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'stock_locations' }, `inventory_return_locations/${inventoryReturnLocationId}/stock_location`, params, options) as unknown as StockLocation + } + + async inventory_model(inventoryReturnLocationId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'inventory_models' }, `inventory_return_locations/${inventoryReturnLocationId}/inventory_model`, params, options) as unknown as InventoryModel + } // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any diff --git a/src/resources/inventory_stock_locations.ts b/src/resources/inventory_stock_locations.ts index 59fb619b..de0d4efa 100644 --- a/src/resources/inventory_stock_locations.ts +++ b/src/resources/inventory_stock_locations.ts @@ -49,7 +49,7 @@ class InventoryStockLocations extends ApiResource { // static readonly PATH = 'inventory_stock_locations' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: InventoryStockLocations.TYPE }, params, options) + return this.resources.list({ type: InventoryStockLocations.TYPE }, params, options) } async create(resource: InventoryStockLocationCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { @@ -67,7 +67,14 @@ class InventoryStockLocations extends ApiResource { async delete(id: string, options?: ResourcesConfig): Promise { await this.resources.delete({ type: InventoryStockLocations.TYPE, id }, options) } - + + async stock_location(inventoryStockLocationId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'stock_locations' }, `inventory_stock_locations/${inventoryStockLocationId}/stock_location`, params, options) as unknown as StockLocation + } + + async inventory_model(inventoryStockLocationId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'inventory_models' }, `inventory_stock_locations/${inventoryStockLocationId}/inventory_model`, params, options) as unknown as InventoryModel + } // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any diff --git a/src/resources/klarna_gateways.ts b/src/resources/klarna_gateways.ts index c89e77fc..aacadba2 100644 --- a/src/resources/klarna_gateways.ts +++ b/src/resources/klarna_gateways.ts @@ -49,7 +49,7 @@ class KlarnaGateways extends ApiResource { // static readonly PATH = 'klarna_gateways' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: KlarnaGateways.TYPE }, params, options) + return this.resources.list({ type: KlarnaGateways.TYPE }, params, options) } async create(resource: KlarnaGatewayCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { @@ -67,7 +67,14 @@ class KlarnaGateways extends ApiResource { async delete(id: string, options?: ResourcesConfig): Promise { await this.resources.delete({ type: KlarnaGateways.TYPE, id }, options) } - + + async payment_methods(klarnaGatewayId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'payment_methods' }, `klarna_gateways/${klarnaGatewayId}/payment_methods`, params, options) as unknown as ListResponse + } + + async klarna_payments(klarnaGatewayId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'klarna_payments' }, `klarna_gateways/${klarnaGatewayId}/klarna_payments`, params, options) as unknown as ListResponse + } // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any diff --git a/src/resources/klarna_payments.ts b/src/resources/klarna_payments.ts index 533fd603..9edce709 100644 --- a/src/resources/klarna_payments.ts +++ b/src/resources/klarna_payments.ts @@ -45,7 +45,7 @@ class KlarnaPayments extends ApiResource { // static readonly PATH = 'klarna_payments' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: KlarnaPayments.TYPE }, params, options) + return this.resources.list({ type: KlarnaPayments.TYPE }, params, options) } async create(resource: KlarnaPaymentCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { @@ -63,7 +63,14 @@ class KlarnaPayments extends ApiResource { async delete(id: string, options?: ResourcesConfig): Promise { await this.resources.delete({ type: KlarnaPayments.TYPE, id }, options) } - + + async order(klarnaPaymentId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'orders' }, `klarna_payments/${klarnaPaymentId}/order`, params, options) as unknown as Order + } + + async payment_gateway(klarnaPaymentId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'payment_gateways' }, `klarna_payments/${klarnaPaymentId}/payment_gateway`, params, options) as unknown as PaymentGateway + } // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any diff --git a/src/resources/line_item_options.ts b/src/resources/line_item_options.ts index e78c1972..f91d95a1 100644 --- a/src/resources/line_item_options.ts +++ b/src/resources/line_item_options.ts @@ -60,7 +60,7 @@ class LineItemOptions extends ApiResource { // static readonly PATH = 'line_item_options' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: LineItemOptions.TYPE }, params, options) + return this.resources.list({ type: LineItemOptions.TYPE }, params, options) } async create(resource: LineItemOptionCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { @@ -78,7 +78,14 @@ class LineItemOptions extends ApiResource { async delete(id: string, options?: ResourcesConfig): Promise { await this.resources.delete({ type: LineItemOptions.TYPE, id }, options) } - + + async line_item(lineItemOptionId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'line_items' }, `line_item_options/${lineItemOptionId}/line_item`, params, options) as unknown as LineItem + } + + async sku_option(lineItemOptionId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'sku_options' }, `line_item_options/${lineItemOptionId}/sku_option`, params, options) as unknown as SkuOption + } // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any diff --git a/src/resources/line_items.ts b/src/resources/line_items.ts index 26cdcb71..73f55a5c 100644 --- a/src/resources/line_items.ts +++ b/src/resources/line_items.ts @@ -107,7 +107,7 @@ class LineItems extends ApiResource { // static readonly PATH = 'line_items' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: LineItems.TYPE }, params, options) + return this.resources.list({ type: LineItems.TYPE }, params, options) } async create(resource: LineItemCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { @@ -125,7 +125,22 @@ class LineItems extends ApiResource { async delete(id: string, options?: ResourcesConfig): Promise { await this.resources.delete({ type: LineItems.TYPE, id }, options) } - + + async order(lineItemId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'orders' }, `line_items/${lineItemId}/order`, params, options) as unknown as Order + } + + async line_item_options(lineItemId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'line_item_options' }, `line_items/${lineItemId}/line_item_options`, params, options) as unknown as ListResponse + } + + async stock_line_items(lineItemId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'stock_line_items' }, `line_items/${lineItemId}/stock_line_items`, params, options) as unknown as ListResponse + } + + async stock_transfers(lineItemId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'stock_transfers' }, `line_items/${lineItemId}/stock_transfers`, params, options) as unknown as ListResponse + } // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any diff --git a/src/resources/manual_gateways.ts b/src/resources/manual_gateways.ts index 7f4f9cd6..9b833690 100644 --- a/src/resources/manual_gateways.ts +++ b/src/resources/manual_gateways.ts @@ -39,7 +39,7 @@ class ManualGateways extends ApiResource { // static readonly PATH = 'manual_gateways' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: ManualGateways.TYPE }, params, options) + return this.resources.list({ type: ManualGateways.TYPE }, params, options) } async create(resource: ManualGatewayCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { @@ -57,7 +57,10 @@ class ManualGateways extends ApiResource { async delete(id: string, options?: ResourcesConfig): Promise { await this.resources.delete({ type: ManualGateways.TYPE, id }, options) } - + + async payment_methods(manualGatewayId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'payment_methods' }, `manual_gateways/${manualGatewayId}/payment_methods`, params, options) as unknown as ListResponse + } // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any diff --git a/src/resources/manual_tax_calculators.ts b/src/resources/manual_tax_calculators.ts index 8554e847..5af042c3 100644 --- a/src/resources/manual_tax_calculators.ts +++ b/src/resources/manual_tax_calculators.ts @@ -50,7 +50,7 @@ class ManualTaxCalculators extends ApiResource { // static readonly PATH = 'manual_tax_calculators' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: ManualTaxCalculators.TYPE }, params, options) + return this.resources.list({ type: ManualTaxCalculators.TYPE }, params, options) } async create(resource: ManualTaxCalculatorCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { @@ -68,7 +68,22 @@ class ManualTaxCalculators extends ApiResource { async delete(id: string, options?: ResourcesConfig): Promise { await this.resources.delete({ type: ManualTaxCalculators.TYPE, id }, options) } - + + async tax_categories(manualTaxCalculatorId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'tax_categories' }, `manual_tax_calculators/${manualTaxCalculatorId}/tax_categories`, params, options) as unknown as ListResponse + } + + async markets(manualTaxCalculatorId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'markets' }, `manual_tax_calculators/${manualTaxCalculatorId}/markets`, params, options) as unknown as ListResponse + } + + async attachments(manualTaxCalculatorId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'attachments' }, `manual_tax_calculators/${manualTaxCalculatorId}/attachments`, params, options) as unknown as ListResponse + } + + async tax_rules(manualTaxCalculatorId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'tax_rules' }, `manual_tax_calculators/${manualTaxCalculatorId}/tax_rules`, params, options) as unknown as ListResponse + } // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any diff --git a/src/resources/markets.ts b/src/resources/markets.ts index 7f66cd56..9b62ddf4 100644 --- a/src/resources/markets.ts +++ b/src/resources/markets.ts @@ -74,7 +74,7 @@ class Markets extends ApiResource { // static readonly PATH = 'markets' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: Markets.TYPE }, params, options) + return this.resources.list({ type: Markets.TYPE }, params, options) } async create(resource: MarketCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { @@ -92,7 +92,30 @@ class Markets extends ApiResource { async delete(id: string, options?: ResourcesConfig): Promise { await this.resources.delete({ type: Markets.TYPE, id }, options) } - + + async merchant(marketId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'merchants' }, `markets/${marketId}/merchant`, params, options) as unknown as Merchant + } + + async price_list(marketId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'price_lists' }, `markets/${marketId}/price_list`, params, options) as unknown as PriceList + } + + async inventory_model(marketId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'inventory_models' }, `markets/${marketId}/inventory_model`, params, options) as unknown as InventoryModel + } + + async tax_calculator(marketId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'tax_calculators' }, `markets/${marketId}/tax_calculator`, params, options) as unknown as TaxCalculator + } + + async customer_group(marketId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'customer_groups' }, `markets/${marketId}/customer_group`, params, options) as unknown as CustomerGroup + } + + async attachments(marketId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'attachments' }, `markets/${marketId}/attachments`, params, options) as unknown as ListResponse + } // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any diff --git a/src/resources/merchants.ts b/src/resources/merchants.ts index 7accf5a8..8ad677f1 100644 --- a/src/resources/merchants.ts +++ b/src/resources/merchants.ts @@ -43,7 +43,7 @@ class Merchants extends ApiResource { // static readonly PATH = 'merchants' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: Merchants.TYPE }, params, options) + return this.resources.list({ type: Merchants.TYPE }, params, options) } async create(resource: MerchantCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { @@ -61,7 +61,14 @@ class Merchants extends ApiResource { async delete(id: string, options?: ResourcesConfig): Promise { await this.resources.delete({ type: Merchants.TYPE, id }, options) } - + + async address(merchantId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise
{ + return this.resources.fetch
({ type: 'addresses' }, `merchants/${merchantId}/address`, params, options) as unknown as Address + } + + async attachments(merchantId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'attachments' }, `merchants/${merchantId}/attachments`, params, options) as unknown as ListResponse + } // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any diff --git a/src/resources/order_amount_promotion_rules.ts b/src/resources/order_amount_promotion_rules.ts index b77de950..384fa2c4 100644 --- a/src/resources/order_amount_promotion_rules.ts +++ b/src/resources/order_amount_promotion_rules.ts @@ -53,7 +53,7 @@ class OrderAmountPromotionRules extends ApiResource { // static readonly PATH = 'order_amount_promotion_rules' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: OrderAmountPromotionRules.TYPE }, params, options) + return this.resources.list({ type: OrderAmountPromotionRules.TYPE }, params, options) } async create(resource: OrderAmountPromotionRuleCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { @@ -71,7 +71,6 @@ class OrderAmountPromotionRules extends ApiResource { async delete(id: string, options?: ResourcesConfig): Promise { await this.resources.delete({ type: OrderAmountPromotionRules.TYPE, id }, options) } - // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any diff --git a/src/resources/order_copies.ts b/src/resources/order_copies.ts index 255be086..ee838dfd 100644 --- a/src/resources/order_copies.ts +++ b/src/resources/order_copies.ts @@ -45,7 +45,7 @@ class OrderCopies extends ApiResource { // static readonly PATH = 'order_copies' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: OrderCopies.TYPE }, params, options) + return this.resources.list({ type: OrderCopies.TYPE }, params, options) } async create(resource: OrderCopyCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { @@ -59,7 +59,18 @@ class OrderCopies extends ApiResource { async delete(id: string, options?: ResourcesConfig): Promise { await this.resources.delete({ type: OrderCopies.TYPE, id }, options) } - + + async source_order(orderCopyId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'orders' }, `order_copies/${orderCopyId}/source_order`, params, options) as unknown as Order + } + + async target_order(orderCopyId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'orders' }, `order_copies/${orderCopyId}/target_order`, params, options) as unknown as Order + } + + async order_subscription(orderCopyId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'order_subscriptions' }, `order_copies/${orderCopyId}/order_subscription`, params, options) as unknown as OrderSubscription + } // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any diff --git a/src/resources/order_subscriptions.ts b/src/resources/order_subscriptions.ts index 29719ffc..58b821c3 100644 --- a/src/resources/order_subscriptions.ts +++ b/src/resources/order_subscriptions.ts @@ -66,7 +66,7 @@ class OrderSubscriptions extends ApiResource { // static readonly PATH = 'order_subscriptions' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: OrderSubscriptions.TYPE }, params, options) + return this.resources.list({ type: OrderSubscriptions.TYPE }, params, options) } async create(resource: OrderSubscriptionCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { @@ -84,7 +84,26 @@ class OrderSubscriptions extends ApiResource { async delete(id: string, options?: ResourcesConfig): Promise { await this.resources.delete({ type: OrderSubscriptions.TYPE, id }, options) } - + + async market(orderSubscriptionId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'markets' }, `order_subscriptions/${orderSubscriptionId}/market`, params, options) as unknown as Market + } + + async source_order(orderSubscriptionId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'orders' }, `order_subscriptions/${orderSubscriptionId}/source_order`, params, options) as unknown as Order + } + + async customer(orderSubscriptionId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'customers' }, `order_subscriptions/${orderSubscriptionId}/customer`, params, options) as unknown as Customer + } + + async order_copies(orderSubscriptionId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'order_copies' }, `order_subscriptions/${orderSubscriptionId}/order_copies`, params, options) as unknown as ListResponse + } + + async orders(orderSubscriptionId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'orders' }, `order_subscriptions/${orderSubscriptionId}/orders`, params, options) as unknown as ListResponse + } // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any diff --git a/src/resources/order_validation_rules.ts b/src/resources/order_validation_rules.ts index 6396845a..83ad8506 100644 --- a/src/resources/order_validation_rules.ts +++ b/src/resources/order_validation_rules.ts @@ -20,13 +20,17 @@ class OrderValidationRules extends ApiResource { // static readonly PATH = 'order_validation_rules' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: OrderValidationRules.TYPE }, params, options) + return this.resources.list({ type: OrderValidationRules.TYPE }, params, options) } async retrieve(id: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { return this.resources.retrieve({ type: OrderValidationRules.TYPE, id }, params, options) } + async market(orderValidationRuleId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'markets' }, `order_validation_rules/${orderValidationRuleId}/market`, params, options) as unknown as Market + } + // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any isOrderValidationRule(resource: any): resource is OrderValidationRule { diff --git a/src/resources/orders.ts b/src/resources/orders.ts index f3750b0b..92fa9a99 100644 --- a/src/resources/orders.ts +++ b/src/resources/orders.ts @@ -240,7 +240,7 @@ class Orders extends ApiResource { // static readonly PATH = 'orders' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: Orders.TYPE }, params, options) + return this.resources.list({ type: Orders.TYPE }, params, options) } async create(resource: OrderCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { @@ -258,7 +258,70 @@ class Orders extends ApiResource { async delete(id: string, options?: ResourcesConfig): Promise { await this.resources.delete({ type: Orders.TYPE, id }, options) } - + + async market(orderId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'markets' }, `orders/${orderId}/market`, params, options) as unknown as Market + } + + async customer(orderId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'customers' }, `orders/${orderId}/customer`, params, options) as unknown as Customer + } + + async shipping_address(orderId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise
{ + return this.resources.fetch
({ type: 'addresses' }, `orders/${orderId}/shipping_address`, params, options) as unknown as Address + } + + async billing_address(orderId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise
{ + return this.resources.fetch
({ type: 'addresses' }, `orders/${orderId}/billing_address`, params, options) as unknown as Address + } + + async available_payment_methods(orderId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'payment_methods' }, `orders/${orderId}/available_payment_methods`, params, options) as unknown as ListResponse + } + + async available_customer_payment_sources(orderId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'customer_payment_sources' }, `orders/${orderId}/available_customer_payment_sources`, params, options) as unknown as ListResponse + } + + async payment_method(orderId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'payment_methods' }, `orders/${orderId}/payment_method`, params, options) as unknown as PaymentMethod + } + + async line_items(orderId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'line_items' }, `orders/${orderId}/line_items`, params, options) as unknown as ListResponse + } + + async shipments(orderId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'shipments' }, `orders/${orderId}/shipments`, params, options) as unknown as ListResponse + } + + async authorizations(orderId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'authorizations' }, `orders/${orderId}/authorizations`, params, options) as unknown as ListResponse + } + + async captures(orderId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'captures' }, `orders/${orderId}/captures`, params, options) as unknown as ListResponse + } + + async voids(orderId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'voids' }, `orders/${orderId}/voids`, params, options) as unknown as ListResponse + } + + async refunds(orderId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'refunds' }, `orders/${orderId}/refunds`, params, options) as unknown as ListResponse + } + + async order_subscriptions(orderId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'order_subscriptions' }, `orders/${orderId}/order_subscriptions`, params, options) as unknown as ListResponse + } + + async order_copies(orderId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'order_copies' }, `orders/${orderId}/order_copies`, params, options) as unknown as ListResponse + } + + async attachments(orderId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'attachments' }, `orders/${orderId}/attachments`, params, options) as unknown as ListResponse + } // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any diff --git a/src/resources/packages.ts b/src/resources/packages.ts index 8fea24f0..2b6a03fb 100644 --- a/src/resources/packages.ts +++ b/src/resources/packages.ts @@ -60,7 +60,7 @@ class Packages extends ApiResource { // static readonly PATH = 'packages' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: Packages.TYPE }, params, options) + return this.resources.list({ type: Packages.TYPE }, params, options) } async create(resource: PackageCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { @@ -78,7 +78,18 @@ class Packages extends ApiResource { async delete(id: string, options?: ResourcesConfig): Promise { await this.resources.delete({ type: Packages.TYPE, id }, options) } - + + async stock_location(packageId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'stock_locations' }, `packages/${packageId}/stock_location`, params, options) as unknown as StockLocation + } + + async parcels(packageId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'parcels' }, `packages/${packageId}/parcels`, params, options) as unknown as ListResponse + } + + async attachments(packageId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'attachments' }, `packages/${packageId}/attachments`, params, options) as unknown as ListResponse + } // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any diff --git a/src/resources/parcel_line_items.ts b/src/resources/parcel_line_items.ts index a745c96d..821763fa 100644 --- a/src/resources/parcel_line_items.ts +++ b/src/resources/parcel_line_items.ts @@ -49,7 +49,7 @@ class ParcelLineItems extends ApiResource { // static readonly PATH = 'parcel_line_items' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: ParcelLineItems.TYPE }, params, options) + return this.resources.list({ type: ParcelLineItems.TYPE }, params, options) } async create(resource: ParcelLineItemCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { @@ -67,7 +67,14 @@ class ParcelLineItems extends ApiResource { async delete(id: string, options?: ResourcesConfig): Promise { await this.resources.delete({ type: ParcelLineItems.TYPE, id }, options) } - + + async parcel(parcelLineItemId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'parcels' }, `parcel_line_items/${parcelLineItemId}/parcel`, params, options) as unknown as Parcel + } + + async stock_line_item(parcelLineItemId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'stock_line_items' }, `parcel_line_items/${parcelLineItemId}/stock_line_item`, params, options) as unknown as StockLineItem + } // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any diff --git a/src/resources/parcels.ts b/src/resources/parcels.ts index f096b158..7b1252da 100644 --- a/src/resources/parcels.ts +++ b/src/resources/parcels.ts @@ -109,7 +109,7 @@ class Parcels extends ApiResource { // static readonly PATH = 'parcels' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: Parcels.TYPE }, params, options) + return this.resources.list({ type: Parcels.TYPE }, params, options) } async create(resource: ParcelCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { @@ -127,7 +127,22 @@ class Parcels extends ApiResource { async delete(id: string, options?: ResourcesConfig): Promise { await this.resources.delete({ type: Parcels.TYPE, id }, options) } - + + async shipment(parcelId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'shipments' }, `parcels/${parcelId}/shipment`, params, options) as unknown as Shipment + } + + async package(parcelId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'packages' }, `parcels/${parcelId}/package`, params, options) as unknown as Package + } + + async parcel_line_items(parcelId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'parcel_line_items' }, `parcels/${parcelId}/parcel_line_items`, params, options) as unknown as ListResponse + } + + async attachments(parcelId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'attachments' }, `parcels/${parcelId}/attachments`, params, options) as unknown as ListResponse + } // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any diff --git a/src/resources/payment_gateways.ts b/src/resources/payment_gateways.ts index bf8f732c..489339e3 100644 --- a/src/resources/payment_gateways.ts +++ b/src/resources/payment_gateways.ts @@ -22,13 +22,17 @@ class PaymentGateways extends ApiResource { // static readonly PATH = 'payment_gateways' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: PaymentGateways.TYPE }, params, options) + return this.resources.list({ type: PaymentGateways.TYPE }, params, options) } async retrieve(id: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { return this.resources.retrieve({ type: PaymentGateways.TYPE, id }, params, options) } + async payment_methods(paymentGatewayId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'payment_methods' }, `payment_gateways/${paymentGatewayId}/payment_methods`, params, options) as unknown as ListResponse + } + // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any isPaymentGateway(resource: any): resource is PaymentGateway { diff --git a/src/resources/payment_methods.ts b/src/resources/payment_methods.ts index 19118596..6e04142e 100644 --- a/src/resources/payment_methods.ts +++ b/src/resources/payment_methods.ts @@ -61,7 +61,7 @@ class PaymentMethods extends ApiResource { // static readonly PATH = 'payment_methods' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: PaymentMethods.TYPE }, params, options) + return this.resources.list({ type: PaymentMethods.TYPE }, params, options) } async create(resource: PaymentMethodCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { @@ -79,7 +79,18 @@ class PaymentMethods extends ApiResource { async delete(id: string, options?: ResourcesConfig): Promise { await this.resources.delete({ type: PaymentMethods.TYPE, id }, options) } - + + async market(paymentMethodId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'markets' }, `payment_methods/${paymentMethodId}/market`, params, options) as unknown as Market + } + + async payment_gateway(paymentMethodId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'payment_gateways' }, `payment_methods/${paymentMethodId}/payment_gateway`, params, options) as unknown as PaymentGateway + } + + async attachments(paymentMethodId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'attachments' }, `payment_methods/${paymentMethodId}/attachments`, params, options) as unknown as ListResponse + } // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any diff --git a/src/resources/paypal_gateways.ts b/src/resources/paypal_gateways.ts index f47264ef..261229b0 100644 --- a/src/resources/paypal_gateways.ts +++ b/src/resources/paypal_gateways.ts @@ -44,7 +44,7 @@ class PaypalGateways extends ApiResource { // static readonly PATH = 'paypal_gateways' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: PaypalGateways.TYPE }, params, options) + return this.resources.list({ type: PaypalGateways.TYPE }, params, options) } async create(resource: PaypalGatewayCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { @@ -62,7 +62,14 @@ class PaypalGateways extends ApiResource { async delete(id: string, options?: ResourcesConfig): Promise { await this.resources.delete({ type: PaypalGateways.TYPE, id }, options) } - + + async payment_methods(paypalGatewayId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'payment_methods' }, `paypal_gateways/${paypalGatewayId}/payment_methods`, params, options) as unknown as ListResponse + } + + async paypal_payments(paypalGatewayId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'paypal_payments' }, `paypal_gateways/${paypalGatewayId}/paypal_payments`, params, options) as unknown as ListResponse + } // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any diff --git a/src/resources/paypal_payments.ts b/src/resources/paypal_payments.ts index edf848b6..92691968 100644 --- a/src/resources/paypal_payments.ts +++ b/src/resources/paypal_payments.ts @@ -52,7 +52,7 @@ class PaypalPayments extends ApiResource { // static readonly PATH = 'paypal_payments' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: PaypalPayments.TYPE }, params, options) + return this.resources.list({ type: PaypalPayments.TYPE }, params, options) } async create(resource: PaypalPaymentCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { @@ -70,7 +70,14 @@ class PaypalPayments extends ApiResource { async delete(id: string, options?: ResourcesConfig): Promise { await this.resources.delete({ type: PaypalPayments.TYPE, id }, options) } - + + async order(paypalPaymentId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'orders' }, `paypal_payments/${paypalPaymentId}/order`, params, options) as unknown as Order + } + + async payment_gateway(paypalPaymentId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'payment_gateways' }, `paypal_payments/${paypalPaymentId}/payment_gateway`, params, options) as unknown as PaymentGateway + } // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any diff --git a/src/resources/percentage_discount_promotions.ts b/src/resources/percentage_discount_promotions.ts index 3a2330a8..1fb2fd19 100644 --- a/src/resources/percentage_discount_promotions.ts +++ b/src/resources/percentage_discount_promotions.ts @@ -87,7 +87,7 @@ class PercentageDiscountPromotions extends ApiResource { // static readonly PATH = 'percentage_discount_promotions' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: PercentageDiscountPromotions.TYPE }, params, options) + return this.resources.list({ type: PercentageDiscountPromotions.TYPE }, params, options) } async create(resource: PercentageDiscountPromotionCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { @@ -105,7 +105,34 @@ class PercentageDiscountPromotions extends ApiResource { async delete(id: string, options?: ResourcesConfig): Promise { await this.resources.delete({ type: PercentageDiscountPromotions.TYPE, id }, options) } - + + async market(percentageDiscountPromotionId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'markets' }, `percentage_discount_promotions/${percentageDiscountPromotionId}/market`, params, options) as unknown as Market + } + + async order_amount_promotion_rule(percentageDiscountPromotionId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'order_amount_promotion_rules' }, `percentage_discount_promotions/${percentageDiscountPromotionId}/order_amount_promotion_rule`, params, options) as unknown as OrderAmountPromotionRule + } + + async sku_list_promotion_rule(percentageDiscountPromotionId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'sku_list_promotion_rules' }, `percentage_discount_promotions/${percentageDiscountPromotionId}/sku_list_promotion_rule`, params, options) as unknown as SkuListPromotionRule + } + + async coupon_codes_promotion_rule(percentageDiscountPromotionId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'coupon_codes_promotion_rules' }, `percentage_discount_promotions/${percentageDiscountPromotionId}/coupon_codes_promotion_rule`, params, options) as unknown as CouponCodesPromotionRule + } + + async attachments(percentageDiscountPromotionId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'attachments' }, `percentage_discount_promotions/${percentageDiscountPromotionId}/attachments`, params, options) as unknown as ListResponse + } + + async sku_list(percentageDiscountPromotionId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'sku_lists' }, `percentage_discount_promotions/${percentageDiscountPromotionId}/sku_list`, params, options) as unknown as SkuList + } + + async skus(percentageDiscountPromotionId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'skus' }, `percentage_discount_promotions/${percentageDiscountPromotionId}/skus`, params, options) as unknown as ListResponse + } // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any diff --git a/src/resources/price_lists.ts b/src/resources/price_lists.ts index f53c106e..32fe622e 100644 --- a/src/resources/price_lists.ts +++ b/src/resources/price_lists.ts @@ -44,7 +44,7 @@ class PriceLists extends ApiResource { // static readonly PATH = 'price_lists' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: PriceLists.TYPE }, params, options) + return this.resources.list({ type: PriceLists.TYPE }, params, options) } async create(resource: PriceListCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { @@ -62,7 +62,14 @@ class PriceLists extends ApiResource { async delete(id: string, options?: ResourcesConfig): Promise { await this.resources.delete({ type: PriceLists.TYPE, id }, options) } - + + async prices(priceListId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'prices' }, `price_lists/${priceListId}/prices`, params, options) as unknown as ListResponse + } + + async attachments(priceListId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'attachments' }, `price_lists/${priceListId}/attachments`, params, options) as unknown as ListResponse + } // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any diff --git a/src/resources/prices.ts b/src/resources/prices.ts index 20bbac0c..db885a72 100644 --- a/src/resources/prices.ts +++ b/src/resources/prices.ts @@ -59,7 +59,7 @@ class Prices extends ApiResource { // static readonly PATH = 'prices' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: Prices.TYPE }, params, options) + return this.resources.list({ type: Prices.TYPE }, params, options) } async create(resource: PriceCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { @@ -77,7 +77,18 @@ class Prices extends ApiResource { async delete(id: string, options?: ResourcesConfig): Promise { await this.resources.delete({ type: Prices.TYPE, id }, options) } - + + async price_list(priceId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'price_lists' }, `prices/${priceId}/price_list`, params, options) as unknown as PriceList + } + + async sku(priceId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'skus' }, `prices/${priceId}/sku`, params, options) as unknown as Sku + } + + async attachments(priceId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'attachments' }, `prices/${priceId}/attachments`, params, options) as unknown as ListResponse + } // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any diff --git a/src/resources/promotion_rules.ts b/src/resources/promotion_rules.ts index 425c0e23..6e24c401 100644 --- a/src/resources/promotion_rules.ts +++ b/src/resources/promotion_rules.ts @@ -25,7 +25,7 @@ class PromotionRules extends ApiResource { // static readonly PATH = 'promotion_rules' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: PromotionRules.TYPE }, params, options) + return this.resources.list({ type: PromotionRules.TYPE }, params, options) } async retrieve(id: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { diff --git a/src/resources/promotions.ts b/src/resources/promotions.ts index a4bcc108..832fd06b 100644 --- a/src/resources/promotions.ts +++ b/src/resources/promotions.ts @@ -38,13 +38,33 @@ class Promotions extends ApiResource { // static readonly PATH = 'promotions' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: Promotions.TYPE }, params, options) + return this.resources.list({ type: Promotions.TYPE }, params, options) } async retrieve(id: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { return this.resources.retrieve({ type: Promotions.TYPE, id }, params, options) } + async market(promotionId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'markets' }, `promotions/${promotionId}/market`, params, options) as unknown as Market + } + + async order_amount_promotion_rule(promotionId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'order_amount_promotion_rules' }, `promotions/${promotionId}/order_amount_promotion_rule`, params, options) as unknown as OrderAmountPromotionRule + } + + async sku_list_promotion_rule(promotionId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'sku_list_promotion_rules' }, `promotions/${promotionId}/sku_list_promotion_rule`, params, options) as unknown as SkuListPromotionRule + } + + async coupon_codes_promotion_rule(promotionId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'coupon_codes_promotion_rules' }, `promotions/${promotionId}/coupon_codes_promotion_rule`, params, options) as unknown as CouponCodesPromotionRule + } + + async attachments(promotionId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'attachments' }, `promotions/${promotionId}/attachments`, params, options) as unknown as ListResponse + } + // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any isPromotion(resource: any): resource is Promotion { diff --git a/src/resources/refunds.ts b/src/resources/refunds.ts index 03ed4ae8..25c4fc10 100644 --- a/src/resources/refunds.ts +++ b/src/resources/refunds.ts @@ -34,13 +34,21 @@ class Refunds extends ApiResource { // static readonly PATH = 'refunds' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: Refunds.TYPE }, params, options) + return this.resources.list({ type: Refunds.TYPE }, params, options) } async retrieve(id: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { return this.resources.retrieve({ type: Refunds.TYPE, id }, params, options) } + async order(refundId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'orders' }, `refunds/${refundId}/order`, params, options) as unknown as Order + } + + async reference_capture(refundId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'captures' }, `refunds/${refundId}/reference_capture`, params, options) as unknown as Capture + } + // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any isRefund(resource: any): resource is Refund { diff --git a/src/resources/return_line_items.ts b/src/resources/return_line_items.ts index 857e558b..f640ef51 100644 --- a/src/resources/return_line_items.ts +++ b/src/resources/return_line_items.ts @@ -51,7 +51,7 @@ class ReturnLineItems extends ApiResource { // static readonly PATH = 'return_line_items' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: ReturnLineItems.TYPE }, params, options) + return this.resources.list({ type: ReturnLineItems.TYPE }, params, options) } async create(resource: ReturnLineItemCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { @@ -69,7 +69,14 @@ class ReturnLineItems extends ApiResource { async delete(id: string, options?: ResourcesConfig): Promise { await this.resources.delete({ type: ReturnLineItems.TYPE, id }, options) } - + + async return(returnLineItemId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'returns' }, `return_line_items/${returnLineItemId}/return`, params, options) as unknown as Return + } + + async line_item(returnLineItemId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'line_items' }, `return_line_items/${returnLineItemId}/line_item`, params, options) as unknown as LineItem + } // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any diff --git a/src/resources/returns.ts b/src/resources/returns.ts index c9ab7c55..67985c74 100644 --- a/src/resources/returns.ts +++ b/src/resources/returns.ts @@ -69,7 +69,7 @@ class Returns extends ApiResource { // static readonly PATH = 'returns' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: Returns.TYPE }, params, options) + return this.resources.list({ type: Returns.TYPE }, params, options) } async create(resource: ReturnCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { @@ -87,7 +87,34 @@ class Returns extends ApiResource { async delete(id: string, options?: ResourcesConfig): Promise { await this.resources.delete({ type: Returns.TYPE, id }, options) } - + + async order(returnId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'orders' }, `returns/${returnId}/order`, params, options) as unknown as Order + } + + async customer(returnId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'customers' }, `returns/${returnId}/customer`, params, options) as unknown as Customer + } + + async stock_location(returnId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'stock_locations' }, `returns/${returnId}/stock_location`, params, options) as unknown as StockLocation + } + + async origin_address(returnId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise
{ + return this.resources.fetch
({ type: 'addresses' }, `returns/${returnId}/origin_address`, params, options) as unknown as Address + } + + async destination_address(returnId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise
{ + return this.resources.fetch
({ type: 'addresses' }, `returns/${returnId}/destination_address`, params, options) as unknown as Address + } + + async return_line_items(returnId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'return_line_items' }, `returns/${returnId}/return_line_items`, params, options) as unknown as ListResponse + } + + async attachments(returnId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'attachments' }, `returns/${returnId}/attachments`, params, options) as unknown as ListResponse + } // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any diff --git a/src/resources/shipments.ts b/src/resources/shipments.ts index d98429a0..f8b4add5 100644 --- a/src/resources/shipments.ts +++ b/src/resources/shipments.ts @@ -80,7 +80,7 @@ class Shipments extends ApiResource { // static readonly PATH = 'shipments' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: Shipments.TYPE }, params, options) + return this.resources.list({ type: Shipments.TYPE }, params, options) } async retrieve(id: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { @@ -91,6 +91,58 @@ class Shipments extends ApiResource { return this.resources.update({ ...resource, type: Shipments.TYPE }, params, options) } + async order(shipmentId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'orders' }, `shipments/${shipmentId}/order`, params, options) as unknown as Order + } + + async shipping_category(shipmentId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'shipping_categories' }, `shipments/${shipmentId}/shipping_category`, params, options) as unknown as ShippingCategory + } + + async stock_location(shipmentId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'stock_locations' }, `shipments/${shipmentId}/stock_location`, params, options) as unknown as StockLocation + } + + async origin_address(shipmentId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise
{ + return this.resources.fetch
({ type: 'addresses' }, `shipments/${shipmentId}/origin_address`, params, options) as unknown as Address + } + + async shipping_address(shipmentId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise
{ + return this.resources.fetch
({ type: 'addresses' }, `shipments/${shipmentId}/shipping_address`, params, options) as unknown as Address + } + + async shipping_method(shipmentId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'shipping_methods' }, `shipments/${shipmentId}/shipping_method`, params, options) as unknown as ShippingMethod + } + + async delivery_lead_time(shipmentId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'delivery_lead_times' }, `shipments/${shipmentId}/delivery_lead_time`, params, options) as unknown as DeliveryLeadTime + } + + async stock_line_items(shipmentId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'stock_line_items' }, `shipments/${shipmentId}/stock_line_items`, params, options) as unknown as ListResponse + } + + async stock_transfers(shipmentId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'stock_transfers' }, `shipments/${shipmentId}/stock_transfers`, params, options) as unknown as ListResponse + } + + async available_shipping_methods(shipmentId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'shipping_methods' }, `shipments/${shipmentId}/available_shipping_methods`, params, options) as unknown as ListResponse + } + + async carrier_accounts(shipmentId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'carrier_accounts' }, `shipments/${shipmentId}/carrier_accounts`, params, options) as unknown as ListResponse + } + + async parcels(shipmentId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'parcels' }, `shipments/${shipmentId}/parcels`, params, options) as unknown as ListResponse + } + + async attachments(shipmentId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'attachments' }, `shipments/${shipmentId}/attachments`, params, options) as unknown as ListResponse + } + // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any isShipment(resource: any): resource is Shipment { diff --git a/src/resources/shipping_categories.ts b/src/resources/shipping_categories.ts index b21e7329..89c49adb 100644 --- a/src/resources/shipping_categories.ts +++ b/src/resources/shipping_categories.ts @@ -38,7 +38,7 @@ class ShippingCategories extends ApiResource { // static readonly PATH = 'shipping_categories' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: ShippingCategories.TYPE }, params, options) + return this.resources.list({ type: ShippingCategories.TYPE }, params, options) } async create(resource: ShippingCategoryCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { @@ -56,7 +56,14 @@ class ShippingCategories extends ApiResource { async delete(id: string, options?: ResourcesConfig): Promise { await this.resources.delete({ type: ShippingCategories.TYPE, id }, options) } - + + async skus(shippingCategoryId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'skus' }, `shipping_categories/${shippingCategoryId}/skus`, params, options) as unknown as ListResponse + } + + async attachments(shippingCategoryId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'attachments' }, `shipping_categories/${shippingCategoryId}/attachments`, params, options) as unknown as ListResponse + } // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any diff --git a/src/resources/shipping_methods.ts b/src/resources/shipping_methods.ts index 2ec2d862..d4cc0fad 100644 --- a/src/resources/shipping_methods.ts +++ b/src/resources/shipping_methods.ts @@ -72,7 +72,7 @@ class ShippingMethods extends ApiResource { // static readonly PATH = 'shipping_methods' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: ShippingMethods.TYPE }, params, options) + return this.resources.list({ type: ShippingMethods.TYPE }, params, options) } async create(resource: ShippingMethodCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { @@ -90,7 +90,26 @@ class ShippingMethods extends ApiResource { async delete(id: string, options?: ResourcesConfig): Promise { await this.resources.delete({ type: ShippingMethods.TYPE, id }, options) } - + + async market(shippingMethodId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'markets' }, `shipping_methods/${shippingMethodId}/market`, params, options) as unknown as Market + } + + async shipping_zone(shippingMethodId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'shipping_zones' }, `shipping_methods/${shippingMethodId}/shipping_zone`, params, options) as unknown as ShippingZone + } + + async shipping_category(shippingMethodId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'shipping_categories' }, `shipping_methods/${shippingMethodId}/shipping_category`, params, options) as unknown as ShippingCategory + } + + async delivery_lead_time_for_shipment(shippingMethodId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'delivery_lead_times' }, `shipping_methods/${shippingMethodId}/delivery_lead_time_for_shipment`, params, options) as unknown as DeliveryLeadTime + } + + async attachments(shippingMethodId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'attachments' }, `shipping_methods/${shippingMethodId}/attachments`, params, options) as unknown as ListResponse + } // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any diff --git a/src/resources/shipping_zones.ts b/src/resources/shipping_zones.ts index 23cd3eba..4faab674 100644 --- a/src/resources/shipping_zones.ts +++ b/src/resources/shipping_zones.ts @@ -54,7 +54,7 @@ class ShippingZones extends ApiResource { // static readonly PATH = 'shipping_zones' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: ShippingZones.TYPE }, params, options) + return this.resources.list({ type: ShippingZones.TYPE }, params, options) } async create(resource: ShippingZoneCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { @@ -72,7 +72,10 @@ class ShippingZones extends ApiResource { async delete(id: string, options?: ResourcesConfig): Promise { await this.resources.delete({ type: ShippingZones.TYPE, id }, options) } - + + async attachments(shippingZoneId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'attachments' }, `shipping_zones/${shippingZoneId}/attachments`, params, options) as unknown as ListResponse + } // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any diff --git a/src/resources/sku_list_items.ts b/src/resources/sku_list_items.ts index 7a8d3580..acdf07f2 100644 --- a/src/resources/sku_list_items.ts +++ b/src/resources/sku_list_items.ts @@ -49,7 +49,7 @@ class SkuListItems extends ApiResource { // static readonly PATH = 'sku_list_items' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: SkuListItems.TYPE }, params, options) + return this.resources.list({ type: SkuListItems.TYPE }, params, options) } async create(resource: SkuListItemCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { @@ -67,7 +67,14 @@ class SkuListItems extends ApiResource { async delete(id: string, options?: ResourcesConfig): Promise { await this.resources.delete({ type: SkuListItems.TYPE, id }, options) } - + + async sku_list(skuListItemId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'sku_lists' }, `sku_list_items/${skuListItemId}/sku_list`, params, options) as unknown as SkuList + } + + async sku(skuListItemId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'skus' }, `sku_list_items/${skuListItemId}/sku`, params, options) as unknown as Sku + } // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any diff --git a/src/resources/sku_list_promotion_rules.ts b/src/resources/sku_list_promotion_rules.ts index f99f243f..00640c86 100644 --- a/src/resources/sku_list_promotion_rules.ts +++ b/src/resources/sku_list_promotion_rules.ts @@ -61,7 +61,7 @@ class SkuListPromotionRules extends ApiResource { // static readonly PATH = 'sku_list_promotion_rules' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: SkuListPromotionRules.TYPE }, params, options) + return this.resources.list({ type: SkuListPromotionRules.TYPE }, params, options) } async create(resource: SkuListPromotionRuleCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { @@ -79,7 +79,14 @@ class SkuListPromotionRules extends ApiResource { async delete(id: string, options?: ResourcesConfig): Promise { await this.resources.delete({ type: SkuListPromotionRules.TYPE, id }, options) } - + + async sku_list(skuListPromotionRuleId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'sku_lists' }, `sku_list_promotion_rules/${skuListPromotionRuleId}/sku_list`, params, options) as unknown as SkuList + } + + async skus(skuListPromotionRuleId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'skus' }, `sku_list_promotion_rules/${skuListPromotionRuleId}/skus`, params, options) as unknown as ListResponse + } // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any diff --git a/src/resources/sku_lists.ts b/src/resources/sku_lists.ts index 56acbfb8..baffafac 100644 --- a/src/resources/sku_lists.ts +++ b/src/resources/sku_lists.ts @@ -53,7 +53,7 @@ class SkuLists extends ApiResource { // static readonly PATH = 'sku_lists' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: SkuLists.TYPE }, params, options) + return this.resources.list({ type: SkuLists.TYPE }, params, options) } async create(resource: SkuListCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { @@ -71,7 +71,18 @@ class SkuLists extends ApiResource { async delete(id: string, options?: ResourcesConfig): Promise { await this.resources.delete({ type: SkuLists.TYPE, id }, options) } - + + async skus(skuListId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'skus' }, `sku_lists/${skuListId}/skus`, params, options) as unknown as ListResponse + } + + async sku_list_items(skuListId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'sku_list_items' }, `sku_lists/${skuListId}/sku_list_items`, params, options) as unknown as ListResponse + } + + async bundles(skuListId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'bundles' }, `sku_lists/${skuListId}/bundles`, params, options) as unknown as ListResponse + } // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any diff --git a/src/resources/sku_options.ts b/src/resources/sku_options.ts index 31cf8e8e..575ada0e 100644 --- a/src/resources/sku_options.ts +++ b/src/resources/sku_options.ts @@ -61,7 +61,7 @@ class SkuOptions extends ApiResource { // static readonly PATH = 'sku_options' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: SkuOptions.TYPE }, params, options) + return this.resources.list({ type: SkuOptions.TYPE }, params, options) } async create(resource: SkuOptionCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { @@ -79,7 +79,14 @@ class SkuOptions extends ApiResource { async delete(id: string, options?: ResourcesConfig): Promise { await this.resources.delete({ type: SkuOptions.TYPE, id }, options) } - + + async market(skuOptionId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'markets' }, `sku_options/${skuOptionId}/market`, params, options) as unknown as Market + } + + async attachments(skuOptionId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'attachments' }, `sku_options/${skuOptionId}/attachments`, params, options) as unknown as ListResponse + } // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any diff --git a/src/resources/skus.ts b/src/resources/skus.ts index 26609378..8ea8aab9 100644 --- a/src/resources/skus.ts +++ b/src/resources/skus.ts @@ -79,7 +79,7 @@ class Skus extends ApiResource { // static readonly PATH = 'skus' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: Skus.TYPE }, params, options) + return this.resources.list({ type: Skus.TYPE }, params, options) } async create(resource: SkuCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { @@ -97,7 +97,30 @@ class Skus extends ApiResource { async delete(id: string, options?: ResourcesConfig): Promise { await this.resources.delete({ type: Skus.TYPE, id }, options) } - + + async shipping_category(skuId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'shipping_categories' }, `skus/${skuId}/shipping_category`, params, options) as unknown as ShippingCategory + } + + async prices(skuId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'prices' }, `skus/${skuId}/prices`, params, options) as unknown as ListResponse + } + + async stock_items(skuId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'stock_items' }, `skus/${skuId}/stock_items`, params, options) as unknown as ListResponse + } + + async delivery_lead_times(skuId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'delivery_lead_times' }, `skus/${skuId}/delivery_lead_times`, params, options) as unknown as ListResponse + } + + async sku_options(skuId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'sku_options' }, `skus/${skuId}/sku_options`, params, options) as unknown as ListResponse + } + + async attachments(skuId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'attachments' }, `skus/${skuId}/attachments`, params, options) as unknown as ListResponse + } // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any diff --git a/src/resources/stock_items.ts b/src/resources/stock_items.ts index 5f8bb023..aff01036 100644 --- a/src/resources/stock_items.ts +++ b/src/resources/stock_items.ts @@ -51,7 +51,7 @@ class StockItems extends ApiResource { // static readonly PATH = 'stock_items' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: StockItems.TYPE }, params, options) + return this.resources.list({ type: StockItems.TYPE }, params, options) } async create(resource: StockItemCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { @@ -69,7 +69,18 @@ class StockItems extends ApiResource { async delete(id: string, options?: ResourcesConfig): Promise { await this.resources.delete({ type: StockItems.TYPE, id }, options) } - + + async stock_location(stockItemId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'stock_locations' }, `stock_items/${stockItemId}/stock_location`, params, options) as unknown as StockLocation + } + + async sku(stockItemId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'skus' }, `stock_items/${stockItemId}/sku`, params, options) as unknown as Sku + } + + async attachments(stockItemId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'attachments' }, `stock_items/${stockItemId}/attachments`, params, options) as unknown as ListResponse + } // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any diff --git a/src/resources/stock_line_items.ts b/src/resources/stock_line_items.ts index 69a6f59e..3490eb83 100644 --- a/src/resources/stock_line_items.ts +++ b/src/resources/stock_line_items.ts @@ -28,13 +28,25 @@ class StockLineItems extends ApiResource { // static readonly PATH = 'stock_line_items' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: StockLineItems.TYPE }, params, options) + return this.resources.list({ type: StockLineItems.TYPE }, params, options) } async retrieve(id: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { return this.resources.retrieve({ type: StockLineItems.TYPE, id }, params, options) } + async shipment(stockLineItemId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'shipments' }, `stock_line_items/${stockLineItemId}/shipment`, params, options) as unknown as Shipment + } + + async line_item(stockLineItemId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'line_items' }, `stock_line_items/${stockLineItemId}/line_item`, params, options) as unknown as LineItem + } + + async stock_item(stockLineItemId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'stock_items' }, `stock_line_items/${stockLineItemId}/stock_item`, params, options) as unknown as StockItem + } + // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any isStockLineItem(resource: any): resource is StockLineItem { diff --git a/src/resources/stock_locations.ts b/src/resources/stock_locations.ts index 7f5f5631..9149f067 100644 --- a/src/resources/stock_locations.ts +++ b/src/resources/stock_locations.ts @@ -58,7 +58,7 @@ class StockLocations extends ApiResource { // static readonly PATH = 'stock_locations' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: StockLocations.TYPE }, params, options) + return this.resources.list({ type: StockLocations.TYPE }, params, options) } async create(resource: StockLocationCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { @@ -76,7 +76,30 @@ class StockLocations extends ApiResource { async delete(id: string, options?: ResourcesConfig): Promise { await this.resources.delete({ type: StockLocations.TYPE, id }, options) } - + + async address(stockLocationId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise
{ + return this.resources.fetch
({ type: 'addresses' }, `stock_locations/${stockLocationId}/address`, params, options) as unknown as Address + } + + async inventory_stock_locations(stockLocationId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'inventory_stock_locations' }, `stock_locations/${stockLocationId}/inventory_stock_locations`, params, options) as unknown as ListResponse + } + + async inventory_return_locations(stockLocationId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'inventory_return_locations' }, `stock_locations/${stockLocationId}/inventory_return_locations`, params, options) as unknown as ListResponse + } + + async stock_items(stockLocationId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'stock_items' }, `stock_locations/${stockLocationId}/stock_items`, params, options) as unknown as ListResponse + } + + async stock_transfers(stockLocationId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'stock_transfers' }, `stock_locations/${stockLocationId}/stock_transfers`, params, options) as unknown as ListResponse + } + + async attachments(stockLocationId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'attachments' }, `stock_locations/${stockLocationId}/attachments`, params, options) as unknown as ListResponse + } // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any diff --git a/src/resources/stock_transfers.ts b/src/resources/stock_transfers.ts index ffec5c7a..a83f845b 100644 --- a/src/resources/stock_transfers.ts +++ b/src/resources/stock_transfers.ts @@ -67,7 +67,7 @@ class StockTransfers extends ApiResource { // static readonly PATH = 'stock_transfers' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: StockTransfers.TYPE }, params, options) + return this.resources.list({ type: StockTransfers.TYPE }, params, options) } async create(resource: StockTransferCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { @@ -85,7 +85,26 @@ class StockTransfers extends ApiResource { async delete(id: string, options?: ResourcesConfig): Promise { await this.resources.delete({ type: StockTransfers.TYPE, id }, options) } - + + async sku(stockTransferId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'skus' }, `stock_transfers/${stockTransferId}/sku`, params, options) as unknown as Sku + } + + async origin_stock_location(stockTransferId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'stock_locations' }, `stock_transfers/${stockTransferId}/origin_stock_location`, params, options) as unknown as StockLocation + } + + async destination_stock_location(stockTransferId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'stock_locations' }, `stock_transfers/${stockTransferId}/destination_stock_location`, params, options) as unknown as StockLocation + } + + async shipment(stockTransferId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'shipments' }, `stock_transfers/${stockTransferId}/shipment`, params, options) as unknown as Shipment + } + + async line_item(stockTransferId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'line_items' }, `stock_transfers/${stockTransferId}/line_item`, params, options) as unknown as LineItem + } // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any diff --git a/src/resources/stripe_gateways.ts b/src/resources/stripe_gateways.ts index 9dcf2024..bd19bd03 100644 --- a/src/resources/stripe_gateways.ts +++ b/src/resources/stripe_gateways.ts @@ -43,7 +43,7 @@ class StripeGateways extends ApiResource { // static readonly PATH = 'stripe_gateways' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: StripeGateways.TYPE }, params, options) + return this.resources.list({ type: StripeGateways.TYPE }, params, options) } async create(resource: StripeGatewayCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { @@ -61,7 +61,14 @@ class StripeGateways extends ApiResource { async delete(id: string, options?: ResourcesConfig): Promise { await this.resources.delete({ type: StripeGateways.TYPE, id }, options) } - + + async payment_methods(stripeGatewayId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'payment_methods' }, `stripe_gateways/${stripeGatewayId}/payment_methods`, params, options) as unknown as ListResponse + } + + async stripe_payments(stripeGatewayId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'stripe_payments' }, `stripe_gateways/${stripeGatewayId}/stripe_payments`, params, options) as unknown as ListResponse + } // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any diff --git a/src/resources/stripe_payments.ts b/src/resources/stripe_payments.ts index 8c58d3da..bfcb9f11 100644 --- a/src/resources/stripe_payments.ts +++ b/src/resources/stripe_payments.ts @@ -47,7 +47,7 @@ class StripePayments extends ApiResource { // static readonly PATH = 'stripe_payments' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: StripePayments.TYPE }, params, options) + return this.resources.list({ type: StripePayments.TYPE }, params, options) } async create(resource: StripePaymentCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { @@ -65,7 +65,14 @@ class StripePayments extends ApiResource { async delete(id: string, options?: ResourcesConfig): Promise { await this.resources.delete({ type: StripePayments.TYPE, id }, options) } - + + async order(stripePaymentId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'orders' }, `stripe_payments/${stripePaymentId}/order`, params, options) as unknown as Order + } + + async payment_gateway(stripePaymentId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'payment_gateways' }, `stripe_payments/${stripePaymentId}/payment_gateway`, params, options) as unknown as PaymentGateway + } // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any diff --git a/src/resources/tax_calculators.ts b/src/resources/tax_calculators.ts index ad6e258b..6378146c 100644 --- a/src/resources/tax_calculators.ts +++ b/src/resources/tax_calculators.ts @@ -26,13 +26,25 @@ class TaxCalculators extends ApiResource { // static readonly PATH = 'tax_calculators' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: TaxCalculators.TYPE }, params, options) + return this.resources.list({ type: TaxCalculators.TYPE }, params, options) } async retrieve(id: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { return this.resources.retrieve({ type: TaxCalculators.TYPE, id }, params, options) } + async tax_categories(taxCalculatorId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'tax_categories' }, `tax_calculators/${taxCalculatorId}/tax_categories`, params, options) as unknown as ListResponse + } + + async markets(taxCalculatorId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'markets' }, `tax_calculators/${taxCalculatorId}/markets`, params, options) as unknown as ListResponse + } + + async attachments(taxCalculatorId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'attachments' }, `tax_calculators/${taxCalculatorId}/attachments`, params, options) as unknown as ListResponse + } + // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any isTaxCalculator(resource: any): resource is TaxCalculator { diff --git a/src/resources/tax_categories.ts b/src/resources/tax_categories.ts index be41b0f1..f8c999ec 100644 --- a/src/resources/tax_categories.ts +++ b/src/resources/tax_categories.ts @@ -56,7 +56,7 @@ class TaxCategories extends ApiResource { // static readonly PATH = 'tax_categories' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: TaxCategories.TYPE }, params, options) + return this.resources.list({ type: TaxCategories.TYPE }, params, options) } async create(resource: TaxCategoryCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { @@ -74,7 +74,14 @@ class TaxCategories extends ApiResource { async delete(id: string, options?: ResourcesConfig): Promise { await this.resources.delete({ type: TaxCategories.TYPE, id }, options) } - + + async sku(taxCategoryId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'skus' }, `tax_categories/${taxCategoryId}/sku`, params, options) as unknown as Sku + } + + async attachments(taxCategoryId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'attachments' }, `tax_categories/${taxCategoryId}/attachments`, params, options) as unknown as ListResponse + } // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any diff --git a/src/resources/tax_rules.ts b/src/resources/tax_rules.ts index f99f981d..c597c174 100644 --- a/src/resources/tax_rules.ts +++ b/src/resources/tax_rules.ts @@ -75,7 +75,7 @@ class TaxRules extends ApiResource { // static readonly PATH = 'tax_rules' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: TaxRules.TYPE }, params, options) + return this.resources.list({ type: TaxRules.TYPE }, params, options) } async create(resource: TaxRuleCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { @@ -93,7 +93,10 @@ class TaxRules extends ApiResource { async delete(id: string, options?: ResourcesConfig): Promise { await this.resources.delete({ type: TaxRules.TYPE, id }, options) } - + + async manual_tax_calculator(taxRuleId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'manual_tax_calculators' }, `tax_rules/${taxRuleId}/manual_tax_calculator`, params, options) as unknown as ManualTaxCalculator + } // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any diff --git a/src/resources/taxjar_accounts.ts b/src/resources/taxjar_accounts.ts index 31b56243..a0cf2253 100644 --- a/src/resources/taxjar_accounts.ts +++ b/src/resources/taxjar_accounts.ts @@ -47,7 +47,7 @@ class TaxjarAccounts extends ApiResource { // static readonly PATH = 'taxjar_accounts' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: TaxjarAccounts.TYPE }, params, options) + return this.resources.list({ type: TaxjarAccounts.TYPE }, params, options) } async create(resource: TaxjarAccountCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { @@ -65,7 +65,18 @@ class TaxjarAccounts extends ApiResource { async delete(id: string, options?: ResourcesConfig): Promise { await this.resources.delete({ type: TaxjarAccounts.TYPE, id }, options) } - + + async tax_categories(taxjarAccountId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'tax_categories' }, `taxjar_accounts/${taxjarAccountId}/tax_categories`, params, options) as unknown as ListResponse + } + + async markets(taxjarAccountId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'markets' }, `taxjar_accounts/${taxjarAccountId}/markets`, params, options) as unknown as ListResponse + } + + async attachments(taxjarAccountId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'attachments' }, `taxjar_accounts/${taxjarAccountId}/attachments`, params, options) as unknown as ListResponse + } // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any diff --git a/src/resources/transactions.ts b/src/resources/transactions.ts index 8241b20b..3e76b628 100644 --- a/src/resources/transactions.ts +++ b/src/resources/transactions.ts @@ -32,13 +32,17 @@ class Transactions extends ApiResource { // static readonly PATH = 'transactions' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: Transactions.TYPE }, params, options) + return this.resources.list({ type: Transactions.TYPE }, params, options) } async retrieve(id: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { return this.resources.retrieve({ type: Transactions.TYPE, id }, params, options) } + async order(transactionId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'orders' }, `transactions/${transactionId}/order`, params, options) as unknown as Order + } + // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any isTransaction(resource: any): resource is Transaction { diff --git a/src/resources/voids.ts b/src/resources/voids.ts index 63bcc9ca..bc04b1c1 100644 --- a/src/resources/voids.ts +++ b/src/resources/voids.ts @@ -34,13 +34,21 @@ class Voids extends ApiResource { // static readonly PATH = 'voids' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: Voids.TYPE }, params, options) + return this.resources.list({ type: Voids.TYPE }, params, options) } async retrieve(id: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { return this.resources.retrieve({ type: Voids.TYPE, id }, params, options) } + async order(voidId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'orders' }, `voids/${voidId}/order`, params, options) as unknown as Order + } + + async reference_authorization(voidId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'authorizations' }, `voids/${voidId}/reference_authorization`, params, options) as unknown as Authorization + } + // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any isVoid(resource: any): resource is Void { diff --git a/src/resources/webhooks.ts b/src/resources/webhooks.ts index ed02ac72..14a9db96 100644 --- a/src/resources/webhooks.ts +++ b/src/resources/webhooks.ts @@ -48,7 +48,7 @@ class Webhooks extends ApiResource { // static readonly PATH = 'webhooks' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: Webhooks.TYPE }, params, options) + return this.resources.list({ type: Webhooks.TYPE }, params, options) } async create(resource: WebhookCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { @@ -66,7 +66,10 @@ class Webhooks extends ApiResource { async delete(id: string, options?: ResourcesConfig): Promise { await this.resources.delete({ type: Webhooks.TYPE, id }, options) } - + + async last_event_callbacks(webhookId: string, params?: QueryParamsList, options?: ResourcesConfig): Promise> { + return this.resources.fetch({ type: 'event_callbacks' }, `webhooks/${webhookId}/last_event_callbacks`, params, options) as unknown as ListResponse + } // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any diff --git a/src/resources/wire_transfers.ts b/src/resources/wire_transfers.ts index 1982c514..79c81910 100644 --- a/src/resources/wire_transfers.ts +++ b/src/resources/wire_transfers.ts @@ -35,7 +35,7 @@ class WireTransfers extends ApiResource { // static readonly PATH = 'wire_transfers' async list(params?: QueryParamsList, options?: ResourcesConfig): Promise> { - return this.resources.list({ type: WireTransfers.TYPE }, params, options) + return this.resources.list({ type: WireTransfers.TYPE }, params, options) } async create(resource: WireTransferCreate, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { @@ -53,7 +53,10 @@ class WireTransfers extends ApiResource { async delete(id: string, options?: ResourcesConfig): Promise { await this.resources.delete({ type: WireTransfers.TYPE, id }, options) } - + + async order(wireTransferId: string, params?: QueryParamsRetrieve, options?: ResourcesConfig): Promise { + return this.resources.fetch({ type: 'orders' }, `wire_transfers/${wireTransferId}/order`, params, options) as unknown as Order + } // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any diff --git a/test/common.ts b/test/common.ts index 1b2e31f4..ccc584c3 100644 --- a/test/common.ts +++ b/test/common.ts @@ -116,8 +116,8 @@ export { handleError, interceptRequest, randomAttributes } -const checkCommon = (config: AxiosRequestConfig, type: string, id?: string, token?: string) => { - expect(config.url).toBe(type + (id ? `/${id}` : '')) +const checkCommon = (config: AxiosRequestConfig, type: string, id?: string, token?: string, relationship?: string) => { + expect(config.url).toBe(type + (id ? `/${id}` : '') + (relationship ? `/${relationship}`: '')) expect(config.headers.Authorization).toContain('Bearer ' + (token || '')) expect(config.timeout).toBe(REQUEST_TIMEOUT) } diff --git a/test/spot.ts b/test/spot.ts index e3cb7525..49124c45 100644 --- a/test/spot.ts +++ b/test/spot.ts @@ -1,3 +1,4 @@ +/* eslint-disable no-console */ // import commercelayer from '../lib/cjs' import commercelayer from '../src' @@ -13,7 +14,7 @@ import commercelayer from '../src' timeout: 5000, }) - const c = await cl.customers.update({ id: 'kopZhGAJBn', customer_group: cl.customer_groups.relationship(null)}, { include: ['customer_group'] }) + const c = await cl.customers.orders('OZqohRjoWn') console.log(c)