Project

oas

0.0
No commit activity in last 3 years
No release in over 3 years
Ruby client for the OpenAdstream API
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 0.9
~> 1.9

Runtime

~> 1.5
~> 2.0
~> 2.0
 Project Readme

OAS Ruby Client Build Status Dependency Status

Ruby client for the OpenAdstream API

Installation

oas is available through Rubygems and can be installed via:

gem install oas

Usage

Applications that make requests on behalf a single user to a single account can pass configuration options as a block to the OAS.configure method.

OAS.configure do |config|
  config.endpoint = OAS_ENDPOINT
  config.account  = OAS_ACCOUNT
  config.username = OAS_USERNAME
  config.password = OAS_PASSWORD
end

Applications that make requests on behalf of multiple users to multiple accounts should avoid using the global configuration and instantiate OAS::Client objects. If the endpoint is the same, you can specify it globally.

OAS.configure do |config|
  config.endpoint = OAS_ENDPOINT
end

client = OAS::Client.new(
  :account  => "oas_account",
  :username => "oas_username",
  :password => "oas_password"
)

Requests should be created using an OAS::AdXML object. Each request type will yield a Nokogiri::XML::Builder object.

doc = OAS::AdXML.new
doc.request do |req|
  req.Advertiser do |xml|
    xml.Database(:action => 'read') {
      xml.Advertiser {
        xml.Id "DPadvtest"
      }
    }
  end
end

Multiple requests can be sent in the same call.

doc = OAS::AdXML.new
doc.request do |req|
  req.Site do |xml|
    xml.Database(:action => "read") {
      xml.Site {
        xml.Id "247media"
      }
    }
  end
  req.Site do |xml|
    xml.Database(:action => "read") {
      xml.Site {
        xml.Id "realmedia"
      }
    }
  end
end

Executing the request

adxml = OAS.execute(doc) # or client.execute(doc)
adxml.each_response do |res|
  if res.success?
    # res.to_hash
  else
    # res.error_code
    # res.error_text
  end
end

Copyright

Copyright (c) 2011 Realmedia Latin America. See LICENSE for details.