Class: Io::Flow::V0::Models::CardNumber
- Inherits:
-
Object
- Object
- Io::Flow::V0::Models::CardNumber
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Direct Known Subclasses
CardNumberUndefinedType, PaymentMethodCardNumberCipher, PaymentMethodCardNumberCleartext
Defined Under Namespace
Modules: Types
Instance Attribute Summary collapse
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(incoming = {}) ⇒ CardNumber
constructor
A new instance of CardNumber.
- #subtype_to_hash ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(incoming = {}) ⇒ CardNumber
Returns a new instance of CardNumber.
9292 9293 9294 9295 9296 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9292 def initialize(incoming={}) opts = HttpClient::Helper.symbolize_keys(incoming) HttpClient::Preconditions.require_keys(opts, [:type], 'CardNumber') @type = HttpClient::Preconditions.assert_class('type', opts.delete(:type), String) end |
Instance Attribute Details
#type ⇒ Object (readonly)
Returns the value of attribute type.
9290 9291 9292 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9290 def type @type end |
Class Method Details
.from_json(hash) ⇒ Object
9306 9307 9308 9309 9310 9311 9312 9313 9314 9315 9316 9317 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9306 def CardNumber.from_json(hash) HttpClient::Preconditions.assert_class('hash', hash, Hash) discriminator = HttpClient::Helper.symbolize_keys(hash)[:type].to_s.strip if discriminator.empty? raise "Union type[card_number] requires a field named 'type'" end case discriminator when Types::PAYMENT_METHOD_CARD_NUMBER_CLEARTEXT; PaymentMethodCardNumberCleartext.new(hash) when Types::PAYMENT_METHOD_CARD_NUMBER_CIPHER; PaymentMethodCardNumberCipher.new(hash) else CardNumberUndefinedType.new(:type => discriminator) end end |
Instance Method Details
#subtype_to_hash ⇒ Object
9298 9299 9300 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9298 def subtype_to_hash raise 'Cannot serialize an instance of card_number directly - must use one of the specific types: payment_method_card_number_cleartext, payment_method_card_number_cipher' end |
#to_hash ⇒ Object
9302 9303 9304 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9302 def to_hash subtype_to_hash.merge(:type => @type) end |