Class: Giftrocket::Organization

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ Organization

Returns a new instance of Organization.



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

def initialize(attributes)
  attributes = attributes.with_indifferent_access
  self.id = attributes[:id]
  self.name = attributes[:name]
  self.website = attributes[:website]
  self.phone = attributes[:phone]
  self.config = attributes[:config]
  self.created_at = attributes[:created_at]
end

Instance Attribute Details

#configObject

Returns the value of attribute config.



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

def config
  @config
end

#created_atObject

Returns the value of attribute created_at.



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

def created_at
  @created_at
end

#idObject

Returns the value of attribute id.



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

def id
  @id
end

#nameObject

Returns the value of attribute name.



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

def name
  @name
end

#phoneObject

Returns the value of attribute phone.



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

def phone
  @phone
end

#websiteObject

Returns the value of attribute website.



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

def website
  @website
end

Class Method Details

.create!(data) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/giftrocket/organization.rb', line 16

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

  Giftrocket::Organization.new(response[:organization])
end

.listObject



26
27
28
29
30
31
32
33
34
# File 'lib/giftrocket/organization.rb', line 26

def self.list
  Giftrocket::Request.get(
    'organizations',
    query: Giftrocket.default_options,
    format: 'json'
  )[:organizations].map do |org|
    Giftrocket::Organization.new(org)
  end
end