module Shipcloud
Constants
- API_HEADERS
- API_VERSION
- DEFAULT_AFFILIATE_ID
- ROOT_PATH
- VERSION
Attributes
configuration[W]
Public Class Methods
affiliate_id()
click to toggle source
# File lib/shipcloud.rb, line 89 def self.affiliate_id configuration.affiliate_id || DEFAULT_AFFILIATE_ID end
api_headers()
click to toggle source
# File lib/shipcloud.rb, line 58 def self.api_headers API_HEADERS.merge( "Affiliate-ID" => affiliate_id, ) end
api_key()
click to toggle source
Returns the set api key
@return [String] The api key
# File lib/shipcloud.rb, line 78 def self.api_key configuration.api_key end
api_key=(api_key)
click to toggle source
Sets the api key
@param [String] api_key
The api key
# File lib/shipcloud.rb, line 85 def self.api_key=(api_key) configuration.api_key = api_key end
configuration()
click to toggle source
rubocop:disable Naming/MemoizedInstanceVariableName
# File lib/shipcloud.rb, line 49 def self.configuration @configuration ||= Configuration.new end
configure() { |configuration| ... }
click to toggle source
rubocop:enable Naming/MemoizedInstanceVariableName
# File lib/shipcloud.rb, line 54 def self.configure yield(configuration) end
request(http_method, api_url, data, api_key: nil, affiliate_id: nil)
click to toggle source
Makes a request against the shipcloud API
@param [Symbol] http_method The http method to use, must be one of :get, :post, :put and :delete @param [String] api_url The API url to use @param [Hash] data The data to send, e.g. used when creating new objects. @param [String] optional api_key
The api key. If no api key is given, Shipcloud.api_key
will be used for the request @return [Array] The parsed JSON response.
# File lib/shipcloud.rb, line 101 def self.request(http_method, api_url, data, api_key: nil, affiliate_id: nil) api_key ||= Shipcloud.api_key affiliate_id ||= Shipcloud.affiliate_id info = Request::Info.new(http_method, api_url, api_key, data, affiliate_id) Request::Base.new(info).perform end