Sha256: e68708b8ddb165523e5123e4d7aec2f890884daf97332f9bdc9030072f5996a0
Contents?: true
Size: 831 Bytes
Versions: 1
Compression:
Stored size: 831 Bytes
Contents
module PayuAPI class Request extend Dry::Initializer::Mixin param :client param :method param :url param :params, default: proc { nil } API_URL = 'https://secure.payu.com/'.freeze API_SANDBOX_URL = 'https://secure.snd.payu.com/'.freeze # rubocop:disable Metrics/AbcSize def send connection = Faraday::Connection.new(api_url) connection.public_send(method.to_s.downcase) do |request| request.url url request.headers['Content-Type'] = 'application/json' request.headers['Authorization'] = "Bearer #{client.auth_token}" request.body = JSON.generate(params) if params end rescue Faraday::Error => e raise RequestError, e.message end private def api_url client.sandbox ? API_SANDBOX_URL : API_URL end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
payu_api-0.1.0 | lib/payu_api/request.rb |