Class: MoreappAPI::Customer

Inherits:
Object
  • Object
show all
Defined in:
lib/moreapp_api/customer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(moreapp_api, data) ⇒ Customer

Returns a new instance of Customer.



8
9
10
11
12
13
14
# File 'lib/moreapp_api/customer.rb', line 8

def initialize(moreapp_api, data)
  @moreapp_api = moreapp_api
  @id = data["customerId"]
  @name = data["name"]

  @raw_data = data
end

Instance Attribute Details

#idObject

Returns the value of attribute id.



6
7
8
# File 'lib/moreapp_api/customer.rb', line 6

def id
  @id
end

#moreapp_apiObject

Returns the value of attribute moreapp_api.



6
7
8
# File 'lib/moreapp_api/customer.rb', line 6

def moreapp_api
  @moreapp_api
end

#nameObject

Returns the value of attribute name.



6
7
8
# File 'lib/moreapp_api/customer.rb', line 6

def name
  @name
end

#raw_dataObject

Returns the value of attribute raw_data.



6
7
8
# File 'lib/moreapp_api/customer.rb', line 6

def raw_data
  @raw_data
end

Instance Method Details

#foldersObject



16
17
18
19
20
21
# File 'lib/moreapp_api/customer.rb', line 16

def folders
  response = @moreapp_api.request(:get, "/api/v1.0/customers/#{self.id}/folders")

  folders = JSON.parse(response.body)
  folders.map{|data| MoreappAPI::Folder.new(self, data)}
end