Module: Authentise::API

Defined in:
lib/authentise/api.rb,
lib/authentise/api/print.rb,
lib/authentise/api/users.rb,
lib/authentise/api/warehouse.rb

Overview

Module for all API-Related

Defined Under Namespace

Modules: Print, Users, Warehouse Classes: Error, NotFoundError, UnknownResponseCodeError

Class Method Summary collapse

Class Method Details

.create_tokenObject

DEPRECATED, use Authentise::API::Print.create_token(…)



24
25
26
27
28
29
30
31
32
# File 'lib/authentise/api.rb', line 24

def create_token
  url = "#{host}/api3/api_create_partner_token"
  params = {
    api_key: Authentise.configuration.secret_partner_key,
  }
  response = RestClient.get(url, params: params)
  data = parse(response)
  data["token"]
end

.get_status(token: nil) ⇒ Object

DEPRECATED Returns a status hash for the given token if the print has started. /!\ Do not call this more than once every 15 seconds.

‘:printing_job_status` can be one of:

  • ‘warming_up`

  • ‘printing`

  • ‘failure`

  • ‘success`

  • ‘confirmed_success`

  • ‘confirmed_failure`



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/authentise/api.rb', line 70

def get_status(token: nil)
  url = "#{host}/api3/api_get_partner_print_status"
  params = {
    api_key: Authentise.configuration.secret_partner_key,
    token: token,
  }
  response = RestClient.get(url, params: params)
  data = parse(response)
  {
    printing_job_status_name: data["printing_job_status_name"].downcase,
    printing_percentage: data["printing_percentage"],
    minutes_left: data["minutes_left"],
    message: data["message"],
  }
end

.upload_file(token: nil, file: nil, email: nil, cents: nil, currency: "USD") ⇒ Object

DEPRECATED, use Authentise::API::Print.create_token(…)



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/authentise/api.rb', line 35

def upload_file(token: nil,
                file: nil,
                email: nil,
                cents: nil,
                currency: "USD")
  url = "#{host}/api3/api_upload_partner_stl"
  params = {
    api_key: Authentise.configuration.secret_partner_key,
    token: token,
    receiver_email: email,
    print_value: cents,
    print_value_currency: currency,
    stl_file: file,
  }
  response = RestClient.post(url, params, accept: :json)
  data = parse(response)

  if Authentise.configuration.use_ssl
    data["ssl_token_link"]
  else
    data["token_link"]
  end
end