Class: RelateIQ::Account

Inherits:
Resource show all
Defined in:
lib/relate_iq/account.rb

Class Method Summary collapse

Methods inherited from Resource

#initialize, #inspect, #method_missing

Constructor Details

This class inherits a constructor from RelateIQ::Resource

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class RelateIQ::Resource

Class Method Details

.allObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/relate_iq/account.rb', line 7

def self.all
  page_size = 20
  start = 0
  accounts = []
 
  loop do 
    page_results = RelateIQ.get('accounts', '_start' => start, '_limit' => page_size)['objects']
    break if page_results.empty?
    
    accounts.concat(page_results.map {|a| self.new(a) })
    start += page_size
    sleep 0.5
  end

  accounts
end

.create(attributes) ⇒ Object



3
4
5
# File 'lib/relate_iq/account.rb', line 3

def self.create(attributes)
  self.new(RelateIQ.post('accounts', attributes))
end