tagalys 0.1.8 → 0.1.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/tagalys.rb +13 -2
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dd44c8cb55995276fa28f55fd378ac66bc841a34c9eaeb8e74858be888e318c2
4
- data.tar.gz: f1a301b0e9b9f5c09e8d67d4707b320eab0fb3a0f59761589dfdda9747bffa4c
3
+ metadata.gz: 6c612a1c338b89ca0674c1708ae4cd0fd930a32a1fa18bae017e0906eac021c2
4
+ data.tar.gz: 0fc17701c812406a8e02139943fdc84e277ace196163580f815bd813490c0f79
5
5
  SHA512:
6
- metadata.gz: a7e50822e31aea949c4e183130960dc7f0c3d0d168d2aec3dfe39c2e6f41a54d45b1a06c123f0000d68b28a0f2ebb5828796d956167ee6e0d24ab1493e583ff7
7
- data.tar.gz: b94e378a98d72197e8ede0b3b153f36569ffc1372889775d168f21972fc7012706266f7c3c270a0ceeae6626ea56434df84ac5646b67592f42743f1658ba6474
6
+ metadata.gz: 33ff8343454f9e434992cbd9a3c4f6d1ba68222a8bacfd8bbed557481f6e3fd65da24e013a188af09445ba0079d7abdc9fa9e45e4bab18f64931185cdf4226df
7
+ data.tar.gz: e19a79c805243dc9cc6489bf6b44350a5deb16a1346c4c3f70be22d9b28ff02d866d4b8dfcecab4f3e5968e46d9118c29b7edd1d177e8d1c1d199476350cbf5a
data/lib/tagalys.rb CHANGED
@@ -42,6 +42,18 @@ module Tagalys
42
42
  search_response = request_tagalys('/search', request_body)
43
43
  end
44
44
 
45
+ def surface_search(query = nil, query_count = 8, product_count = 3)
46
+ return { status: "Either query or filter should be present" } if query == nil
47
+ # return { status: "Filter should be a hash" } if filters && filters.class != Hash
48
+ request_body = {
49
+ identification: identification,
50
+ q: query.strip.length > 0 ? query : nil,
51
+ queries: query_count,
52
+ products: product_count,
53
+ }.compact
54
+ search_response = request_tagalys('/ss', request_body)
55
+ end
56
+
45
57
  def get_page_details(page_name, filters = nil, sort = nil, page = 1, per_page = 30)
46
58
  request_body = {
47
59
  identification: identification,
@@ -116,14 +128,13 @@ module Tagalys
116
128
  end
117
129
 
118
130
  def request_tagalys(path, request_body)
119
- uri = URI.parse("https://api-r1.tagalys.com/v1/" + path)
131
+ uri = URI.parse("https://api-r1.tagalys.com/v1" + path)
120
132
  header = {'Content-Type': 'application/json'}
121
133
  http = Net::HTTP.new(uri.host, uri.port)
122
134
  http.use_ssl = true
123
135
  request = Net::HTTP::Post.new(uri.request_uri, header)
124
136
  puts request_body.to_json
125
137
  request.body = request_body.to_json
126
-
127
138
  # Send the request
128
139
  response = http.request(request)
129
140
  return JSON.parse(response.body)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tagalys
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anbazhagan Palani