Sha256: 8eaffce19df4813ae26ba134626489a4634413d8a3990460b3ec61d577a04ad1

Contents?: true

Size: 682 Bytes

Versions: 1

Compression:

Stored size: 682 Bytes

Contents

require 'net/http'
require 'uri'
require 'active_support/all'
# require 'ostruct'
require 'payture/hash'

class Payture::API
  def initialize(host)
    raise ArgumentError, "host is required" if not host
    @host = host
  end

  def host
    @host
  end

  def request(path, merchant, params)
    data      = { VWID: merchant, DATA: params.url_encode }

    uri       = URI::HTTP.build({ host: @host, path: path })
    http      = Net::HTTP.new(uri.host, uri.port)
    req       = Net::HTTP::Post.new(uri.request_uri)
    req.body  = data.to_query
    res       = http.request(req)

    # OpenStruct.new(Hash.from_xml(res.body).downcase_key)
    Hash.from_xml(res.body)
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
payture_api-0.1.2 lib/payture/api.rb