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.
6318 6319 6320 6321 6322 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6318 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.
6316 6317 6318 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6316 def discriminator @discriminator end |
Class Method Details
.from_json(hash) ⇒ Object
6332 6333 6334 6335 6336 6337 6338 6339 6340 6341 6342 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6332 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
6324 6325 6326 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6324 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
6328 6329 6330 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 6328 def to_hash subtype_to_hash.merge(:discriminator => @discriminator) end |