constructorio 2.0.8 → 2.0.13

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 4f1460ee4a45a554fdded5ffc3868e162a886f52
4
- data.tar.gz: 9d69a6002effdebb0247f07ae13e77a7de93366a
2
+ SHA256:
3
+ metadata.gz: 2ca3e31d09af72a9dec708d345fd8ea2f22cc64e2623e3a4205de1bf841e17a2
4
+ data.tar.gz: e38e090bb932ca4238e51047fc453dadb2117dc5cc9838514cc082379f884df2
5
5
  SHA512:
6
- metadata.gz: 372bdfd4ff213924afbf4c88e92f638200e8d874d9634eedea1dadf3756c835d93c58868e37ed847759d865feeb954a7757fc72a44c5513ddac30232c61757c5
7
- data.tar.gz: 65d7a7c4ea26094244624b2ce94ce8bbe72209bbca8fb4e04f2b83b5683e839c56bbec59d0160d1ca104021b646fdea773461dc67ee654c83feef15056809faf
6
+ metadata.gz: 85b0abb3888259d2db059f941aadb985136f58c197055d60e917dc614ff7cab03c9d838badb7611adfc12d5b63de6f11db383a561cb19b6ca6659f9f883e3071
7
+ data.tar.gz: 1f399b18dd1d2bea7f402f6c1090fedeeb1fd6caa9084b61824aa98576f5220f031eacdcd21303174b9801952dad82820cca71115ab7d65e4aca0b944fe83d6c
data/README.md CHANGED
@@ -14,7 +14,7 @@ And then execute:
14
14
 
15
15
  Or install it yourself:
16
16
 
17
- $ gem install customerio
17
+ $ gem install constructorio
18
18
 
19
19
  ## Usage
20
20
 
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_dependency 'faraday', '~> 0.9', '>= 0.9.0'
21
+ spec.add_dependency 'faraday', '~> 1.0', '>= 1.0'
22
22
  spec.add_development_dependency "bundler", "~> 1.7"
23
23
  spec.add_development_dependency "rake", "~> 10.0"
24
24
  spec.add_development_dependency 'pry', '~> 0.10', '>= 0.10.1'
@@ -17,6 +17,10 @@ module ConstructorIO
17
17
  call_api("item", "post", params)
18
18
  end
19
19
 
20
+ def add_or_update(params)
21
+ call_api("item", "put", params, {force: 1})
22
+ end
23
+
20
24
  def remove(params)
21
25
  call_api("item", "delete", params)
22
26
  end
@@ -45,21 +49,30 @@ module ConstructorIO
45
49
  call_api("batch_items", "post", params)
46
50
  end
47
51
 
52
+ def add_or_update_batch(params)
53
+ call_api("batch_items", "put", params, {force: 1})
54
+ end
55
+
56
+ def remove_batch(params)
57
+ call_api("batch_items", "delete", params)
58
+ end
59
+
48
60
  private
49
61
 
50
- def call_api(path, method, params = {})
62
+ def call_api(path, method, params = {}, additional_query_params = {})
51
63
  api_token = self.local_configuration.api_token
52
64
  api_url = self.local_configuration.api_url
53
65
  autocomplete_key = self.local_configuration.autocomplete_key
54
66
  @http_client ||= Faraday.new(url: api_url)
55
67
  @http_client.basic_auth(api_token, '')
56
68
 
57
- send_request(path, method, @http_client, params, autocomplete_key)
69
+ send_request(path, method, @http_client, params, autocomplete_key, additional_query_params)
58
70
  end
59
71
 
60
- def send_request(path, method, http_client, params, autocomplete_key)
72
+ def send_request(path, method, http_client, params, autocomplete_key, additional_query_params)
73
+ query_params = additional_query_params ? "&#{URI.encode_www_form(additional_query_params)}" : ""
61
74
  response = http_client.send(method) do |request|
62
- request.url "/v1/#{path}?autocomplete_key=#{autocomplete_key}"
75
+ request.url "/v1/#{path}?autocomplete_key=#{autocomplete_key}#{query_params}"
63
76
  request.headers['Content-Type'] = 'application/json'
64
77
  request.body = params.to_json
65
78
  end
@@ -1,3 +1,3 @@
1
1
  module ConstructorIO
2
- VERSION = "2.0.8"
2
+ VERSION = "2.0.13"
3
3
  end
@@ -10,6 +10,6 @@ class ConfigurationTest < MiniTest::Test
10
10
  end
11
11
 
12
12
  def test_configure_api_url
13
- assert_equal ConstructorIO.configuration.api_url, "https://devac.cnstrc.com"
13
+ assert_equal ConstructorIO.configuration.api_url, "https://ac.cnstrc.com"
14
14
  end
15
15
  end
@@ -19,12 +19,39 @@ class ConstructorIOTest < MiniTest::Test
19
19
  "post",
20
20
  instance_of(Faraday::Connection),
21
21
  { item_name: "power drill" },
22
- "example_autocomplete_key"
22
+ "example_autocomplete_key",
23
+ {}
23
24
  )
24
25
 
25
26
  c.add( { item_name: "power drill" } )
26
27
  end
27
28
 
29
+ def test_add_or_update_record_calls_post
30
+ c = ConstructorIO::Client.new
31
+ c.expects(:call_api).with(
32
+ "item",
33
+ "put",
34
+ { item_name: "power drill" },
35
+ { force: 1 }
36
+ )
37
+
38
+ c.add_or_update( { item_name: "power drill" } )
39
+ end
40
+
41
+ def test_add_or_update_record_sends_request
42
+ c = ConstructorIO::Client.new
43
+ c.expects(:send_request).with(
44
+ "item",
45
+ "put",
46
+ instance_of(Faraday::Connection),
47
+ { item_name: "power drill" },
48
+ "example_autocomplete_key",
49
+ { force: 1 }
50
+ )
51
+
52
+ c.add_or_update( { item_name: "power drill" } )
53
+ end
54
+
28
55
  def test_add_record_sends_request_with_local_config
29
56
  c = ConstructorIO::Client.new(ConstructorIO::Configuration.new(
30
57
  api_token: "this-api-token",
@@ -36,7 +63,8 @@ class ConstructorIOTest < MiniTest::Test
36
63
  "post",
37
64
  instance_of(Faraday::Connection),
38
65
  { item_name: "power drill" },
39
- "this-autocomplete-key"
66
+ "this-autocomplete-key",
67
+ {}
40
68
  )
41
69
 
42
70
  c.add( { item_name: "power drill" } )
@@ -82,9 +110,99 @@ class ConstructorIOTest < MiniTest::Test
82
110
  "get",
83
111
  instance_of(Faraday::Connection),
84
112
  {},
85
- "example_autocomplete_key"
113
+ "example_autocomplete_key",
114
+ {}
86
115
  )
87
116
 
88
117
  c.verify
89
118
  end
119
+
120
+ def test_add_batch_calls_post
121
+ c = ConstructorIO::Client.new
122
+ c.expects(:call_api).with(
123
+ "batch_items",
124
+ "post",
125
+ { autocomplete_section: "Products", items: [ { item_name: "item" } ] }
126
+ )
127
+
128
+ c.add_batch(
129
+ {
130
+ autocomplete_section: "Products",
131
+ items: [ { item_name: "item" } ]
132
+ }
133
+ )
134
+ end
135
+
136
+ def test_add_batch_sends_request
137
+ c = ConstructorIO::Client.new
138
+ c.expects(:send_request).with(
139
+ "batch_items",
140
+ "post",
141
+ instance_of(Faraday::Connection),
142
+ { autocomplete_section: "Products", items: [ { item_name: "item" } ] },
143
+ "example_autocomplete_key",
144
+ {}
145
+ )
146
+
147
+ c.add_batch(
148
+ {
149
+ autocomplete_section: "Products",
150
+ items: [ { item_name: "item" } ]
151
+ }
152
+ )
153
+ end
154
+
155
+ def test_add_or_update_batch_calls_post
156
+ c = ConstructorIO::Client.new
157
+ c.expects(:call_api).with(
158
+ "batch_items",
159
+ "put",
160
+ { autocomplete_section: "Products", items: [ { item_name: "item" } ] },
161
+ { force: 1 }
162
+ )
163
+
164
+ c.add_or_update_batch(
165
+ {
166
+ autocomplete_section: "Products",
167
+ items: [ { item_name: "item" } ]
168
+ }
169
+ )
170
+ end
171
+
172
+ def test_add_or_update_batch_sends_request
173
+ c = ConstructorIO::Client.new
174
+ c.expects(:send_request).with(
175
+ "batch_items",
176
+ "put",
177
+ instance_of(Faraday::Connection),
178
+ { autocomplete_section: "Products", items: [ { item_name: "item" } ] },
179
+ "example_autocomplete_key",
180
+ { force: 1 }
181
+ )
182
+
183
+ c.add_or_update_batch(
184
+ {
185
+ autocomplete_section: "Products",
186
+ items: [ { item_name: "item" } ]
187
+ }
188
+ )
189
+ end
190
+
191
+ def test_remove_batch_sends_request
192
+ c = ConstructorIO::Client.new
193
+ c.expects(:send_request).with(
194
+ "batch_items",
195
+ "delete",
196
+ instance_of(Faraday::Connection),
197
+ { autocomplete_section: "Products", items: [ { item_name: "item" } ] },
198
+ "example_autocomplete_key",
199
+ {}
200
+ )
201
+ c.remove_batch(
202
+ {
203
+ autocomplete_section: "Products",
204
+ items: [ { item_name: "item" } ]
205
+ }
206
+ )
207
+ end
90
208
  end
@@ -13,7 +13,79 @@ class ConstructorIOVCRTest < MiniTest::Test
13
13
 
14
14
  VCR.use_cassette("add_item") do
15
15
  response = c.add(
16
- { item_name: "power_drill", autocomplete_section: "standard" }
16
+ { item_name: "power_drill", autocomplete_section: "Search Suggestions" }
17
+ )
18
+ assert_equal response.status, 204
19
+ end
20
+ end
21
+
22
+ def test_add_item_with_metadata
23
+ c = ConstructorIO::Client.new
24
+
25
+ VCR.use_cassette("add_item_with_metadata") do
26
+ response = c.add(
27
+ { item_name: "power_drill", autocomplete_section: "Products", url: "/condition/1", metadata: { key1: "value1", key2: "value2" } }
28
+ )
29
+ assert_equal response.status, 204
30
+ end
31
+ end
32
+
33
+ def test_add_or_update_item
34
+ c = ConstructorIO::Client.new
35
+
36
+ VCR.use_cassette("add_or_update_item") do
37
+ response = c.add_or_update(
38
+ { item_name: "power_drill", autocomplete_section: "Search Suggestions" }
39
+ )
40
+ assert_equal response.status, 204
41
+ end
42
+ end
43
+
44
+ def test_add_batch
45
+ c = ConstructorIO::Client.new
46
+
47
+ VCR.use_cassette("add_batch") do
48
+ response = c.add_batch(
49
+ autocomplete_section: "Search Suggestions",
50
+ items: [
51
+ { item_name: "power drill x11" },
52
+ { item_name: "power drill x12" },
53
+ { item_name: "power drill x13" },
54
+ { item_name: "power drill x14" },
55
+ ]
56
+ )
57
+ assert_equal response.status, 204
58
+ end
59
+ end
60
+
61
+ def test_add_batch_with_metadata
62
+ c = ConstructorIO::Client.new
63
+
64
+ VCR.use_cassette("add_batch_with_metadata") do
65
+ response = c.add_batch(
66
+ autocomplete_section: "Products",
67
+ items: [
68
+ { item_name: "power_drill 1", url: "/condition/1", metadata: { key1: "value1", key2: "value2" } },
69
+ { item_name: "power_drill 2", url: "/condition/2", metadata: { key3: "value3", key4: "value4" } },
70
+ { item_name: "power_drill 3", url: "/condition/3", metadata: { key5: "value5", key6: "value6" } }
71
+ ]
72
+ )
73
+ assert_equal response.status, 204
74
+ end
75
+ end
76
+
77
+ def test_add_or_update_batch
78
+ c = ConstructorIO::Client.new
79
+
80
+ VCR.use_cassette("add_or_update_batch") do
81
+ response = c.add_or_update_batch(
82
+ autocomplete_section: "Search Suggestions",
83
+ items: [
84
+ { item_name: "power drill x1" },
85
+ { item_name: "power drill x2" },
86
+ { item_name: "power drill x3" },
87
+ { item_name: "power drill x4" },
88
+ ]
17
89
  )
18
90
  assert_equal response.status, 204
19
91
  end
@@ -24,7 +96,24 @@ class ConstructorIOVCRTest < MiniTest::Test
24
96
 
25
97
  VCR.use_cassette("remove_item") do
26
98
  response = c.remove(
27
- { item_name: "power_drill", autocomplete_section: "standard" }
99
+ { item_name: "power_drill", autocomplete_section: "Search Suggestions" }
100
+ )
101
+ assert_equal response.status, 204
102
+ end
103
+ end
104
+
105
+ def test_remove_batch
106
+ c = ConstructorIO::Client.new
107
+
108
+ VCR.use_cassette("remove_batch") do
109
+ response = c.remove_batch(
110
+ autocomplete_section: "Search Suggestions",
111
+ items: [
112
+ { item_name: "power_drill x1" },
113
+ { item_name: "power_drill x2" },
114
+ { item_name: "power_drill x3" },
115
+ { item_name: "power_drill x4" },
116
+ ]
28
117
  )
29
118
  assert_equal response.status, 204
30
119
  end
@@ -35,7 +124,7 @@ class ConstructorIOVCRTest < MiniTest::Test
35
124
 
36
125
  VCR.use_cassette("modify_item") do
37
126
  response = c.remove(
38
- { item_name: "power_drill", autocomplete_section: "standard", suggested_score: 10 }
127
+ { item_name: "power_drill", autocomplete_section: "Search Suggestions", suggested_score: 10 }
39
128
  )
40
129
  assert_equal response.status, 204
41
130
  end
@@ -0,0 +1,53 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://example_api_token:@ac.cnstrc.com/v1/batch_items?autocomplete_key=example_autocomplete_key
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"autocomplete_section":"Search Suggestions","items":[{"item_name":"power
9
+ drill x11"},{"item_name":"power drill x12"},{"item_name":"power drill x13"},{"item_name":"power
10
+ drill x14"}]}'
11
+ headers:
12
+ User-Agent:
13
+ - Faraday v0.9.1
14
+ Content-Type:
15
+ - application/json
16
+ Accept-Encoding:
17
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
18
+ Accept:
19
+ - "*/*"
20
+ response:
21
+ status:
22
+ code: 204
23
+ message: NO CONTENT
24
+ headers:
25
+ Accept-Ranges:
26
+ - bytes
27
+ Age:
28
+ - '0'
29
+ Content-Length:
30
+ - '0'
31
+ Content-Type:
32
+ - text/html; charset=utf-8
33
+ Date:
34
+ - Wed, 16 Nov 2016 05:06:53 GMT
35
+ Server:
36
+ - nginx/1.4.6 (Ubuntu)
37
+ Set-Cookie:
38
+ - session=eyJwd19oYXNoIjp7IiBiIjoiSkRKaEpEQTRKRlY0YVVacFNpODFUa3hhWTJWaE5sQmtPRWxwU0M1MEwyeHhjME0zVFZkbFJFWm1hQzUzVmpSQ2RuSkhjbGhuVGxjdVIweHAifX0.Cw167Q.Jw-ZHw-7tRKVPOEBUp0-o4fXp58;
39
+ HttpOnly; Path=/
40
+ Strict-Transport-Security:
41
+ - max-age=31536000
42
+ Via:
43
+ - 1.1 varnish
44
+ X-Varnish:
45
+ - '1827964804'
46
+ Connection:
47
+ - keep-alive
48
+ body:
49
+ encoding: UTF-8
50
+ string: ''
51
+ http_version:
52
+ recorded_at: Wed, 16 Nov 2016 05:06:53 GMT
53
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,54 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://example_api_token:@ac.cnstrc.com/v1/batch_items?autocomplete_key=example_autocomplete_key
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"autocomplete_section":"Products","items":[{"item_name":"power_drill
9
+ 1","url":"/condition/1","metadata":{"key1":"value1","key2":"value2"}},{"item_name":"power_drill
10
+ 2","url":"/condition/2","metadata":{"key3":"value3","key4":"value4"}},{"item_name":"power_drill
11
+ 3","url":"/condition/3","metadata":{"key5":"value5","key6":"value6"}}]}'
12
+ headers:
13
+ User-Agent:
14
+ - Faraday v0.9.1
15
+ Content-Type:
16
+ - application/json
17
+ Accept-Encoding:
18
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
19
+ Accept:
20
+ - "*/*"
21
+ response:
22
+ status:
23
+ code: 204
24
+ message: NO CONTENT
25
+ headers:
26
+ Accept-Ranges:
27
+ - bytes
28
+ Age:
29
+ - '0'
30
+ Content-Length:
31
+ - '0'
32
+ Content-Type:
33
+ - text/html; charset=utf-8
34
+ Date:
35
+ - Wed, 16 Nov 2016 05:06:52 GMT
36
+ Server:
37
+ - nginx/1.4.6 (Ubuntu)
38
+ Set-Cookie:
39
+ - session=eyJwd19oYXNoIjp7IiBiIjoiSkRKaEpEQTRKRlY0YVVacFNpODFUa3hhWTJWaE5sQmtPRWxwU0M1MEwyeHhjME0zVFZkbFJFWm1hQzUzVmpSQ2RuSkhjbGhuVGxjdVIweHAifX0.Cw167A.J1MXRYqdpA5qlEKI0AfwHKspaJQ;
40
+ HttpOnly; Path=/
41
+ Strict-Transport-Security:
42
+ - max-age=31536000
43
+ Via:
44
+ - 1.1 varnish
45
+ X-Varnish:
46
+ - '739215592'
47
+ Connection:
48
+ - keep-alive
49
+ body:
50
+ encoding: UTF-8
51
+ string: ''
52
+ http_version:
53
+ recorded_at: Wed, 16 Nov 2016 05:06:52 GMT
54
+ recorded_with: VCR 2.9.3
@@ -2,10 +2,10 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: post
5
- uri: https://example_api_token:@devac.cnstrc.com/v1/item?autocomplete_key=example_autocomplete_key
5
+ uri: https://example_api_token:@ac.cnstrc.com/v1/item?autocomplete_key=example_autocomplete_key
6
6
  body:
7
7
  encoding: UTF-8
8
- string: '{"item_name":"power_drill","autocomplete_section":"standard"}'
8
+ string: '{"item_name":"power_drill","autocomplete_section":"Search Suggestions"}'
9
9
  headers:
10
10
  User-Agent:
11
11
  - Faraday v0.9.1
@@ -29,23 +29,23 @@ http_interactions:
29
29
  Content-Type:
30
30
  - text/html; charset=utf-8
31
31
  Date:
32
- - Fri, 16 Oct 2015 16:31:30 GMT
32
+ - Wed, 16 Nov 2016 05:06:52 GMT
33
33
  Server:
34
34
  - nginx/1.4.6 (Ubuntu)
35
35
  Set-Cookie:
36
- - session=eyJwd19oYXNoIjp7IiBiIjoiSkRKaEpEQTRKRkpQY1RkNGJGSnlOeTlzWXpaVFYzWkNjbFYyUkM1YVZqQXlZMjlUVVM5b05DNVZhRlJUVG5Bek5XSlZVVFZ0UXpobWNrd3kifX0.CQK34g.J6XoEQJTyZV5ngAmVgSsYthAz0c;
36
+ - session=eyJwd19oYXNoIjp7IiBiIjoiSkRKaEpEQTRKRlY0YVVacFNpODFUa3hhWTJWaE5sQmtPRWxwU0M1MEwyeHhjME0zVFZkbFJFWm1hQzUzVmpSQ2RuSkhjbGhuVGxjdVIweHAifX0.Cw167A.J1MXRYqdpA5qlEKI0AfwHKspaJQ;
37
37
  HttpOnly; Path=/
38
38
  Strict-Transport-Security:
39
39
  - max-age=31536000
40
40
  Via:
41
41
  - 1.1 varnish
42
42
  X-Varnish:
43
- - '1717338774'
43
+ - '816986814'
44
44
  Connection:
45
45
  - keep-alive
46
46
  body:
47
47
  encoding: UTF-8
48
48
  string: ''
49
49
  http_version:
50
- recorded_at: Fri, 16 Oct 2015 16:31:27 GMT
50
+ recorded_at: Wed, 16 Nov 2016 05:06:52 GMT
51
51
  recorded_with: VCR 2.9.3
@@ -0,0 +1,51 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://example_api_token:@ac.cnstrc.com/v1/item?autocomplete_key=example_autocomplete_key
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"item_name":"power_drill","autocomplete_section":"Products","url":"/condition/1","metadata":{"key1":"value1","key2":"value2"}}'
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.9.1
12
+ Content-Type:
13
+ - application/json
14
+ Accept-Encoding:
15
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
16
+ Accept:
17
+ - "*/*"
18
+ response:
19
+ status:
20
+ code: 204
21
+ message: NO CONTENT
22
+ headers:
23
+ Accept-Ranges:
24
+ - bytes
25
+ Age:
26
+ - '0'
27
+ Content-Length:
28
+ - '0'
29
+ Content-Type:
30
+ - text/html; charset=utf-8
31
+ Date:
32
+ - Wed, 16 Nov 2016 05:06:53 GMT
33
+ Server:
34
+ - nginx/1.4.6 (Ubuntu)
35
+ Set-Cookie:
36
+ - session=eyJwd19oYXNoIjp7IiBiIjoiSkRKaEpEQTRKRlY0YVVacFNpODFUa3hhWTJWaE5sQmtPRWxwU0M1MEwyeHhjME0zVFZkbFJFWm1hQzUzVmpSQ2RuSkhjbGhuVGxjdVIweHAifX0.Cw167Q.Jw-ZHw-7tRKVPOEBUp0-o4fXp58;
37
+ HttpOnly; Path=/
38
+ Strict-Transport-Security:
39
+ - max-age=31536000
40
+ Via:
41
+ - 1.1 varnish
42
+ X-Varnish:
43
+ - '739215594'
44
+ Connection:
45
+ - keep-alive
46
+ body:
47
+ encoding: UTF-8
48
+ string: ''
49
+ http_version:
50
+ recorded_at: Wed, 16 Nov 2016 05:06:53 GMT
51
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,53 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: put
5
+ uri: https://example_api_token:@ac.cnstrc.com/v1/batch_items?autocomplete_key=example_autocomplete_key&force=1
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"autocomplete_section":"Search Suggestions","items":[{"item_name":"power
9
+ drill x1"},{"item_name":"power drill x2"},{"item_name":"power drill x3"},{"item_name":"power
10
+ drill x4"}]}'
11
+ headers:
12
+ User-Agent:
13
+ - Faraday v0.9.1
14
+ Content-Type:
15
+ - application/json
16
+ Accept-Encoding:
17
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
18
+ Accept:
19
+ - "*/*"
20
+ response:
21
+ status:
22
+ code: 204
23
+ message: NO CONTENT
24
+ headers:
25
+ Accept-Ranges:
26
+ - bytes
27
+ Age:
28
+ - '0'
29
+ Content-Length:
30
+ - '0'
31
+ Content-Type:
32
+ - text/html; charset=utf-8
33
+ Date:
34
+ - Wed, 16 Nov 2016 05:06:53 GMT
35
+ Server:
36
+ - nginx/1.4.6 (Ubuntu)
37
+ Set-Cookie:
38
+ - session=eyJwd19oYXNoIjp7IiBiIjoiSkRKaEpEQTRKRlY0YVVacFNpODFUa3hhWTJWaE5sQmtPRWxwU0M1MEwyeHhjME0zVFZkbFJFWm1hQzUzVmpSQ2RuSkhjbGhuVGxjdVIweHAifX0.Cw167Q.Jw-ZHw-7tRKVPOEBUp0-o4fXp58;
39
+ HttpOnly; Path=/
40
+ Strict-Transport-Security:
41
+ - max-age=31536000
42
+ Via:
43
+ - 1.1 varnish
44
+ X-Varnish:
45
+ - '816986817'
46
+ Connection:
47
+ - keep-alive
48
+ body:
49
+ encoding: UTF-8
50
+ string: ''
51
+ http_version:
52
+ recorded_at: Wed, 16 Nov 2016 05:06:53 GMT
53
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,51 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: put
5
+ uri: https://example_api_token:@ac.cnstrc.com/v1/item?autocomplete_key=example_autocomplete_key&force=1
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"item_name":"power_drill","autocomplete_section":"Search Suggestions"}'
9
+ headers:
10
+ User-Agent:
11
+ - Faraday v0.9.1
12
+ Content-Type:
13
+ - application/json
14
+ Accept-Encoding:
15
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
16
+ Accept:
17
+ - "*/*"
18
+ response:
19
+ status:
20
+ code: 204
21
+ message: NO CONTENT
22
+ headers:
23
+ Accept-Ranges:
24
+ - bytes
25
+ Age:
26
+ - '0'
27
+ Content-Length:
28
+ - '0'
29
+ Content-Type:
30
+ - text/html; charset=utf-8
31
+ Date:
32
+ - Wed, 16 Nov 2016 05:06:52 GMT
33
+ Server:
34
+ - nginx/1.4.6 (Ubuntu)
35
+ Set-Cookie:
36
+ - session=eyJwd19oYXNoIjp7IiBiIjoiSkRKaEpEQTRKRlY0YVVacFNpODFUa3hhWTJWaE5sQmtPRWxwU0M1MEwyeHhjME0zVFZkbFJFWm1hQzUzVmpSQ2RuSkhjbGhuVGxjdVIweHAifX0.Cw167A.J1MXRYqdpA5qlEKI0AfwHKspaJQ;
37
+ HttpOnly; Path=/
38
+ Strict-Transport-Security:
39
+ - max-age=31536000
40
+ Via:
41
+ - 1.1 varnish
42
+ X-Varnish:
43
+ - '739215593'
44
+ Connection:
45
+ - keep-alive
46
+ body:
47
+ encoding: UTF-8
48
+ string: ''
49
+ http_version:
50
+ recorded_at: Wed, 16 Nov 2016 05:06:52 GMT
51
+ recorded_with: VCR 2.9.3
@@ -2,10 +2,10 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: delete
5
- uri: https://example_api_token:@devac.cnstrc.com/v1/item?autocomplete_key=example_autocomplete_key
5
+ uri: https://example_api_token:@ac.cnstrc.com/v1/item?autocomplete_key=example_autocomplete_key
6
6
  body:
7
7
  encoding: UTF-8
8
- string: '{"item_name":"power_drill","autocomplete_section":"standard","suggested_score":10}'
8
+ string: '{"item_name":"power_drill","autocomplete_section":"Search Suggestions","suggested_score":10}'
9
9
  headers:
10
10
  User-Agent:
11
11
  - Faraday v0.9.1
@@ -29,23 +29,23 @@ http_interactions:
29
29
  Content-Type:
30
30
  - text/html; charset=utf-8
31
31
  Date:
32
- - Fri, 16 Oct 2015 16:32:45 GMT
32
+ - Wed, 16 Nov 2016 05:06:52 GMT
33
33
  Server:
34
34
  - nginx/1.4.6 (Ubuntu)
35
35
  Set-Cookie:
36
- - session=eyJwd19oYXNoIjp7IiBiIjoiSkRKaEpEQTRKRkpQY1RkNGJGSnlOeTlzWXpaVFYzWkNjbFYyUkM1YVZqQXlZMjlUVVM5b05DNVZhRlJUVG5Bek5XSlZVVFZ0UXpobWNrd3kifX0.CQK4LQ.pCfOTI1WpHfQS43FrXjaoC69dE4;
36
+ - session=eyJwd19oYXNoIjp7IiBiIjoiSkRKaEpEQTRKRlY0YVVacFNpODFUa3hhWTJWaE5sQmtPRWxwU0M1MEwyeHhjME0zVFZkbFJFWm1hQzUzVmpSQ2RuSkhjbGhuVGxjdVIweHAifX0.Cw167A.J1MXRYqdpA5qlEKI0AfwHKspaJQ;
37
37
  HttpOnly; Path=/
38
38
  Strict-Transport-Security:
39
39
  - max-age=31536000
40
40
  Via:
41
41
  - 1.1 varnish
42
42
  X-Varnish:
43
- - '1717338812'
43
+ - '1827964802'
44
44
  Connection:
45
45
  - keep-alive
46
46
  body:
47
47
  encoding: UTF-8
48
48
  string: ''
49
49
  http_version:
50
- recorded_at: Fri, 16 Oct 2015 16:32:42 GMT
50
+ recorded_at: Wed, 16 Nov 2016 05:06:52 GMT
51
51
  recorded_with: VCR 2.9.3
@@ -0,0 +1,53 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: delete
5
+ uri: https://example_api_token:@ac.cnstrc.com/v1/batch_items?autocomplete_key=example_autocomplete_key
6
+ body:
7
+ encoding: UTF-8
8
+ string: '{"autocomplete_section":"Search Suggestions","items":[{"item_name":"power_drill
9
+ x1"},{"item_name":"power_drill x2"},{"item_name":"power_drill x3"},{"item_name":"power_drill
10
+ x4"}]}'
11
+ headers:
12
+ User-Agent:
13
+ - Faraday v0.9.1
14
+ Content-Type:
15
+ - application/json
16
+ Accept-Encoding:
17
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
18
+ Accept:
19
+ - "*/*"
20
+ response:
21
+ status:
22
+ code: 204
23
+ message: NO CONTENT
24
+ headers:
25
+ Accept-Ranges:
26
+ - bytes
27
+ Age:
28
+ - '0'
29
+ Content-Length:
30
+ - '0'
31
+ Content-Type:
32
+ - text/html; charset=utf-8
33
+ Date:
34
+ - Wed, 16 Nov 2016 05:06:54 GMT
35
+ Server:
36
+ - nginx/1.4.6 (Ubuntu)
37
+ Set-Cookie:
38
+ - session=eyJwd19oYXNoIjp7IiBiIjoiSkRKaEpEQTRKRlY0YVVacFNpODFUa3hhWTJWaE5sQmtPRWxwU0M1MEwyeHhjME0zVFZkbFJFWm1hQzUzVmpSQ2RuSkhjbGhuVGxjdVIweHAifX0.Cw167g.bIpQgiI5kG0qDYfl2X7PMJIq-H0;
39
+ HttpOnly; Path=/
40
+ Strict-Transport-Security:
41
+ - max-age=31536000
42
+ Via:
43
+ - 1.1 varnish
44
+ X-Varnish:
45
+ - '1827964805'
46
+ Connection:
47
+ - keep-alive
48
+ body:
49
+ encoding: UTF-8
50
+ string: ''
51
+ http_version:
52
+ recorded_at: Wed, 16 Nov 2016 05:06:53 GMT
53
+ recorded_with: VCR 2.9.3
@@ -2,10 +2,10 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: delete
5
- uri: https://example_api_token:@devac.cnstrc.com/v1/item?autocomplete_key=example_autocomplete_key
5
+ uri: https://example_api_token:@ac.cnstrc.com/v1/item?autocomplete_key=example_autocomplete_key
6
6
  body:
7
7
  encoding: UTF-8
8
- string: '{"item_name":"power_drill","autocomplete_section":"standard"}'
8
+ string: '{"item_name":"power_drill","autocomplete_section":"Search Suggestions"}'
9
9
  headers:
10
10
  User-Agent:
11
11
  - Faraday v0.9.1
@@ -29,23 +29,23 @@ http_interactions:
29
29
  Content-Type:
30
30
  - text/html; charset=utf-8
31
31
  Date:
32
- - Fri, 16 Oct 2015 16:32:33 GMT
32
+ - Wed, 16 Nov 2016 05:06:51 GMT
33
33
  Server:
34
34
  - nginx/1.4.6 (Ubuntu)
35
35
  Set-Cookie:
36
- - session=eyJwd19oYXNoIjp7IiBiIjoiSkRKaEpEQTRKRkpQY1RkNGJGSnlOeTlzWXpaVFYzWkNjbFYyUkM1YVZqQXlZMjlUVVM5b05DNVZhRlJUVG5Bek5XSlZVVFZ0UXpobWNrd3kifX0.CQK4IQ.H03aEqDi2KY5OCpQiI02AdxSZ00;
36
+ - session=eyJwd19oYXNoIjp7IiBiIjoiSkRKaEpEQTRKRlY0YVVacFNpODFUa3hhWTJWaE5sQmtPRWxwU0M1MEwyeHhjME0zVFZkbFJFWm1hQzUzVmpSQ2RuSkhjbGhuVGxjdVIweHAifX0.Cw166w.0Z3Yfne0N19DLbcLyMC7q1rjvRU;
37
37
  HttpOnly; Path=/
38
38
  Strict-Transport-Security:
39
39
  - max-age=31536000
40
40
  Via:
41
41
  - 1.1 varnish
42
42
  X-Varnish:
43
- - '1717338807'
43
+ - '1827964801'
44
44
  Connection:
45
45
  - keep-alive
46
46
  body:
47
47
  encoding: UTF-8
48
48
  string: ''
49
49
  http_version:
50
- recorded_at: Fri, 16 Oct 2015 16:32:30 GMT
50
+ recorded_at: Wed, 16 Nov 2016 05:06:51 GMT
51
51
  recorded_with: VCR 2.9.3
data/test/test_helper.rb CHANGED
@@ -6,5 +6,5 @@ require_relative '../lib/constructorio'
6
6
  ConstructorIO.configure do |config|
7
7
  config.api_token = ENV['CONSTRUCTORIO_API_TOKEN'] || "example_api_token"
8
8
  config.autocomplete_key = ENV['CONSTRUCTORIO_AUTOCOMPLETE_KEY'] || "example_autocomplete_key"
9
- config.api_url = "https://devac.cnstrc.com"
9
+ config.api_url = "https://ac.cnstrc.com"
10
10
  end
metadata CHANGED
@@ -1,35 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: constructorio
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.8
4
+ version: 2.0.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan McCormick
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-15 00:00:00.000000000 Z
11
+ date: 2021-03-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '0.9'
20
17
  - - ">="
21
18
  - !ruby/object:Gem::Version
22
- version: 0.9.0
19
+ version: '1.0'
20
+ - - "~>"
21
+ - !ruby/object:Gem::Version
22
+ version: '1.0'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
- - - "~>"
28
- - !ruby/object:Gem::Version
29
- version: '0.9'
30
27
  - - ">="
31
28
  - !ruby/object:Gem::Version
32
- version: 0.9.0
29
+ version: '1.0'
30
+ - - "~>"
31
+ - !ruby/object:Gem::Version
32
+ version: '1.0'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: bundler
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -82,22 +82,22 @@ dependencies:
82
82
  name: mocha
83
83
  requirement: !ruby/object:Gem::Requirement
84
84
  requirements:
85
- - - "~>"
86
- - !ruby/object:Gem::Version
87
- version: '1.1'
88
85
  - - ">="
89
86
  - !ruby/object:Gem::Version
90
87
  version: 1.1.0
88
+ - - "~>"
89
+ - !ruby/object:Gem::Version
90
+ version: '1.1'
91
91
  type: :development
92
92
  prerelease: false
93
93
  version_requirements: !ruby/object:Gem::Requirement
94
94
  requirements:
95
- - - "~>"
96
- - !ruby/object:Gem::Version
97
- version: '1.1'
98
95
  - - ">="
99
96
  - !ruby/object:Gem::Version
100
97
  version: 1.1.0
98
+ - - "~>"
99
+ - !ruby/object:Gem::Version
100
+ version: '1.1'
101
101
  - !ruby/object:Gem::Dependency
102
102
  name: minitest
103
103
  requirement: !ruby/object:Gem::Requirement
@@ -169,16 +169,21 @@ files:
169
169
  - test/constructorio_test.rb
170
170
  - test/constructorio_vcr_test.rb
171
171
  - test/constructorio_vcr_test_errors.rb
172
+ - test/fixtures/vcr_cassettes/add_batch.yml
173
+ - test/fixtures/vcr_cassettes/add_batch_with_metadata.yml
172
174
  - test/fixtures/vcr_cassettes/add_item.yml
173
- - test/fixtures/vcr_cassettes/add_item_error.yml
175
+ - test/fixtures/vcr_cassettes/add_item_with_metadata.yml
176
+ - test/fixtures/vcr_cassettes/add_or_update_batch.yml
177
+ - test/fixtures/vcr_cassettes/add_or_update_item.yml
174
178
  - test/fixtures/vcr_cassettes/modify_item.yml
179
+ - test/fixtures/vcr_cassettes/remove_batch.yml
175
180
  - test/fixtures/vcr_cassettes/remove_item.yml
176
181
  - test/test_helper.rb
177
182
  homepage: http://constructor.io
178
183
  licenses:
179
184
  - MIT
180
185
  metadata: {}
181
- post_install_message:
186
+ post_install_message:
182
187
  rdoc_options: []
183
188
  require_paths:
184
189
  - lib
@@ -193,9 +198,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
193
198
  - !ruby/object:Gem::Version
194
199
  version: '0'
195
200
  requirements: []
196
- rubyforge_project:
197
- rubygems_version: 2.2.2
198
- signing_key:
201
+ rubygems_version: 3.0.8
202
+ signing_key:
199
203
  specification_version: 4
200
204
  summary: Ruby gem for Constructor.io
201
205
  test_files:
@@ -203,8 +207,13 @@ test_files:
203
207
  - test/constructorio_test.rb
204
208
  - test/constructorio_vcr_test.rb
205
209
  - test/constructorio_vcr_test_errors.rb
210
+ - test/fixtures/vcr_cassettes/add_batch.yml
211
+ - test/fixtures/vcr_cassettes/add_batch_with_metadata.yml
206
212
  - test/fixtures/vcr_cassettes/add_item.yml
207
- - test/fixtures/vcr_cassettes/add_item_error.yml
213
+ - test/fixtures/vcr_cassettes/add_item_with_metadata.yml
214
+ - test/fixtures/vcr_cassettes/add_or_update_batch.yml
215
+ - test/fixtures/vcr_cassettes/add_or_update_item.yml
208
216
  - test/fixtures/vcr_cassettes/modify_item.yml
217
+ - test/fixtures/vcr_cassettes/remove_batch.yml
209
218
  - test/fixtures/vcr_cassettes/remove_item.yml
210
219
  - test/test_helper.rb
@@ -1,99 +0,0 @@
1
- ---
2
- http_interactions:
3
- - request:
4
- method: post
5
- uri: https://Bad%20token:@devac.cnstrc.com/v1/item?autocomplete_key=example_autocomplete_key
6
- body:
7
- encoding: UTF-8
8
- string: '{"item_name":"power_drill","autocomplete_section":"standard"}'
9
- headers:
10
- User-Agent:
11
- - Faraday v0.9.1
12
- Content-Type:
13
- - application/json
14
- Accept-Encoding:
15
- - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
16
- Accept:
17
- - "*/*"
18
- response:
19
- status:
20
- code: 401
21
- message: UNAUTHORIZED
22
- headers:
23
- Accept-Ranges:
24
- - bytes
25
- Age:
26
- - '0'
27
- Content-Type:
28
- - application/json
29
- Date:
30
- - Fri, 16 Oct 2015 16:38:59 GMT
31
- Server:
32
- - nginx/1.4.6 (Ubuntu)
33
- Strict-Transport-Security:
34
- - max-age=31536000
35
- Via:
36
- - 1.1 varnish
37
- X-Varnish:
38
- - '1717338970'
39
- Content-Length:
40
- - '120'
41
- Connection:
42
- - keep-alive
43
- body:
44
- encoding: UTF-8
45
- string: |-
46
- {
47
- "message": "Invalid auth_token. If you've forgotten your token, you can generate a new one in the admin dashboard"
48
- }
49
- http_version:
50
- recorded_at: Fri, 16 Oct 2015 16:38:57 GMT
51
- - request:
52
- method: post
53
- uri: https://example_api_token:@devac.cnstrc.com/v1/item?autocomplete_key=bad_autocomplete_key
54
- body:
55
- encoding: UTF-8
56
- string: '{"item_name":"power_drill","autocomplete_section":"standard"}'
57
- headers:
58
- User-Agent:
59
- - Faraday v0.9.1
60
- Content-Type:
61
- - application/json
62
- Accept-Encoding:
63
- - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
64
- Accept:
65
- - "*/*"
66
- response:
67
- status:
68
- code: 401
69
- message: UNAUTHORIZED
70
- headers:
71
- Accept-Ranges:
72
- - bytes
73
- Age:
74
- - '0'
75
- Content-Type:
76
- - application/json
77
- Date:
78
- - Fri, 16 Oct 2015 16:40:14 GMT
79
- Server:
80
- - nginx/1.4.6 (Ubuntu)
81
- Strict-Transport-Security:
82
- - max-age=31536000
83
- Via:
84
- - 1.1 varnish
85
- X-Varnish:
86
- - '1717338996'
87
- Content-Length:
88
- - '126'
89
- Connection:
90
- - keep-alive
91
- body:
92
- encoding: UTF-8
93
- string: |-
94
- {
95
- "message": "You have supplied an invalid autocomplete key. Look up your valid autocomplete key in your admin dashboard."
96
- }
97
- http_version:
98
- recorded_at: Fri, 16 Oct 2015 16:40:11 GMT
99
- recorded_with: VCR 2.9.3