class Bluepay::Request

Constants

HOST
PORT

Attributes

action[R]

Public Class Methods

new(action) click to toggle source
# File lib/bluepay/request.rb, line 10
def initialize(action)
  @action = action
end

Public Instance Methods

execute!() click to toggle source
# File lib/bluepay/request.rb, line 14
def execute!
  uri = URI::HTTPS.build(
    host: HOST,
    path: action.path
  )

  req = Net::HTTP::Post.new(uri)
  req.set_form_data(action.data)
  req['User-Agent'] = 'BluepayRB Ruby Client'
  req['Content-Type'] = 'application/x-www-form-urlencoded'

  res = Net::HTTP.start(
    HOST, PORT,
    use_ssl: true,
  ) { |http| http.request(req) }

  Response.new(res)
end