Class: SignWell::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/sign_well/client.rb

Constant Summary collapse

BASE_URL =
'https://www.signwell.com/api/v1'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(x_api_key:, stubs: nil) ⇒ Client

Returns a new instance of Client.



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

def initialize(x_api_key:, stubs: nil)
  @x_api_key = x_api_key
  @stubs = stubs
end

Instance Attribute Details

#stubsObject (readonly)

Returns the value of attribute stubs.



3
4
5
# File 'lib/sign_well/client.rb', line 3

def stubs
  @stubs
end

#x_api_keyObject (readonly)

Returns the value of attribute x_api_key.



3
4
5
# File 'lib/sign_well/client.rb', line 3

def x_api_key
  @x_api_key
end

Instance Method Details

#api_application(id, params = {}) ⇒ Object



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

def api_application(id, params = {})
  ApiApplicationResource.new(self).get(id, params)
end

#completed_pdf(id, params) ⇒ Object



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

def completed_pdf(id, params)
  DocumentResource.new(self).completed_pdf(id, params)
end

#connectionObject



71
72
73
74
75
76
77
78
79
# File 'lib/sign_well/client.rb', line 71

def connection
  @connection ||= Faraday.new(url: BASE_URL) do |conn|
    conn.headers['X-Api-Key'] = x_api_key
    conn.response :json, content_type: 'application/json'
    if @stubs
      conn.adapter :test, @stubs
    end
  end
end

#create_document(params) ⇒ Object



15
16
17
# File 'lib/sign_well/client.rb', line 15

def create_document(params)
  DocumentResource.new(self).create(params)
end

#create_document_from_template(params) ⇒ Object



19
20
21
# File 'lib/sign_well/client.rb', line 19

def create_document_from_template(params)
  DocumentResource.new(self).create_from_template(params)
end

#create_template(params) ⇒ Object



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

def create_template(params)
  TemplateResource.new(self).create(params)
end

#create_web_hook(params) ⇒ Object



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

def create_web_hook(params)
  WebHookResource.new(self).create(params)
end

#delete_api_application(id) ⇒ Object



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

def delete_api_application(id)
  ApiApplicationResource.new(self).delete(id)
end

#delete_document(id) ⇒ Object



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

def delete_document(id)
  DocumentResource.new(self).delete(id)
end

#delete_template(id) ⇒ Object



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

def delete_template(id)
  TemplateResource.new(self).delete(id)
end

#delete_web_hook(id) ⇒ Object



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

def delete_web_hook(id)
  WebHookResource.new(self).delete(id)
end

#document(id, params = {}) ⇒ Object



11
12
13
# File 'lib/sign_well/client.rb', line 11

def document(id, params = {})
  DocumentResource.new(self).get(id, params)
end

#list_web_hooksObject



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

def list_web_hooks
  WebHookResource.new(self).list
end

#meObject



67
68
69
# File 'lib/sign_well/client.rb', line 67

def me
  MeResource.new(self).get
end

#template(id, params = {}) ⇒ Object



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

def template(id, params = {})
  TemplateResource.new(self).get(id, params)
end

#update_and_send_document(id, params) ⇒ Object



23
24
25
# File 'lib/sign_well/client.rb', line 23

def update_and_send_document(id, params)
  DocumentResource.new(self).update_and_send_document(id, params)
end