Class: SmplkitGeneratedClient::App::PaymentMethod
- Inherits:
-
ApiModelBase
- Object
- ApiModelBase
- SmplkitGeneratedClient::App::PaymentMethod
- Defined in:
- lib/smplkit/_generated/app/lib/smplkit_app_client/models/payment_method.rb
Overview
A saved card on file for the account, used to charge subscription invoices. The default payment method is changed via the ‘set_default` action rather than by updating this field through PUT.
Instance Attribute Summary collapse
-
#billing_details ⇒ Object
Billing details (name, email, phone, address) associated with the card.
-
#brand ⇒ Object
Card network brand, e.g.
-
#created_at ⇒ Object
When the payment method was registered.
-
#default ⇒ Object
Whether this payment method is the account’s default for subscription charges.
-
#exp_month ⇒ Object
Expiry month (1-12).
-
#exp_year ⇒ Object
Expiry year (four-digit).
-
#last4 ⇒ Object
Last four digits of the card number.
-
#updated_at ⇒ Object
When the payment method was last modified.
Class Method Summary collapse
-
.acceptable_attribute_map ⇒ Object
Returns attribute mapping this model knows about.
-
.acceptable_attributes ⇒ Object
Returns all the JSON keys this model knows about.
-
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
-
.build_from_hash(attributes) ⇒ Object
Builds the object from hash.
-
.openapi_nullable ⇒ Object
List of attributes with nullable: true.
-
.openapi_types ⇒ Object
Attribute type mapping.
Instance Method Summary collapse
-
#==(o) ⇒ Object
Checks equality by comparing each attribute.
- #eql?(o) ⇒ Boolean
-
#hash ⇒ Integer
Calculates hash code according to all attributes.
-
#initialize(attributes = {}) ⇒ PaymentMethod
constructor
Initializes the object.
-
#list_invalid_properties ⇒ Object
Show invalid properties with the reasons.
-
#to_hash ⇒ Hash
Returns the object in the form of hash.
-
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid.
Methods inherited from ApiModelBase
_deserialize, #_to_hash, #to_body, #to_s
Constructor Details
#initialize(attributes = {}) ⇒ PaymentMethod
Initializes the object
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/smplkit/_generated/app/lib/smplkit_app_client/models/payment_method.rb', line 97 def initialize(attributes = {}) if (!attributes.is_a?(Hash)) fail ArgumentError, "The input argument (attributes) must be a hash in `SmplkitGeneratedClient::App::PaymentMethod` initialize method" end # check to see if the attribute exists and convert string to symbol for hash key acceptable_attribute_map = self.class.acceptable_attribute_map attributes = attributes.each_with_object({}) { |(k, v), h| if (!acceptable_attribute_map.key?(k.to_sym)) fail ArgumentError, "`#{k}` is not a valid attribute in `SmplkitGeneratedClient::App::PaymentMethod`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect end h[k.to_sym] = v } if attributes.key?(:'brand') self.brand = attributes[:'brand'] end if attributes.key?(:'last4') self.last4 = attributes[:'last4'] end if attributes.key?(:'exp_month') self.exp_month = attributes[:'exp_month'] end if attributes.key?(:'exp_year') self.exp_year = attributes[:'exp_year'] end if attributes.key?(:'default') self.default = attributes[:'default'] end if attributes.key?(:'billing_details') if (value = attributes[:'billing_details']).is_a?(Hash) self.billing_details = value end end if attributes.key?(:'created_at') self.created_at = attributes[:'created_at'] end if attributes.key?(:'updated_at') self.updated_at = attributes[:'updated_at'] end end |
Instance Attribute Details
#billing_details ⇒ Object
Billing details (name, email, phone, address) associated with the card.
35 36 37 |
# File 'lib/smplkit/_generated/app/lib/smplkit_app_client/models/payment_method.rb', line 35 def billing_details @billing_details end |
#brand ⇒ Object
Card network brand, e.g. ‘visa`, `mastercard`, `amex`.
20 21 22 |
# File 'lib/smplkit/_generated/app/lib/smplkit_app_client/models/payment_method.rb', line 20 def brand @brand end |
#created_at ⇒ Object
When the payment method was registered.
38 39 40 |
# File 'lib/smplkit/_generated/app/lib/smplkit_app_client/models/payment_method.rb', line 38 def created_at @created_at end |
#default ⇒ Object
Whether this payment method is the account’s default for subscription charges. Use the ‘set_default` action to change which payment method is default — this field is not writable via PUT.
32 33 34 |
# File 'lib/smplkit/_generated/app/lib/smplkit_app_client/models/payment_method.rb', line 32 def default @default end |
#exp_month ⇒ Object
Expiry month (1-12).
26 27 28 |
# File 'lib/smplkit/_generated/app/lib/smplkit_app_client/models/payment_method.rb', line 26 def exp_month @exp_month end |
#exp_year ⇒ Object
Expiry year (four-digit).
29 30 31 |
# File 'lib/smplkit/_generated/app/lib/smplkit_app_client/models/payment_method.rb', line 29 def exp_year @exp_year end |
#last4 ⇒ Object
Last four digits of the card number.
23 24 25 |
# File 'lib/smplkit/_generated/app/lib/smplkit_app_client/models/payment_method.rb', line 23 def last4 @last4 end |
#updated_at ⇒ Object
When the payment method was last modified.
41 42 43 |
# File 'lib/smplkit/_generated/app/lib/smplkit_app_client/models/payment_method.rb', line 41 def updated_at @updated_at end |
Class Method Details
.acceptable_attribute_map ⇒ Object
Returns attribute mapping this model knows about
58 59 60 |
# File 'lib/smplkit/_generated/app/lib/smplkit_app_client/models/payment_method.rb', line 58 def self.acceptable_attribute_map attribute_map end |
.acceptable_attributes ⇒ Object
Returns all the JSON keys this model knows about
63 64 65 |
# File 'lib/smplkit/_generated/app/lib/smplkit_app_client/models/payment_method.rb', line 63 def self.acceptable_attributes acceptable_attribute_map.values end |
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/smplkit/_generated/app/lib/smplkit_app_client/models/payment_method.rb', line 44 def self.attribute_map { :'brand' => :'brand', :'last4' => :'last4', :'exp_month' => :'exp_month', :'exp_year' => :'exp_year', :'default' => :'default', :'billing_details' => :'billing_details', :'created_at' => :'created_at', :'updated_at' => :'updated_at' } end |
.build_from_hash(attributes) ⇒ Object
Builds the object from hash
239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 |
# File 'lib/smplkit/_generated/app/lib/smplkit_app_client/models/payment_method.rb', line 239 def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) transformed_hash = {} openapi_types.each_pair do |key, type| if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not if attributes[attribute_map[key]].is_a?(Array) transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } end elsif !attributes[attribute_map[key]].nil? transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) end end new(transformed_hash) end |
.openapi_nullable ⇒ Object
List of attributes with nullable: true
82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/smplkit/_generated/app/lib/smplkit_app_client/models/payment_method.rb', line 82 def self.openapi_nullable Set.new([ :'brand', :'last4', :'exp_month', :'exp_year', :'default', :'billing_details', :'created_at', :'updated_at' ]) end |
.openapi_types ⇒ Object
Attribute type mapping.
68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/smplkit/_generated/app/lib/smplkit_app_client/models/payment_method.rb', line 68 def self.openapi_types { :'brand' => :'String', :'last4' => :'String', :'exp_month' => :'Integer', :'exp_year' => :'Integer', :'default' => :'Boolean', :'billing_details' => :'Hash<String, Object>', :'created_at' => :'Time', :'updated_at' => :'Time' } end |
Instance Method Details
#==(o) ⇒ Object
Checks equality by comparing each attribute.
211 212 213 214 215 216 217 218 219 220 221 222 |
# File 'lib/smplkit/_generated/app/lib/smplkit_app_client/models/payment_method.rb', line 211 def ==(o) return true if self.equal?(o) self.class == o.class && brand == o.brand && last4 == o.last4 && exp_month == o.exp_month && exp_year == o.exp_year && default == o.default && billing_details == o.billing_details && created_at == o.created_at && updated_at == o.updated_at end |
#eql?(o) ⇒ Boolean
226 227 228 |
# File 'lib/smplkit/_generated/app/lib/smplkit_app_client/models/payment_method.rb', line 226 def eql?(o) self == o end |
#hash ⇒ Integer
Calculates hash code according to all attributes.
232 233 234 |
# File 'lib/smplkit/_generated/app/lib/smplkit_app_client/models/payment_method.rb', line 232 def hash [brand, last4, exp_month, exp_year, default, billing_details, created_at, updated_at].hash end |
#list_invalid_properties ⇒ Object
Show invalid properties with the reasons. Usually used together with valid?
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
# File 'lib/smplkit/_generated/app/lib/smplkit_app_client/models/payment_method.rb', line 148 def list_invalid_properties warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' invalid_properties = Array.new if !@exp_month.nil? && @exp_month > 12 invalid_properties.push('invalid value for "exp_month", must be smaller than or equal to 12.') end if !@exp_month.nil? && @exp_month < 1 invalid_properties.push('invalid value for "exp_month", must be greater than or equal to 1.') end if !@exp_year.nil? && @exp_year > 2100 invalid_properties.push('invalid value for "exp_year", must be smaller than or equal to 2100.') end if !@exp_year.nil? && @exp_year < 2000 invalid_properties.push('invalid value for "exp_year", must be greater than or equal to 2000.') end invalid_properties end |
#to_hash ⇒ Hash
Returns the object in the form of hash
261 262 263 264 265 266 267 268 269 270 271 272 273 |
# File 'lib/smplkit/_generated/app/lib/smplkit_app_client/models/payment_method.rb', line 261 def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) if value.nil? is_nullable = self.class.openapi_nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end hash[param] = _to_hash(value) end hash end |
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid
172 173 174 175 176 177 178 179 |
# File 'lib/smplkit/_generated/app/lib/smplkit_app_client/models/payment_method.rb', line 172 def valid? warn '[DEPRECATED] the `valid?` method is obsolete' return false if !@exp_month.nil? && @exp_month > 12 return false if !@exp_month.nil? && @exp_month < 1 return false if !@exp_year.nil? && @exp_year > 2100 return false if !@exp_year.nil? && @exp_year < 2000 true end |