Class: Stripe::Billing::CreditGrant

Inherits:
APIResource show all
Extended by:
APIOperations::Create, APIOperations::List
Includes:
APIOperations::Save
Defined in:
lib/stripe/resources/billing/credit_grant.rb

Overview

A credit grant is an API resource that documents the allocation of some billing credits to a customer.

Related guide: Billing credits

Defined Under Namespace

Classes: Amount, ApplicabilityConfig

Constant Summary collapse

OBJECT_NAME =
"billing.credit_grant"

Constants inherited from StripeObject

StripeObject::RESERVED_FIELD_NAMES

Instance Attribute Summary collapse

Attributes inherited from APIResource

#save_with_parent

Attributes inherited from StripeObject

#last_response

Class Method Summary collapse

Instance Method Summary collapse

Methods included from APIOperations::Create

create

Methods included from APIOperations::List

list

Methods included from APIOperations::Save

included, #save

Methods inherited from APIResource

class_name, custom_method, #refresh, #request_stripe_object, resource_url, #resource_url, retrieve, save_nested_resource

Methods included from APIOperations::Request

included

Methods inherited from StripeObject

#==, #[], #[]=, #_get_inner_class_type, additive_object_param, additive_object_param?, #as_json, construct_from, #deleted?, #dirty!, #each, #eql?, #hash, #initialize, #inspect, #keys, #marshal_dump, #marshal_load, protected_fields, #serialize_params, #to_hash, #to_json, #to_s, #update_attributes, #values

Constructor Details

This class inherits a constructor from Stripe::StripeObject

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Stripe::StripeObject

Instance Attribute Details

#amountObject (readonly)

Attribute for field amount



168
169
170
# File 'lib/stripe/resources/billing/credit_grant.rb', line 168

def amount
  @amount
end

#applicability_configObject (readonly)

Attribute for field applicability_config



170
171
172
# File 'lib/stripe/resources/billing/credit_grant.rb', line 170

def applicability_config
  @applicability_config
end

#categoryObject (readonly)

The category of this credit grant. This is for tracking purposes and isn't displayed to the customer.



172
173
174
# File 'lib/stripe/resources/billing/credit_grant.rb', line 172

def category
  @category
end

#createdObject (readonly)

Time at which the object was created. Measured in seconds since the Unix epoch.



174
175
176
# File 'lib/stripe/resources/billing/credit_grant.rb', line 174

def created
  @created
end

#customerObject (readonly)

ID of the customer receiving the billing credits.



176
177
178
# File 'lib/stripe/resources/billing/credit_grant.rb', line 176

def customer
  @customer
end

#customer_accountObject (readonly)

ID of the account representing the customer receiving the billing credits



178
179
180
# File 'lib/stripe/resources/billing/credit_grant.rb', line 178

def 
  @customer_account
end

#effective_atObject (readonly)

The time when the billing credits become effective-when they're eligible for use.



180
181
182
# File 'lib/stripe/resources/billing/credit_grant.rb', line 180

def effective_at
  @effective_at
end

#expires_atObject (readonly)

The time when the billing credits expire. If not present, the billing credits don't expire.



182
183
184
# File 'lib/stripe/resources/billing/credit_grant.rb', line 182

def expires_at
  @expires_at
end

#idObject (readonly)

Unique identifier for the object.



184
185
186
# File 'lib/stripe/resources/billing/credit_grant.rb', line 184

def id
  @id
end

#livemodeObject (readonly)

If the object exists in live mode, the value is true. If the object exists in test mode, the value is false.



186
187
188
# File 'lib/stripe/resources/billing/credit_grant.rb', line 186

def livemode
  @livemode
end

#metadataObject (readonly)

Set of key-value pairs that you can attach to an object. This can be useful for storing additional information about the object in a structured format.



188
189
190
# File 'lib/stripe/resources/billing/credit_grant.rb', line 188

def 
  @metadata
end

#nameObject (readonly)

A descriptive name shown in dashboard.



190
191
192
# File 'lib/stripe/resources/billing/credit_grant.rb', line 190

def name
  @name
end

#objectObject (readonly)

String representing the object's type. Objects of the same type share the same value.



192
193
194
# File 'lib/stripe/resources/billing/credit_grant.rb', line 192

def object
  @object
end

#priorityObject (readonly)

The priority for applying this credit grant. The highest priority is 0 and the lowest is 100.



194
195
196
# File 'lib/stripe/resources/billing/credit_grant.rb', line 194

def priority
  @priority
end

#test_clockObject (readonly)

ID of the test clock this credit grant belongs to.



196
197
198
# File 'lib/stripe/resources/billing/credit_grant.rb', line 196

def test_clock
  @test_clock
end

#updatedObject (readonly)

Time at which the object was last updated. Measured in seconds since the Unix epoch.



198
199
200
# File 'lib/stripe/resources/billing/credit_grant.rb', line 198

def updated
  @updated
end

#voided_atObject (readonly)

The time when this credit grant was voided. If not present, the credit grant hasn't been voided.



200
201
202
# File 'lib/stripe/resources/billing/credit_grant.rb', line 200

def voided_at
  @voided_at
end

Class Method Details

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

Creates a credit grant.



203
204
205
206
207
208
209
210
# File 'lib/stripe/resources/billing/credit_grant.rb', line 203

def self.create(params = {}, opts = {})
  request_stripe_object(
    method: :post,
    path: "/v1/billing/credit_grants",
    params: params,
    opts: opts
  )
end

.expire(id, params = {}, opts = {}) ⇒ Object

Expires a credit grant.



223
224
225
226
227
228
229
230
# File 'lib/stripe/resources/billing/credit_grant.rb', line 223

def self.expire(id, params = {}, opts = {})
  request_stripe_object(
    method: :post,
    path: format("/v1/billing/credit_grants/%<id>s/expire", { id: CGI.escape(id) }),
    params: params,
    opts: opts
  )
end

.field_encodingsObject



280
281
282
283
284
285
286
287
# File 'lib/stripe/resources/billing/credit_grant.rb', line 280

def self.field_encodings
  @field_encodings = {
    amount: {
      kind: :object,
      fields: { custom_pricing_unit: { kind: :object, fields: { value: :decimal_string } } },
    },
  }
end

.field_remappingsObject



276
277
278
# File 'lib/stripe/resources/billing/credit_grant.rb', line 276

def self.field_remappings
  @field_remappings = {}
end

.inner_class_typesObject



272
273
274
# File 'lib/stripe/resources/billing/credit_grant.rb', line 272

def self.inner_class_types
  @inner_class_types = { amount: Amount, applicability_config: ApplicabilityConfig }
end

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

Retrieve a list of credit grants.



233
234
235
236
237
238
239
240
# File 'lib/stripe/resources/billing/credit_grant.rb', line 233

def self.list(params = {}, opts = {})
  request_stripe_object(
    method: :get,
    path: "/v1/billing/credit_grants",
    params: params,
    opts: opts
  )
end

.object_nameObject



15
16
17
# File 'lib/stripe/resources/billing/credit_grant.rb', line 15

def self.object_name
  "billing.credit_grant"
end

.update(id, params = {}, opts = {}) ⇒ Object

Updates a credit grant.



243
244
245
246
247
248
249
250
# File 'lib/stripe/resources/billing/credit_grant.rb', line 243

def self.update(id, params = {}, opts = {})
  request_stripe_object(
    method: :post,
    path: format("/v1/billing/credit_grants/%<id>s", { id: CGI.escape(id) }),
    params: params,
    opts: opts
  )
end

.void_grant(id, params = {}, opts = {}) ⇒ Object

Voids a credit grant.



263
264
265
266
267
268
269
270
# File 'lib/stripe/resources/billing/credit_grant.rb', line 263

def self.void_grant(id, params = {}, opts = {})
  request_stripe_object(
    method: :post,
    path: format("/v1/billing/credit_grants/%<id>s/void", { id: CGI.escape(id) }),
    params: params,
    opts: opts
  )
end

Instance Method Details

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

Expires a credit grant.



213
214
215
216
217
218
219
220
# File 'lib/stripe/resources/billing/credit_grant.rb', line 213

def expire(params = {}, opts = {})
  request_stripe_object(
    method: :post,
    path: format("/v1/billing/credit_grants/%<id>s/expire", { id: CGI.escape(self["id"]) }),
    params: params,
    opts: opts
  )
end

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

Voids a credit grant.



253
254
255
256
257
258
259
260
# File 'lib/stripe/resources/billing/credit_grant.rb', line 253

def void_grant(params = {}, opts = {})
  request_stripe_object(
    method: :post,
    path: format("/v1/billing/credit_grants/%<id>s/void", { id: CGI.escape(self["id"]) }),
    params: params,
    opts: opts
  )
end