Class: TitlePage::Driver
- Inherits:
-
Handsoap::Service
- Object
- Handsoap::Service
- TitlePage::Driver
- Defined in:
- lib/titlepage/driver.rb
Instance Method Summary collapse
-
#login(username, password) ⇒ Object
Login to the webservice.
-
#logout(token) ⇒ Object
logout from the webservice.
-
#search_by_ean(token, ean) ⇒ Object
search for products by EAN.
-
#search_by_isbn(token, isbn) ⇒ Object
search for products by ISBN10.
-
#search_by_isbn13(token, isbn) ⇒ Object
search for products by ISBN13.
Instance Method Details
#login(username, password) ⇒ Object
Login to the webservice. Accepts a username and password.
Note that you can use the standard same username and password, but the account needs to have API access activated first.
Returns a string token that must be passed to all other methods.
14 15 16 17 18 19 20 |
# File 'lib/titlepage/driver.rb', line 14 def login(username, password) response = invoke("Login") do || .add "UserName", username .add "Password", password end response.document.xpath("//Token/text()").to_s end |
#logout(token) ⇒ Object
logout from the webservice. The standard authentication token must be provided.
There is no useful return value
27 28 29 30 31 32 |
# File 'lib/titlepage/driver.rb', line 27 def logout(token) response = invoke("Logout") do || .add "token", token end true end |
#search_by_ean(token, ean) ⇒ Object
search for products by EAN. The standard authentication token must be provided along with the ISBN.
Returns an array of results.
Note that although in theory EAN and ISBN13 are the same, many suppliers don’t include an explicit EAN in the ONIX files they provide Titlepage, so it is nearly always preferable to search by ISBN13.
73 74 75 76 77 78 79 80 81 |
# File 'lib/titlepage/driver.rb', line 73 def search_by_ean(token, ean) response = invoke("SearchByEAN") do || .add "Token", token .add "EAN", ean end response.document.xpath("//SearchResults/Product").collect do |node| TitlePage::Product.from_xml(node) end end |
#search_by_isbn(token, isbn) ⇒ Object
search for products by ISBN10. The standard authentication token must be provided along with the ISBN.
Returns an array of results.
39 40 41 42 43 44 45 46 47 |
# File 'lib/titlepage/driver.rb', line 39 def search_by_isbn(token, isbn) response = invoke("SearchByISBN") do || .add "Token", token .add "ISBN", isbn end response.document.xpath("//SearchResults/Product").collect do |node| TitlePage::Product.from_xml(node) end end |
#search_by_isbn13(token, isbn) ⇒ Object
search for products by ISBN13. The standard authentication token must be provided along with the ISBN.
Returns an array of results.
54 55 56 57 58 59 60 61 62 |
# File 'lib/titlepage/driver.rb', line 54 def search_by_isbn13(token, isbn) response = invoke("SearchByISBN13") do || .add "Token", token .add "ISBN13", isbn end response.document.xpath("//SearchResults/Product").collect do |node| TitlePage::Product.from_xml(node) end end |