chatmeter 1.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,368 @@
1
+ module Chatmeter
2
+ class API
3
+ module Mock
4
+
5
+ # stub GET /dashboard/reviewReport
6
+ Excon.stub(expects: 200, method: :get, path: '/v5/dashboard/reviewReport') do |params|
7
+ request_params, mock_data = parse_stub_params(params)
8
+ {
9
+ body: {
10
+ "dateRange":{
11
+ "startDate":"2016-03",
12
+ "endDate":"2016-06"
13
+ },
14
+ "periodSummary":{
15
+ "count":1142,
16
+ "countWithResponses":218,
17
+ "oneStarRatings":128,
18
+ "fiveStarRatings":604,
19
+ "avgRating":4.0275454545454545,
20
+ "countByRating":{
21
+ "4star":234,
22
+ "2star":54,
23
+ "3star":80,
24
+ "5star":604,
25
+ "1star":128
26
+ }
27
+ },
28
+ "competitorsPeriodSummary":{
29
+ "count":160,
30
+ "countWithResponses":41,
31
+ "oneStarRatings":17,
32
+ "fiveStarRatings":100,
33
+ "avgRating":4.1580547112462005,
34
+ "countByRating":{
35
+ "4star":21,
36
+ "2star":7,
37
+ "3star":10,
38
+ "5star":100,
39
+ "1star":17
40
+ }
41
+ },
42
+ "totalSummary":{
43
+ "count":31217,
44
+ "countWithResponses":1763,
45
+ "oneStarRatings":2268,
46
+ "fiveStarRatings":17142,
47
+ "avgRating":4.144513477975017,
48
+ "countByRating":{
49
+ "4star":6607,
50
+ "2star":1502,
51
+ "3star":2901,
52
+ "5star":17142,
53
+ "1star":2268
54
+ }
55
+ },
56
+ "competitorsTotalSummary":{
57
+ "count":37754,
58
+ "countWithResponses":1429,
59
+ "oneStarRatings":1910,
60
+ "fiveStarRatings":21718,
61
+ "avgRating":4.265295391681018,
62
+ "countByRating":{
63
+ "4star":7808,
64
+ "2star":1579,
65
+ "3star":3167,
66
+ "5star":21718,
67
+ "1star":1910
68
+ }
69
+ },
70
+ "reviewsByPeriod":{
71
+ "period":"Month",
72
+ "values":{
73
+ "2016-05":{
74
+ "total":348,
75
+ "avgRating":3.957057057057057
76
+ },
77
+ "2016-04":{
78
+ "total":418,
79
+ "avgRating":4.072319201995012
80
+ },
81
+ "2016-03":{
82
+ "total":376,
83
+ "avgRating":4.042622950819672
84
+ }
85
+ }
86
+ },
87
+ "providerReport":{
88
+ "BING":{
89
+ "lastRating":1,
90
+ "count":139,
91
+ "avgRating":3.8333333333333335
92
+ },
93
+ "YELLOWPAGES":{
94
+ "count":0
95
+ },
96
+ "YELPCA":{
97
+ "lastRating":1,
98
+ "count":5,
99
+ "avgRating":4
100
+ },
101
+ "OPENTABLE":{
102
+ "lastRating":4,
103
+ "count":55,
104
+ "avgRating":4.127272727272727
105
+ },
106
+ "YAHOOCA":{
107
+ "count":0
108
+ },
109
+ "DEALERRATER":{
110
+ "lastRating":5,
111
+ "count":34,
112
+ "avgRating":4.626470588235294
113
+ },
114
+ "INSIDERPAGES":{
115
+ "lastRating":5,
116
+ "count":1,
117
+ "avgRating":5
118
+ },
119
+ "APARTMENTRATINGS":{
120
+ "lastRating":5,
121
+ "count":2,
122
+ "avgRating":5
123
+ },
124
+ "YAHOO":{
125
+ "lastRating":2,
126
+ "count":132,
127
+ "avgRating":3.792307692307692
128
+ },
129
+ "DOCTOROOGLE":{
130
+ "count":0
131
+ },
132
+ "FACEBOOK":{
133
+ "lastRating":5,
134
+ "count":106,
135
+ "avgRating":4.122641509433962
136
+ },
137
+ "SCOOT":{
138
+ "count":0
139
+ },
140
+ "YELPGB":{
141
+ "lastRating":3,
142
+ "count":5,
143
+ "avgRating":2.6
144
+ },
145
+ "CITYSEARCH":{
146
+ "lastRating":5,
147
+ "count":1,
148
+ "avgRating":5
149
+ },
150
+ "HEALTHGRADES":{
151
+ "count":0
152
+ },
153
+ "EDMUNDS":{
154
+ "lastRating":1,
155
+ "count":1,
156
+ "avgRating":1
157
+ },
158
+ "ZOCDOC":{
159
+ "count":0
160
+ },
161
+ "CARS":{
162
+ "lastRating":1,
163
+ "count":6,
164
+ "avgRating":3.3333333333333335
165
+ },
166
+ "ZOMATO":{
167
+ "lastRating":3,
168
+ "count":2,
169
+ "avgRating":3
170
+ },
171
+ "REALSELF":{
172
+ "count":0
173
+ },
174
+ "SUPERPAGES":{
175
+ "lastRating":5,
176
+ "count":1,
177
+ "avgRating":5
178
+ },
179
+ "GOOGLE":{
180
+ "lastRating":5,
181
+ "count":258,
182
+ "avgRating":4.12015503875969
183
+ },
184
+ "MERCHANTCIRCLE":{
185
+ "count":0
186
+ },
187
+ "YELL":{
188
+ "count":0
189
+ },
190
+ "FOURSQUARE":{
191
+ "count":15
192
+ },
193
+ "APARTMENTGUIDE":{
194
+ "count":0
195
+ },
196
+ "TRIPADVISOR":{
197
+ "lastRating":4,
198
+ "count":217,
199
+ "avgRating":4.336405529953917
200
+ },
201
+ "YELLOWPAGESCA":{
202
+ "count":0
203
+ },
204
+ "YELP":{
205
+ "lastRating":2,
206
+ "count":162,
207
+ "avgRating":3.6419753086419755
208
+ }
209
+ }
210
+ },
211
+ status: 200
212
+ }
213
+ end
214
+
215
+ reviews = {
216
+ "reviews": [
217
+ {
218
+ "id": "1048748",
219
+ "locationId": "123111",
220
+ "contentProvider": "YELP",
221
+ "rating": 5.0,
222
+ "reviewerUserName": "NA",
223
+ "reviewerPictureURL": "NA",
224
+ "reviewDetail": "Itook my 2008 Buick Lacerne to ValMark Cheverolet on 8/12/11 concerning vibration san noise. Roger Bittner, my service representative for several years, greated me in a friendly and courteous manner as always. He accepted the car for service and found the motor mounts were broken. Mounts were ordered and installed under warnty. This did not solve the noise problem. After checkin, Roger called to tell me the cost of repairs would be $1,055.00 to install new struts and mounts. I told Roger that in view of all the problems I have with the car since new, I would pick up the car unrepaired around 5;30 P.M. At about 3;30 P.M., Jim the service manager called to say that Roger informed him of the problem. With Roger in his office, they called General Motors concerning the issue, and General Motors agreed to cover all but $300.00 Dollars. The car was then repaird and picked up 8/23/11. Roger Bittner is truly an asset to ValMark and its customers. Sincerely, Erwin C. Tschoepe, Jr.",
225
+ "reviewURL": "http://www.dealerrater.com/dealer/ValMark-Chevrolet-review-22508/page11/",
226
+ "responseURL":"https://biz.yelp.com/r2r/sqoouYxSEiLrf8ZppuLmzQ",
227
+ "reviewDate": "2011-09-03",
228
+ "responses": [
229
+ {
230
+ "responseUserName": "Dealership Owner",
231
+ "responseUserTitle": "Business Owner",
232
+ "responseDetail": "We appreciate your custom",
233
+ "responseDate": "2015-08-17 00:00:00"
234
+ }
235
+ ],
236
+ "dateAdded": "2013-02-21 14:53:23.0",
237
+ "lastUpdated": "2013-02-21 14:52:02.0"
238
+ },
239
+ {
240
+ "id": "1048749",
241
+ "locationId": "123111",
242
+ "contentProvider": "DEALERRATER",
243
+ "rating": 5.0,
244
+ "reviewerUserName": "NA",
245
+ "reviewerPictureURL": "NA",
246
+ "reviewDetail": "Great experience, realistic trade in allowance ($2500 more than anyone else!), Good price on the vehicle I wanted. No need to haggle- one of those rare times when you feel as if both sides were happy. Definitely buy your next car there!",
247
+ "reviewURL": "http://www.dealerrater.com/dealer/ValMark-Chevrolet-review-22508/page11/",
248
+ "responseURL":"https://biz.yelp.com/r2r/sqeorYxTEiLrf8ZppcLmzQ",
249
+ "reviewDate": "2011-09-02",
250
+ "responses": [],
251
+ "dateAdded": "2013-02-21 14:53:23.0",
252
+ "lastUpdated": "2013-02-21 14:52:02.0"
253
+ }
254
+ ],
255
+ "hasMore": true
256
+ }
257
+
258
+ # stub GET /reviews
259
+ Excon.stub(expects: 200, method: :get, path: '/v5/reviews') do |params|
260
+ request_params, mock_data = parse_stub_params(params)
261
+ {
262
+ body: reviews,
263
+ status: 200
264
+ }
265
+ end
266
+
267
+ # stub GET /reviews/{reviewId}
268
+ Excon.stub(expects: 200, method: :get, path: %r{^/v5/reviews/([^/]+)$}) do |params|
269
+ request_params, mock_data = parse_stub_params(params)
270
+ {
271
+ body: reviews,
272
+ status: 200
273
+ }
274
+ end
275
+
276
+ # stub POST /reviews/{ReviewId}/responses
277
+ Excon.stub(expects: 200, method: :post, path: %r{^/v5/reviews/([^/]+)/responses$}) do |params|
278
+ request_params, mock_data = parse_stub_params(params)
279
+ {
280
+ body: {
281
+ "reviewResponse": {
282
+ "id": "59b6d56fb64adcbec92acaff",
283
+ "responseUserName": "Location Name Here",
284
+ "responseDetail": "Thank you for your review",
285
+ "responseDate": "2017-09-11T11:26:55.416-07:00",
286
+ "isFromOwner": true,
287
+ "authorUserId": "5952c822a49444c45fe28482",
288
+ "publishingStatus": "PUBLISHED"
289
+ }
290
+ },
291
+ status: 200
292
+ }
293
+ end
294
+
295
+ # stub GET /reviews/reports/{ReviewId}
296
+ Excon.stub(expects: 200, method: :get, path: %r{^/v5/reviews/reports/([^/]+)$}) do |params|
297
+ request_params, mock_data = parse_stub_params(params)
298
+ {
299
+ body: {
300
+ "reportResults": [
301
+ {
302
+ "id": {
303
+ "locationId": "123111",
304
+ "contentProvider": "DEALERRATER"
305
+ },
306
+ "value":{
307
+ "count": 1,
308
+ "countByRating": {
309
+ "4star": 0,
310
+ "2star": 0,
311
+ "3star": 0,
312
+ "5star": 1,
313
+ "0star": 0,
314
+ "1star": 0
315
+ },
316
+ "avgRating": 5.0
317
+ }
318
+ }
319
+ ],
320
+ "hasMore": true
321
+ },
322
+ status: 200
323
+ }
324
+ end
325
+
326
+ # stub POST /reviews
327
+ Excon.stub(expects: [200, 201], method: :post, path: '/v5/reviews') do |params|
328
+ request_params, mock_data = parse_stub_params(params)
329
+ {
330
+ status: 200
331
+ }
332
+ end
333
+
334
+ # stub POST /reviews/{ReviewId}/notMine
335
+ Excon.stub(expects: 200, method: :post, path: %r{^/v5/reviews/([^/]+)/notMine$}) do |params|
336
+ request_params, mock_data = parse_stub_params(params)
337
+ {
338
+ status: 200
339
+ }
340
+ end
341
+
342
+ # stub DELETE /reviews/{ReviewId}
343
+ Excon.stub(expects: 200, method: :delete, path: %r{^/v5/reviews/([^/]+)$}) do |params|
344
+ request_params, mock_data = parse_stub_params(params)
345
+ {
346
+ body: {
347
+ "totalFound": 2,
348
+ "hasMore": false,
349
+ "reviews": [
350
+ {
351
+ "reviewId": "580169412ab4c9b057dcb869",
352
+ "removedOn": "2017-03-20T23:33:25.537Z",
353
+ "reason": "flagged as duplicate"
354
+ },
355
+ {
356
+ "reviewId": "580169412ab4c9b057dcb86b",
357
+ "removedOn": "2017-03-20T23:33:25.534Z",
358
+ "reason": "flagged as duplicate"
359
+ }
360
+ ]
361
+ },
362
+ status: 200
363
+ }
364
+ end
365
+
366
+ end
367
+ end
368
+ end
@@ -0,0 +1,18 @@
1
+ module Chatmeter
2
+ class API
3
+ module Mock
4
+
5
+ # GET /v5/singlesignon/generateLoginToken?username={username}
6
+ Excon.stub(expects: 200, method: :get, path: %r{^/v5/singlesignon/generateLoginToken\?username=([^/]+)$}) do |params|
7
+ request_params, mock_data = parse_stub_params(params)
8
+ {
9
+ body: '{
10
+ "ssoToken":"284c4b1e-090c-420a-8479-c39617b264dc"
11
+ }',
12
+ status: 200
13
+ }
14
+ end
15
+
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,41 @@
1
+ module Chatmeter
2
+ class API
3
+ module Mock
4
+
5
+ # stub GET /users/{user_id}/groups
6
+ Excon.stub(expects: 200, method: :get, path: %r{^/v5/users/([^/]+)/groups$}) do |params|
7
+ request_params, mock_data = parse_stub_params(params)
8
+ {
9
+ body: {
10
+ "groups": [
11
+ {
12
+ "id": "406ab658-7f13-11e4-b116-123b93f75cba",
13
+ "accountId": "232",
14
+ "groupName": "Coffee shop San Diego"
15
+ }
16
+ ],
17
+ "hasMore": false
18
+ },
19
+ status: 200
20
+ }
21
+ end
22
+
23
+ # stub POST /users/{user_id}/groups
24
+ Excon.stub(expects: 200, method: :post, path: %r{^/v5/users/([^/]+)/groups$}) do |params|
25
+ request_params, mock_data = parse_stub_params(params)
26
+ {
27
+ status: 200
28
+ }
29
+ end
30
+
31
+ # stub DELETE /users/{user_id}/groups?groupIds={group_ids}
32
+ Excon.stub(expects: 200, method: :delete, path: %r{^/v5/users/([^/]+)/groups(.*)$}) do |params|
33
+ request_params, mock_data = parse_stub_params(params)
34
+ {
35
+ status: 200
36
+ }
37
+ end
38
+
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,38 @@
1
+ module Chatmeter
2
+ class API
3
+ module Mock
4
+
5
+ # stub GET /users/{user_id}/locations
6
+ Excon.stub(expects: 200, method: :get, path: %r{^/v5/users/([^/]+)/locations$}) do |params|
7
+ request_params, mock_data = parse_stub_params(params)
8
+ {
9
+ status: 200
10
+ }
11
+ end
12
+
13
+ # stub POST /users/{user_id}/groups
14
+ Excon.stub(expects: 200, method: :post, path: %r{^/v5/users/([^/]+)/locations$}) do |params|
15
+ request_params, mock_data = parse_stub_params(params)
16
+ {
17
+ status: 200
18
+ }
19
+ end
20
+
21
+ # stub DELETE /users/{user_id}/locations?locationIds={group_ids}
22
+ Excon.stub(expects: 200, method: :delete, path: %r{^/v5/users/([^/]+)/locations(.*)$}) do |params|
23
+ request_params, mock_data = parse_stub_params(params)
24
+ {
25
+ status: 200
26
+ }
27
+ end
28
+
29
+ Excon.stub(expects: 200, method: :post, path: %r{^/v5/users/([^/]+)/locations/delete}) do |params|
30
+ request_params, mock_data = parse_stub_params(params)
31
+ {
32
+ status: 200
33
+ }
34
+ end
35
+
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,108 @@
1
+ module Chatmeter
2
+ class API
3
+ module Mock
4
+
5
+ # stub GET /users/
6
+ Excon.stub(expects: 200, method: :get, path: '/v5/users') do |params|
7
+ request_params, mock_data = parse_stub_params(params)
8
+ {
9
+ body: '{
10
+ "users": [
11
+ {
12
+ "id": "3233",
13
+ "accountId": "23232",
14
+ "username": "TestUser",
15
+ "email": "user@test.com",
16
+ "phoneNumber": "555555555",
17
+ "firstName": "test",
18
+ "lastName": "User",
19
+ "userType": "Standard"
20
+ }
21
+ ],
22
+ "hasMore": false
23
+ }',
24
+ status: 200
25
+ }
26
+ end
27
+
28
+ # stub GET /user/{user_id}
29
+ Excon.stub(expects: 200, method: :get, path: %r{^/v5/user/([^/]+)$}) do |params|
30
+ request_params, mock_data = parse_stub_params(params)
31
+ {
32
+ body: {
33
+ "id": "5877d8e8b71466175f392449",
34
+ "username": "companyuser",
35
+ "email": "billsmith@company.com",
36
+ "phoneNumber": "8443245000",
37
+ "firstName": "Bill",
38
+ "lastName": "Smith",
39
+ "userType": "Standard",
40
+ "accountId": "5997d8bbee5427ff15007df1",
41
+ "enabled": true,
42
+ "alertEmails": false,
43
+ "permissionOverrides": []
44
+ },
45
+ status: 200
46
+ }
47
+ end
48
+
49
+ # stub POST /users
50
+ Excon.stub(expects: 200, method: :post, path: '/v5/users') do |params|
51
+ {
52
+ body: '{
53
+ "accountId": "23232",
54
+ "username": "TestUser",
55
+ "email": "user@test.com",
56
+ "phoneNumber": "555555555",
57
+ "firstName": "Test",
58
+ "lastName": "User",
59
+ "userType": "Standard"
60
+ }',
61
+ status: 200
62
+ }
63
+ end
64
+
65
+ # stub PUT /users/{user_id}
66
+ Excon.stub(expects: 200, method: :put, path: %r{^/v5/users/([^/]+)$}) do |params|
67
+ request_params, mock_data = parse_stub_params(params)
68
+ {
69
+ body: {
70
+ "accountId": request_params[:body]["accountId"],
71
+ "username": request_params[:body]["username"],
72
+ "email": request_params[:body]["email"],
73
+ "phoneNumber": request_params[:body]["phoneNumber"],
74
+ "firstName": request_params[:body]["firstName"],
75
+ "lastName": request_params[:body]["lastName"],
76
+ "userType": request_params[:body]["userType"]
77
+ },
78
+ status: 200
79
+ }
80
+ end
81
+
82
+ # stub PUT /users/{user_id}/password
83
+ Excon.stub(expects: 200, method: :put, path: %r{^/v5/users/([^/]+)/password$}) do |params|
84
+ request_params, mock_data = parse_stub_params(params)
85
+ {
86
+ status: 200
87
+ }
88
+ end
89
+
90
+ # stub DELETE /users/{user_id}
91
+ Excon.stub(expects: 200, method: :delete, path: %r{^/v5/users/([^/]+)$}) do |params|
92
+ request_params, mock_data = parse_stub_params(params)
93
+ {
94
+ status: 200
95
+ }
96
+ end
97
+
98
+ # stub POST /users/{user_id}/status
99
+ Excon.stub(expects: 200, method: :post, path: %r{^/v5/users/([^/]+)/status$}) do |params|
100
+ request_params, mock_data = parse_stub_params(params)
101
+ {
102
+ status: 200
103
+ }
104
+ end
105
+
106
+ end
107
+ end
108
+ end
@@ -0,0 +1,39 @@
1
+ require 'chatmeter/api/mock/user_management'
2
+ require 'chatmeter/api/mock/single_signon'
3
+ require 'chatmeter/api/mock/group'
4
+ require 'chatmeter/api/mock/user_group_access'
5
+ require 'chatmeter/api/mock/user_location_access'
6
+ require 'chatmeter/api/mock/login'
7
+ require 'chatmeter/api/mock/location'
8
+ require 'chatmeter/api/mock/review'
9
+ require 'chatmeter/api/mock/account'
10
+ require 'chatmeter/api/mock/campaign'
11
+
12
+ module Chatmeter
13
+ class API
14
+ module Mock
15
+
16
+ @mock_data = Hash.new do |hash, key|
17
+ hash[key] = {}
18
+ end
19
+
20
+ def self.parse_stub_params(params)
21
+ mock_data = nil
22
+
23
+ if params[:headers].has_key?(:Authorization)
24
+ api_key = params[:headers][:Authorization]
25
+
26
+ parsed = params.dup
27
+ begin # try to JSON decode
28
+ parsed[:body] &&= MultiJson.load(parsed[:body])
29
+ rescue # else leave as is
30
+ end
31
+ mock_data = @mock_data[api_key]
32
+ end
33
+
34
+ [parsed, mock_data]
35
+ end
36
+
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,84 @@
1
+ module Chatmeter
2
+ class API
3
+
4
+ # GET /dashboard/reviewReport
5
+ def get_review_metrics(params={})
6
+ request(
7
+ expects: 200,
8
+ method: :get,
9
+ path: "/dashboard/reviewReport",
10
+ query: params
11
+ )
12
+ end
13
+
14
+ # GET /reviews
15
+ def get_all_reviews(params={})
16
+ request(
17
+ expects: 200,
18
+ method: :get,
19
+ path: "/reviews",
20
+ query: params
21
+ )[:reviews]
22
+ end
23
+
24
+ # GET /reviews/{reviewId}
25
+ def get_single_review(review_id)
26
+ request(
27
+ expects: 200,
28
+ method: :get,
29
+ path: "/reviews/#{review_id}"
30
+ )
31
+ end
32
+
33
+ # POST /reviews/{ReviewId}/responses
34
+ def respond_to_review(review_id, params)
35
+ request(
36
+ expects: 200,
37
+ method: :post,
38
+ path: "/reviews/#{review_id}/responses",
39
+ body: params.to_json
40
+ )
41
+ end
42
+
43
+ # GET /reviews/reports/{ReportId}
44
+ def aggregate_reports(review_id, params={})
45
+ request(
46
+ expects: 200,
47
+ method: :get,
48
+ path: "/reviews/reports/{report_id}",
49
+ query: params
50
+ )
51
+ end
52
+
53
+ # POST /v5/reviews
54
+ def add_reviews(params)
55
+ request(
56
+ expects: [200, 201],
57
+ method: :post,
58
+ path: "/reviews",
59
+ body: params.to_json
60
+ )
61
+ end
62
+
63
+ # POST /reviews/{reviewId}/notMine
64
+ def review_not_mine(review_id, params)
65
+ request(
66
+ expects: 200,
67
+ method: :post,
68
+ path: "/reviews/#{review_id}/notMine",
69
+ body: params.to_json
70
+ )
71
+ end
72
+
73
+ # DELETE /reviews/{review_id}
74
+ def delete_review(review_id, params)
75
+ request(
76
+ expects: 200,
77
+ method: :delete,
78
+ path: "/reviews/#{review_id}",
79
+ query: params
80
+ )
81
+ end
82
+
83
+ end
84
+ end