Class: CdnetworksClient

Inherits:
Object
  • Object
show all
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

OpenApiKeys::GET_KEY_PATH

Constants included from AuthOpenApi

AuthOpenApi::LOGIN_URL, AuthOpenApi::LOGOUT_URL

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from StatisticsOpenApi

#bandwidth_usage

Methods included from OpenApiKeys

#get_api_key, #get_api_key_list

Methods included from AuthOpenApi

#get_session_token

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

#locationObject

Returns the value of attribute location.



19
20
21
# File 'lib/cdnetworks-client.rb', line 19

def location
  @location
end

#passwordObject

Returns the value of attribute password.



19
20
21
# File 'lib/cdnetworks-client.rb', line 19

def password
  @password
end

#userObject

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,options,session_retries=0)
  response = http.request(compose_request(path,options))

  if location == "Beta"
    process_beta_response(path, options, 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,options)
  request = Net::HTTP::Post.new("#{base_url(location)}#{path}")
  request.set_form_data(options)
  request
end