Class: Io::Flow::V0::Models::FlowRole
- Inherits:
-
Object
- Object
- Io::Flow::V0::Models::FlowRole
- Defined in:
- lib/flow_commerce/flow_api_v0_client.rb
Overview
All roles available to attach to a user.
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 = {}) ⇒ FlowRole
constructor
A new instance of FlowRole.
- #subtype_to_hash ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(incoming = {}) ⇒ FlowRole
Returns a new instance of FlowRole.
9528 9529 9530 9531 9532 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9528 def initialize(incoming={}) opts = HttpClient::Helper.symbolize_keys(incoming) HttpClient::Preconditions.require_keys(opts, [:discriminator], 'FlowRole') @discriminator = HttpClient::Preconditions.assert_class('discriminator', opts.delete(:discriminator), String) end |
Instance Attribute Details
#discriminator ⇒ Object (readonly)
Returns the value of attribute discriminator.
9526 9527 9528 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9526 def discriminator @discriminator end |
Class Method Details
.from_json(hash) ⇒ Object
9542 9543 9544 9545 9546 9547 9548 9549 9550 9551 9552 9553 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9542 def FlowRole.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[flow_role] requires a field named 'discriminator'" end case discriminator when Types::FLOW_USER_ROLE; FlowUserRole.new(hash) when Types::FLOW_ADDON_ROLE; FlowAddonRole.new(hash) else FlowRoleUndefinedType.new(:discriminator => discriminator) end end |
Instance Method Details
#subtype_to_hash ⇒ Object
9534 9535 9536 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9534 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_hash ⇒ Object
9538 9539 9540 |
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 9538 def to_hash subtype_to_hash.merge(:discriminator => @discriminator) end |