Class: RoflmOAS::Client
- Inherits:
-
Object
- Object
- RoflmOAS::Client
- Includes:
- Campaign
- Defined in:
- lib/roflmoas/client.rb
Instance Attribute Summary collapse
-
#account ⇒ Object
Returns the value of attribute account.
-
#endpoint ⇒ Object
Returns the value of attribute endpoint.
-
#password ⇒ Object
Returns the value of attribute password.
-
#username ⇒ Object
Returns the value of attribute username.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
- #request(method) ⇒ Object
Methods included from Campaign
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/roflmoas/client.rb', line 7 def initialize( = {}) .reverse_merge! :endpoint => RoflmOAS.endpoint, :account => RoflmOAS.account, :username => RoflmOAS.username, :password => RoflmOAS.password .each_pair do |key, value| send "#{key}=", value end end |
Instance Attribute Details
#account ⇒ Object
Returns the value of attribute account.
3 4 5 |
# File 'lib/roflmoas/client.rb', line 3 def account @account end |
#endpoint ⇒ Object
Returns the value of attribute endpoint.
3 4 5 |
# File 'lib/roflmoas/client.rb', line 3 def endpoint @endpoint end |
#password ⇒ Object
Returns the value of attribute password.
3 4 5 |
# File 'lib/roflmoas/client.rb', line 3 def password @password end |
#username ⇒ Object
Returns the value of attribute username.
3 4 5 |
# File 'lib/roflmoas/client.rb', line 3 def username @username end |
Instance Method Details
#request(method) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/roflmoas/client.rb', line 18 def request(method) body = Nokogiri::XML::Builder.new(:encoding => "UTF-8") do |xml| xml.AdXML do xml.Request(:type => method) do yield xml end end end response = Savon::Client.new(endpoint).request :n1, :oas_xml_request, :"xmlns:n1" => "http://api.oas.tfsm.com/" do soap.body = { "String_1" => account, "String_2" => username, "String_3" => password, "String_4" => body.to_xml } end parse(response) end |