Skip to content

Commit

Permalink
feat: update resources to schema v6.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
pviti committed Jul 23, 2024
1 parent 18275c2 commit 4eb92f4
Show file tree
Hide file tree
Showing 33 changed files with 4,654 additions and 2,445 deletions.
4,438 changes: 3,097 additions & 1,341 deletions gen/openapi.json

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,16 @@
"axios": "1.3.4"
},
"devDependencies": {
"@babel/preset-env": "^7.24.5",
"@babel/preset-typescript": "^7.24.1",
"@babel/preset-env": "^7.24.8",
"@babel/preset-typescript": "^7.24.7",
"@commercelayer/eslint-config-ts": "^0.1.4",
"@commercelayer/js-auth": "^2.3.0",
"@semantic-release/changelog": "^6.0.3",
"@semantic-release/git": "^10.0.1",
"@types/debug": "^4.1.12",
"@types/jest": "^29.5.12",
"@types/lodash": "^4.17.4",
"@types/node": "^18.19.33",
"@types/lodash": "^4.17.7",
"@types/node": "^18.19.41",
"dotenv": "^16.4.5",
"eslint": "^8.57.0",
"inflector-js": "^1.0.1",
Expand Down
2,100 changes: 1,081 additions & 1,019 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion specs/resources/attachments.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe('Attachments resource', () => {

const createAttributes = {
name: randomValue('string', 'name'),
attachable: cl.bundles.relationship(TestData.id),
attachable: cl.geocoders.relationship(TestData.id),
}

const attributes = { ...createAttributes, reference: TestData.reference }
Expand Down
19 changes: 19 additions & 0 deletions specs/resources/bing_geocoders.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,25 @@ describe('BingGeocoders resource', () => {



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 + '.addresses', async () => {

const id = TestData.id
Expand Down
19 changes: 19 additions & 0 deletions specs/resources/captures.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,4 +217,23 @@ describe('Captures resource', () => {

})


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))

})

})
71 changes: 71 additions & 0 deletions specs/resources/carrier_accounts.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,36 @@ describe('CarrierAccounts resource', () => {
const resourceType = 'carrier_accounts'


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

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

const attributes = { ...createAttributes, reference: TestData.reference }
const params = { fields: { carrier_accounts: CommonData.paramsFields } }
const resData = attributes

const intId = cl.addRequestInterceptor((config) => {
expect(config.method).toBe('post')
checkCommon(config, resourceType)
checkCommonData(config, resourceType, attributes)
expect(cl[resourceType].isCarrierAccount(config.data.data)).toBeTruthy()
return interceptRequest()
})

await cl[resourceType].create(resData, params, CommonData.options)
.catch(handleError)
.finally(() => cl.removeInterceptor('request', intId))

})
/* spec.create.stop */


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

Expand All @@ -42,6 +72,47 @@ describe('CarrierAccounts resource', () => {
/* spec.retrieve.stop */


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

const attributes = { reference_origin: TestData.reference_origin, metadata: TestData.metadata }
const params = { fields: { carrier_accounts: CommonData.paramsFields } }
const resData = { id: TestData.id, ...attributes}

const intId = cl.addRequestInterceptor((config) => {
expect(config.method).toBe('patch')
checkCommon(config, resourceType, resData.id, currentAccessToken)
checkCommonData(config, resourceType, attributes, resData.id)
return interceptRequest()
})

await cl[resourceType].update(resData, params, CommonData.options)
.catch(handleError)
.finally(() => cl.removeInterceptor('request', intId))

})
/* spec.update.stop */


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

const id = TestData.id

const intId = cl.addRequestInterceptor((config) => {
expect(config.method).toBe('delete')
checkCommon(config, resourceType, id, currentAccessToken)
return interceptRequest()
})

await cl[resourceType].delete(id, CommonData.options)
.catch(handleError)
.finally(() => cl.removeInterceptor('request', intId))

})
/* spec.delete.stop */


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

Expand Down
19 changes: 19 additions & 0 deletions specs/resources/geocoders.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,25 @@ describe('Geocoders resource', () => {



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 + '.addresses', async () => {

const id = TestData.id
Expand Down
19 changes: 19 additions & 0 deletions specs/resources/google_geocoders.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,25 @@ describe('GoogleGeocoders resource', () => {



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 + '.addresses', async () => {

const id = TestData.id
Expand Down
2 changes: 1 addition & 1 deletion specs/resources/line_items.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe('LineItems resource', () => {
const createAttributes = {
quantity: randomValue('integer', 'quantity'),
order: cl.orders.relationship(TestData.id),
item: cl.adjustments.relationship(TestData.id),
item: cl.skus.relationship(TestData.id),
tags: [ cl.tags.relationship(TestData.id) ],
}

Expand Down
22 changes: 21 additions & 1 deletion specs/resources/markets.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ describe('Markets resource', () => {
price_list: cl.price_lists.relationship(TestData.id),
inventory_model: cl.inventory_models.relationship(TestData.id),
subscription_model: cl.subscription_models.relationship(TestData.id),
tax_calculator: cl.tax_calculators.relationship(TestData.id),
tax_calculator: cl.avalara_accounts.relationship(TestData.id),
customer_group: cl.customer_groups.relationship(TestData.id),
geocoder: cl.geocoders.relationship(TestData.id),
}

const attributes = { ...createAttributes, reference: TestData.reference }
Expand Down Expand Up @@ -270,6 +271,25 @@ describe('Markets resource', () => {
})


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))

})


it(resourceType + '.price_list_schedulers', async () => {

const id = TestData.id
Expand Down
2 changes: 1 addition & 1 deletion specs/resources/order_subscription_items.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe('OrderSubscriptionItems resource', () => {
const createAttributes = {
quantity: randomValue('integer', 'quantity'),
order_subscription: cl.order_subscriptions.relationship(TestData.id),
item: cl.adjustments.relationship(TestData.id),
item: cl.skus.relationship(TestData.id),
sku: cl.skus.relationship(TestData.id),
bundle: cl.bundles.relationship(TestData.id),
adjustment: cl.adjustments.relationship(TestData.id),
Expand Down
19 changes: 19 additions & 0 deletions specs/resources/refunds.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,4 +176,23 @@ describe('Refunds resource', () => {

})


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))

})

})
58 changes: 58 additions & 0 deletions specs/resources/returns.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ describe('Returns resource', () => {
const createAttributes = {
order: cl.orders.relationship(TestData.id),
stock_location: cl.stock_locations.relationship(TestData.id),
reference_capture: cl.captures.relationship(TestData.id),
tags: [ cl.tags.relationship(TestData.id) ],
}

Expand Down Expand Up @@ -247,6 +248,44 @@ describe('Returns resource', () => {
})


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))

})


it(resourceType + '.reference_refund', 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, 'reference_refund')
checkCommonParams(config, params)
return interceptRequest()
})

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

})


it(resourceType + '.return_line_items', async () => {

const id = TestData.id
Expand Down Expand Up @@ -285,6 +324,25 @@ describe('Returns resource', () => {
})


it(resourceType + '.resource_errors', async () => {

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

const intId = cl.addRequestInterceptor((config) => {
expect(config.method).toBe('get')
checkCommon(config, resourceType, id, currentAccessToken, 'resource_errors')
checkCommonParams(config, params)
return interceptRequest()
})

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

})


it(resourceType + '.events', async () => {

const id = TestData.id
Expand Down
2 changes: 1 addition & 1 deletion src/commercelayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Debug from './debug'
const debug = Debug('commercelayer')

// Autogenerated schema version number, do not remove this line
const OPEN_API_SCHEMA_VERSION = '5.4.3'
const OPEN_API_SCHEMA_VERSION = '6.1.0'
export { OPEN_API_SCHEMA_VERSION }


Expand Down
2 changes: 1 addition & 1 deletion src/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export type { BraintreePayment, BraintreePaymentCreate, BraintreePaymentUpdate }
export type { Bundle, BundleCreate, BundleUpdate } from './resources/bundles'
export type { BuyXPayYPromotion, BuyXPayYPromotionCreate, BuyXPayYPromotionUpdate } from './resources/buy_x_pay_y_promotions'
export type { Capture, CaptureUpdate } from './resources/captures'
export type { CarrierAccount } from './resources/carrier_accounts'
export type { CarrierAccount, CarrierAccountCreate, CarrierAccountUpdate } from './resources/carrier_accounts'
export type { CheckoutComGateway, CheckoutComGatewayCreate, CheckoutComGatewayUpdate } from './resources/checkout_com_gateways'
export type { CheckoutComPayment, CheckoutComPaymentCreate, CheckoutComPaymentUpdate } from './resources/checkout_com_payments'
export type { Cleanup, CleanupCreate } from './resources/cleanups'
Expand Down
Loading

0 comments on commit 4eb92f4

Please sign in to comment.