Class: Dotloop::Client

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/dotloop/client.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_key:, application: 'dotloop') ⇒ Client

Returns a new instance of Client.



10
11
12
13
14
# File 'lib/dotloop/client.rb', line 10

def initialize(api_key:, application: 'dotloop')
  @api_key = api_key
  @application = application
  raise 'Please enter an API key' unless @api_key
end

Instance Attribute Details

#api_keyObject

Returns the value of attribute api_key.



7
8
9
# File 'lib/dotloop/client.rb', line 7

def api_key
  @api_key
end

#applicationObject

Returns the value of attribute application.



8
9
10
# File 'lib/dotloop/client.rb', line 8

def application
  @application
end

Class Method Details

.snakify(hash) ⇒ Object



67
68
69
70
71
72
73
# File 'lib/dotloop/client.rb', line 67

def self.snakify(hash)
  if hash.is_a? Array
    hash.map(&:to_snake_keys)
  else
    hash.to_snake_keys
  end
end

Instance Method Details

#DocumentObject



35
36
37
# File 'lib/dotloop/client.rb', line 35

def Document
  @document ||= Dotloop::Document.new(client: self)
end

#DocumentActivityObject



59
60
61
# File 'lib/dotloop/client.rb', line 59

def DocumentActivity
  @document_activity ||= Dotloop::DocumentActivity.new(client: self)
end

#EmployeeObject



55
56
57
# File 'lib/dotloop/client.rb', line 55

def Employee
  @employee ||= Dotloop::Employee.new(client: self)
end

#FolderObject



51
52
53
# File 'lib/dotloop/client.rb', line 51

def Folder
  @folder ||= Dotloop::Folder.new(client: self)
end

#get(page, params = {}) ⇒ Object



16
17
18
19
# File 'lib/dotloop/client.rb', line 16

def get(page, params = {})
  response = raw(page, params)
  self.class.snakify(response)
end

#LoopObject



31
32
33
# File 'lib/dotloop/client.rb', line 31

def Loop
  @loop ||= Dotloop::Loop.new(client: self)
end

#LoopActivityObject



43
44
45
# File 'lib/dotloop/client.rb', line 43

def LoopActivity
  @loop_activity ||= Dotloop::LoopActivity.new(client: self)
end

#ParticipantObject



39
40
41
# File 'lib/dotloop/client.rb', line 39

def Participant
  @participant ||= Dotloop::Participant.new(client: self)
end

#PersonObject



63
64
65
# File 'lib/dotloop/client.rb', line 63

def Person
  @person ||= Dotloop::Person.new(client: self)
end

#ProfileObject



27
28
29
# File 'lib/dotloop/client.rb', line 27

def Profile
  @profile ||= Dotloop::Profile.new(client: self)
end

#raw(page, params = {}) ⇒ Object



21
22
23
24
25
# File 'lib/dotloop/client.rb', line 21

def raw(page, params = {})
  response = self.class.get(page, query: params, headers: headers, timeout: 60)
  raise "Error communicating: Response code #{response.code}" unless response.code == 200
  response.parsed_response
end

#TaskObject



47
48
49
# File 'lib/dotloop/client.rb', line 47

def Task
  @task ||= Dotloop::Task.new(client: self)
end