Class: FourTell::Request
- Inherits:
-
Object
- Object
- FourTell::Request
- Defined in:
- lib/four_tell/request.rb
Instance Attribute Summary collapse
-
#cart_product_ids ⇒ Object
writeonly
List of product IDs in the customer’s cart.
-
#click_stream_product_ids ⇒ Object
writeonly
Ordered list of most recently visited to least recently visited product IDs.
-
#customer_id ⇒ Object
writeonly
REQUIRED: The customer_id sent to 4-Tell.
-
#num_results ⇒ Object
writeonly
The number of desired results between 1-20 (20 is the max limit in the 4-Tell API).
-
#page_type ⇒ Object
writeonly
Help 4-Tell provide the right kind of recommendations for the page.
-
#product_id ⇒ Object
writeonly
The product ID of the primary item on the page.
-
#result_type ⇒ Object
writeonly
The result type to return.
Instance Method Summary collapse
-
#initialize(client_alias) ⇒ Request
constructor
A new instance of Request.
-
#params ⇒ Hash
Parameters for the 4-Tell call.
- #url ⇒ Object
Constructor Details
#initialize(client_alias) ⇒ Request
Returns a new instance of Request.
6 7 8 9 10 11 |
# File 'lib/four_tell/request.rb', line 6 def initialize(client_alias) @client_alias = client_alias @format = 'json' @num_results = 20 @result_type = :cross_sell end |
Instance Attribute Details
#cart_product_ids=(value) ⇒ Object
List of product IDs in the customer’s cart
48 49 50 |
# File 'lib/four_tell/request.rb', line 48 def cart_product_ids=(value) @cart_product_ids = value end |
#click_stream_product_ids=(value) ⇒ Object
Ordered list of most recently visited to least recently visited product IDs. Only 5 unique product IDs will be included.
43 44 45 |
# File 'lib/four_tell/request.rb', line 43 def click_stream_product_ids=(value) @click_stream_product_ids = value end |
#customer_id=(value) ⇒ Object
REQUIRED: The customer_id sent to 4-Tell. This should correspond to the customer ID sent via data exports.
17 18 19 |
# File 'lib/four_tell/request.rb', line 17 def customer_id=(value) @customer_id = value end |
#num_results=(value) ⇒ Object
The number of desired results between 1-20 (20 is the max limit in the 4-Tell API)
32 33 34 |
# File 'lib/four_tell/request.rb', line 32 def num_results=(value) @num_results = value end |
#page_type=(value) ⇒ Object
Help 4-Tell provide the right kind of recommendations for the page
Can be one of:
- Hm
- Pdp1
- Pdp2
- Cat
- Srch
- Cart
- Chkout
- Bought
- Admin
- Other
65 66 67 |
# File 'lib/four_tell/request.rb', line 65 def page_type=(value) @page_type = value end |
#product_id=(value) ⇒ Object
The product ID of the primary item on the page
37 38 39 |
# File 'lib/four_tell/request.rb', line 37 def product_id=(value) @product_id = value end |
#result_type=(value) ⇒ Object
The result type to return
-
cross-sell: recommending something based on a customer’s likes
-
personal: based upon purchase history
-
similar: just bought a shirt, here’s another
26 27 28 |
# File 'lib/four_tell/request.rb', line 26 def result_type=(value) @result_type = value end |
Instance Method Details
#params ⇒ Hash
Parameters for the 4-Tell call. Empty parameters are omitted.
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/four_tell/request.rb', line 70 def params {}.tap { |h| h['clientAlias'] = client_alias h['format'] = format h['customerID'] = customer_id h['numResults'] = num_results h['resultType'] = result_type h['productIDs'] = product_id h['clickStreamIDs'] = click_stream_product_ids h['cartIDs'] = cart_product_ids h['pageType'] = page_type }.reduce({}) do |h, (k, v)| h[k] = v if v h end end |
#url ⇒ Object
87 88 89 90 91 |
# File 'lib/four_tell/request.rb', line 87 def url u = URI('https://live.4-tell.net/Boost2.0/rest/GetRecIDs/array') u.query = URI.encode_www_form(params) u.to_s end |