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
Returns a new instance of Client.
11 12 13 14 15 |
# File 'lib/dotloop/client.rb', line 11 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.
8 9 10 |
# File 'lib/dotloop/client.rb', line 8 def api_key @api_key end |
#application ⇒ Object
Returns the value of attribute application.
9 10 11 |
# File 'lib/dotloop/client.rb', line 9 def application @application end |
Class Method Details
.snakify(hash) ⇒ Object
80 81 82 83 84 85 86 |
# File 'lib/dotloop/client.rb', line 80 def self.snakify(hash) if hash.is_a? Array hash.map { |item| item.to_snake_keys.symbolize_keys } else hash.to_snake_keys.symbolize_keys end end |
Instance Method Details
#Document ⇒ Object
48 49 50 |
# File 'lib/dotloop/client.rb', line 48 def Document @document ||= Dotloop::Document.new(client: self) end |
#DocumentActivity ⇒ Object
72 73 74 |
# File 'lib/dotloop/client.rb', line 72 def DocumentActivity @document_activity ||= Dotloop::DocumentActivity.new(client: self) end |
#Employee ⇒ Object
68 69 70 |
# File 'lib/dotloop/client.rb', line 68 def Employee @employee ||= Dotloop::Employee.new(client: self) end |
#Folder ⇒ Object
64 65 66 |
# File 'lib/dotloop/client.rb', line 64 def Folder @folder ||= Dotloop::Folder.new(client: self) end |
#get(page, params = {}) ⇒ Object
17 18 19 20 |
# File 'lib/dotloop/client.rb', line 17 def get(page, params = {}) response = raw(page, params) self.class.snakify(response) end |
#handle_dotloop_error(response_code) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/dotloop/client.rb', line 28 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
44 45 46 |
# File 'lib/dotloop/client.rb', line 44 def Loop @loop ||= Dotloop::Loop.new(client: self) end |
#LoopActivity ⇒ Object
56 57 58 |
# File 'lib/dotloop/client.rb', line 56 def LoopActivity @loop_activity ||= Dotloop::LoopActivity.new(client: self) end |
#Participant ⇒ Object
52 53 54 |
# File 'lib/dotloop/client.rb', line 52 def Participant @participant ||= Dotloop::Participant.new(client: self) end |
#Person ⇒ Object
76 77 78 |
# File 'lib/dotloop/client.rb', line 76 def Person @person ||= Dotloop::Person.new(client: self) end |
#Profile ⇒ Object
40 41 42 |
# File 'lib/dotloop/client.rb', line 40 def Profile @profile ||= Dotloop::Profile.new(client: self) end |
#raw(page, params = {}) ⇒ Object
22 23 24 25 26 |
# File 'lib/dotloop/client.rb', line 22 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
60 61 62 |
# File 'lib/dotloop/client.rb', line 60 def Task @task ||= Dotloop::Task.new(client: self) end |