Class: Giftrocket::OrganizationMember

Inherits:
Object
  • Object
show all
Defined in:
lib/giftrocket/organization_member.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ OrganizationMember

Returns a new instance of OrganizationMember.



6
7
8
9
10
11
12
13
# File 'lib/giftrocket/organization_member.rb', line 6

def initialize(attributes)
  attributes = attributes.with_indifferent_access
  self.id = attributes[:id]
  self.name = attributes[:name]
  self.email = attributes[:email]
  self.role = attributes[:role]
  self.invite_url = attributes[:invite_url]
end

Instance Attribute Details

#emailObject

Returns the value of attribute email.



4
5
6
# File 'lib/giftrocket/organization_member.rb', line 4

def email
  @email
end

#idObject

Returns the value of attribute id.



4
5
6
# File 'lib/giftrocket/organization_member.rb', line 4

def id
  @id
end

#invite_urlObject

Returns the value of attribute invite_url.



4
5
6
# File 'lib/giftrocket/organization_member.rb', line 4

def invite_url
  @invite_url
end

#nameObject

Returns the value of attribute name.



4
5
6
# File 'lib/giftrocket/organization_member.rb', line 4

def name
  @name
end

#roleObject

Returns the value of attribute role.



4
5
6
# File 'lib/giftrocket/organization_member.rb', line 4

def role
  @role
end

Class Method Details

.create!(organization_id, data) ⇒ Object



19
20
21
22
23
24
25
26
27
# File 'lib/giftrocket/organization_member.rb', line 19

def self.create!(organization_id, data)
  response = Giftrocket::Request.post(
    to_path(organization_id),
    body: data.merge(Giftrocket.default_options).to_json,
    headers: { 'Content-Type' => 'application/json' }
  )

  Giftrocket::OrganizationMember.new(response[:member])
end

.list(organization_id) ⇒ Object



29
30
31
32
33
34
35
36
37
# File 'lib/giftrocket/organization_member.rb', line 29

def self.list(organization_id)
  Giftrocket::Request.get(
    to_path(organization_id),
    query: Giftrocket.default_options,
    format: 'json'
  )[:members].map do |member|
    Giftrocket::OrganizationMember.new(member)
  end
end

.to_path(organization_id) ⇒ Object



15
16
17
# File 'lib/giftrocket/organization_member.rb', line 15

def self.to_path(organization_id)
  "organizations/#{organization_id}/members"
end