Class: Idcf::Your::Client

Inherits:
Object
  • Object
show all
Includes:
Idcf::Your::ClientExtensions::Billing
Defined in:
lib/idcf/your/client.rb

Overview

Your API Client

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Idcf::Your::ClientExtensions::Billing

#list_billing_detail, #list_billing_history

Constructor Details

#initialize(api_key:, secret_key:, host: 'your.idcfcloud.com', endpoint: '/api/v1', verify_ssl: true) ⇒ Client

Returns a new instance of Client.



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/idcf/your/client.rb', line 16

def initialize(api_key:, secret_key:, host: 'your.idcfcloud.com',
               endpoint: '/api/v1', verify_ssl: true)
  @api_key    = api_key
  @secret_key = secret_key
  @host       = host
  @endpoint   = endpoint
  @verify_ssl = verify_ssl
  Faraday::Request.register_middleware(
    signature: Idcf::FaradayMiddleware::Signature
  )
end

Instance Attribute Details

#api_keyObject (readonly)

Returns the value of attribute api_key.



14
15
16
# File 'lib/idcf/your/client.rb', line 14

def api_key
  @api_key
end

#endpointObject (readonly)

Returns the value of attribute endpoint.



14
15
16
# File 'lib/idcf/your/client.rb', line 14

def endpoint
  @endpoint
end

#hostObject (readonly)

Returns the value of attribute host.



14
15
16
# File 'lib/idcf/your/client.rb', line 14

def host
  @host
end

#secret_keyObject (readonly)

Returns the value of attribute secret_key.



14
15
16
# File 'lib/idcf/your/client.rb', line 14

def secret_key
  @secret_key
end

#verify_sslObject (readonly)

Returns the value of attribute verify_ssl.



14
15
16
# File 'lib/idcf/your/client.rb', line 14

def verify_ssl
  @verify_ssl
end

Instance Method Details

#connectionObject



28
29
30
31
32
33
34
35
36
37
# File 'lib/idcf/your/client.rb', line 28

def connection
  @connection ||=
    Faraday.new(url: url_prefix, ssl: ssl_options) do |faraday|
      faraday.request :json
      faraday.request :signature, api_key: api_key, secret_key: secret_key
      faraday.response :json
      faraday.use :cookie_jar
      faraday.adapter Faraday.default_adapter
    end
end

#get(resource, parameters = {}, headers = {}) ⇒ Object



39
40
41
# File 'lib/idcf/your/client.rb', line 39

def get(resource, parameters = {}, headers = {})
  send 'get', resource, parameters, headers
end

#get!(resource, parameters = {}, headers = {}) ⇒ Object



43
44
45
# File 'lib/idcf/your/client.rb', line 43

def get!(resource, parameters = {}, headers = {})
  send! 'get', resource, parameters, headers
end