Class: Stripe::PromotionCodeService

Inherits:
StripeService show all
Defined in:
lib/stripe/services/promotion_code_service.rb

Defined Under Namespace

Classes: CreateParams, ListParams, RetrieveParams, UpdateParams

Instance Method Summary collapse

Methods inherited from StripeService

#initialize, #request, #request_stream

Constructor Details

This class inherits a constructor from Stripe::StripeService

Instance Method Details

#create(params = {}, opts = {}) ⇒ Object

A promotion code points to a coupon. You can optionally restrict the code to a specific customer, redemption limit, and expiration date.



185
186
187
188
189
190
191
192
193
# File 'lib/stripe/services/promotion_code_service.rb', line 185

def create(params = {}, opts = {})
  request(
    method: :post,
    path: "/v1/promotion_codes",
    params: params,
    opts: opts,
    base_address: :api
  )
end

#list(params = {}, opts = {}) ⇒ Object

Returns a list of your promotion codes.



196
197
198
199
200
201
202
203
204
# File 'lib/stripe/services/promotion_code_service.rb', line 196

def list(params = {}, opts = {})
  request(
    method: :get,
    path: "/v1/promotion_codes",
    params: params,
    opts: opts,
    base_address: :api
  )
end

#retrieve(promotion_code, params = {}, opts = {}) ⇒ Object

Retrieves the promotion code with the given ID. In order to retrieve a promotion code by the customer-facing code use [list](stripe.com/docs/api/promotion_codes/list) with the desired code.



207
208
209
210
211
212
213
214
215
# File 'lib/stripe/services/promotion_code_service.rb', line 207

def retrieve(promotion_code, params = {}, opts = {})
  request(
    method: :get,
    path: format("/v1/promotion_codes/%<promotion_code>s", { promotion_code: CGI.escape(promotion_code) }),
    params: params,
    opts: opts,
    base_address: :api
  )
end

#update(promotion_code, params = {}, opts = {}) ⇒ Object

Updates the specified promotion code by setting the values of the parameters passed. Most fields are, by design, not editable.



218
219
220
221
222
223
224
225
226
# File 'lib/stripe/services/promotion_code_service.rb', line 218

def update(promotion_code, params = {}, opts = {})
  request(
    method: :post,
    path: format("/v1/promotion_codes/%<promotion_code>s", { promotion_code: CGI.escape(promotion_code) }),
    params: params,
    opts: opts,
    base_address: :api
  )
end