Module: Tagalys
- Defined in:
- lib/tagalys.rb,
lib/tagalys/configuration.rb
Defined Under Namespace
Classes: Configuration
Class Attribute Summary collapse
-
.configuration ⇒ Object
Returns the value of attribute configuration.
Class Method Summary collapse
- .bulk_product_sync(link, product_count, callback_url = nil) ⇒ Object
- .configure {|configuration| ... } ⇒ Object
- .create_store(currencies, fields, tag_sets, sort_options) ⇒ Object
- .get_best_selling_products ⇒ Object
-
.get_merchandisable_similar_products(product_id, recommendation_id) ⇒ Object
merchandisable similar products, it is a add-on feature on Taglys, please contact Tagalys to enable this feature.
- .get_page_details(page_name, filters = nil, sort = nil, page = 1, per_page = 30) ⇒ Object
- .get_page_list(page = 1, per_page = 30) ⇒ Object
-
.get_recommendation(recommendation_name) ⇒ Object
recommendation_name can be one of the following new_arrivals, bestsellers, most_viewed, top_discounts_percentage, top_discounts_amount, recently_viewed.
-
.get_recommendations_for_product(product_id, recommendation_id) ⇒ Object
Please contact Tagalys to enable this feature.
- .get_similar_products(product_id) ⇒ Object
- .identification ⇒ Object
- .product_sync(link, product_count, callback_url = nil) ⇒ Object
- .request_tagalys(path, request_body) ⇒ Object
- .reset ⇒ Object
- .search(query = nil, filters = nil, sort = nil, page = 1, per_page = 30) ⇒ Object
- .surface_search(query = nil, query_count = 8, product_count = 3) ⇒ Object
Class Attribute Details
.configuration ⇒ Object
Returns the value of attribute configuration.
5 6 7 |
# File 'lib/tagalys.rb', line 5 def configuration @configuration end |
Class Method Details
.bulk_product_sync(link, product_count, callback_url = nil) ⇒ Object
189 190 191 192 193 194 195 196 197 |
# File 'lib/tagalys.rb', line 189 def bulk_product_sync(link, product_count, callback_url = nil) request_body = { identification: identification, link: link, updates_count: product_count, callback_url: callback_url } create_response = request_tagalys('/products/sync_feed', request_body) end |
.configure {|configuration| ... } ⇒ Object
18 19 20 |
# File 'lib/tagalys.rb', line 18 def configure yield(configuration) end |
.create_store(currencies, fields, tag_sets, sort_options) ⇒ Object
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
# File 'lib/tagalys.rb', line 158 def create_store(currencies, fields, tag_sets, ) request_body = { identification: identification, stores: [ { id: "1", label: "Store 1", currencies: currencies, fields: fields, tag_sets: tag_sets, sort_options: , locale: "en_US", timezone: "India/Kolkata", multi_currency_mode: "exchange_rate", products_count: 21532 } ] } create_response = request_tagalys('/configuration', request_body) end |
.get_best_selling_products ⇒ Object
99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/tagalys.rb', line 99 def get_best_selling_products request_body = { identification: identification, max_products: 16, request: [ "details", "results" ] }.compact search_response = request_tagalys("/recommendations/bestsellers", request_body) end |
.get_merchandisable_similar_products(product_id, recommendation_id) ⇒ Object
merchandisable similar products, it is a add-on feature on Taglys, please contact Tagalys to enable this feature. the recommendation_id can be obtained from the Tagalys dashboard via the embed code for the merchandisable similar product feature
143 144 145 146 147 148 149 150 151 152 153 154 |
# File 'lib/tagalys.rb', line 143 def get_merchandisable_similar_products(product_id, recommendation_id) request_body = { identification: identification, max_products: 16, product_id: product_id, request: [ "details", "results" ] }.compact search_response = request_tagalys("/recommendations/" + recommendation_id, request_body) end |
.get_page_details(page_name, filters = nil, sort = nil, page = 1, per_page = 30) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/tagalys.rb', line 57 def get_page_details(page_name, filters = nil, sort = nil, page = 1, per_page = 30) request_body = { identification: identification, sort: sort, f: filters, page: page, per_page: per_page, request: [ "banners", "details", "filters", "results", "sort_options", "total", "variables" ] }.compact search_response = request_tagalys('/mpages/' + page_name, request_body) end |
.get_page_list(page = 1, per_page = 30) ⇒ Object
77 78 79 80 81 82 83 84 85 |
# File 'lib/tagalys.rb', line 77 def get_page_list(page = 1, per_page = 30) request_body = { identification: identification, request: ["url_component", "variables"], page: page, per_page: per_page }.compact search_response = request_tagalys('/mpages/', request_body) end |
.get_recommendation(recommendation_name) ⇒ Object
recommendation_name can be one of the following new_arrivals, bestsellers, most_viewed, top_discounts_percentage, top_discounts_amount, recently_viewed
114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/tagalys.rb', line 114 def get_recommendation(recommendation_name) request_body = { identification: identification, max_products: 16, request: [ "details", "results" ] }.compact search_response = request_tagalys("/recommendations/" + recommendation_name, request_body) end |
.get_recommendations_for_product(product_id, recommendation_id) ⇒ Object
Please contact Tagalys to enable this feature. the recommendation_id can be obtained from the Tagalys dashboard via the embed code for the merchandisable similar product feature
128 129 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/tagalys.rb', line 128 def get_recommendations_for_product(product_id, recommendation_id) request_body = { identification: identification, max_products: 16, product_id: product_id, request: [ "details", "results" ] }.compact search_response = request_tagalys("/recommendations/" + recommendation_id, request_body) end |
.get_similar_products(product_id) ⇒ Object
87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/tagalys.rb', line 87 def get_similar_products(product_id) request_body = { identification: identification, max_products: 16, request: [ "details", "results" ] }.compact search_response = request_tagalys("/products/#{product_id}/similar", request_body) end |
.identification ⇒ Object
211 212 213 214 215 216 217 |
# File 'lib/tagalys.rb', line 211 def identification { client_code: configuration.client_code, store_id: configuration.store_id, api_key: configuration.api_key } end |
.product_sync(link, product_count, callback_url = nil) ⇒ Object
179 180 181 182 183 184 185 186 187 |
# File 'lib/tagalys.rb', line 179 def product_sync(link, product_count, callback_url = nil) request_body = { identification: identification, link: link, updates_count: product_count, callback_url: callback_url } create_response = request_tagalys('/products/sync_updates', request_body) end |
.request_tagalys(path, request_body) ⇒ Object
199 200 201 202 203 204 205 206 207 208 209 |
# File 'lib/tagalys.rb', line 199 def request_tagalys(path, request_body) uri = URI.parse("https://api-r1.tagalys.com/v1" + path) header = {'Content-Type': 'application/json'} http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true request = Net::HTTP::Post.new(uri.request_uri, header) request.body = request_body.to_json # Send the request response = http.request(request) return JSON.parse(response.body) end |
.reset ⇒ Object
14 15 16 |
# File 'lib/tagalys.rb', line 14 def reset @configuration = Configuration.new end |
.search(query = nil, filters = nil, sort = nil, page = 1, per_page = 30) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/tagalys.rb', line 22 def search(query = nil, filters = nil, sort = nil, page = 1, per_page = 30) return { status: "Either query or filter should be present" } if query == nil && filters == nil # return { status: "Filter should be a hash" } if filters && filters.class != Hash request_body = { identification: identification, q: query.strip.length > 0 ? query : nil, sort: sort, qf: filters, page: page, per_page: per_page, request: [ "banners", "details", "filters", "results", "sort_options", "total", "variables" ] }.compact search_response = request_tagalys('/search', request_body) end |
.surface_search(query = nil, query_count = 8, product_count = 3) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/tagalys.rb', line 45 def surface_search(query = nil, query_count = 8, product_count = 3) return { status: "Either query or filter should be present" } if query == nil # return { status: "Filter should be a hash" } if filters && filters.class != Hash request_body = { identification: identification, q: query.strip.length > 0 ? query : nil, queries: query_count, products: product_count, }.compact search_response = request_tagalys('/ss', request_body) end |