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.



46224
46225
46226
46227
46228
46229
46230
46231
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 46224

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.apply(x)) }
end

Instance Attribute Details

#organizationObject (readonly)

Returns the value of attribute organization.



46222
46223
46224
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 46222

def organization
  @organization
end

#roleObject (readonly)

Returns the value of attribute role.



46222
46223
46224
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 46222

def role
  @role
end

#rolesObject (readonly)

Returns the value of attribute roles.



46222
46223
46224
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 46222

def roles
  @roles
end

#userObject (readonly)

Returns the value of attribute user.



46222
46223
46224
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 46222

def user
  @user
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



46237
46238
46239
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 46237

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

#to_hashObject



46241
46242
46243
46244
46245
46246
46247
46248
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 46241

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

#to_jsonObject



46233
46234
46235
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 46233

def to_json
  JSON.dump(to_hash)
end