Class: CdnetworksClient
- Inherits:
-
Object
- Object
- CdnetworksClient
- Includes:
- CacheFlushOpenApi, CachePurgeApi, ConfigOpenApi, StatisticsOpenApi
- Defined in:
- lib/cdnetworks-client.rb
Constant Summary collapse
- MAX_SESSION_RETRIES =
2
Constants included from StatisticsOpenApi
StatisticsOpenApi::BANDWIDTH_PATH
Constants included from OpenApiKeys
Constants included from AuthOpenApi
AuthOpenApi::LOGIN_URL, AuthOpenApi::LOGOUT_URL
Instance Attribute Summary collapse
-
#location ⇒ Object
Returns the value of attribute location.
-
#password ⇒ Object
Returns the value of attribute password.
-
#user ⇒ Object
Returns the value of attribute user.
Instance Method Summary collapse
- #call(path, options, session_retries = 0) ⇒ Object
- #compose_request(path, options) ⇒ Object
-
#initialize(credentials = {}) ⇒ CdnetworksClient
constructor
A new instance of CdnetworksClient.
Methods included from StatisticsOpenApi
Methods included from OpenApiKeys
#get_api_key, #get_api_key_list
Methods included from AuthOpenApi
Methods included from CacheFlushOpenApi
#add_flush_credentials, #cache_flush_path, #do_purge, #pad_list, #status
Methods included from CachePurgeApi
#add_purge_credentials, #execute_cache_purge, #get_cache_domain_list, #open_api_path
Methods included from ConfigOpenApi
#add, #add_config_credentials, #config_open_path, #edit, #list, #view
Constructor Details
#initialize(credentials = {}) ⇒ CdnetworksClient
Returns a new instance of CdnetworksClient.
23 24 25 26 27 |
# File 'lib/cdnetworks-client.rb', line 23 def initialize(credentials={}) self.user = credentials[:user] self.password = credentials[:pass] self.location = credentials[:location] end |
Instance Attribute Details
#location ⇒ Object
Returns the value of attribute location.
19 20 21 |
# File 'lib/cdnetworks-client.rb', line 19 def location @location end |
#password ⇒ Object
Returns the value of attribute password.
19 20 21 |
# File 'lib/cdnetworks-client.rb', line 19 def password @password end |
#user ⇒ Object
Returns the value of attribute user.
19 20 21 |
# File 'lib/cdnetworks-client.rb', line 19 def user @user end |
Instance Method Details
#call(path, options, session_retries = 0) ⇒ Object
35 36 37 38 39 40 41 42 43 |
# File 'lib/cdnetworks-client.rb', line 35 def call(path,,session_retries=0) response = http.request(compose_request(path,)) if location == "Beta" process_beta_response(path, , response, session_retries) else response_hash = { code: response.code, body: response.body } end end |
#compose_request(path, options) ⇒ Object
29 30 31 32 33 |
# File 'lib/cdnetworks-client.rb', line 29 def compose_request(path,) request = Net::HTTP::Post.new("#{base_url(location)}#{path}") request.set_form_data() request end |