Class: Io::Flow::V0::Models::MembershipForm

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

Overview

Top level resource to create a membership.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(incoming = {}) ⇒ MembershipForm

Returns a new instance of MembershipForm.



34335
34336
34337
34338
34339
34340
34341
34342
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34335

def initialize(incoming={})
  opts = HttpClient::Helper.symbolize_keys(incoming)
  HttpClient::Preconditions.require_keys(opts, [:organization, :user], 'MembershipForm')
  @organization = HttpClient::Preconditions.assert_class('organization', opts.delete(:organization), String)
  @user = HttpClient::Preconditions.assert_class('user', opts.delete(:user), String)
  @role = (x = (x = opts.delete(:role); x.nil? ? "member" : x); x.is_a?(::Io::Flow::V0::Models::Role) ? x : ::Io::Flow::V0::Models::Role.apply(x))
  @roles = HttpClient::Preconditions.assert_class('roles', (x = opts.delete(:roles); x.nil? ? [] : x), Array).map { |v| (x = v; x.is_a?(::Io::Flow::V0::Models::FlowRole) ? x : ::Io::Flow::V0::Models::FlowRole.from_json(x)) }
end

Instance Attribute Details

#organizationObject (readonly)

Returns the value of attribute organization.



34333
34334
34335
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34333

def organization
  @organization
end

#roleObject (readonly)

Returns the value of attribute role.



34333
34334
34335
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34333

def role
  @role
end

#rolesObject (readonly)

Returns the value of attribute roles.



34333
34334
34335
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34333

def roles
  @roles
end

#userObject (readonly)

Returns the value of attribute user.



34333
34334
34335
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34333

def user
  @user
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



34348
34349
34350
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34348

def copy(incoming={})
  MembershipForm.new(to_hash.merge(HttpClient::Helper.symbolize_keys(incoming)))
end

#to_hashObject



34352
34353
34354
34355
34356
34357
34358
34359
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34352

def to_hash
  {
    :organization => organization,
    :user => user,
    :role => role.value,
    :roles => roles.map { |o| o.to_hash }
  }
end

#to_jsonObject



34344
34345
34346
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 34344

def to_json
  JSON.dump(to_hash)
end