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

conn, get, post

Class Method Details

.batch_create(token:, batch:) ⇒ Object



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

def batch_create(token:, batch:)
  batch.map do |params|
    create(token: token, params: params)
  end
end

.body(params) ⇒ Object



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

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