Sha256: a7e9058a08cc0de7cb61b4db7d59a8d4d0d74469a68111b90a52d95d65cf8766

Contents?: true

Size: 652 Bytes

Versions: 1

Compression:

Stored size: 652 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)
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

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