class GogoKit::Client
Client
for the viagogo API
Public Class Methods
Initializes a new {GogoKit::Client}
@param options [Hash] @option options [String] :client_id Client
Id of your application @option options [String] :client_secret Client
Secret of your application @option options [String] :api_root_endpoint Endpoint where the API root is located @option options [String] :oauth_token_endpoint Endpoint for obtaining OAuth
access tokens @raise [GogoKit::Error::ConfigurationError] Error
is raised when supplied client credentials are not a String or Symbol. @return [GogoKit::Client]
# File lib/gogokit/client.rb, line 58 def initialize(options = {}) reset! options.each do |key, value| send(:"#{key}=", value) end yield self if block_given? validate_configuration_credentials! validate_configuration_api_environment! validate_configuration_endpoints! end
Public Instance Methods
Perform an HTTP DELETE request
@return [Hash] object containing response information
# File lib/gogokit/client.rb, line 81 def delete(url, options = {}) request(:delete, url, options) end
Perform an HTTP GET request
@return [Hash] object containing response information
# File lib/gogokit/client.rb, line 88 def get(url, options = {}) request(:get, url, options) end
Perform an HTTP HEAD request
@return [Hash] object containing response information
# File lib/gogokit/client.rb, line 95 def head(url, options = {}) request(:head, url, options) end
Perform an HTTP PATCH request
@return [Hash] object containing response information
# File lib/gogokit/client.rb, line 102 def patch(url, options = {}) request(:patch, url, options) end
Perform an HTTP POST request
@return [Hash] object containing response information
# File lib/gogokit/client.rb, line 109 def post(url, options = {}) request(:post, url, options) end
Perform an HTTP PUT request
@return [Hash] object containing response information
# File lib/gogokit/client.rb, line 116 def put(url, options = {}) request(:put, url, options) end
The User-Agent header used when making HTTP requests
@return [String]
# File lib/gogokit/client.rb, line 74 def user_agent @user_agent ||= "GogoKit Ruby Gem #{GogoKit::VERSION}" end
Private Instance Methods
Expands a URI template with the given parameters
# File lib/gogokit/client.rb, line 134 def expand_url(url, params) params ||= {} template = url.respond_to?(:expand) ? url : Addressable::Template.new(url) if template.variables.empty? && !params.empty? # the URI isn't templated so just append the query parameters non_templated_url = Addressable::URI.parse(url) existing_query_values = non_templated_url.query_values(Hash) || {} non_templated_url.query_values = existing_query_values.merge(params) return non_templated_url.to_s end template.expand(params || {}).to_s end
Perform an HTTP request
@return [Hash] object containing response information
# File lib/gogokit/client.rb, line 125 def request(method, url, options = {}) options ||= {} url = expand_url(url, options[:params]) try_add_authorization_header(options) connection.send(method.to_sym, url, options[:body], options[:headers]).env end