Class: Amzwish::Services::WebsiteWrapper
- Inherits:
-
Object
- Object
- Amzwish::Services::WebsiteWrapper
- Defined in:
- lib/amzwish/services/website_wrapper.rb
Constant Summary collapse
- FIND_WISHLIST_URL =
"http://www.amazon.co.uk/gp/registry/search.html?ie=UTF8&type=wishlist"- DISPLAY_WISHLIST_URL_TEMPLATE =
"http://www.amazon.co.uk/registry/wishlist/%s"
Instance Method Summary collapse
- #find_for(email) ⇒ Object
- #get_page(wishlist_id, page = 1) ⇒ Object
-
#initialize(rest_client = RestClientWrapper.new) ⇒ WebsiteWrapper
constructor
A new instance of WebsiteWrapper.
Constructor Details
#initialize(rest_client = RestClientWrapper.new) ⇒ WebsiteWrapper
Returns a new instance of WebsiteWrapper.
8 9 10 |
# File 'lib/amzwish/services/website_wrapper.rb', line 8 def initialize(rest_client = RestClientWrapper.new) @rest_client = rest_client end |
Instance Method Details
#find_for(email) ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/amzwish/services/website_wrapper.rb', line 12 def find_for(email) resp = @rest_client.post(email) # If a user has a single public wishlist then should get a redirect to it if (resp[:code] == 302) /(?:\?|&)id=(\w*)/ =~ resp[:headers][:location] [{:id => $~[1]}] else [] end end |
#get_page(wishlist_id, page = 1) ⇒ Object
23 24 25 |
# File 'lib/amzwish/services/website_wrapper.rb', line 23 def get_page(wishlist_id, page=1) @rest_client.get(wishlist_id, page) end |