Bugfixing

This commit is contained in:
Dan Milne
2022-08-10 11:47:30 +10:00
parent e04d258b07
commit 7aebd186a5

View File

@@ -1,11 +1,12 @@
require 'net/http' require 'net/http'
require 'aws-sigv4' require 'aws-sigv4'
require 'byebug'
module Paapi module Paapi
class Client class Client
attr_accessor :partner_tag, :marketplace, :resources, :condition attr_accessor :partner_tag, :marketplace, :resources, :condition
attr_reader :partner_type, :access_key, :secret_key, :market attr_reader :partner_type, :access_key, :secret_key, :market, :http
def initialize(access_key: Paapi.access_key, def initialize(access_key: Paapi.access_key,
secret_key: Paapi.secret_key, secret_key: Paapi.secret_key,
@@ -25,6 +26,7 @@ module Paapi
self.market = market self.market = market
@partner_tag = partner_tag if !partner_tag.nil? @partner_tag = partner_tag if !partner_tag.nil?
byebug
#if defined?(HTTPX) #if defined?(HTTPX)
# @http = HTTPX.plugin(:persistent) # @http = HTTPX.plugin(:persistent)
#elsif defined?(HTTP) #elsif defined?(HTTP)
@@ -108,13 +110,12 @@ module Paapi
headers['Authorization'] = signature.headers['authorization'] headers['Authorization'] = signature.headers['authorization']
headers['Content-Type'] = 'application/json; charset=utf-8' headers['Content-Type'] = 'application/json; charset=utf-8'
if defined?(HTTP) unless @http.nil?
Response.new( HTTP.headers(headers).post(endpoint, json: payload ) ) Response.new( @http.headers(headers).post(endpoint, json: payload ) )
else else
Response.new( Client.post(url: endpoint, body: payload, headers: headers)) Response.new( Client.post(url: endpoint, body: payload, headers: headers))
end end
Response.new(@http_client.headers(headers))
end end
def self.post(url:, body:, headers:) def self.post(url:, body:, headers:)