Class: Clicksign::API::DocumentsSigners

Inherits:
Object
  • Object
show all
Extended by:
Requests
Defined in:
lib/clicksign/api/documents_signers.rb

Constant Summary collapse

REQUEST_PATH =
'/api/v1/lists/'
ATTRIBUTES =
[
  :document_key, :signer_key, :sign_as
]

Class Method Summary collapse

Methods included from Requests

get, patch, post

Class Method Details

.batch_create(token:, params:) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/clicksign/api/documents_signers.rb', line 20

def batch_create(token:, params:)
  params = params.transform_keys(&:to_sym)

  params[:batch].map do |single_params|
    create(token: token, params: single_params)
  end
end

.body(params) ⇒ Object



28
29
30
31
32
33
34
35
36
# File 'lib/clicksign/api/documents_signers.rb', line 28

def body(params)
  params = params.transform_keys(&:to_sym)

  list = ATTRIBUTES.each.with_object({}) do |key, hash|
    hash[key] = params[key] if params.has_key?(key)
  end

  body = { list: list }
end

.create(token:, params: {}) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/clicksign/api/documents_signers.rb', line 12

def create(token:, params: {})
  post(
    REQUEST_PATH,
    body(params),
    token
  )
end