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



20110
20111
20112
20113
20114
20115
20116
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20110

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))
end

Instance Attribute Details

#organizationObject (readonly)

Returns the value of attribute organization.



20108
20109
20110
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20108

def organization
  @organization
end

#roleObject (readonly)

Returns the value of attribute role.



20108
20109
20110
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20108

def role
  @role
end

#userObject (readonly)

Returns the value of attribute user.



20108
20109
20110
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20108

def user
  @user
end

Instance Method Details

#copy(incoming = {}) ⇒ Object



20122
20123
20124
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20122

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

#to_hashObject



20126
20127
20128
20129
20130
20131
20132
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20126

def to_hash
  {
    :organization => organization,
    :user => user,
    :role => role.value
  }
end

#to_jsonObject



20118
20119
20120
# File 'lib/flow_commerce/flow_api_v0_client.rb', line 20118

def to_json
  JSON.dump(to_hash)
end