Class: Paperform::Client

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

Constant Summary collapse

BASE_URL =
'https://api.paperform.co/v1'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Client.



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

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

Instance Attribute Details

#tokenObject (readonly)

Returns the value of attribute token.



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

def token
  @token
end

Instance Method Details

#form(slug_or_id) ⇒ Object



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

def form(slug_or_id)
  handle_response connection.get("forms/#{slug_or_id}")
end

#form_fields(slug_or_id) ⇒ Object



22
23
24
# File 'lib/paperform/client.rb', line 22

def form_fields(slug_or_id)
  handle_response connection.get("forms/#{slug_or_id}/fields")
end

#forms(**params) ⇒ Object



12
13
14
# File 'lib/paperform/client.rb', line 12

def forms(**params)
  handle_response connection.get('forms', params)
end

#partial_submission(slug_or_id) ⇒ Object



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

def partial_submission(slug_or_id)
  handle_response connection.get("partial-submissions/#{slug_or_id}")
end

#partial_submissions(form:, **params) ⇒ Object



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

def partial_submissions(form:, **params)
  handle_response connection.get('partial-submissions', {form: form}.merge(params))
end

#submission(slug_or_id) ⇒ Object



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

def submission(slug_or_id)
  handle_response connection.get("submissions/#{slug_or_id}")
end

#submissions(form:, **params) ⇒ Object



38
39
40
# File 'lib/paperform/client.rb', line 38

def submissions(form:, **params)
  handle_response(connection.get('submissions', {form: form}.merge(params)))
end