Skip to content

Commit

Permalink
feat: update resources to schema v5.4.2
Browse files Browse the repository at this point in the history
  • Loading branch information
pviti committed Jun 12, 2024
1 parent 335d1a5 commit ba45aba
Show file tree
Hide file tree
Showing 7 changed files with 191 additions and 10 deletions.
135 changes: 134 additions & 1 deletion gen/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"openapi": "3.1.0",
"info": {
"title": "Commerce Layer API",
"version": "5.4.1",
"version": "5.4.2",
"contact": {
"name": "API Support",
"url": "https://commercelayer.io",
Expand Down Expand Up @@ -16517,6 +16517,33 @@
}
}
},
"/order_subscriptions/{orderSubscriptionId}/tags": {
"get": {
"operationId": "GET/orderSubscriptionId/tags",
"summary": "Retrieve the tags associated to the order subscription",
"description": "Retrieve the tags associated to the order subscription",
"tags": [
"has_many",
"tags"
],
"parameters": [
{
"name": "orderSubscriptionId",
"in": "path",
"schema": {
"type": "string"
},
"required": true,
"description": "The resource's id"
}
],
"responses": {
"200": {
"description": "The tags associated to the order subscription"
}
}
}
},
"/order_subscriptions/{orderSubscriptionId}/versions": {
"get": {
"operationId": "GET/orderSubscriptionId/versions",
Expand Down Expand Up @@ -73426,6 +73453,28 @@
}
}
},
"tags": {
"type": "object",
"properties": {
"data": {
"type": "object",
"properties": {
"type": {
"type": "string",
"description": "The resource's type",
"enum": [
"tags"
]
},
"id": {
"type": "string",
"description": "The resource's id",
"example": "XGZwpOSrWL"
}
}
}
}
},
"versions": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -73581,6 +73630,31 @@
}
}
}
},
"tags": {
"required": [
"data"
],
"type": "object",
"properties": {
"data": {
"type": "object",
"properties": {
"type": {
"type": "string",
"description": "The resource's type",
"enum": [
"tags"
]
},
"id": {
"type": "string",
"description": "The resource's id",
"example": "XGZwpOSrWL"
}
}
}
}
}
},
"required": [
Expand Down Expand Up @@ -73729,6 +73803,31 @@
}
}
}
},
"tags": {
"required": [
"data"
],
"type": "object",
"properties": {
"data": {
"type": "object",
"properties": {
"type": {
"type": "string",
"description": "The resource's type",
"enum": [
"tags"
]
},
"id": {
"type": "string",
"description": "The resource's id",
"example": "XGZwpOSrWL"
}
}
}
}
}
}
}
Expand Down Expand Up @@ -74109,6 +74208,40 @@
}
}
},
"tags": {
"type": "object",
"properties": {
"links": {
"type": "object",
"properties": {
"self": {
"type": "string",
"description": "URL"
},
"related": {
"type": "string",
"description": "URL"
}
}
},
"data": {
"type": "object",
"properties": {
"type": {
"type": "string",
"description": "The resource's type",
"enum": [
"tags"
]
},
"id": {
"type": "string",
"description": "The resource ID"
}
}
}
}
},
"versions": {
"type": "object",
"properties": {
Expand Down
15 changes: 15 additions & 0 deletions gen/resources.json
Original file line number Diff line number Diff line change
Expand Up @@ -19464,6 +19464,20 @@
"parent_resource": "Api::OrderSubscriptionResource",
"class_name": "Event"
},
"tags": {
"type": "has_many",
"desc": "The associated tags.",
"creatable": true,
"fetchable": true,
"updatable": true,
"filterable": true,
"sortable": false,
"conditions": {
"include": "Taggable"
},
"parent_resource": "Api::OrderSubscriptionResource",
"class_name": "Tag"
},
"versions": {
"type": "has_many",
"desc": "The associated changes.",
Expand Down Expand Up @@ -19504,6 +19518,7 @@
"customer_id",
"customer_payment_source_id",
"events_id",
"tags_id",
"ids",
"starts_at_from",
"starts_at_to",
Expand Down
16 changes: 8 additions & 8 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions specs/resources/order_subscriptions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ describe('OrderSubscriptions resource', () => {
frequency: randomValue('string', 'frequency'),
market: cl.markets.relationship(TestData.id),
source_order: cl.orders.relationship(TestData.id),
tags: [ cl.tags.relationship(TestData.id) ],
}

const attributes = { ...createAttributes, reference: TestData.reference }
Expand Down Expand Up @@ -412,6 +413,27 @@ describe('OrderSubscriptions resource', () => {
/* relationship.events stop */


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

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

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

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

})
/* relationship.tags stop */


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

Expand Down
1 change: 1 addition & 0 deletions src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,7 @@ export type TaggableResourceType =
| 'gift_cards'
| 'line_item_options'
| 'line_items'
| 'order_subscriptions'
| 'orders'
| 'percentage_discount_promotions'
| 'promotions'
Expand Down
2 changes: 1 addition & 1 deletion src/commercelayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const debug = Debug('commercelayer')


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


Expand Down
10 changes: 10 additions & 0 deletions src/resources/order_subscriptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ import type { OrderSubscriptionItem } from './order_subscription_items'
import type { OrderFactory } from './order_factories'
import type { RecurringOrderCopy } from './recurring_order_copies'
import type { Event } from './events'
import type { Tag, TagType } from './tags'
import type { Version } from './versions'


type OrderSubscriptionType = 'order_subscriptions'
type OrderSubscriptionRel = ResourceRel & { type: OrderSubscriptionType }
type MarketRel = ResourceRel & { type: MarketType }
type OrderRel = ResourceRel & { type: OrderType }
type TagRel = ResourceRel & { type: TagType }
type CustomerPaymentSourceRel = ResourceRel & { type: CustomerPaymentSourceType }


Expand Down Expand Up @@ -110,6 +112,7 @@ interface OrderSubscription extends Resource {
recurring_order_copies?: RecurringOrderCopy[] | null
orders?: Order[] | null
events?: Event[] | null
tags?: Tag[] | null
versions?: Version[] | null

}
Expand Down Expand Up @@ -150,6 +153,7 @@ interface OrderSubscriptionCreate extends ResourceCreate {

market?: MarketRel | null
source_order: OrderRel
tags?: TagRel[] | null

}

Expand Down Expand Up @@ -208,6 +212,7 @@ interface OrderSubscriptionUpdate extends ResourceUpdate {
_convert?: boolean | null

customer_payment_source?: CustomerPaymentSourceRel | null
tags?: TagRel[] | null

}

Expand Down Expand Up @@ -278,6 +283,11 @@ class OrderSubscriptions extends ApiResource<OrderSubscription> {
return this.resources.fetch<Event>({ type: 'events' }, `order_subscriptions/${_orderSubscriptionId}/events`, params, options) as unknown as ListResponse<Event>
}

async tags(orderSubscriptionId: string | OrderSubscription, params?: QueryParamsList<Tag>, options?: ResourcesConfig): Promise<ListResponse<Tag>> {
const _orderSubscriptionId = (orderSubscriptionId as OrderSubscription).id || orderSubscriptionId as string
return this.resources.fetch<Tag>({ type: 'tags' }, `order_subscriptions/${_orderSubscriptionId}/tags`, params, options) as unknown as ListResponse<Tag>
}

async versions(orderSubscriptionId: string | OrderSubscription, params?: QueryParamsList<Version>, options?: ResourcesConfig): Promise<ListResponse<Version>> {
const _orderSubscriptionId = (orderSubscriptionId as OrderSubscription).id || orderSubscriptionId as string
return this.resources.fetch<Version>({ type: 'versions' }, `order_subscriptions/${_orderSubscriptionId}/versions`, params, options) as unknown as ListResponse<Version>
Expand Down

0 comments on commit ba45aba

Please sign in to comment.