class Akamai::Client::Base
Attributes
client[R]
Public Class Methods
new(host:, client_token:, access_token:, client_secret:)
click to toggle source
# File lib/akamai/client/base.rb, line 7 def initialize(host:, client_token:, access_token:, client_secret:) @client = Akamai::Core::Client.new( host: host, client_token: client_token, access_token: access_token, client_secret: client_secret ) end
Private Instance Methods
base_path()
click to toggle source
# File lib/akamai/client/base.rb, line 73 def base_path raise(NotImplementedError, "plase override in subclass") end
build_full_path(resource_name, query_params = {})
click to toggle source
# File lib/akamai/client/base.rb, line 41 def build_full_path(resource_name, query_params = {}) path = URI(File.join(base_path, resource_name.to_s).gsub(/\/$/, "")) params = {}.tap do |hash| query_params.each do |k, v| hash[k.to_s.camelize(:lower)] = v end end path.query = params.present? ? params.to_param : nil path.to_s end
transform_hash(element)
click to toggle source
# File lib/akamai/client/base.rb, line 65 def transform_hash(element) {}.tap do |hash| element.each do |k, v| hash[k.underscore] = v end end.with_indifferent_access end
transform_to_snakecase(data)
click to toggle source
# File lib/akamai/client/base.rb, line 52 def transform_to_snakecase(data) if "Array" == data.class.name [].tap do |arr| data.each do |element| arr << transform_hash(element) end break arr end else transform_hash(data) end end