diff --git a/lib/recurly.d.ts b/lib/recurly.d.ts index dffb4bb3..14f40d32 100644 --- a/lib/recurly.d.ts +++ b/lib/recurly.d.ts @@ -2676,6 +2676,23 @@ export declare class ExternalProduct { } +export declare class ExternalProductReferenceCollection { + /** + * Will always be List. + */ + object?: string | null; + /** + * Indicates there are more results on subsequent pages. + */ + hasMore?: boolean | null; + /** + * Path to subsequent page of results. + */ + next?: string | null; + data?: ExternalProductReferenceMini[] | null; + +} + export declare class BinaryFile { data?: string | null; @@ -4446,6 +4463,48 @@ export interface MeasuredUnitUpdate { } +export interface ExternalProductCreate { + /** + * External product name. + */ + name?: string | null; + /** + * Recurly plan UUID. + */ + planId?: string | null; + /** + * List of external product references of the external product. + */ + externalProductReferences?: ExternalProductReferenceBase[] | null; + +} + +export interface ExternalProductReferenceBase { + /** + * A code which associates the external product to a corresponding object or resource in an external platform like the Apple App Store or Google Play Store. + */ + referenceCode?: string | null; + externalConnectionType?: string | null; + +} + +export interface ExternalProductUpdate { + /** + * Recurly plan UUID. + */ + planId?: string | null; + +} + +export interface ExternalProductReferenceCreate { + /** + * A code which associates the external product to a corresponding object or resource in an external platform like the Apple App Store or Google Play Store. + */ + referenceCode?: string | null; + externalConnectionType?: string | null; + +} + export interface InvoiceUpdate { /** * This identifies the PO number associated with the invoice. Not editable for credit invoices. @@ -7958,6 +8017,16 @@ endpoint to obtain only the newly generated `UniqueCouponCodes`. * @return {Pager} A list of the the external_products on a site. */ listExternalProducts(options?: object): Pager; + /** + * Create an external product + * + * API docs: https://developers.recurly.com/api/v2021-02-25#operation/create_external_product + * + * + * @param {ExternalProductCreate} body - The object representing the JSON request to send to the server. It should conform to the schema of {ExternalProductCreate} + * @return {Promise} Returns the external product + */ + createExternalProduct(body: ExternalProductCreate): Promise; /** * Fetch an external product * @@ -7968,6 +8037,76 @@ endpoint to obtain only the newly generated `UniqueCouponCodes`. * @return {Promise} Settings for an external product. */ getExternalProduct(externalProductId: string): Promise; + /** + * Update an external product + * + * API docs: https://developers.recurly.com/api/v2021-02-25#operation/update_external_product + * + * + * @param {string} externalProductId - External product id + * @param {ExternalProductUpdate} body - The object representing the JSON request to send to the server. It should conform to the schema of {ExternalProductUpdate} + * @return {Promise} Settings for an external product. + */ + updateExternalProduct(externalProductId: string, body: ExternalProductUpdate): Promise; + /** + * Deactivate an external product + * + * API docs: https://developers.recurly.com/api/v2021-02-25#operation/deactivate_external_products + * + * + * @param {string} externalProductId - External product id + * @return {Promise} Deactivated external product. + */ + deactivateExternalProducts(externalProductId: string): Promise; + /** + * List the external product references for an external product + * + * API docs: https://developers.recurly.com/api/v2021-02-25#operation/list_external_product_external_product_references + * + * + * @param {string} externalProductId - External product id + * @param {Object} options - Optional configurations for the request + * @param {Object} options.params - The optional url parameters for this request. + * @param {string} options.params.sort - Sort field. You *really* only want to sort by `updated_at` in ascending + * order. In descending order updated records will move behind the cursor and could + * prevent some records from being returned. + * + * @return {Pager} A list of the the external product references for an external product. + */ + listExternalProductExternalProductReferences(externalProductId: string, options?: object): Pager; + /** + * Create an external product reference on an external product + * + * API docs: https://developers.recurly.com/api/v2021-02-25#operation/create_external_product_external_product_reference + * + * + * @param {string} externalProductId - External product id + * @param {ExternalProductReferenceCreate} body - The object representing the JSON request to send to the server. It should conform to the schema of {ExternalProductReferenceCreate} + * @return {Promise} Details for the external product reference. + */ + createExternalProductExternalProductReference(externalProductId: string, body: ExternalProductReferenceCreate): Promise; + /** + * Fetch an external product reference + * + * API docs: https://developers.recurly.com/api/v2021-02-25#operation/get_external_product_external_product_reference + * + * + * @param {string} externalProductId - External product id + * @param {string} externalProductReferenceId - External product reference ID, e.g. `d39iun2fw1v4`. + * @return {Promise} Details for an external product reference. + */ + getExternalProductExternalProductReference(externalProductId: string, externalProductReferenceId: string): Promise; + /** + * Deactivate an external product reference + * + * API docs: https://developers.recurly.com/api/v2021-02-25#operation/deactivate_external_product_external_product_reference + * + * + * @param {string} externalProductId - External product id + * @param {string} externalProductReferenceId - External product reference ID, e.g. `d39iun2fw1v4`. + * @return {Promise} Details for an external product reference. + */ + deactivateExternalProductExternalProductReference(externalProductId: string, externalProductReferenceId: string): Promise; /** * List a site's external subscriptions * diff --git a/lib/recurly/Client.js b/lib/recurly/Client.js index 082adc32..8e3fd45d 100644 --- a/lib/recurly/Client.js +++ b/lib/recurly/Client.js @@ -2350,6 +2350,21 @@ endpoint to obtain only the newly generated `UniqueCouponCodes`. return new Pager(this, path, options) } + /** + * Create an external product + * + * API docs: {@link https://developers.recurly.com/api/v2021-02-25#operation/create_external_product} + * + * + * @param {ExternalProductCreate} body - The object representing the JSON request to send to the server. It should conform to the schema of {ExternalProductCreate} + * @return {Promise} Returns the external product + */ + async createExternalProduct (body, options = {}) { + let path = '/external_products' + path = this._interpolatePath(path) + return this._makeRequest('POST', path, body, options) + } + /** * Fetch an external product * @@ -2365,6 +2380,106 @@ endpoint to obtain only the newly generated `UniqueCouponCodes`. return this._makeRequest('GET', path, null, options) } + /** + * Update an external product + * + * API docs: {@link https://developers.recurly.com/api/v2021-02-25#operation/update_external_product} + * + * + * @param {string} externalProductId - External product id + * @param {ExternalProductUpdate} body - The object representing the JSON request to send to the server. It should conform to the schema of {ExternalProductUpdate} + * @return {Promise} Settings for an external product. + */ + async updateExternalProduct (externalProductId, body, options = {}) { + let path = '/external_products/{external_product_id}' + path = this._interpolatePath(path, { 'external_product_id': externalProductId }) + return this._makeRequest('PUT', path, body, options) + } + + /** + * Deactivate an external product + * + * API docs: {@link https://developers.recurly.com/api/v2021-02-25#operation/deactivate_external_products} + * + * + * @param {string} externalProductId - External product id + * @return {Promise} Deactivated external product. + */ + async deactivateExternalProducts (externalProductId, options = {}) { + let path = '/external_products/{external_product_id}' + path = this._interpolatePath(path, { 'external_product_id': externalProductId }) + return this._makeRequest('DELETE', path, null, options) + } + + /** + * List the external product references for an external product + * + * API docs: {@link https://developers.recurly.com/api/v2021-02-25#operation/list_external_product_external_product_references} + * + * + * @param {string} externalProductId - External product id + * @param {Object} options - Optional configurations for the request + * @param {Object} options.params - The optional url parameters for this request. + * @param {string} options.params.sort - Sort field. You *really* only want to sort by `updated_at` in ascending + * order. In descending order updated records will move behind the cursor and could + * prevent some records from being returned. + * + * @return {Pager} A list of the the external product references for an external product. + */ + listExternalProductExternalProductReferences (externalProductId, options = {}) { + let path = '/external_products/{external_product_id}/external_product_references' + path = this._interpolatePath(path, { 'external_product_id': externalProductId }) + return new Pager(this, path, options) + } + + /** + * Create an external product reference on an external product + * + * API docs: {@link https://developers.recurly.com/api/v2021-02-25#operation/create_external_product_external_product_reference} + * + * + * @param {string} externalProductId - External product id + * @param {ExternalProductReferenceCreate} body - The object representing the JSON request to send to the server. It should conform to the schema of {ExternalProductReferenceCreate} + * @return {Promise} Details for the external product reference. + */ + async createExternalProductExternalProductReference (externalProductId, body, options = {}) { + let path = '/external_products/{external_product_id}/external_product_references' + path = this._interpolatePath(path, { 'external_product_id': externalProductId }) + return this._makeRequest('POST', path, body, options) + } + + /** + * Fetch an external product reference + * + * API docs: {@link https://developers.recurly.com/api/v2021-02-25#operation/get_external_product_external_product_reference} + * + * + * @param {string} externalProductId - External product id + * @param {string} externalProductReferenceId - External product reference ID, e.g. `d39iun2fw1v4`. + * @return {Promise} Details for an external product reference. + */ + async getExternalProductExternalProductReference (externalProductId, externalProductReferenceId, options = {}) { + let path = '/external_products/{external_product_id}/external_product_references/{external_product_reference_id}' + path = this._interpolatePath(path, { 'external_product_id': externalProductId, 'external_product_reference_id': externalProductReferenceId }) + return this._makeRequest('GET', path, null, options) + } + + /** + * Deactivate an external product reference + * + * API docs: {@link https://developers.recurly.com/api/v2021-02-25#operation/deactivate_external_product_external_product_reference} + * + * + * @param {string} externalProductId - External product id + * @param {string} externalProductReferenceId - External product reference ID, e.g. `d39iun2fw1v4`. + * @return {Promise} Details for an external product reference. + */ + async deactivateExternalProductExternalProductReference (externalProductId, externalProductReferenceId, options = {}) { + let path = '/external_products/{external_product_id}/external_product_references/{external_product_reference_id}' + path = this._interpolatePath(path, { 'external_product_id': externalProductId, 'external_product_reference_id': externalProductReferenceId }) + return this._makeRequest('DELETE', path, null, options) + } + /** * List a site's external subscriptions * diff --git a/lib/recurly/resources/ExternalProductReferenceCollection.js b/lib/recurly/resources/ExternalProductReferenceCollection.js new file mode 100644 index 00000000..25b5aa7d --- /dev/null +++ b/lib/recurly/resources/ExternalProductReferenceCollection.js @@ -0,0 +1,31 @@ +/* istanbul ignore file */ +/** + * This file is automatically created by Recurly's OpenAPI generation process + * and thus any edits you make by hand will be lost. If you wish to make a + * change to this file, please create a Github issue explaining the changes you + * need and we will usher them to the appropriate places. + */ +'use strict' + +const Resource = require('../Resource') + +/** + * ExternalProductReferenceCollection + * @typedef {Object} ExternalProductReferenceCollection + * @prop {Array.} data + * @prop {boolean} hasMore - Indicates there are more results on subsequent pages. + * @prop {string} next - Path to subsequent page of results. + * @prop {string} object - Will always be List. + */ +class ExternalProductReferenceCollection extends Resource { + static getSchema () { + return { + data: ['ExternalProductReferenceMini'], + hasMore: Boolean, + next: String, + object: String + } + } +} + +module.exports = ExternalProductReferenceCollection diff --git a/lib/recurly/resources/index.js b/lib/recurly/resources/index.js index b16ff868..6b5d206d 100644 --- a/lib/recurly/resources/index.js +++ b/lib/recurly/resources/index.js @@ -70,6 +70,7 @@ module.exports.Item = require('./Item') module.exports.Pricing = require('./Pricing') module.exports.MeasuredUnit = require('./MeasuredUnit') module.exports.ExternalProduct = require('./ExternalProduct') +module.exports.ExternalProductReferenceCollection = require('./ExternalProductReferenceCollection') module.exports.BinaryFile = require('./BinaryFile') module.exports.Plan = require('./Plan') module.exports.PlanRampInterval = require('./PlanRampInterval') diff --git a/openapi/api.yaml b/openapi/api.yaml index 2e416067..d66ed15f 100644 --- a/openapi/api.yaml +++ b/openapi/api.yaml @@ -206,6 +206,7 @@ x-tagGroups: - external_invoices - external_products - external_accounts + - external_product_references - name: Products and Promotions tags: - item @@ -360,6 +361,10 @@ tags: description: A product from an external resource that is not managed by the Recurly platform and instead is managed by third-party platforms like Apple App Store and Google Play Store. +- name: external_product_references + x-displayName: External Product Reference + description: Associates an external product to a corresponding resource on an external + platform like the Apple App Store or Google Play Store. - name: gift_cards x-displayName: Gift Cards description: Add gift card purchases to your checkout and allow gift card recipients @@ -7745,6 +7750,43 @@ paths: schema: "$ref": "#/components/schemas/Error" x-code-samples: [] + post: + tags: + - external_products + operationId: create_external_product + summary: Create an external product + requestBody: + content: + application/json: + schema: + "$ref": "#/components/schemas/ExternalProductCreate" + required: true + responses: + '201': + description: Returns the external product + content: + application/json: + schema: + "$ref": "#/components/schemas/ExternalProduct" + '400': + description: Bad request; perhaps missing or invalid parameters. + content: + application/json: + schema: + "$ref": "#/components/schemas/Error" + '404': + description: External product cannot be created for the specified reason. + content: + application/json: + schema: + "$ref": "#/components/schemas/Error" + default: + description: Unexpected error. + content: + application/json: + schema: + "$ref": "#/components/schemas/Error" + x-code-samples: [] "/external_products/{external_product_id}": parameters: - "$ref": "#/components/parameters/external_product_id" @@ -7773,6 +7815,181 @@ paths: schema: "$ref": "#/components/schemas/Error" x-code-samples: [] + put: + tags: + - external_products + operationId: update_external_product + summary: Update an external product + requestBody: + content: + application/json: + schema: + "$ref": "#/components/schemas/ExternalProductUpdate" + required: true + responses: + '200': + description: Settings for an external product. + content: + application/json: + schema: + "$ref": "#/components/schemas/ExternalProduct" + '404': + description: Bad request; perhaps missing or invalid parameters. + content: + application/json: + schema: + "$ref": "#/components/schemas/Error" + default: + description: Unexpected error. + content: + application/json: + schema: + "$ref": "#/components/schemas/Error" + x-code-samples: [] + delete: + tags: + - external_products + operationId: deactivate_external_products + summary: Deactivate an external product + description: Deactivate an external product. + responses: + '200': + description: Deactivated external product. + content: + application/json: + schema: + "$ref": "#/components/schemas/ExternalProduct" + '404': + description: Bad request; perhaps missing or invalid parameters. + content: + application/json: + schema: + "$ref": "#/components/schemas/Error" + default: + description: Unexpected error. + content: + application/json: + schema: + "$ref": "#/components/schemas/Error" + x-code-samples: [] + "/external_products/{external_product_id}/external_product_references": + parameters: + - "$ref": "#/components/parameters/external_product_id" + get: + tags: + - external_product_references + operationId: list_external_product_external_product_references + summary: List the external product references for an external product + description: See the [Pagination Guide](/developers/guides/pagination.html) + to learn how to use pagination in the API and Client Libraries. + parameters: + - "$ref": "#/components/parameters/sort_dates" + responses: + '200': + description: A list of the the external product references for an external + product. + content: + application/json: + schema: + "$ref": "#/components/schemas/ExternalProductReferenceCollection" + '404': + description: Incorrect site or external product ID. + content: + application/json: + schema: + "$ref": "#/components/schemas/Error" + default: + description: Unexpected error. + content: + application/json: + schema: + "$ref": "#/components/schemas/Error" + x-code-samples: [] + post: + tags: + - external_product_references + operationId: create_external_product_external_product_reference + summary: Create an external product reference on an external product + requestBody: + content: + application/json: + schema: + "$ref": "#/components/schemas/ExternalProductReferenceCreate" + required: true + responses: + '201': + description: Details for the external product reference. + content: + application/json: + schema: + "$ref": "#/components/schemas/ExternalProductReferenceMini" + '404': + description: Incorrect site. + content: + application/json: + schema: + "$ref": "#/components/schemas/Error" + default: + description: Unexpected error. + content: + application/json: + schema: + "$ref": "#/components/schemas/Error" + x-code-samples: [] + "/external_products/{external_product_id}/external_product_references/{external_product_reference_id}": + parameters: + - "$ref": "#/components/parameters/external_product_id" + - "$ref": "#/components/parameters/external_product_reference_id" + get: + tags: + - external_product_references + operationId: get_external_product_external_product_reference + summary: Fetch an external product reference + responses: + '200': + description: Details for an external product reference. + content: + application/json: + schema: + "$ref": "#/components/schemas/ExternalProductReferenceMini" + '404': + description: Incorrect site or external product ID. + content: + application/json: + schema: + "$ref": "#/components/schemas/Error" + default: + description: Unexpected error. + content: + application/json: + schema: + "$ref": "#/components/schemas/Error" + x-code-samples: [] + delete: + tags: + - external_product_references + operationId: deactivate_external_product_external_product_reference + summary: Deactivate an external product reference + responses: + '200': + description: Details for an external product reference. + content: + application/json: + schema: + "$ref": "#/components/schemas/ExternalProductReferenceMini" + '404': + description: Incorrect site or external product reference ID. + content: + application/json: + schema: + "$ref": "#/components/schemas/Error" + default: + description: Unexpected error. + content: + application/json: + schema: + "$ref": "#/components/schemas/Error" + x-code-samples: [] "/external_subscriptions": get: tags: @@ -16014,6 +16231,13 @@ components: required: true schema: type: string + external_product_reference_id: + name: external_product_reference_id + in: path + description: External product reference ID, e.g. `d39iun2fw1v4`. + required: true + schema: + type: string external_subscription_id: name: external_subscription_id in: path @@ -23220,6 +23444,73 @@ components: type: array items: "$ref": "#/components/schemas/ExternalProduct" + ExternalProductCreate: + type: object + properties: + name: + type: string + description: External product name. + plan_id: + type: string + description: Recurly plan UUID. + external_product_references: + type: array + title: External Product References + description: List of external product references of the external product. + items: + "$ref": "#/components/schemas/ExternalProductReferenceBase" + required: + - name + ExternalProductUpdate: + type: object + properties: + plan_id: + type: string + description: Recurly plan UUID. + required: + - plan_id + ExternalProductReferenceBase: + type: object + properties: + reference_code: + type: string + description: A code which associates the external product to a corresponding + object or resource in an external platform like the Apple App Store or + Google Play Store. + maxLength: 255 + external_connection_type: + "$ref": "#/components/schemas/ExternalProductReferenceConnectionTypeEnum" + ExternalProductReferenceCollection: + type: object + properties: + object: + type: string + title: Object type + description: Will always be List. + has_more: + type: boolean + description: Indicates there are more results on subsequent pages. + next: + type: string + description: Path to subsequent page of results. + data: + type: array + items: + "$ref": "#/components/schemas/ExternalProductReferenceMini" + ExternalProductReferenceCreate: + allOf: + - "$ref": "#/components/schemas/ExternalProductReferenceBase" + required: + - reference_code + - external_connection_type + ExternalProductReferenceUpdate: + allOf: + - "$ref": "#/components/schemas/ExternalProductReferenceBase" + ExternalProductReferenceConnectionTypeEnum: + type: string + enum: + - apple_app_store + - google_play_store ExternalAccountList: type: object properties: diff --git a/package-lock.json b/package-lock.json index 9325b660..4a693fb2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "recurly", - "version": "4.35.0", + "version": "4.36.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "recurly", - "version": "4.35.0", + "version": "4.36.0", "license": "MIT", "devDependencies": { "@types/node": "^12.11.1",