Sha256: c6a299658244d537b846943205d81a4c5b8cef6ff19d82997cdc1fcb9e942893
Contents?: true
Size: 1021 Bytes
Versions: 2
Compression:
Stored size: 1021 Bytes
Contents
class ShippingEasy::Http::Request attr_accessor :http_method, :body, :params, :relative_path def initialize(options = {}) @http_method = options.fetch(:http_method, :get) @params = options.fetch(:params, {}) @body = options[:payload] && options[:payload].to_json @relative_path = options.delete(:relative_path) end def self.connect!(options = {}) new(options).connect! end def connect! sign_request! adapter.connect! end def sign_request! params[:api_key] = api_key params[:api_timestamp] = Time.now.to_i params[:api_signature] = signature.to_s end def uri "/api#{relative_path}" end def signature ShippingEasy::Signature.new(api_secret: api_secret, method: http_method, path: uri, params: params, body: body) end def adapter ShippingEasy.configuration.http_adapter.new(self) end def api_secret ShippingEasy.api_secret end def api_key ShippingEasy.api_key end def base_url ShippingEasy.base_url end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
shipping_easy-0.7.1 | lib/shipping_easy/http/request.rb |
shipping_easy-0.7.0 | lib/shipping_easy/http/request.rb |