Sha256: e00b5826096715874dd6dd699234315bfd92daf9749659c57bdfda22a82e9220

Contents?: true

Size: 800 Bytes

Versions: 7

Compression:

Stored size: 800 Bytes

Contents

module Clicksign
  module API
    class DocumentsSigners
      extend Requests

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

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

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

        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
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
clicksign-api-1.1.6.alpha lib/clicksign/api/documents_signers.rb
clicksign-api-1.1.5.alpha lib/clicksign/api/documents_signers.rb
clicksign-api-1.1.4.alpha lib/clicksign/api/documents_signers.rb
clicksign-api-1.1.1 lib/clicksign/api/documents_signers.rb
clicksign-api-1.1.0 lib/clicksign/api/documents_signers.rb
clicksign-api-1.1.0.alpha6 lib/clicksign/api/documents_signers.rb
clicksign-api-1.1.0.alpha5 lib/clicksign/api/documents_signers.rb