Class: Cryptopay::Subscription
- Inherits:
-
Object
- Object
- Cryptopay::Subscription
- Defined in:
- lib/cryptopay/models/subscription.rb
Class Method Summary collapse
-
.build_from_hash(data) ⇒ Cryptopay::Subscription
Builds the object from hash.
Instance Method Summary collapse
-
#amount ⇒ Object
Subscription amount.
- #cancelled_at ⇒ Object
- #created_at ⇒ Object
-
#currency ⇒ Object
Subscription amount currency.
- #current_period_ends_at ⇒ Object
- #current_period_paid ⇒ Object
- #current_period_starts_at ⇒ Object
-
#custom_id ⇒ Object
Subscription reference ID in your system.
-
#id ⇒ Object
Subscription ID.
-
#initialize(attributes = {}) ⇒ Subscription
constructor
Initializes the object.
- #inspect ⇒ Object
-
#invalid_properties ⇒ Object
Show invalid properties with the reasons.
-
#name ⇒ Object
Subscription name.
- #payer_email ⇒ Object
- #payer_name ⇒ Object
- #period ⇒ Object
- #period_quantity ⇒ Object
- #product_description ⇒ Object
- #product_name ⇒ Object
- #status ⇒ Object
-
#success_redirect_url ⇒ Object
The URL that the customer will be redirected to upon transaction confirmation.
-
#to_hash ⇒ Hash
Returns the object in the form of hash.
- #unsuccess_redirect_url ⇒ Object
-
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid.
Constructor Details
#initialize(attributes = {}) ⇒ Subscription
Initializes the object
74 75 76 |
# File 'lib/cryptopay/models/subscription.rb', line 74 def initialize(attributes = {}) @attributes = ENCODER.sanitize(attributes) end |
Class Method Details
.build_from_hash(data) ⇒ Cryptopay::Subscription
Builds the object from hash
67 68 69 70 |
# File 'lib/cryptopay/models/subscription.rb', line 67 def self.build_from_hash(data) attributes = ENCODER.build_from_hash(data) new(attributes) end |
Instance Method Details
#amount ⇒ Object
Subscription amount
98 99 100 |
# File 'lib/cryptopay/models/subscription.rb', line 98 def amount @attributes[:amount] end |
#cancelled_at ⇒ Object
156 157 158 |
# File 'lib/cryptopay/models/subscription.rb', line 156 def cancelled_at @attributes[:cancelled_at] end |
#created_at ⇒ Object
152 153 154 |
# File 'lib/cryptopay/models/subscription.rb', line 152 def created_at @attributes[:created_at] end |
#currency ⇒ Object
Subscription amount currency
103 104 105 |
# File 'lib/cryptopay/models/subscription.rb', line 103 def currency @attributes[:currency] end |
#current_period_ends_at ⇒ Object
119 120 121 |
# File 'lib/cryptopay/models/subscription.rb', line 119 def current_period_ends_at @attributes[:current_period_ends_at] end |
#current_period_paid ⇒ Object
123 124 125 |
# File 'lib/cryptopay/models/subscription.rb', line 123 def current_period_paid @attributes[:current_period_paid] end |
#current_period_starts_at ⇒ Object
115 116 117 |
# File 'lib/cryptopay/models/subscription.rb', line 115 def current_period_starts_at @attributes[:current_period_starts_at] end |
#custom_id ⇒ Object
Subscription reference ID in your system
88 89 90 |
# File 'lib/cryptopay/models/subscription.rb', line 88 def custom_id @attributes[:custom_id] end |
#id ⇒ Object
Subscription ID
79 80 81 |
# File 'lib/cryptopay/models/subscription.rb', line 79 def id @attributes[:id] end |
#inspect ⇒ Object
218 219 220 |
# File 'lib/cryptopay/models/subscription.rb', line 218 def inspect "#<#{self.class}:0x#{object_id.to_s(16)}> JSON: " + JSON.pretty_generate(to_hash) end |
#invalid_properties ⇒ Object
Show invalid properties with the reasons. Usually used together with valid?
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 |
# File 'lib/cryptopay/models/subscription.rb', line 162 def invalid_properties properties = [] properties.push('invalid value for "id", id cannot be nil.') if id.nil? properties.push('invalid value for "status", status cannot be nil.') if status.nil? if !status.nil? && !%w[active cancelled].include?(status) properties.push('invalid value for status, must be one of "active", "cancelled"') end properties.push('invalid value for "name", name cannot be nil.') if name.nil? properties.push('invalid value for "amount", amount cannot be nil.') if amount.nil? properties.push('invalid value for "currency", currency cannot be nil.') if currency.nil? properties.push('invalid value for "period", period cannot be nil.') if period.nil? if !period.nil? && !%w[day week month year].include?(period) properties.push('invalid value for period, must be one of "day", "week", "month", "year"') end properties.push('invalid value for "period_quantity", period_quantity cannot be nil.') if period_quantity.nil? if current_period_starts_at.nil? properties.push('invalid value for "current_period_starts_at", current_period_starts_at cannot be nil.') end if current_period_ends_at.nil? properties.push('invalid value for "current_period_ends_at", current_period_ends_at cannot be nil.') end if current_period_paid.nil? properties.push('invalid value for "current_period_paid", current_period_paid cannot be nil.') end properties.push('invalid value for "payer_email", payer_email cannot be nil.') if payer_email.nil? properties.push('invalid value for "created_at", created_at cannot be nil.') if created_at.nil? properties end |
#name ⇒ Object
Subscription name
93 94 95 |
# File 'lib/cryptopay/models/subscription.rb', line 93 def name @attributes[:name] end |
#payer_email ⇒ Object
127 128 129 |
# File 'lib/cryptopay/models/subscription.rb', line 127 def payer_email @attributes[:payer_email] end |
#payer_name ⇒ Object
131 132 133 |
# File 'lib/cryptopay/models/subscription.rb', line 131 def payer_name @attributes[:payer_name] end |
#period ⇒ Object
107 108 109 |
# File 'lib/cryptopay/models/subscription.rb', line 107 def period @attributes[:period] end |
#period_quantity ⇒ Object
111 112 113 |
# File 'lib/cryptopay/models/subscription.rb', line 111 def period_quantity @attributes[:period_quantity] end |
#product_description ⇒ Object
139 140 141 |
# File 'lib/cryptopay/models/subscription.rb', line 139 def product_description @attributes[:product_description] end |
#product_name ⇒ Object
135 136 137 |
# File 'lib/cryptopay/models/subscription.rb', line 135 def product_name @attributes[:product_name] end |
#status ⇒ Object
83 84 85 |
# File 'lib/cryptopay/models/subscription.rb', line 83 def status @attributes[:status] end |
#success_redirect_url ⇒ Object
The URL that the customer will be redirected to upon transaction confirmation
144 145 146 |
# File 'lib/cryptopay/models/subscription.rb', line 144 def success_redirect_url @attributes[:success_redirect_url] end |
#to_hash ⇒ Hash
Returns the object in the form of hash
214 215 216 |
# File 'lib/cryptopay/models/subscription.rb', line 214 def to_hash ENCODER.to_hash(@attributes) end |
#unsuccess_redirect_url ⇒ Object
148 149 150 |
# File 'lib/cryptopay/models/subscription.rb', line 148 def unsuccess_redirect_url @attributes[:unsuccess_redirect_url] end |
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid
208 209 210 |
# File 'lib/cryptopay/models/subscription.rb', line 208 def valid? invalid_properties.empty? end |