Skip to content

Commit

Permalink
Merge pull request #293 from recurly/v3-v2021-02-25-1675723504
Browse files Browse the repository at this point in the history
Generated Latest Changes for v2021-02-25 (GiftCard endpoints and new transaction error support)
  • Loading branch information
arzitney committed Feb 6, 2023
2 parents e6bf066 + 34c05ad commit 1168b11
Show file tree
Hide file tree
Showing 9 changed files with 8,987 additions and 13,538 deletions.
248 changes: 248 additions & 0 deletions lib/recurly.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,10 @@ export declare class TransactionError {
* Code
*/
code?: string | null;
/**
* Decline code
*/
declineCode?: string | null;
/**
* Customer message
*/
Expand Down Expand Up @@ -1805,6 +1809,14 @@ export declare class Subscription {
* The invoice ID of the latest invoice created for an active subscription.
*/
activeInvoiceId?: string | null;
/**
* Whether the subscription was started with a gift certificate.
*/
startedWithGift?: boolean | null;
/**
* When the subscription was converted from a gift card.
*/
convertedAt?: Date | null;

}

Expand Down Expand Up @@ -3290,6 +3302,114 @@ export declare class GrantedBy {

}

export declare class GiftCard {
/**
* Gift card ID
*/
id?: string | null;
/**
* Object type
*/
object?: string | null;
/**
* The ID of the account that purchased the gift card.
*/
gifterAccountId?: string | null;
/**
* The ID of the account that redeemed the gift card redemption code. Does not have a value until gift card is redeemed.
*/
recipientAccountId?: string | null;
/**
* The ID of the invoice for the gift card purchase made by the gifter.
*/
purchaseInvoiceId?: string | null;
/**
* The ID of the invoice for the gift card redemption made by the recipient. Does not have a value until gift card is redeemed.
*/
redemptionInvoiceId?: string | null;
/**
* The unique redemption code for the gift card, generated by Recurly. Will be 16 characters, alphanumeric, displayed uppercase, but accepted in any case at redemption. Used by the recipient account to create a credit in the amount of the `unit_amount` on their account.
*/
redemptionCode?: string | null;
/**
* The remaining credit on the recipient account associated with this gift card. Only has a value once the gift card has been redeemed. Can be used to create gift card balance displays for your customers.
*/
balance?: number | null;
/**
* The product code or SKU of the gift card product.
*/
productCode?: string | null;
/**
* The amount of the gift card, which is the amount of the charge to the gifter account and the amount of credit that is applied to the recipient account upon successful redemption.
*/
unitAmount?: number | null;
/**
* 3-letter ISO 4217 currency code.
*/
currency?: string | null;
/**
* The delivery details for the gift card.
*/
delivery?: GiftCardDelivery | null;
/**
* Created at
*/
createdAt?: Date | null;
/**
* Last updated at
*/
updatedAt?: Date | null;
/**
* When the gift card was sent to the recipient by Recurly via email, if method was email and the "Gift Card Delivery" email template was enabled. This will be empty for post delivery or email delivery where the email template was disabled.
*/
deliveredAt?: Date | null;
/**
* When the gift card was redeemed by the recipient.
*/
redeemedAt?: Date | null;
/**
* When the gift card was canceled.
*/
canceledAt?: Date | null;

}

export declare class GiftCardDelivery {
/**
* Whether the delivery method is email or postal service.
*/
method?: string | null;
/**
* The email address of the recipient.
*/
emailAddress?: string | null;
/**
* When the gift card should be delivered to the recipient. If null, the gift card will be delivered immediately. If a datetime is provided, the delivery will be in an hourly window, rounding down. For example, 6:23 pm will be in the 6:00 pm hourly batch.
*/
deliverAt?: Date | null;
/**
* The first name of the recipient.
*/
firstName?: string | null;
/**
* The last name of the recipient.
*/
lastName?: string | null;
/**
* Address information for the recipient.
*/
recipientAddress?: Address | null;
/**
* The name of the gifter for the purpose of a message displayed to the recipient.
*/
gifterName?: string | null;
/**
* The personal message from the gifter to the recipient.
*/
personalMessage?: string | null;

}



export interface Empty {
Expand Down Expand Up @@ -4992,6 +5112,10 @@ export interface SubscriptionCreate {
* An optional type designation for the payment gateway transaction created by this request. Supports 'moto' value, which is the acronym for mail order and telephone transactions.
*/
transactionType?: string | null;
/**
* A gift card redemption code to be redeemed on the purchase invoice.
*/
giftCardRedemptionCode?: string | null;

}

Expand Down Expand Up @@ -5624,6 +5748,80 @@ export interface DunningCampaignsBulkUpdate {

}

export interface GiftCardCreate {
/**
* The product code or SKU of the gift card product.
*/
productCode?: string | null;
/**
* The amount of the gift card, which is the amount of the charge to the gifter account and the amount of credit that is applied to the recipient account upon successful redemption.
*/
unitAmount?: number | null;
/**
* 3-letter ISO 4217 currency code.
*/
currency?: string | null;
/**
* The delivery details for the gift card.
*/
delivery?: GiftCardDeliveryCreate | null;
/**
* Block of account details for the gifter. This references an existing account_code.
*/
gifterAccount?: AccountPurchase | null;

}

export interface GiftCardDeliveryCreate {
/**
* Whether the delivery method is email or postal service.
*/
method?: string | null;
/**
* The email address of the recipient. Required if `method` is `email`.
*/
emailAddress?: string | null;
/**
* When the gift card should be delivered to the recipient. If null, the gift card will be delivered immediately. If a datetime is provided, the delivery will be in an hourly window, rounding down. For example, 6:23 pm will be in the 6:00 pm hourly batch.
*/
deliverAt?: Date | null;
/**
* The first name of the recipient.
*/
firstName?: string | null;
/**
* The last name of the recipient.
*/
lastName?: string | null;
/**
* Address information for the recipient. Required if `method` is `post`.
*/
recipientAddress?: Address | null;
/**
* The name of the gifter for the purpose of a message displayed to the recipient.
*/
gifterName?: string | null;
/**
* The personal message from the gifter to the recipient.
*/
personalMessage?: string | null;

}

export interface GiftCardRedeem {
/**
* The account for the recipient of the gift card.
*/
recipientAccount?: AccountReference | null;

}

export interface AccountReference {
id?: string | null;
code?: string | null;

}


export declare class Client {
constructor(apiKey: string, options?: object);
Expand Down Expand Up @@ -9546,6 +9744,56 @@ endpoint to obtain only the newly generated `UniqueCouponCodes`.
* @return {Pager<ExternalSubscription>} A list of the the external_subscriptions on an account.
*/
listAccountExternalSubscriptions(accountId: string, options?: object): Pager<ExternalSubscription>;
/**
* List gift cards
*
* API docs: https://developers.recurly.com/api/v2021-02-25#operation/list_gift_cards
*
*
* @return {Pager<GiftCard>} List of all created gift cards on your site.
*/
listGiftCards(options?: object): Pager<GiftCard>;
/**
* Create gift card
*
* API docs: https://developers.recurly.com/api/v2021-02-25#operation/create_gift_card
*
*
* @param {GiftCardCreate} body - The object representing the JSON request to send to the server. It should conform to the schema of {GiftCardCreate}
* @return {Promise<GiftCard>} Returns the gift card
*/
createGiftCard(body: GiftCardCreate): Promise<GiftCard>;
/**
* Fetch a gift card
*
* API docs: https://developers.recurly.com/api/v2021-02-25#operation/get_gift_card
*
*
* @param {string} giftCardId - Gift Card ID, e.g. `e28zov4fw0v2`.
* @return {Promise<GiftCard>} Gift card details
*/
getGiftCard(giftCardId: string): Promise<GiftCard>;
/**
* Preview gift card
*
* API docs: https://developers.recurly.com/api/v2021-02-25#operation/preview_gift_card
*
*
* @param {GiftCardCreate} body - The object representing the JSON request to send to the server. It should conform to the schema of {GiftCardCreate}
* @return {Promise<GiftCard>} Returns the gift card
*/
previewGiftCard(body: GiftCardCreate): Promise<GiftCard>;
/**
* Redeem gift card
*
* API docs: https://developers.recurly.com/api/v2021-02-25#operation/redeem_gift_card
*
*
* @param {string} redemptionCode - Gift Card redemption code, e.g., `N1A2T8IRXSCMO40V`.
* @param {GiftCardRedeem} body - The object representing the JSON request to send to the server. It should conform to the schema of {GiftCardRedeem}
* @return {Promise<GiftCard>} Redeems and returns the gift card
*/
redeemGiftCard(redemptionCode: string, body: GiftCardRedeem): Promise<GiftCard>;

}

Expand Down
75 changes: 75 additions & 0 deletions lib/recurly/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -4670,6 +4670,81 @@ endpoint to obtain only the newly generated `UniqueCouponCodes`.
path = this._interpolatePath(path, { 'account_id': accountId })
return new Pager(this, path, options)
}

/**
* List gift cards
*
* API docs: {@link https://developers.recurly.com/api/v2021-02-25#operation/list_gift_cards}
*
*
* @return {Pager<GiftCard>} List of all created gift cards on your site.
*/
listGiftCards (options = {}) {
let path = '/gift_cards'
path = this._interpolatePath(path)
return new Pager(this, path, options)
}

/**
* Create gift card
*
* API docs: {@link https://developers.recurly.com/api/v2021-02-25#operation/create_gift_card}
*
*
* @param {GiftCardCreate} body - The object representing the JSON request to send to the server. It should conform to the schema of {GiftCardCreate}
* @return {Promise<GiftCard>} Returns the gift card
*/
async createGiftCard (body, options = {}) {
let path = '/gift_cards'
path = this._interpolatePath(path)
return this._makeRequest('POST', path, body, options)
}

/**
* Fetch a gift card
*
* API docs: {@link https://developers.recurly.com/api/v2021-02-25#operation/get_gift_card}
*
*
* @param {string} giftCardId - Gift Card ID, e.g. `e28zov4fw0v2`.
* @return {Promise<GiftCard>} Gift card details
*/
async getGiftCard (giftCardId, options = {}) {
let path = '/gift_cards/{gift_card_id}'
path = this._interpolatePath(path, { 'gift_card_id': giftCardId })
return this._makeRequest('GET', path, null, options)
}

/**
* Preview gift card
*
* API docs: {@link https://developers.recurly.com/api/v2021-02-25#operation/preview_gift_card}
*
*
* @param {GiftCardCreate} body - The object representing the JSON request to send to the server. It should conform to the schema of {GiftCardCreate}
* @return {Promise<GiftCard>} Returns the gift card
*/
async previewGiftCard (body, options = {}) {
let path = '/gift_cards/preview'
path = this._interpolatePath(path)
return this._makeRequest('POST', path, body, options)
}

/**
* Redeem gift card
*
* API docs: {@link https://developers.recurly.com/api/v2021-02-25#operation/redeem_gift_card}
*
*
* @param {string} redemptionCode - Gift Card redemption code, e.g., `N1A2T8IRXSCMO40V`.
* @param {GiftCardRedeem} body - The object representing the JSON request to send to the server. It should conform to the schema of {GiftCardRedeem}
* @return {Promise<GiftCard>} Redeems and returns the gift card
*/
async redeemGiftCard (redemptionCode, body, options = {}) {
let path = '/gift_cards/{redemption_code}/redeem'
path = this._interpolatePath(path, { 'redemption_code': redemptionCode })
return this._makeRequest('POST', path, body, options)
}
}

module.exports = Client
Loading

0 comments on commit 1168b11

Please sign in to comment.