Class: PicturePath::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/picturepath/client.rb

Overview

The client that submits a request and returns a response.

Class Method Summary collapse

Class Method Details

.submit(request, account, action) ⇒ Object

Submit a request to the provided account. Use :check as the action to simulate a request and response and use :submit to actually submit the request.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/picturepath/client.rb', line 11

def self.submit(request, , action)
  if action == :submit
    action = "Submit"
  elsif action == :check
    action = "Check"
  else
    raise "Action can only be :submit or :check"
  end
  xml = CGI.escape(request.to_xml)
  postUrl = "username=#{.escape_username}&password=#{.escape_password}&client=AUI&version=5.0&action=#{action}&xml=#{xml}"
  url = "#{.action_url}?#{postUrl}"

  output = open(url).read

  return Response.new(output)
end