Class: DocusignDtr::Client

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(token:, test_mode: true, application: 'docusign_dtr') ⇒ Client

Returns a new instance of Client.



6
7
8
9
10
11
# File 'lib/docusign_dtr/client.rb', line 6

def initialize(token:, test_mode: true, application: 'docusign_dtr')
  @test_mode = test_mode
  @token = token
  @application = application
  raise 'Missing Token' unless token
end

Instance Attribute Details

#tokenObject

Returns the value of attribute token.



4
5
6
# File 'lib/docusign_dtr/client.rb', line 4

def token
  @token
end

Instance Method Details

#base_uriObject



65
66
67
# File 'lib/docusign_dtr/client.rb', line 65

def base_uri
  @base_uri ||= @test_mode ? 'https://stage.cartavi.com/restapi/v1' : 'https://cartavi.com/restapi/v1'
end

#DocumentObject

rubocop:disable Naming/MethodName



33
34
35
# File 'lib/docusign_dtr/client.rb', line 33

def Document # rubocop:disable  Naming/MethodName
  @document ||= DocusignDtr::Document.new(client: self) # rubocop:disable Naming/MemoizedInstanceVariableName
end

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



13
14
15
16
# File 'lib/docusign_dtr/client.rb', line 13

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

#handle_error(response_code) ⇒ Object

Raises:

  • (error_type(response_code))


25
26
27
# File 'lib/docusign_dtr/client.rb', line 25

def handle_error(response_code)
  raise error_type(response_code), "Error communicating: Response code #{response_code}"
end

#MemberObject

rubocop:disable Naming/MethodName



37
38
39
# File 'lib/docusign_dtr/client.rb', line 37

def Member # rubocop:disable  Naming/MethodName
  @member ||= DocusignDtr::Member.new(client: self) # rubocop:disable Naming/MemoizedInstanceVariableName
end

#MetaObject

rubocop:disable Naming/MethodName



41
42
43
# File 'lib/docusign_dtr/client.rb', line 41

def Meta # rubocop:disable  Naming/MethodName
  @meta ||= DocusignDtr::Meta.new(client: self) # rubocop:disable Naming/MemoizedInstanceVariableName
end

#OfficeObject

rubocop:disable Naming/MethodName



29
30
31
# File 'lib/docusign_dtr/client.rb', line 29

def Office # rubocop:disable  Naming/MethodName
  @office ||= DocusignDtr::Office.new(client: self) # rubocop:disable Naming/MemoizedInstanceVariableName
end

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



18
19
20
21
22
23
# File 'lib/docusign_dtr/client.rb', line 18

def raw(page, params = {})
  full_path = [base_uri, page].join
  response = self.class.get(full_path, query: params, headers: headers, timeout: 60)
  handle_error(response.code) if response.code != 200
  response.parsed_response
end

#RoomObject

rubocop:disable Naming/MethodName



45
46
47
# File 'lib/docusign_dtr/client.rb', line 45

def Room # rubocop:disable  Naming/MethodName
  @room ||= DocusignDtr::Room.new(client: self) # rubocop:disable Naming/MemoizedInstanceVariableName
end

#TaskObject

rubocop:disable Naming/MethodName



49
50
51
# File 'lib/docusign_dtr/client.rb', line 49

def Task # rubocop:disable  Naming/MethodName
  @task ||= DocusignDtr::Task.new(client: self) # rubocop:disable Naming/MemoizedInstanceVariableName
end

#TaskListObject

rubocop:disable Naming/MethodName



53
54
55
# File 'lib/docusign_dtr/client.rb', line 53

def TaskList # rubocop:disable  Naming/MethodName
  @task_list ||= DocusignDtr::TaskList.new(client: self) # rubocop:disable Naming/MemoizedInstanceVariableName
end

#TitleObject

rubocop:disable Naming/MethodName



57
58
59
# File 'lib/docusign_dtr/client.rb', line 57

def Title # rubocop:disable  Naming/MethodName
  @title ||= DocusignDtr::Title.new(client: self) # rubocop:disable Naming/MemoizedInstanceVariableName
end

#UserObject

rubocop:disable Naming/MethodName



61
62
63
# File 'lib/docusign_dtr/client.rb', line 61

def User # rubocop:disable  Naming/MethodName
  @user ||= DocusignDtr::User.new(client: self) # rubocop:disable Naming/MemoizedInstanceVariableName
end