Class: Io::Flow::V0::Models::FlowRole

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

Overview

All roles available to attach to a user.

Defined Under Namespace

Modules: Types

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ FlowRole

Returns a new instance of FlowRole.



8330
8331
8332
8333
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8330

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  @__discriminator__ = opts[:__discriminator__] ||'flow_role'
end

Instance Attribute Details

#__discriminator__Object (readonly)

Returns the value of attribute __discriminator__.



8328
8329
8330
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8328

def __discriminator__
  @__discriminator__
end

Class Method Details

.from_json(hash) ⇒ Object



8343
8344
8345
8346
8347
8348
8349
8350
8351
8352
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8343

def FlowRole.from_json(hash)
  HttpClient::Preconditions.assert_class('hash', hash, Hash)
  hash.map do |union_type_name, data|
    case union_type_name
      when Types::FLOW_USER_ROLE; FlowUserRole.new(data)
      when Types::FLOW_ADDON_ROLE; FlowAddonRole.new(data)
      else FlowRoleUndefinedType.new(:__discriminator__ => union_type_name)
    end
  end.first
end

Instance Method Details

#subtype_to_hashObject



8335
8336
8337
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8335

def subtype_to_hash
  raise 'Cannot serialize an instance of flow_role directly - must use one of the specific types: flow_user_role, flow_addon_role'
end

#to_hashObject



8339
8340
8341
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8339

def to_hash
  { @__discriminator__ => subtype_to_hash }
end