Class: Shopsense::API
Instance Method Summary collapse
-
#get_brands ⇒ String
This method returns a list of brands that have live products.
-
#get_category_histogram(search_string = nil) ⇒ String
This method returns a list of categories and product counts that describe the results of a given product query.
-
#get_filter_histogram(filter_type = nil, search_string = nil) ⇒ String
This method returns a list of categories and product counts that describe the results of a given product query.
-
#get_look(look_id = nil) ⇒ String
This method returns information about a particular look and its products.
-
#get_looks(look_type = nil, index = 0, num_results = 10) ⇒ String
This method returns information about looks that match different kinds of searches.
-
#get_retailers ⇒ Sting
This method returns a list of retailers that have live products.
-
#get_stylebook(user_name = nil, index = 0, num_results = 10) ⇒ String
This method returns information about a particular user’s Stylebook, the looks within that Stylebook, and the title and description associated with each look.
-
#get_trends(category = "", products = 0) ⇒ String
This method returns the popular brands for a given category along with a sample product for the brand-category combination.
-
#search(search_string = nil, index = 0, num_results = 10) ⇒ Object
Searches the shopsense API.
-
#visit_retailer(id) ⇒ String
TODO: This method does not return a reponse of XML or JSON data like the other elements of the API.
Methods inherited from Client
Constructor Details
This class inherits a constructor from Shopsense::Client
Instance Method Details
#get_brands ⇒ String
This method returns a list of brands that have live products. Brands that have very few products will be omitted.
62 63 64 |
# File 'lib/shopsense/api.rb', line 62 def get_brands return call_api( __method__) end |
#get_category_histogram(search_string = nil) ⇒ String
This method returns a list of categories and product counts that describe the results of a given product query. The query is specified using the product query parameters.
32 33 34 35 36 37 38 |
# File 'lib/shopsense/api.rb', line 32 def get_category_histogram( search_string = nil) raise "no search string provieded!" if( search_string === nil) fts = "fts=" + search_string.split().join( '+').to_s return call_api( __method__, fts) end |
#get_filter_histogram(filter_type = nil, search_string = nil) ⇒ String
This method returns a list of categories and product counts that describe the results of a given product query. The query is specified using the product query parameters.
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/shopsense/api.rb', line 48 def get_filter_histogram( filter_type = nil, search_string = nil) raise "no search string provieded!" if( search_string === nil) raise "invalid filter type" if( !self.filter_types.include?( filter_type)) filterType = "filterType=" + filter_type.to_s fts = "fts=" + search_string.split().join( '+').to_s args = [filterType, fts].join( '&') return call_api( __method__, args) end |
#get_look(look_id = nil) ⇒ String
This method returns information about a particular look and its products.
75 76 77 78 79 80 81 |
# File 'lib/shopsense/api.rb', line 75 def get_look( look_id = nil) raise "no look_id provieded!" if( look_id === nil) look = "look=" + look_id.to_s return call_api( __method__, look) end |
#get_looks(look_type = nil, index = 0, num_results = 10) ⇒ String
This method returns information about looks that match different kinds of searches.
126 127 128 129 130 131 132 133 134 135 |
# File 'lib/shopsense/api.rb', line 126 def get_looks( look_type = nil, index = 0, num_results = 10) raise "invalid filter type must be one of the following: #{self.look_types}" if( !self.look_types.include?( look_type)) type = "type=" + look_type.to_s min = "min=" + index.to_s count = "count=" + num_results.to_s args = [type, min, count].join( '&') return call_api( __method__, args) end |
#get_retailers ⇒ Sting
This method returns a list of retailers that have live products.
85 86 87 |
# File 'lib/shopsense/api.rb', line 85 def get_retailers return call_api( __method__) end |
#get_stylebook(user_name = nil, index = 0, num_results = 10) ⇒ String
This method returns information about a particular user’s Stylebook, the looks within that Stylebook, and the title and description associated with each look.
100 101 102 103 104 105 106 107 108 109 |
# File 'lib/shopsense/api.rb', line 100 def get_stylebook( user_name = nil, index = 0, num_results = 10) raise "no user_name provieded!" if( user_name === nil) handle = "handle=" + user_name.to_s min = "min=" + index.to_s count = "count=" + num_results.to_s args = [handle, min, count].join( '&') return call_api( __method__, args) end |
#get_trends(category = "", products = 0) ⇒ String
This method returns the popular brands for a given category along with a sample product for the brand-category combination.
160 161 162 163 164 165 166 |
# File 'lib/shopsense/api.rb', line 160 def get_trends( category = "", products = 0) cat = "cat=" + category.to_s products = "products=" + products.to_s args = [cat, products].join( '&') return call_api( __method__, args) end |
#search(search_string = nil, index = 0, num_results = 10) ⇒ Object
Searches the shopsense API
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/shopsense/api.rb', line 15 def search( search_string = nil, index = 0, num_results = 10) raise "no search string provieded!" if( search_string === nil) fts = "fts=" + search_string.split().join( '+').to_s min = "min=" + index.to_s count = "count=" + num_results.to_s args = [fts, min, count].join( '&') return call_api( __method__, args) end |
#visit_retailer(id) ⇒ String
TODO: This method does not return a reponse of XML or JSON data like the other elements of the API. Instead, it forwards the user to the retailer’s product page for a given product. It is the typical behavior to offer when the user clicks on a product. The apiSearch method returns URLs that call this method for each of the products it returns.
149 150 151 |
# File 'lib/shopsense/api.rb', line 149 def visit_retailer( id) end |