Module: Authentise::API::Print

Defined in:
lib/authentise/api/print.rb

Overview

Calls to the print streaming API

Class Method Summary collapse

Class Method Details

.create_token(receiver_email: nil, model_url: nil, print_value: nil, print_value_currency: nil, partner_job_id: nil) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/authentise/api/print.rb', line 9

def create_token(receiver_email: nil,
                 model_url: nil,
                 print_value: nil,
                 print_value_currency: nil,
                 partner_job_id: nil)
  url = "https://print.authentise.com/token/"
  body = {
    api_key: Authentise.configuration.secret_partner_key,
    model: model_url,
    receiver_email: receiver_email,
    print_value: print_value,
    print_value_currency: print_value_currency,
    partner_job_id: partner_job_id,
  }.to_json

  RestClient.post(url, body, rest_client_options) do |response, _, _|
    if response.code == 201
      { url: response.headers[:x_token_location] }
    else
      fail UnknownResponseCodeError.new(response.code, response)
    end
  end
end

.rest_client_optionsObject



33
34
35
36
37
38
39
40
# File 'lib/authentise/api/print.rb', line 33

def rest_client_options
  {
    content_type: :json,
    accept: :json,
    open_timeout: 2,
    timeout: 2,
  }
end