Class: Idcf::Your::Client
- Inherits:
-
Object
- Object
- Idcf::Your::Client
- Includes:
- Idcf::Your::ClientExtensions::Billing
- Defined in:
- lib/idcf/your/client.rb
Overview
Your API Client
Instance Attribute Summary collapse
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
-
#endpoint ⇒ Object
readonly
Returns the value of attribute endpoint.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#secret_key ⇒ Object
readonly
Returns the value of attribute secret_key.
-
#verify_ssl ⇒ Object
readonly
Returns the value of attribute verify_ssl.
Instance Method Summary collapse
- #connection ⇒ Object
- #get(resource, parameters = {}, headers = {}) ⇒ Object
- #get!(resource, parameters = {}, headers = {}) ⇒ Object
-
#initialize(api_key:, secret_key:, host: 'your.idcfcloud.com', endpoint: '/api/v1', verify_ssl: true) ⇒ Client
constructor
A new instance of Client.
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_key ⇒ Object (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 |
#endpoint ⇒ Object (readonly)
Returns the value of attribute endpoint.
14 15 16 |
# File 'lib/idcf/your/client.rb', line 14 def endpoint @endpoint end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
14 15 16 |
# File 'lib/idcf/your/client.rb', line 14 def host @host end |
#secret_key ⇒ Object (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_ssl ⇒ Object (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
#connection ⇒ Object
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: ) 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 |