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](docs.stripe.com/billing/subscriptions/usage-based/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

#==, #[], #[]=, 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



33
34
35
# File 'lib/stripe/resources/billing/credit_grant.rb', line 33

def amount
  @amount
end

#applicability_configObject (readonly)

Attribute for field applicability_config



35
36
37
# File 'lib/stripe/resources/billing/credit_grant.rb', line 35

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.



37
38
39
# File 'lib/stripe/resources/billing/credit_grant.rb', line 37

def category
  @category
end

#createdObject (readonly)

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



39
40
41
# File 'lib/stripe/resources/billing/credit_grant.rb', line 39

def created
  @created
end

#customerObject (readonly)

ID of the customer receiving the billing credits.



41
42
43
# File 'lib/stripe/resources/billing/credit_grant.rb', line 41

def customer
  @customer
end

#effective_atObject (readonly)

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



43
44
45
# File 'lib/stripe/resources/billing/credit_grant.rb', line 43

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.



45
46
47
# File 'lib/stripe/resources/billing/credit_grant.rb', line 45

def expires_at
  @expires_at
end

#idObject (readonly)

Unique identifier for the object.



47
48
49
# File 'lib/stripe/resources/billing/credit_grant.rb', line 47

def id
  @id
end

#livemodeObject (readonly)

Has the value ‘true` if the object exists in live mode or the value `false` if the object exists in test mode.



49
50
51
# File 'lib/stripe/resources/billing/credit_grant.rb', line 49

def livemode
  @livemode
end

#metadataObject (readonly)

Set of [key-value pairs](stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.



51
52
53
# File 'lib/stripe/resources/billing/credit_grant.rb', line 51

def 
  @metadata
end

#nameObject (readonly)

A descriptive name shown in dashboard.



53
54
55
# File 'lib/stripe/resources/billing/credit_grant.rb', line 53

def name
  @name
end

#objectObject (readonly)

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



55
56
57
# File 'lib/stripe/resources/billing/credit_grant.rb', line 55

def object
  @object
end

#test_clockObject (readonly)

ID of the test clock this credit grant belongs to.



57
58
59
# File 'lib/stripe/resources/billing/credit_grant.rb', line 57

def test_clock
  @test_clock
end

#updatedObject (readonly)

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



59
60
61
# File 'lib/stripe/resources/billing/credit_grant.rb', line 59

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.



61
62
63
# File 'lib/stripe/resources/billing/credit_grant.rb', line 61

def voided_at
  @voided_at
end

Class Method Details

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

Creates a credit grant.



64
65
66
67
68
69
70
71
# File 'lib/stripe/resources/billing/credit_grant.rb', line 64

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.



84
85
86
87
88
89
90
91
# File 'lib/stripe/resources/billing/credit_grant.rb', line 84

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

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

Retrieve a list of credit grants.



94
95
96
97
98
99
100
101
# File 'lib/stripe/resources/billing/credit_grant.rb', line 94

def self.list(filters = {}, opts = {})
  request_stripe_object(
    method: :get,
    path: "/v1/billing/credit_grants",
    params: filters,
    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.



104
105
106
107
108
109
110
111
# File 'lib/stripe/resources/billing/credit_grant.rb', line 104

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.



124
125
126
127
128
129
130
131
# File 'lib/stripe/resources/billing/credit_grant.rb', line 124

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.



74
75
76
77
78
79
80
81
# File 'lib/stripe/resources/billing/credit_grant.rb', line 74

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.



114
115
116
117
118
119
120
121
# File 'lib/stripe/resources/billing/credit_grant.rb', line 114

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