lib/agrid_client/api_client.rb in agrid-client-0.0.1 vs lib/agrid_client/api_client.rb in agrid-client-0.0.2
- old
+ new
@@ -1,27 +1,14 @@
-=begin
-Agrid Quotes API
-
-
-
-OpenAPI spec version: 1.0
-
-Generated by: https://github.com/swagger-api/swagger-codegen.git
-
-
-=end
-
require 'date'
require 'json'
require 'logger'
require 'tempfile'
require 'typhoeus'
require 'uri'
module AgridClient
class ApiClient
- # The Configuration object holding settings to be used in the API client.
attr_accessor :config
# Defines the headers to be used in HTTP requests of all API calls by default.
#
# @return [Hash]
@@ -29,15 +16,16 @@
# Initializes the ApiClient
# @option config [Configuration] Configuraiton for initializing the object, default to Configuration.default
def initialize(config = Configuration.default)
@config = config
- @user_agent = "Swagger-Codegen/#{VERSION}/ruby"
+ @user_agent = "agrid_client/#{VERSION}/ruby"
@default_headers = {
'Content-Type' => "application/json",
'User-Agent' => @user_agent
}
+
if config.app_credentials
@default_headers['AGRID-APP-ID'] = config.app_credentials[:id]
@default_headers['AGRID-APP-KEY'] = config.app_credentials[:key]
end
end
@@ -191,10 +179,9 @@
sub_type = $1
{}.tap do |hash|
data.each {|k, v| hash[k] = convert_to_type(v, sub_type) }
end
else
- # models, e.g. Pet
AgridClient.const_get(return_type).new.tap do |model|
model.build_from_hash data
end
end
end