mirror of
https://github.com/dkam/paapi.git
synced 2025-12-28 15:14:52 +00:00
Bugfixing
This commit is contained in:
@@ -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,
|
||||||
@@ -24,7 +25,8 @@ module Paapi
|
|||||||
@condition = condition
|
@condition = condition
|
||||||
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)
|
||||||
@@ -72,7 +74,7 @@ module Paapi
|
|||||||
|
|
||||||
def request(op:, payload:)
|
def request(op:, payload:)
|
||||||
raise ArguemntError unless Paapi::OPERATIONS.keys.include?(op)
|
raise ArguemntError unless Paapi::OPERATIONS.keys.include?(op)
|
||||||
|
|
||||||
operation = OPERATIONS[op]
|
operation = OPERATIONS[op]
|
||||||
|
|
||||||
headers = {
|
headers = {
|
||||||
@@ -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:)
|
||||||
|
|||||||
Reference in New Issue
Block a user