class CityPayApiClient::Card
Attributes
Defines whether the card is a commercial card.
Defines whether the card is a corporate business card.
The determined country where the card was issued.
Defines whether the card is a credit card.
The default currency determined for the card.
Defines whether the card is a debit card.
A description of the bin on the card to identify what type of product the card is.
Defines whether the card is regulated within the EU.
The id of the card that is returned. Should be used for referencing the card when perform any changes.
The status of the card such, valid values are - ACTIVE the card is active for processing - INACTIVE the card is not active for processing - EXPIRED for cards that have passed their expiry date.
Determines if the card is the default card for the account and should be regarded as the first option to be used for processing.
The expiry month of the card.
The expiry year of the card.
A label which identifies this card.
A label which also provides the expiry date of the card.
The last 4 digits of the card to aid in identification.
The scheme that issued the card.
A token that can be used to process against the card.
Public Class Methods
Attribute mapping from ruby-style variable name to JSON key.
# File lib/citypay_api_client/models/card.rb, line 71 def self.attribute_map { :'bin_commercial' => :'bin_commercial', :'bin_corporate' => :'bin_corporate', :'bin_country_issued' => :'bin_country_issued', :'bin_credit' => :'bin_credit', :'bin_currency' => :'bin_currency', :'bin_debit' => :'bin_debit', :'bin_description' => :'bin_description', :'bin_eu' => :'bin_eu', :'card_id' => :'card_id', :'card_status' => :'card_status', :'default' => :'default', :'expmonth' => :'expmonth', :'expyear' => :'expyear', :'label' => :'label', :'label2' => :'label2', :'last4digits' => :'last4digits', :'scheme' => :'scheme', :'token' => :'token' } end
Builds the object from hash @param [Hash] attributes Model attributes in the form of hash @return [Object] Returns the model itself
# File lib/citypay_api_client/models/card.rb, line 313 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/citypay_api_client/models/card.rb, line 126 def initialize(attributes = {}) if (!attributes.is_a?(Hash)) fail ArgumentError, "The input argument (attributes) must be a hash in `CityPayApiClient::Card` 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 `CityPayApiClient::Card`. 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?(:'bin_commercial') self.bin_commercial = attributes[:'bin_commercial'] end if attributes.key?(:'bin_corporate') self.bin_corporate = attributes[:'bin_corporate'] end if attributes.key?(:'bin_country_issued') self.bin_country_issued = attributes[:'bin_country_issued'] end if attributes.key?(:'bin_credit') self.bin_credit = attributes[:'bin_credit'] end if attributes.key?(:'bin_currency') self.bin_currency = attributes[:'bin_currency'] end if attributes.key?(:'bin_debit') self.bin_debit = attributes[:'bin_debit'] end if attributes.key?(:'bin_description') self.bin_description = attributes[:'bin_description'] end if attributes.key?(:'bin_eu') self.bin_eu = attributes[:'bin_eu'] end if attributes.key?(:'card_id') self.card_id = attributes[:'card_id'] end if attributes.key?(:'card_status') self.card_status = attributes[:'card_status'] end if attributes.key?(:'default') self.default = attributes[:'default'] end if attributes.key?(:'expmonth') self.expmonth = attributes[:'expmonth'] end if attributes.key?(:'expyear') self.expyear = attributes[:'expyear'] end if attributes.key?(:'label') self.label = attributes[:'label'] end if attributes.key?(:'label2') self.label2 = attributes[:'label2'] end if attributes.key?(:'last4digits') self.last4digits = attributes[:'last4digits'] end if attributes.key?(:'scheme') self.scheme = attributes[:'scheme'] end if attributes.key?(:'token') self.token = attributes[:'token'] end end
List of attributes with nullable: true
# File lib/citypay_api_client/models/card.rb, line 119 def self.openapi_nullable Set.new([ ]) end
Attribute type mapping.
# File lib/citypay_api_client/models/card.rb, line 95 def self.openapi_types { :'bin_commercial' => :'Boolean', :'bin_corporate' => :'Boolean', :'bin_country_issued' => :'String', :'bin_credit' => :'Boolean', :'bin_currency' => :'String', :'bin_debit' => :'Boolean', :'bin_description' => :'String', :'bin_eu' => :'Boolean', :'card_id' => :'String', :'card_status' => :'String', :'default' => :'Boolean', :'expmonth' => :'Integer', :'expyear' => :'Integer', :'label' => :'String', :'label2' => :'String', :'last4digits' => :'String', :'scheme' => :'String', :'token' => :'String' } end
Public Instance Methods
Checks equality by comparing each attribute. @param [Object] Object to be compared
# File lib/citypay_api_client/models/card.rb, line 275 def ==(o) return true if self.equal?(o) self.class == o.class && bin_commercial == o.bin_commercial && bin_corporate == o.bin_corporate && bin_country_issued == o.bin_country_issued && bin_credit == o.bin_credit && bin_currency == o.bin_currency && bin_debit == o.bin_debit && bin_description == o.bin_description && bin_eu == o.bin_eu && card_id == o.card_id && card_status == o.card_status && default == o.default && expmonth == o.expmonth && expyear == o.expyear && label == o.label && label2 == o.label2 && last4digits == o.last4digits && scheme == o.scheme && token == o.token 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/citypay_api_client/models/card.rb, line 341 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 CityPayApiClient.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/citypay_api_client/models/card.rb, line 410 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
Builds the object from hash @param [Hash] attributes Model attributes in the form of hash @return [Object] Returns the model itself
# File lib/citypay_api_client/models/card.rb, line 320 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
@see the `==` method @param [Object] Object to be compared
# File lib/citypay_api_client/models/card.rb, line 300 def eql?(o) self == o end
Custom attribute writer method with validation @param [Object] expmonth Value to be assigned
# File lib/citypay_api_client/models/card.rb, line 247 def expmonth=(expmonth) if !expmonth.nil? && expmonth > 12 fail ArgumentError, 'invalid value for "expmonth", must be smaller than or equal to 12.' end if !expmonth.nil? && expmonth < 1 fail ArgumentError, 'invalid value for "expmonth", must be greater than or equal to 1.' end @expmonth = expmonth end
Custom attribute writer method with validation @param [Object] expyear Value to be assigned
# File lib/citypay_api_client/models/card.rb, line 261 def expyear=(expyear) if !expyear.nil? && expyear > 2100 fail ArgumentError, 'invalid value for "expyear", must be smaller than or equal to 2100.' end if !expyear.nil? && expyear < 2000 fail ArgumentError, 'invalid value for "expyear", must be greater than or equal to 2000.' end @expyear = expyear end
Calculates hash code according to all attributes. @return [Integer] Hash code
# File lib/citypay_api_client/models/card.rb, line 306 def hash [bin_commercial, bin_corporate, bin_country_issued, bin_credit, bin_currency, bin_debit, bin_description, bin_eu, card_id, card_status, default, expmonth, expyear, label, label2, last4digits, scheme, token].hash end
Show invalid properties with the reasons. Usually used together with valid? @return Array for valid properties with the reasons
# File lib/citypay_api_client/models/card.rb, line 214 def list_invalid_properties invalid_properties = Array.new if !@expmonth.nil? && @expmonth > 12 invalid_properties.push('invalid value for "expmonth", must be smaller than or equal to 12.') end if !@expmonth.nil? && @expmonth < 1 invalid_properties.push('invalid value for "expmonth", must be greater than or equal to 1.') end if !@expyear.nil? && @expyear > 2100 invalid_properties.push('invalid value for "expyear", must be smaller than or equal to 2100.') end if !@expyear.nil? && @expyear < 2000 invalid_properties.push('invalid value for "expyear", must be greater than or equal to 2000.') end invalid_properties end
Returns the object in the form of hash @return [Hash] Returns the object in the form of hash
# File lib/citypay_api_client/models/card.rb, line 392 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
Returns the string representation of the object @return [String] String presentation of the object
# File lib/citypay_api_client/models/card.rb, line 380 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/citypay_api_client/models/card.rb, line 237 def valid? return false if !@expmonth.nil? && @expmonth > 12 return false if !@expmonth.nil? && @expmonth < 1 return false if !@expyear.nil? && @expyear > 2100 return false if !@expyear.nil? && @expyear < 2000 true end