Sha256: 042cebfbb422a965d5f1f3250ef9941a1bf819ecbb5a0d192a75dd5c612e874b

Contents?: true

Size: 867 Bytes

Versions: 1

Compression:

Stored size: 867 Bytes

Contents

module EROI
  module Request
    class Get
      API_URL = 'http://emailer.emailroi.com/dbadmin/xml_retrieve2.pl'

      def self.send(client, fields)
        uri = URI.parse(API_URL)
        uri.query = fields.merge({
          :user_token => client.user_token,
          :api_password => client.api_password }).collect { |k,v| "#{k}=#{v}" }.join('&')
        Response::Get.new(Crack::XML.parse(Net::HTTP.get(uri)))
      end
    end

    class Post
      API_URL = 'http://emailer.emailroi.com/dbadmin/xml_post.pl'

      def self.send(client, xml)
        response = Net::HTTP.post_form(
           URI.parse(API_URL),
           { :user_token => client.user_token,
             :api_password => client.api_password,
             :xml_body => xml }).body
        Response::Post.new(Crack::XML.parse("<Response>#{response}</Response>"))
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
eroi-0.1.0 lib/eroi/request.rb