Sha256: ba02f86967a067b7afd6c0f31cedde6a8161ffb0c886813703268c64df221e0d

Contents?: true

Size: 738 Bytes

Versions: 1

Compression:

Stored size: 738 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 }
    puts "request.data: #{data}"

    uri       = URI::HTTP.build({ host: @host, path: path })
    puts "URI: #{uri}"
    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.3 lib/payture/api.rb