UNPKG

pulumi-stripe

Version:

A Pulumi package for creating and managing Stripe resources.

111 lines 5.08 kB
"use strict"; // *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. *** // *** Do not edit by hand unless you're certain you know what you are doing! *** Object.defineProperty(exports, "__esModule", { value: true }); exports.PromotionCode = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = require("./utilities"); /** * With this resource, you can create a promotion code - [Stripe API promotion code documentation](https://stripe.com/docs/api/promotion_codes). * * A Promotion Code represents a customer-redeemable code for a coupon. It can be used to create multiple codes for a single coupon. * * > Removal of the promotion code isn't supported through the Stripe SDK. * * ## Example Usage * * <!--Start PulumiCodeChooser --> * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as stripe from "pulumi-stripe"; * * // promotion code for the coupon * const codePromotionCode = new stripe.PromotionCode("codePromotionCode", { * coupon: stripe_coupon.coupon.id, * code: "FREE", * }); * // promotion code for the coupon with limitations * const codeIndex_promotionCodePromotionCode = new stripe.PromotionCode("codeIndex/promotionCodePromotionCode", { * coupon: stripe_coupon.coupon.id, * code: "FREE", * maxRedemptions: 5, * expiresAt: "2025-08-03T08:37:18+00:00", * }); * // promotion code for the coupon to customer * const codeStripeIndex_promotionCodePromotionCode = new stripe.PromotionCode("codeStripeIndex/promotionCodePromotionCode", { * coupon: stripe_coupon.coupon.id, * code: "FREE", * customer: "cus...", * }); * // promotion code for the coupon with restrictions * const codeStripeIndex_promotionCodePromotionCode1 = new stripe.PromotionCode("codeStripeIndex/promotionCodePromotionCode1", { * coupon: stripe_coupon.coupon.id, * code: "FREE", * restrictions: { * firstTimeTransaction: true, * minimumAmount: 100, * minimumAmountCurrency: "aud", * }, * }); * ``` * <!--End PulumiCodeChooser --> */ class PromotionCode extends pulumi.CustomResource { /** * Get an existing PromotionCode resource's state with the given name, ID, and optional extra * properties used to qualify the lookup. * * @param name The _unique_ name of the resulting resource. * @param id The _unique_ provider ID of the resource to lookup. * @param state Any extra arguments used during the lookup. * @param opts Optional settings to control the behavior of the CustomResource. */ static get(name, id, state, opts) { return new PromotionCode(name, state, Object.assign(Object.assign({}, opts), { id: id })); } /** * Returns true if the given object is an instance of PromotionCode. This is designed to work even * when multiple copies of the Pulumi SDK have been loaded into the same process. */ static isInstance(obj) { if (obj === undefined || obj === null) { return false; } return obj['__pulumiType'] === PromotionCode.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["active"] = state ? state.active : undefined; resourceInputs["code"] = state ? state.code : undefined; resourceInputs["coupon"] = state ? state.coupon : undefined; resourceInputs["customer"] = state ? state.customer : undefined; resourceInputs["expiresAt"] = state ? state.expiresAt : undefined; resourceInputs["maxRedemptions"] = state ? state.maxRedemptions : undefined; resourceInputs["metadata"] = state ? state.metadata : undefined; resourceInputs["restrictions"] = state ? state.restrictions : undefined; } else { const args = argsOrState; if ((!args || args.coupon === undefined) && !opts.urn) { throw new Error("Missing required property 'coupon'"); } resourceInputs["active"] = args ? args.active : undefined; resourceInputs["code"] = args ? args.code : undefined; resourceInputs["coupon"] = args ? args.coupon : undefined; resourceInputs["customer"] = args ? args.customer : undefined; resourceInputs["expiresAt"] = args ? args.expiresAt : undefined; resourceInputs["maxRedemptions"] = args ? args.maxRedemptions : undefined; resourceInputs["metadata"] = args ? args.metadata : undefined; resourceInputs["restrictions"] = args ? args.restrictions : undefined; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(PromotionCode.__pulumiType, name, resourceInputs, opts); } } exports.PromotionCode = PromotionCode; /** @internal */ PromotionCode.__pulumiType = 'stripe:index/promotionCode:PromotionCode'; //# sourceMappingURL=promotionCode.js.map