Class: Io::Flow::V0::Models::TokenForm

Inherits:
Object
  • Object
show all
Defined in:
lib/flow_commerce/flow_api_v0_client.rb

Defined Under Namespace

Modules: Types

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ TokenForm

Returns a new instance of TokenForm.



4864
4865
4866
4867
4868
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4864

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:name], 'TokenForm')
  @name = HttpClient::Preconditions.assert_class('name', opts.delete(:name), String)
end

Class Method Details

.from_json(hash) ⇒ Object



4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4878

def TokenForm.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[token_form] requires a field named 'discriminator'"
  end
  case discriminator
    when Types::ORGANIZATION_TOKEN_FORM; OrganizationTokenForm.new(hash)
    when Types::PARTNER_TOKEN_FORM; PartnerTokenForm.new(hash)
    else TokenFormUndefinedType.new(:name => discriminator)
  end
end

Instance Method Details

#subtype_to_hashObject



4870
4871
4872
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4870

def subtype_to_hash
  raise 'Cannot serialize an instance of token_form directly - must use one of the specific types: organization_token_form, partner_token_form'
end

#to_hashObject



4874
4875
4876
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 4874

def to_hash
  subtype_to_hash.merge(:discriminator => @name)
end