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.



8202
8203
8204
8205
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8202

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__.



8200
8201
8202
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8200

def __discriminator__
  @__discriminator__
end

Class Method Details

.from_json(hash) ⇒ Object



8215
8216
8217
8218
8219
8220
8221
8222
8223
8224
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8215

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



8207
8208
8209
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8207

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



8211
8212
8213
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 8211

def to_hash
  { @__discriminator__ => subtype_to_hash }
end