module Authentise::API::Print

Calls to the print streaming API

Public Instance Methods

create_token(receiver_email: nil, model_url: nil, print_value: nil, print_value_currency: nil, partner_job_id: nil) click to toggle source
# 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_options() click to toggle source
# File lib/authentise/api/print.rb, line 33
def rest_client_options
  {
    content_type: :json,
    accept: :json,
    open_timeout: 2,
    timeout: 2,
  }
end