Class: Io::Flow::V0::Models::HintForm
- Inherits:
-
Object
- Object
- Io::Flow::V0::Models::HintForm
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Overview
Describes types of forms that can be used to assign an HS code based on product data.
Direct Known Subclasses
Defined Under Namespace
Modules: Types
Instance Attribute Summary collapse
-
#discriminator ⇒ Object
readonly
Returns the value of attribute discriminator.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(incoming = {}) ⇒ HintForm
constructor
A new instance of HintForm.
- #subtype_to_hash ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(incoming = {}) ⇒ HintForm
Returns a new instance of HintForm.
8115 8116 8117 8118 8119 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8115 def initialize(incoming={}) opts = HttpClient::Helper.symbolize_keys(incoming) HttpClient::Preconditions.require_keys(opts, [:discriminator], 'HintForm') @discriminator = HttpClient::Preconditions.assert_class('discriminator', opts.delete(:discriminator), String) end |
Instance Attribute Details
#discriminator ⇒ Object (readonly)
Returns the value of attribute discriminator.
8113 8114 8115 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8113 def discriminator @discriminator end |
Class Method Details
.from_json(hash) ⇒ Object
8129 8130 8131 8132 8133 8134 8135 8136 8137 8138 8139 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8129 def HintForm.from_json(hash) HttpClient::Preconditions.assert_class('hash', hash, Hash) discriminator = HttpClient::Helper.symbolize_keys(hash)[:discriminator].to_s.strip if discriminator.empty? raise "Union type[hint_form] requires a field named 'discriminator'" end case discriminator when Types::PHRASE_HINT_FORM; PhraseHintForm.new(hash) else HintFormUndefinedType.new(:discriminator => discriminator) end end |
Instance Method Details
#subtype_to_hash ⇒ Object
8121 8122 8123 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8121 def subtype_to_hash raise 'Cannot serialize an instance of hint_form directly - must use one of the specific types: phrase_hint_form' end |
#to_hash ⇒ Object
8125 8126 8127 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8125 def to_hash subtype_to_hash.merge(:discriminator => @discriminator) end |