Skip to content

Commit

Permalink
feat: update resources to schema v7.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
pviti committed Dec 11, 2024
1 parent 9bbc8ee commit 191bfb1
Show file tree
Hide file tree
Showing 27 changed files with 4,432 additions and 2,385 deletions.
2,715 changes: 1,666 additions & 1,049 deletions gen/openapi.json

Large diffs are not rendered by default.

2,486 changes: 1,867 additions & 619 deletions gen/resources.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"@types/debug": "^4.1.12",
"@types/jest": "^29.5.14",
"@types/node": "^22.10.1",
"dotenv": "^16.4.5",
"dotenv": "^16.4.7",
"eslint": "^8.57.1",
"jest": "^29.7.0",
"json-typescript": "^1.1.2",
Expand Down
857 changes: 436 additions & 421 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions specs/resources/line_items.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,27 @@ describe('LineItems resource', () => {
/* relationship.stock_transfers stop */


/* relationship.notifications start */
it(resourceType + '.notifications', async () => {

const id = TestData.id
const params = { fields: { notifications: CommonData.paramsFields } }

const intId = cl.addRequestInterceptor((request) => {
expect(request.options.method).toBe('GET')
checkCommon(request, resourcePath, id, currentAccessToken, 'notifications')
checkCommonParams(request, params)
return interceptRequest()
})

await cl[resourcePath].notifications(id, params, CommonData.options)
.catch(handleError)
.finally(() => cl.removeInterceptor('request'))

})
/* relationship.notifications stop */


/* relationship.events start */
it(resourceType + '.events', async () => {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Source code generated automatically by SDK codegen
**/

import { CommerceLayerClient, BillingInfoValidationRule } from '../../src'
import { CommerceLayerClient, Notification } from '../../src'
import isEqual from 'lodash.isequal'
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import { getClient, TestData, CommonData, handleError, interceptRequest, checkCommon, checkCommonData, checkCommonParamsList, checkCommonParams, currentAccessToken, randomValue } from '../../test/common'
Expand All @@ -16,17 +16,18 @@ let cl: CommerceLayerClient
beforeAll(async () => { cl = await getClient() })


describe('BillingInfoValidationRules resource', () => {
describe('Notifications resource', () => {

const resourceType = 'billing_info_validation_rules'
const resourcePath = 'billing_info_validation_rules'
const resourceType = 'notifications'
const resourcePath = 'notifications'


/* spec.create.start */
it(resourceType + '.create', async () => {

const createAttributes = {
market: cl.markets.relationship(TestData.id),
name: randomValue('string', 'name'),
notifiable: cl.orders.relationship(TestData.id),
}

const attributes = { ...createAttributes, reference: TestData.reference }
Expand All @@ -38,12 +39,12 @@ describe('BillingInfoValidationRules resource', () => {
expect(request.options.method).toBe('POST')
checkCommon(request, resourcePath)
checkCommonData(data, resourceType, attributes)
expect(cl[resourcePath].isBillingInfoValidationRule(data.data)).toBeTruthy()
expect(cl[resourcePath].isNotification(data.data)).toBeTruthy()
return interceptRequest()
})

await cl[resourcePath].create(resData, params, CommonData.options)
.then((res: BillingInfoValidationRule) => expect(res).not.toBeNull())
.then((res: Notification) => expect(res).not.toBeNull())
.catch(handleError)
.finally(() => cl.removeInterceptor('request'))

Expand All @@ -65,7 +66,7 @@ describe('BillingInfoValidationRules resource', () => {
})

await cl[resourcePath].retrieve(id, params, CommonData.options)
.then((res: BillingInfoValidationRule) => expect(res).not.toBeNull())
.then((res: Notification) => expect(res).not.toBeNull())
.catch(handleError)
.finally(() => cl.removeInterceptor('request'))

Expand All @@ -89,7 +90,7 @@ describe('BillingInfoValidationRules resource', () => {
})

await cl[resourcePath].update(resData, params, CommonData.options)
.then((res: BillingInfoValidationRule) => expect(res).not.toBeNull())
.then((res: Notification) => expect(res).not.toBeNull())
.catch(handleError)
.finally(() => cl.removeInterceptor('request'))

Expand Down Expand Up @@ -140,7 +141,7 @@ describe('BillingInfoValidationRules resource', () => {
it(resourceType + '.type', async () => {

const resource = { id: TestData.id, type: resourceType }
expect(cl[resourcePath].isBillingInfoValidationRule(resource)).toBeTruthy()
expect(cl[resourcePath].isNotification(resource)).toBeTruthy()

const type = cl[resourcePath].type()
expect(type).toBe(resourceType)
Expand Down Expand Up @@ -190,7 +191,7 @@ describe('BillingInfoValidationRules resource', () => {
}
`
const res = cl[resourcePath].parse(payload) as BillingInfoValidationRule
const res = cl[resourcePath].parse(payload) as Notification
expect(res.type).toBe(resourceType)
expect(res.reference).toBe(reference)
Expand All @@ -200,68 +201,5 @@ describe('BillingInfoValidationRules resource', () => {
/* spec.parse.stop */



/* relationship.market start */
it(resourceType + '.market', async () => {

const id = TestData.id
const params = { fields: { markets: CommonData.paramsFields } }

const intId = cl.addRequestInterceptor((request) => {
expect(request.options.method).toBe('GET')
checkCommon(request, resourcePath, id, currentAccessToken, 'market')
checkCommonParams(request, params)
return interceptRequest()
})

await cl[resourcePath].market(id, params, CommonData.options)
.catch(handleError)
.finally(() => cl.removeInterceptor('request'))

})
/* relationship.market stop */


/* relationship.attachments start */
it(resourceType + '.attachments', async () => {

const id = TestData.id
const params = { fields: { attachments: CommonData.paramsFields } }

const intId = cl.addRequestInterceptor((request) => {
expect(request.options.method).toBe('GET')
checkCommon(request, resourcePath, id, currentAccessToken, 'attachments')
checkCommonParams(request, params)
return interceptRequest()
})

await cl[resourcePath].attachments(id, params, CommonData.options)
.catch(handleError)
.finally(() => cl.removeInterceptor('request'))

})
/* relationship.attachments stop */


/* relationship.versions start */
it(resourceType + '.versions', async () => {

const id = TestData.id
const params = { fields: { versions: CommonData.paramsFields } }

const intId = cl.addRequestInterceptor((request) => {
expect(request.options.method).toBe('GET')
checkCommon(request, resourcePath, id, currentAccessToken, 'versions')
checkCommonParams(request, params)
return interceptRequest()
})

await cl[resourcePath].versions(id, params, CommonData.options)
.catch(handleError)
.finally(() => cl.removeInterceptor('request'))

})
/* relationship.versions stop */


})
47 changes: 47 additions & 0 deletions specs/resources/orders.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,27 @@ describe('Orders resource', () => {
/* relationship.attachments stop */


/* relationship.notifications start */
it(resourceType + '.notifications', async () => {

const id = TestData.id
const params = { fields: { notifications: CommonData.paramsFields } }

const intId = cl.addRequestInterceptor((request) => {
expect(request.options.method).toBe('GET')
checkCommon(request, resourcePath, id, currentAccessToken, 'notifications')
checkCommonParams(request, params)
return interceptRequest()
})

await cl[resourcePath].notifications(id, params, CommonData.options)
.catch(handleError)
.finally(() => cl.removeInterceptor('request'))

})
/* relationship.notifications stop */


/* relationship.links start */
it(resourceType + '.links', async () => {

Expand Down Expand Up @@ -1266,6 +1287,32 @@ describe('Orders resource', () => {
/* trigger._nullify_payment_source stop */


/* trigger._fix_payment_source start */
it(resourceType + '._fix_payment_source', async () => {

let triggerAttr = '_fix_payment_source'
if (!triggerAttr.startsWith('_')) triggerAttr = `_${triggerAttr}`

const triggerValue = true
const attributes = { [triggerAttr]: triggerValue }
const id = TestData.id

const intId = cl.addRequestInterceptor((request) => {
const data = JSON.parse(String(request.options.body))
expect(request.options.method).toBe('PATCH')
checkCommon(request, resourcePath, id, currentAccessToken)
checkCommonData(data, resourceType, attributes, id)
return interceptRequest()
})

await cl[resourcePath]._fix_payment_source(id, {}, CommonData.options)
.catch(handleError)
.finally(() => cl.removeInterceptor('request'))

})
/* trigger._fix_payment_source stop */


/* trigger._billing_address_clone_id start */
it(resourceType + '._billing_address_clone_id', async () => {

Expand Down
17 changes: 8 additions & 9 deletions src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export { default as Authorizations } from './resources/authorizations'
export { default as AvalaraAccounts } from './resources/avalara_accounts'
export { default as AxerveGateways } from './resources/axerve_gateways'
export { default as AxervePayments } from './resources/axerve_payments'
export { default as BillingInfoValidationRules } from './resources/billing_info_validation_rules'
export { default as BingGeocoders } from './resources/bing_geocoders'
export { default as BraintreeGateways } from './resources/braintree_gateways'
export { default as BraintreePayments } from './resources/braintree_payments'
Expand Down Expand Up @@ -70,6 +69,7 @@ export { default as ManualGateways } from './resources/manual_gateways'
export { default as ManualTaxCalculators } from './resources/manual_tax_calculators'
export { default as Markets } from './resources/markets'
export { default as Merchants } from './resources/merchants'
export { default as Notifications } from './resources/notifications'
export { default as OrderAmountPromotionRules } from './resources/order_amount_promotion_rules'
export { default as OrderCopies } from './resources/order_copies'
export { default as OrderFactories } from './resources/order_factories'
Expand Down Expand Up @@ -147,7 +147,6 @@ export type ResourceTypeLock =
| 'avalara_accounts'
| 'axerve_gateways'
| 'axerve_payments'
| 'billing_info_validation_rules'
| 'bing_geocoders'
| 'braintree_gateways'
| 'braintree_payments'
Expand Down Expand Up @@ -199,6 +198,7 @@ export type ResourceTypeLock =
| 'manual_tax_calculators'
| 'markets'
| 'merchants'
| 'notifications'
| 'order_amount_promotion_rules'
| 'order_copies'
| 'order_factories'
Expand Down Expand Up @@ -276,7 +276,6 @@ export const resourceList: ResourceTypeLock[] = [
'avalara_accounts',
'axerve_gateways',
'axerve_payments',
'billing_info_validation_rules',
'bing_geocoders',
'braintree_gateways',
'braintree_payments',
Expand Down Expand Up @@ -328,6 +327,7 @@ export const resourceList: ResourceTypeLock[] = [
'manual_tax_calculators',
'markets',
'merchants',
'notifications',
'order_amount_promotion_rules',
'order_copies',
'order_factories',
Expand Down Expand Up @@ -449,7 +449,6 @@ export type CreatableResourceType =
| 'avalara_accounts'
| 'axerve_gateways'
| 'axerve_payments'
| 'billing_info_validation_rules'
| 'bing_geocoders'
| 'braintree_gateways'
| 'braintree_payments'
Expand Down Expand Up @@ -497,6 +496,7 @@ export type CreatableResourceType =
| 'manual_tax_calculators'
| 'markets'
| 'merchants'
| 'notifications'
| 'order_amount_promotion_rules'
| 'order_copies'
| 'order_subscription_items'
Expand Down Expand Up @@ -564,7 +564,6 @@ export type UpdatableResourceType =
| 'avalara_accounts'
| 'axerve_gateways'
| 'axerve_payments'
| 'billing_info_validation_rules'
| 'bing_geocoders'
| 'braintree_gateways'
| 'braintree_payments'
Expand Down Expand Up @@ -614,6 +613,7 @@ export type UpdatableResourceType =
| 'manual_tax_calculators'
| 'markets'
| 'merchants'
| 'notifications'
| 'order_amount_promotion_rules'
| 'order_copies'
| 'order_subscription_items'
Expand Down Expand Up @@ -682,7 +682,6 @@ export type DeletableResourceType =
| 'avalara_accounts'
| 'axerve_gateways'
| 'axerve_payments'
| 'billing_info_validation_rules'
| 'bing_geocoders'
| 'braintree_gateways'
| 'braintree_payments'
Expand Down Expand Up @@ -730,6 +729,7 @@ export type DeletableResourceType =
| 'manual_tax_calculators'
| 'markets'
| 'merchants'
| 'notifications'
| 'order_amount_promotion_rules'
| 'order_copies'
| 'order_subscription_items'
Expand Down Expand Up @@ -829,7 +829,6 @@ export type VersionableResourceType =
| 'avalara_accounts'
| 'axerve_gateways'
| 'axerve_payments'
| 'billing_info_validation_rules'
| 'braintree_gateways'
| 'braintree_payments'
| 'bundles'
Expand Down Expand Up @@ -940,7 +939,6 @@ export type ResourceFields = {
avalara_accounts: models.AvalaraAccount,
axerve_gateways: models.AxerveGateway,
axerve_payments: models.AxervePayment,
billing_info_validation_rules: models.BillingInfoValidationRule,
bing_geocoders: models.BingGeocoder,
braintree_gateways: models.BraintreeGateway,
braintree_payments: models.BraintreePayment,
Expand Down Expand Up @@ -992,6 +990,7 @@ export type ResourceFields = {
manual_tax_calculators: models.ManualTaxCalculator,
markets: models.Market,
merchants: models.Merchant,
notifications: models.Notification,
order_amount_promotion_rules: models.OrderAmountPromotionRule,
order_copies: models.OrderCopy,
order_factories: models.OrderFactory,
Expand Down Expand Up @@ -1070,7 +1069,6 @@ export type ResourceSortFields = {
avalara_accounts: models.AvalaraAccountSort,
axerve_gateways: models.AxerveGatewaySort,
axerve_payments: models.AxervePaymentSort,
billing_info_validation_rules: models.BillingInfoValidationRuleSort,
bing_geocoders: models.BingGeocoderSort,
braintree_gateways: models.BraintreeGatewaySort,
braintree_payments: models.BraintreePaymentSort,
Expand Down Expand Up @@ -1122,6 +1120,7 @@ export type ResourceSortFields = {
manual_tax_calculators: models.ManualTaxCalculatorSort,
markets: models.MarketSort,
merchants: models.MerchantSort,
notifications: models.NotificationSort,
order_amount_promotion_rules: models.OrderAmountPromotionRuleSort,
order_copies: models.OrderCopySort,
order_factories: models.OrderFactorySort,
Expand Down
Loading

0 comments on commit 191bfb1

Please sign in to comment.