Class: Dotloop::Client
- Inherits:
-
Object
- Object
- Dotloop::Client
- Includes:
- HTTParty
- Defined in:
- lib/dotloop/client.rb
Instance Attribute Summary collapse
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#application ⇒ Object
Returns the value of attribute application.
Class Method Summary collapse
Instance Method Summary collapse
- #Document ⇒ Object
- #DocumentActivity ⇒ Object
- #Employee ⇒ Object
- #Folder ⇒ Object
- #get(page, params = {}) ⇒ Object
- #handle_dotloop_error(response_code) ⇒ Object
-
#initialize(api_key:, application: 'dotloop') ⇒ Client
constructor
A new instance of Client.
- #Loop ⇒ Object
- #LoopActivity ⇒ Object
- #Participant ⇒ Object
- #Person ⇒ Object
- #Profile ⇒ Object
- #raw(page, params = {}) ⇒ Object
- #Task ⇒ Object
Constructor Details
#initialize(api_key:, application: 'dotloop') ⇒ 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_key ⇒ Object
Returns the value of attribute api_key.
7 8 9 |
# File 'lib/dotloop/client.rb', line 7 def api_key @api_key end |
#application ⇒ Object
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
79 80 81 82 83 84 85 |
# File 'lib/dotloop/client.rb', line 79 def self.snakify(hash) if hash.is_a? Array hash.map(&:to_snake_keys) else hash.to_snake_keys end end |
Instance Method Details
#Document ⇒ Object
47 48 49 |
# File 'lib/dotloop/client.rb', line 47 def Document @document ||= Dotloop::Document.new(client: self) end |
#DocumentActivity ⇒ Object
71 72 73 |
# File 'lib/dotloop/client.rb', line 71 def DocumentActivity @document_activity ||= Dotloop::DocumentActivity.new(client: self) end |
#Employee ⇒ Object
67 68 69 |
# File 'lib/dotloop/client.rb', line 67 def Employee @employee ||= Dotloop::Employee.new(client: self) end |
#Folder ⇒ Object
63 64 65 |
# File 'lib/dotloop/client.rb', line 63 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 |
#handle_dotloop_error(response_code) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/dotloop/client.rb', line 27 def handle_dotloop_error(response_code) error = case response_code when 401 Dotloop:: when 403 Dotloop::Forbidden else StandardError end raise error, "Error communicating: Response code #{response_code}" end |
#Loop ⇒ Object
43 44 45 |
# File 'lib/dotloop/client.rb', line 43 def Loop @loop ||= Dotloop::Loop.new(client: self) end |
#LoopActivity ⇒ Object
55 56 57 |
# File 'lib/dotloop/client.rb', line 55 def LoopActivity @loop_activity ||= Dotloop::LoopActivity.new(client: self) end |
#Participant ⇒ Object
51 52 53 |
# File 'lib/dotloop/client.rb', line 51 def Participant @participant ||= Dotloop::Participant.new(client: self) end |
#Person ⇒ Object
75 76 77 |
# File 'lib/dotloop/client.rb', line 75 def Person @person ||= Dotloop::Person.new(client: self) end |
#Profile ⇒ Object
39 40 41 |
# File 'lib/dotloop/client.rb', line 39 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) handle_dotloop_error(response.code) if response.code != 200 response.parsed_response end |
#Task ⇒ Object
59 60 61 |
# File 'lib/dotloop/client.rb', line 59 def Task @task ||= Dotloop::Task.new(client: self) end |