Class: Komoju::Refund
- Inherits:
-
ApiModelBase
- Object
- ApiModelBase
- Komoju::Refund
- Defined in:
- lib/komoju-sdk/models/refund.rb
Defined Under Namespace
Classes: EnumAttributeValidator
Instance Attribute Summary collapse
-
#amount ⇒ Object
The refund amount with tax included, greater than or equal to 0, in the lowest denomination of the currency (e.g. cents for USD).
-
#chargeback ⇒ Object
Denotes if this refund was created due to a chargeback.
-
#created_at ⇒ Object
Returns the value of attribute created_at.
-
#currency ⇒ Object
Returns the value of attribute currency.
-
#description ⇒ Object
Description of the refund.
-
#id ⇒ Object
A unique 25-character alphanumeric refund identifier.
-
#payment ⇒ Object
A unique 25-character alphanumeric payment identifier.
-
#platform_details ⇒ Object
Returns the value of attribute platform_details.
-
#refund_type ⇒ Object
Returns the value of attribute refund_type.
-
#resource ⇒ Object
Resource name.
Class Method Summary collapse
-
._deserialize(type, value) ⇒ Object
Deserializes the data based on type.
-
.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.
-
#_to_hash(value) ⇒ Hash
Outputs non-array value in the form of hash For object, use to_hash.
- #eql?(o) ⇒ Boolean
-
#hash ⇒ Integer
Calculates hash code according to all attributes.
-
#initialize(attributes = {}) ⇒ Refund
constructor
Initializes the object.
-
#list_invalid_properties ⇒ Object
Show invalid properties with the reasons.
-
#to_body ⇒ Hash
to_body is an alias to to_hash (backward compatibility).
-
#to_hash ⇒ Hash
Returns the object in the form of hash.
-
#to_s ⇒ String
Returns the string representation of the object.
-
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid.
Constructor Details
#initialize(attributes = {}) ⇒ Refund
Initializes the object
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 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 |
# File 'lib/komoju-sdk/models/refund.rb', line 116 def initialize(attributes = {}) if (!attributes.is_a?(Hash)) fail ArgumentError, "The input argument (attributes) must be a hash in `Komoju::Refund` 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 `Komoju::Refund`. 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?(:'id') self.id = attributes[:'id'] else self.id = nil end if attributes.key?(:'resource') self.resource = attributes[:'resource'] else self.resource = nil end if attributes.key?(:'amount') self.amount = attributes[:'amount'] else self.amount = nil end if attributes.key?(:'currency') self.currency = attributes[:'currency'] else self.currency = nil end if attributes.key?(:'payment') self.payment = attributes[:'payment'] else self.payment = nil end if attributes.key?(:'description') self.description = attributes[:'description'] else self.description = nil end if attributes.key?(:'created_at') self.created_at = attributes[:'created_at'] else self.created_at = nil end if attributes.key?(:'chargeback') self.chargeback = attributes[:'chargeback'] else self.chargeback = nil end if attributes.key?(:'refund_type') self.refund_type = attributes[:'refund_type'] end if attributes.key?(:'platform_details') self.platform_details = attributes[:'platform_details'] end end |
Instance Attribute Details
#amount ⇒ Object
The refund amount with tax included, greater than or equal to 0, in the lowest denomination of the currency (e.g. cents for USD).
25 26 27 |
# File 'lib/komoju-sdk/models/refund.rb', line 25 def amount @amount end |
#chargeback ⇒ Object
Denotes if this refund was created due to a chargeback.
38 39 40 |
# File 'lib/komoju-sdk/models/refund.rb', line 38 def chargeback @chargeback end |
#created_at ⇒ Object
Returns the value of attribute created_at.
35 36 37 |
# File 'lib/komoju-sdk/models/refund.rb', line 35 def created_at @created_at end |
#currency ⇒ Object
Returns the value of attribute currency.
27 28 29 |
# File 'lib/komoju-sdk/models/refund.rb', line 27 def currency @currency end |
#description ⇒ Object
Description of the refund.
33 34 35 |
# File 'lib/komoju-sdk/models/refund.rb', line 33 def description @description end |
#id ⇒ Object
A unique 25-character alphanumeric refund identifier.
19 20 21 |
# File 'lib/komoju-sdk/models/refund.rb', line 19 def id @id end |
#payment ⇒ Object
A unique 25-character alphanumeric payment identifier.
30 31 32 |
# File 'lib/komoju-sdk/models/refund.rb', line 30 def payment @payment end |
#platform_details ⇒ Object
Returns the value of attribute platform_details.
42 43 44 |
# File 'lib/komoju-sdk/models/refund.rb', line 42 def platform_details @platform_details end |
#refund_type ⇒ Object
Returns the value of attribute refund_type.
40 41 42 |
# File 'lib/komoju-sdk/models/refund.rb', line 40 def refund_type @refund_type end |
#resource ⇒ Object
Resource name. Will always be refund.
22 23 24 |
# File 'lib/komoju-sdk/models/refund.rb', line 22 def resource @resource end |
Class Method Details
._deserialize(type, value) ⇒ Object
Deserializes the data based on type
431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 |
# File 'lib/komoju-sdk/models/refund.rb', line 431 def self._deserialize(type, value) case type.to_sym when :Time Time.parse(value) rescue value when :Date Date.parse(value) rescue value when :String value.to_s when :Integer value.to_i when :Float value.to_f when :Boolean if value.to_s =~ /\A(true|t|yes|y|1)\z/i true else false end when :Object # generic object (usually a Hash), return directly value when /\AArray<(?<inner_type>.+)>\z/ inner_type = Regexp.last_match[:inner_type] value.map { |v| _deserialize(inner_type, v) } when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/ k_type = Regexp.last_match[:k_type] v_type = Regexp.last_match[:v_type] {}.tap do |hash| value.each do |k, v| hash[_deserialize(k_type, k)] = _deserialize(v_type, v) end end else # model # models (e.g. Pet) or oneOf klass = Komoju.const_get(type) klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end |
.acceptable_attribute_map ⇒ Object
Returns attribute mapping this model knows about
83 84 85 |
# File 'lib/komoju-sdk/models/refund.rb', line 83 def self.acceptable_attribute_map attribute_map end |
.acceptable_attributes ⇒ Object
Returns all the JSON keys this model knows about
88 89 90 |
# File 'lib/komoju-sdk/models/refund.rb', line 88 def self.acceptable_attributes acceptable_attribute_map.values end |
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/komoju-sdk/models/refund.rb', line 67 def self.attribute_map { :'id' => :'id', :'resource' => :'resource', :'amount' => :'amount', :'currency' => :'currency', :'payment' => :'payment', :'description' => :'description', :'created_at' => :'created_at', :'chargeback' => :'chargeback', :'refund_type' => :'refund_type', :'platform_details' => :'platform_details' } end |
.build_from_hash(attributes) ⇒ Object
Builds the object from hash
401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 |
# File 'lib/komoju-sdk/models/refund.rb', line 401 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 begin new(transformed_hash) rescue ArgumentError => e obj = allocate transformed_hash.each { |k, v| obj.instance_variable_set(:"@#{k}", v) } obj end end |
.openapi_nullable ⇒ Object
List of attributes with nullable: true
109 110 111 112 |
# File 'lib/komoju-sdk/models/refund.rb', line 109 def self.openapi_nullable Set.new([ ]) end |
.openapi_types ⇒ Object
Attribute type mapping.
93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/komoju-sdk/models/refund.rb', line 93 def self.openapi_types { :'id' => :'String', :'resource' => :'String', :'amount' => :'Integer', :'currency' => :'Currency', :'payment' => :'String', :'description' => :'String', :'created_at' => :'Time', :'chargeback' => :'Boolean', :'refund_type' => :'String', :'platform_details' => :'PlatformDetails' } end |
Instance Method Details
#==(o) ⇒ Object
Checks equality by comparing each attribute.
371 372 373 374 375 376 377 378 379 380 381 382 383 384 |
# File 'lib/komoju-sdk/models/refund.rb', line 371 def ==(o) return true if self.equal?(o) self.class == o.class && id == o.id && resource == o.resource && amount == o.amount && currency == o.currency && payment == o.payment && description == o.description && created_at == o.created_at && chargeback == o.chargeback && refund_type == o.refund_type && platform_details == o.platform_details end |
#_to_hash(value) ⇒ Hash
Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value
502 503 504 505 506 507 508 509 510 511 512 513 514 |
# File 'lib/komoju-sdk/models/refund.rb', line 502 def _to_hash(value) if value.is_a?(Array) value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash value.to_hash else value end end |
#eql?(o) ⇒ Boolean
388 389 390 |
# File 'lib/komoju-sdk/models/refund.rb', line 388 def eql?(o) self == o end |
#hash ⇒ Integer
Calculates hash code according to all attributes.
394 395 396 |
# File 'lib/komoju-sdk/models/refund.rb', line 394 def hash [id, resource, amount, currency, payment, description, created_at, chargeback, refund_type, platform_details].hash end |
#list_invalid_properties ⇒ Object
Show invalid properties with the reasons. Usually used together with valid?
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 |
# File 'lib/komoju-sdk/models/refund.rb', line 189 def list_invalid_properties warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' invalid_properties = Array.new if @id.nil? invalid_properties.push('invalid value for "id", id cannot be nil.') end if @id.to_s.length > 25 invalid_properties.push('invalid value for "id", the character length must be smaller than or equal to 25.') end if @id.to_s.length < 25 invalid_properties.push('invalid value for "id", the character length must be greater than or equal to 25.') end if @resource.nil? invalid_properties.push('invalid value for "resource", resource cannot be nil.') end if @amount.nil? invalid_properties.push('invalid value for "amount", amount cannot be nil.') end if @amount < 0 invalid_properties.push('invalid value for "amount", must be greater than or equal to 0.') end if @currency.nil? invalid_properties.push('invalid value for "currency", currency cannot be nil.') end if @payment.nil? invalid_properties.push('invalid value for "payment", payment cannot be nil.') end if @payment.to_s.length > 25 invalid_properties.push('invalid value for "payment", the character length must be smaller than or equal to 25.') end if @payment.to_s.length < 25 invalid_properties.push('invalid value for "payment", the character length must be greater than or equal to 25.') end if @description.nil? invalid_properties.push('invalid value for "description", description cannot be nil.') end if @created_at.nil? invalid_properties.push('invalid value for "created_at", created_at cannot be nil.') end if @chargeback.nil? invalid_properties.push('invalid value for "chargeback", chargeback cannot be nil.') end invalid_properties end |
#to_body ⇒ Hash
to_body is an alias to to_hash (backward compatibility)
478 479 480 |
# File 'lib/komoju-sdk/models/refund.rb', line 478 def to_body to_hash end |
#to_hash ⇒ Hash
Returns the object in the form of hash
484 485 486 487 488 489 490 491 492 493 494 495 496 |
# File 'lib/komoju-sdk/models/refund.rb', line 484 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 |
#to_s ⇒ String
Returns the string representation of the object
472 473 474 |
# File 'lib/komoju-sdk/models/refund.rb', line 472 def to_s to_hash.to_s end |
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid
249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 |
# File 'lib/komoju-sdk/models/refund.rb', line 249 def valid? warn '[DEPRECATED] the `valid?` method is obsolete' return false if @id.nil? return false if @id.to_s.length > 25 return false if @id.to_s.length < 25 return false if @resource.nil? resource_validator = EnumAttributeValidator.new('String', ["refund"]) return false unless resource_validator.valid?(@resource) return false if @amount.nil? return false if @amount < 0 return false if @currency.nil? return false if @payment.nil? return false if @payment.to_s.length > 25 return false if @payment.to_s.length < 25 return false if @description.nil? return false if @created_at.nil? return false if @chargeback.nil? true end |