class Yapstone::CardDataResource
Payment card details.
Attributes
Issuing authority
Name on the card
The card number.
The token to get the card details from vault.
Type of the card ( DEBIT, CREDIT)
Currency.
CVV number.
Public Class Methods
Attribute mapping from ruby-style variable name to JSON key.
# File lib/yapstone-so/models/card_data_resource.rb, line 68 def self.attribute_map { :'card_type' => :'cardType', :'brand' => :'brand', :'card_token_source' => :'cardTokenSource', :'expiration_date' => :'expirationDate', :'billing_address' => :'billingAddress', :'card_holder_name' => :'cardHolderName', :'card_token_data' => :'cardTokenData', :'card_number' => :'cardNumber', :'cvv' => :'cvv', :'currency' => :'currency' } end
Builds the object from hash @param [Hash] attributes Model attributes in the form of hash @return [Object] Returns the model itself
# File lib/yapstone-so/models/card_data_resource.rb, line 275 def self.build_from_hash(attributes) new.build_from_hash(attributes) end
Initializes the object @param [Hash] attributes Model attributes in the form of hash
# File lib/yapstone-so/models/card_data_resource.rb, line 101 def initialize(attributes = {}) if (!attributes.is_a?(Hash)) fail ArgumentError, "The input argument (attributes) must be a hash in `Yapstone::CardDataResource` initialize method" end # check to see if the attribute exists and convert string to symbol for hash key attributes = attributes.each_with_object({}) { |(k, v), h| if (!self.class.attribute_map.key?(k.to_sym)) fail ArgumentError, "`#{k}` is not a valid attribute in `Yapstone::CardDataResource`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect end h[k.to_sym] = v } if attributes.key?(:'card_type') self.card_type = attributes[:'card_type'] end if attributes.key?(:'brand') self.brand = attributes[:'brand'] end if attributes.key?(:'card_token_source') self.card_token_source = attributes[:'card_token_source'] end if attributes.key?(:'expiration_date') self.expiration_date = attributes[:'expiration_date'] end if attributes.key?(:'billing_address') self.billing_address = attributes[:'billing_address'] end if attributes.key?(:'card_holder_name') self.card_holder_name = attributes[:'card_holder_name'] end if attributes.key?(:'card_token_data') self.card_token_data = attributes[:'card_token_data'] end if attributes.key?(:'card_number') self.card_number = attributes[:'card_number'] end if attributes.key?(:'cvv') self.cvv = attributes[:'cvv'] end if attributes.key?(:'currency') self.currency = attributes[:'currency'] end end
Attribute type mapping.
# File lib/yapstone-so/models/card_data_resource.rb, line 84 def self.openapi_types { :'card_type' => :'String', :'brand' => :'String', :'card_token_source' => :'String', :'expiration_date' => :'ExpirationDateResource', :'billing_address' => :'AddressResource', :'card_holder_name' => :'String', :'card_token_data' => :'String', :'card_number' => :'String', :'cvv' => :'String', :'currency' => :'String' } end
Public Instance Methods
Checks equality by comparing each attribute. @param [Object] Object to be compared
# File lib/yapstone-so/models/card_data_resource.rb, line 245 def ==(o) return true if self.equal?(o) self.class == o.class && card_type == o.card_type && brand == o.brand && card_token_source == o.card_token_source && expiration_date == o.expiration_date && billing_address == o.billing_address && card_holder_name == o.card_holder_name && card_token_data == o.card_token_data && card_number == o.card_number && cvv == o.cvv && currency == o.currency end
Deserializes the data based on type @param string type Data type @param string value Value to be deserialized @return [Object] Deserialized data
# File lib/yapstone-so/models/card_data_resource.rb, line 303 def _deserialize(type, value) case type.to_sym when :DateTime DateTime.parse(value) when :Date Date.parse(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 Yapstone.const_get(type).build_from_hash(value) end end
Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value @param [Object] value Any valid value @return [Hash] Returns the value in the form of hash
# File lib/yapstone-so/models/card_data_resource.rb, line 368 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
Custom attribute writer method checking allowed values (enum). @param [Object] brand Object to be assigned
# File lib/yapstone-so/models/card_data_resource.rb, line 201 def brand=(brand) validator = EnumAttributeValidator.new('String', ["VISA", "MASTERCARD", "AMEX", "DISCOVER"]) unless validator.valid?(brand) fail ArgumentError, "invalid value for \"brand\", must be one of #{validator.allowable_values}." end @brand = brand end
Builds the object from hash @param [Hash] attributes Model attributes in the form of hash @return [Object] Returns the model itself
# File lib/yapstone-so/models/card_data_resource.rb, line 282 def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) self.class.openapi_types.each_pair do |key, type| if 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[self.class.attribute_map[key]].is_a?(Array) self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) end elsif !attributes[self.class.attribute_map[key]].nil? self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) end # or else data not found in attributes(hash), not an issue as the data can be optional end self end
Custom attribute writer method with validation @param [Object] card_number
Value to be assigned
# File lib/yapstone-so/models/card_data_resource.rb, line 221 def card_number=(card_number) if !card_number.nil? && card_number.to_s.length < 12 fail ArgumentError, 'invalid value for "card_number", the character length must be great than or equal to 12.' end @card_number = card_number end
Custom attribute writer method checking allowed values (enum). @param [Object] card_token_source
Object to be assigned
# File lib/yapstone-so/models/card_data_resource.rb, line 211 def card_token_source=(card_token_source) validator = EnumAttributeValidator.new('String', ["APPLE", "ANDROID", "SAMSUNG"]) unless validator.valid?(card_token_source) fail ArgumentError, "invalid value for \"card_token_source\", must be one of #{validator.allowable_values}." end @card_token_source = card_token_source end
Custom attribute writer method checking allowed values (enum). @param [Object] card_type
Object to be assigned
# File lib/yapstone-so/models/card_data_resource.rb, line 191 def card_type=(card_type) validator = EnumAttributeValidator.new('String', ["DEBIT", "CREDIT"]) unless validator.valid?(card_type) fail ArgumentError, "invalid value for \"card_type\", must be one of #{validator.allowable_values}." end @card_type = card_type end
Custom attribute writer method with validation @param [Object] cvv Value to be assigned
# File lib/yapstone-so/models/card_data_resource.rb, line 231 def cvv=(cvv) if !cvv.nil? && cvv.to_s.length > 4 fail ArgumentError, 'invalid value for "cvv", the character length must be smaller than or equal to 4.' end if !cvv.nil? && cvv.to_s.length < 3 fail ArgumentError, 'invalid value for "cvv", the character length must be great than or equal to 3.' end @cvv = cvv end
@see the `==` method @param [Object] Object to be compared
# File lib/yapstone-so/models/card_data_resource.rb, line 262 def eql?(o) self == o end
Calculates hash code according to all attributes. @return [Integer] Hash code
# File lib/yapstone-so/models/card_data_resource.rb, line 268 def hash [card_type, brand, card_token_source, expiration_date, billing_address, card_holder_name, card_token_data, card_number, cvv, currency].hash end
Show invalid properties with the reasons. Usually used together with valid? @return Array for valid properties with the reasons
# File lib/yapstone-so/models/card_data_resource.rb, line 157 def list_invalid_properties invalid_properties = Array.new if !@card_number.nil? && @card_number.to_s.length < 12 invalid_properties.push('invalid value for "card_number", the character length must be great than or equal to 12.') end if !@cvv.nil? && @cvv.to_s.length > 4 invalid_properties.push('invalid value for "cvv", the character length must be smaller than or equal to 4.') end if !@cvv.nil? && @cvv.to_s.length < 3 invalid_properties.push('invalid value for "cvv", the character length must be great than or equal to 3.') end invalid_properties end
Returns the object in the form of hash @return [Hash] Returns the object in the form of hash
# File lib/yapstone-so/models/card_data_resource.rb, line 354 def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) next if value.nil? hash[param] = _to_hash(value) end hash end
Returns the string representation of the object @return [String] String presentation of the object
# File lib/yapstone-so/models/card_data_resource.rb, line 342 def to_s to_hash.to_s end
Check to see if the all the properties in the model are valid @return true if the model is valid
# File lib/yapstone-so/models/card_data_resource.rb, line 176 def valid? card_type_validator = EnumAttributeValidator.new('String', ["DEBIT", "CREDIT"]) return false unless card_type_validator.valid?(@card_type) brand_validator = EnumAttributeValidator.new('String', ["VISA", "MASTERCARD", "AMEX", "DISCOVER"]) return false unless brand_validator.valid?(@brand) card_token_source_validator = EnumAttributeValidator.new('String', ["APPLE", "ANDROID", "SAMSUNG"]) return false unless card_token_source_validator.valid?(@card_token_source) return false if !@card_number.nil? && @card_number.to_s.length < 12 return false if !@cvv.nil? && @cvv.to_s.length > 4 return false if !@cvv.nil? && @cvv.to_s.length < 3 true end