Class: Cruz::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/cruz/client.rb,
lib/cruz/client/keys.rb

Overview

License Service API Client

Defined Under Namespace

Classes: Keys

Instance Method Summary collapse

Constructor Details

#initialize(config = {}) ⇒ Client

Desribe the behaviour of the method

Attributes

  • config - License Service API credential attribute

Options



16
17
18
19
20
# File 'lib/cruz/client.rb', line 16

def initialize(config = {})
  @app_id = config[:app_id]
  @username = config[:username]
  @api_key = config[:api_key]
end

Instance Method Details

#keysObject



41
42
43
# File 'lib/cruz/client.rb', line 41

def keys
  Keys.new(self)
end

#rest_get_with_token(path, query_params = {}, headers = {}) ⇒ Object



22
23
24
25
26
27
# File 'lib/cruz/client.rb', line 22

def rest_get_with_token(path, query_params = {}, headers = {})
  api_headers = token.merge(headers)
  headers[:params] = query_params unless query_params.empty?
  response = RestClient.get("#{Cruz.api_base}#{path}", api_headers)
  from_rest_client_response(response)
end

#rest_post_with_token(path, body = {}, headers = {}) ⇒ Object



35
36
37
38
39
# File 'lib/cruz/client.rb', line 35

def rest_post_with_token(path, body = {}, headers = {})
  api_headers = token.merge(headers)
  response = RestClient.post("#{Cruz.api_base}#{path}", encode_json(body), api_headers)
  from_rest_client_response(response)
end

#rest_put_with_token(path, body = {}, headers = {}) ⇒ Object



29
30
31
32
33
# File 'lib/cruz/client.rb', line 29

def rest_put_with_token(path, body = {}, headers = {})
  api_headers = token.merge(headers)
  response = RestClient.put("#{Cruz.api_base}#{path}", encode_json(body), api_headers)
  from_rest_client_response(response)
end