wix-hive-ruby 0.9.1 → 0.9.2
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.
- checksums.yaml +5 -13
- data/README.md +30 -16
- data/e2e/activities_api_spec.rb +44 -18
- data/e2e/contacts_api_spec.rb +57 -35
- data/e2e/e2e_helper.rb +0 -4
- data/lib/hive/activities/contact/contact_create_activity.rb +1 -1
- data/lib/hive/activities/contact/contact_form_activity.rb +1 -1
- data/lib/hive/activities/conversion/conversion_complete_activity.rb +2 -2
- data/lib/hive/activities/e_commerce/purchase_activity.rb +1 -1
- data/lib/hive/activities/factory.rb +5 -2
- data/lib/hive/activities/hotels/hotels_cancel_activity.rb +1 -1
- data/lib/hive/activities/hotels/hotels_confirmation_activity.rb +3 -1
- data/lib/hive/activities/hotels/hotels_purchase_activity.rb +1 -1
- data/lib/hive/activities/hotels/hotels_purchase_failed_activity.rb +1 -1
- data/lib/hive/activities/messaging/send_activity.rb +2 -2
- data/lib/hive/activities/music/album_fan_activity.rb +2 -16
- data/lib/hive/activities/music/album_played_activity.rb +36 -0
- data/lib/hive/activities/music/album_share_activity.rb +2 -2
- data/lib/hive/activities/music/track_lyrics_activity.rb +2 -9
- data/lib/hive/activities/music/track_play_activity.rb +2 -9
- data/lib/hive/activities/music/track_played_activity.rb +2 -9
- data/lib/hive/activities/music/track_share_activity.rb +2 -9
- data/lib/hive/activities/music/track_skipped_activity.rb +2 -9
- data/lib/hive/activities/scheduler/scheduler_appointment_activity.rb +1 -1
- data/lib/hive/rest/contacts.rb +34 -34
- data/lib/hive/version.rb +1 -1
- data/spec/hive/activities/conversion/conversion_complete_activity_spec.rb +1 -1
- data/spec/hive/activities/factory_spec.rb +7 -3
- data/spec/hive/activities/messaging/send_activity_spec.rb +1 -1
- data/spec/hive/rest/contacts_spec.rb +15 -15
- metadata +52 -50
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
MWI3MDdkOTNjZGY0YjIyMDY4OWI0YTI2MmE1N2VlNTMwYzM4OGEwNw==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b9c0a428e9d239062e4bed3ecd09e30c80d5e221
|
4
|
+
data.tar.gz: 7456a654728360f4c7ecc7d265aab7c862beced0
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
Njg2NDg5ZTQ0MjM0NjllMmY1YmFlZjQ5YjcwMzk5MjZmODdhZDk3NjU3NTIw
|
11
|
-
ZGJjYzc1NzRhYWU4NjFlMzM0Y2MwN2RiMWMyNzlmOGI0MGVkMGY=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
Y2IzOTg2ODE5ODk1MmIxOTA4MDlmNDFmZTMwZTM1MGQ3N2QyYzczYTAyZWI4
|
14
|
-
OGM2MDIwOTliNDZiNGI2NjM2NzUwZmQ0NDgyZDZmZmJiNGMwODg1MWIyNjgy
|
15
|
-
ZTdjMTFhN2EzYjEwZWU2NjhjNDU5NjcxODZjYTI2NmQ3ZDgyNjc=
|
6
|
+
metadata.gz: 17922239717fc4db75d6c06a2190491e5a3ab903abd80d4bfca7ecccaf8ec9478c2d6fabdc7e53f070a5d29a926214a5914524a0935d599bc97154611491ce07
|
7
|
+
data.tar.gz: fef830329b8e23d4284a3af80adc5c6822a5c70cb535ae708bfdca4ef38464d60cac0849f6c2a3fc27721c8d87aefd10ad91e8cd5916e0751274c08e749a75ee
|
data/README.md
CHANGED
@@ -22,6 +22,7 @@ A Ruby interface to the Wix Hive API.
|
|
22
22
|
* **[Response Errors](#response-errors)**
|
23
23
|
* **[Other Errors](#other-errors)**
|
24
24
|
* **[Contacts API](#contacts-api)**
|
25
|
+
* **[Concurrency Control](#concurrency-control)**
|
25
26
|
* **[client.new_contact](#clientnew_contact)**
|
26
27
|
* **[client.contact](#clientcontact)**
|
27
28
|
* **[client.update_contact (PENDING)](#clientupdate_contact-pending)**
|
@@ -314,6 +315,19 @@ Hive::SignatureError
|
|
314
315
|
|
315
316
|
### Contacts API
|
316
317
|
|
318
|
+
#### Concurrency Control
|
319
|
+
The contacts add and update methods have a concurrency control mechanism associated with them. The mechanism is based on the ``modifiedAt`` request parameter. This parameter needs to have the same value as the underlying contact that is being updated.
|
320
|
+
For example: let us assume we have a contact with ``id=1`` and ``modifiedAt=2014-10-01T14:43:48.560+03:00`` and we want to update the email field. What we would need to do is execute the following method:
|
321
|
+
``` ruby
|
322
|
+
new_email = Hive::Email.new
|
323
|
+
new_email.tag = 'work_new'
|
324
|
+
new_email.email = 'alex_new@example.com'
|
325
|
+
new_email.emailStatus = 'optOut'
|
326
|
+
|
327
|
+
client.add_contact_email('1', new_email, '2014-10-01T14:43:48.560+03:00')
|
328
|
+
```
|
329
|
+
So lets think about the concurrency now. Let assume we have two update email requests that come in the same time and they get processed sequentially. First one would get processed and update the contact email and in the same time the contacts’ ``modifiedAt`` will change. Second request gets processed but it will fail with a concurrency validation error because it is trying to perform an update operation on a old version of the contact object. And the system knows that by comparing the two ``modifiedAt`` parameters (one from the DB and the one provided).
|
330
|
+
|
317
331
|
#### client.new_contact
|
318
332
|
|
319
333
|
**Example:**
|
@@ -351,7 +365,7 @@ client.contact(CONTACT_ID)
|
|
351
365
|
contact.add_url(url: 'wix.com', tag: 'site')
|
352
366
|
|
353
367
|
# PENDING
|
354
|
-
client.update_contact(CONTACT_ID, contact)
|
368
|
+
client.update_contact(CONTACT_ID, contact, MODIFIED_AT)
|
355
369
|
```
|
356
370
|
|
357
371
|
#### client.contacts_tags (PENDING)
|
@@ -372,7 +386,7 @@ client.contacts_subscribers
|
|
372
386
|
|
373
387
|
**Example:**
|
374
388
|
``` ruby
|
375
|
-
client.update_contact_name(CONTACT_ID, Hive::Name.new(first: 'New_Name'))
|
389
|
+
client.update_contact_name(CONTACT_ID, Hive::Name.new(first: 'New_Name'), MODIFIED_AT)
|
376
390
|
```
|
377
391
|
|
378
392
|
#### client.update_contact_company
|
@@ -382,14 +396,14 @@ client.update_contact_name(CONTACT_ID, Hive::Name.new(first: 'New_Name'))
|
|
382
396
|
company = Hive::Company.new
|
383
397
|
company.name = 'New_Company'
|
384
398
|
|
385
|
-
client.update_contact_company(CONTACT_ID, company)
|
399
|
+
client.update_contact_company(CONTACT_ID, company, MODIFIED_AT)
|
386
400
|
```
|
387
401
|
|
388
402
|
#### client.update_contact_picture
|
389
403
|
|
390
404
|
**Example:**
|
391
405
|
``` ruby
|
392
|
-
client.update_contact_picture(CONTACT_ID, 'wix.com/example.jpg')
|
406
|
+
client.update_contact_picture(CONTACT_ID, 'wix.com/example.jpg', MODIFIED_AT)
|
393
407
|
```
|
394
408
|
|
395
409
|
#### client.update_contact_address
|
@@ -400,7 +414,7 @@ updated_address = Hive::Address.new
|
|
400
414
|
updated_address.tag = 'work'
|
401
415
|
updated_address.address = '1625 Larimer St.'
|
402
416
|
|
403
|
-
client.update_contact_address(CONTACT_ID, ADDRESS_ID, updated_address)
|
417
|
+
client.update_contact_address(CONTACT_ID, ADDRESS_ID, updated_address, MODIFIED_AT)
|
404
418
|
```
|
405
419
|
|
406
420
|
#### client.update_contact_email
|
@@ -412,7 +426,7 @@ updated_email = Hive::Email.new
|
|
412
426
|
updated_email.email = 'alex@example.com'
|
413
427
|
updated_email.emailStatus = 'optOut'
|
414
428
|
|
415
|
-
client.update_contact_email(CONTACT_ID, EMAIL_ID, updated_email)
|
429
|
+
client.update_contact_email(CONTACT_ID, EMAIL_ID, updated_email, MODIFIED_AT)
|
416
430
|
```
|
417
431
|
|
418
432
|
#### client.update_contact_phone
|
@@ -423,7 +437,7 @@ updated_phone = Hive::Phone.new
|
|
423
437
|
updated_phone.tag = 'work'
|
424
438
|
updated_phone.phone = '18006666'
|
425
439
|
|
426
|
-
client.update_contact_phone(CONTACT_ID, PHONE_ID, updated_phone)
|
440
|
+
client.update_contact_phone(CONTACT_ID, PHONE_ID, updated_phone, MODIFIED_AT)
|
427
441
|
```
|
428
442
|
|
429
443
|
#### client.update_contact_date
|
@@ -434,7 +448,7 @@ date = Hive::Date.new
|
|
434
448
|
date.date = Time.now.iso8601(3)
|
435
449
|
date.tag = 'update'
|
436
450
|
|
437
|
-
client.update_contact_date(CONTACT_ID, DATE_ID, date)
|
451
|
+
client.update_contact_date(CONTACT_ID, DATE_ID, date, MODIFIED_AT)
|
438
452
|
```
|
439
453
|
|
440
454
|
#### client.update_contact_note (PENDING)
|
@@ -445,7 +459,7 @@ note = Hive::Note.new
|
|
445
459
|
note.content = 'Note'
|
446
460
|
note.modifiedAt = Time.now.iso8601(3)
|
447
461
|
|
448
|
-
client.update_contact_phone(CONTACT_ID, NOTE_ID, note)
|
462
|
+
client.update_contact_phone(CONTACT_ID, NOTE_ID, note, MODIFIED_AT)
|
449
463
|
```
|
450
464
|
|
451
465
|
#### client.update_contact_custom (PENDING)
|
@@ -456,7 +470,7 @@ custom = Hive::Custom.new
|
|
456
470
|
custom.field = 'custom_update'
|
457
471
|
custom.value = 'custom_value'
|
458
472
|
|
459
|
-
client.update_contact_phone(CONTACT_ID, CUSTOM_ID, custom)
|
473
|
+
client.update_contact_phone(CONTACT_ID, CUSTOM_ID, custom, MODIFIED_AT)
|
460
474
|
```
|
461
475
|
|
462
476
|
#### client.add_contact_address
|
@@ -467,7 +481,7 @@ new_address = Hive::Address.new
|
|
467
481
|
new_address.tag = 'work'
|
468
482
|
new_address.address = '1625 Larimer St.'
|
469
483
|
|
470
|
-
client.add_contact_address(CONTACT_ID, new_address)
|
484
|
+
client.add_contact_address(CONTACT_ID, new_address, MODIFIED_AT)
|
471
485
|
```
|
472
486
|
|
473
487
|
#### client.add_contact_email
|
@@ -479,7 +493,7 @@ new_email = Hive::Email.new
|
|
479
493
|
new_email.email = 'alex_new@example.com'
|
480
494
|
new_email.emailStatus = 'optOut'
|
481
495
|
|
482
|
-
client.add_contact_email(CONTACT_ID, new_email)
|
496
|
+
client.add_contact_email(CONTACT_ID, new_email, MODIFIED_AT)
|
483
497
|
```
|
484
498
|
|
485
499
|
#### client.add_contact_phone
|
@@ -490,7 +504,7 @@ new_phone = Hive::Phone.new
|
|
490
504
|
new_phone.tag = 'work_new'
|
491
505
|
new_phone.phone = '18006666'
|
492
506
|
|
493
|
-
client.add_contact_phone(CONTACT_ID, new_phone)
|
507
|
+
client.add_contact_phone(CONTACT_ID, new_phone, MODIFIED_AT)
|
494
508
|
```
|
495
509
|
|
496
510
|
#### client.add_contact_note
|
@@ -499,7 +513,7 @@ new_phone = Hive::Phone.new
|
|
499
513
|
note = Hive::Note.new
|
500
514
|
note.content = 'Note'
|
501
515
|
|
502
|
-
client.add_contact_note(CONTACT_ID, note)
|
516
|
+
client.add_contact_note(CONTACT_ID, note, MODIFIED_AT)
|
503
517
|
```
|
504
518
|
|
505
519
|
#### client.add_contact_custom
|
@@ -510,7 +524,7 @@ custom = Hive::Custom.new
|
|
510
524
|
custom.field = 'custom_update'
|
511
525
|
custom.value = 'custom_value'
|
512
526
|
|
513
|
-
client.add_contact_custom(CONTACT_ID, custom)
|
527
|
+
client.add_contact_custom(CONTACT_ID, custom, MODIFIED_AT)
|
514
528
|
```
|
515
529
|
|
516
530
|
#### client.add_contact_tags (PENDING)
|
@@ -519,7 +533,7 @@ custom = Hive::Custom.new
|
|
519
533
|
``` ruby
|
520
534
|
tags = ['tag1/tag', 'tag2/tag']
|
521
535
|
|
522
|
-
client.add_contact_tags(CONTACT_ID, tags)
|
536
|
+
client.add_contact_tags(CONTACT_ID, tags, MODIFIED_AT)
|
523
537
|
```
|
524
538
|
|
525
539
|
#### client.add_contact_activity
|
data/e2e/activities_api_spec.rb
CHANGED
@@ -81,7 +81,7 @@ describe 'Activities API' do
|
|
81
81
|
type: FACTORY::CONVERSION_COMPLETE.type,
|
82
82
|
locationUrl: 'http://www.wix.com',
|
83
83
|
details: {summary: 'test', additionalInfoUrl: 'http://www.wix.com'},
|
84
|
-
info: {conversionType: 'PAGEVIEW'})
|
84
|
+
info: {conversionType: 'PAGEVIEW', messageId: '12345', metadata: [{ name: 'a', value: 'b' }] })
|
85
85
|
|
86
86
|
new_activity_result = client.new_activity(session_id, activity)
|
87
87
|
|
@@ -89,7 +89,7 @@ describe 'Activities API' do
|
|
89
89
|
end
|
90
90
|
|
91
91
|
it 'E_COMMERCE_PURCHASE' do
|
92
|
-
coupon = {total: '1', title: 'Dis'}
|
92
|
+
coupon = {total: '1', formattedTotal: 1, title: 'Dis'}
|
93
93
|
tax = {total: 1, formattedTotal: 1}
|
94
94
|
shipping = {total: 1, formattedTotal: 1}
|
95
95
|
payment = {total: '1', subtotal: '1', formattedTotal: '1.0', formattedSubtotal: '1.0', currency: 'EUR', coupon: coupon, tax: tax, shipping: shipping}
|
@@ -120,9 +120,10 @@ describe 'Activities API' do
|
|
120
120
|
end
|
121
121
|
|
122
122
|
it 'MESSAGING_SEND' do
|
123
|
-
|
123
|
+
conversion_target = { conversionType:'FAN', metadata: [ { name: 'wix', value: '124'} ] }
|
124
|
+
recipient = {method: 'EMAIL', destination: {name: {first: 'Alex'}, target: 'localhost', contactId: '1234'}}
|
124
125
|
|
125
|
-
send = FACTORY::MESSAGING_SEND.klass.new(recipient: recipient)
|
126
|
+
send = FACTORY::MESSAGING_SEND.klass.new(messageId: '1111', recipient: recipient, conversionTarget: conversion_target)
|
126
127
|
|
127
128
|
activity = Hive::Activity.new(
|
128
129
|
type: FACTORY::MESSAGING_SEND.type,
|
@@ -135,12 +136,24 @@ describe 'Activities API' do
|
|
135
136
|
expect(new_activity_result.activityId).to be_truthy
|
136
137
|
end
|
137
138
|
|
139
|
+
it 'MUSIC_ALBUM_PLAYED' do
|
140
|
+
activity = Hive::Activity.new(
|
141
|
+
type: FACTORY::MUSIC_ALBUM_PLAYED.type,
|
142
|
+
locationUrl: 'http://www.wix.com',
|
143
|
+
details: {summary: 'test', additionalInfoUrl: 'http://www.wix.com'},
|
144
|
+
info: { album: { name: 'Wix', id: '1234' }, artist: {name: 'WIx', id: 'id_123'} })
|
145
|
+
|
146
|
+
new_activity_result = client.new_activity(session_id, activity)
|
147
|
+
|
148
|
+
expect(new_activity_result.activityId).to be_truthy
|
149
|
+
end
|
150
|
+
|
138
151
|
it 'MUSIC_ALBUM_FAN' do
|
139
152
|
activity = Hive::Activity.new(
|
140
153
|
type: FACTORY::MUSIC_ALBUM_FAN.type,
|
141
154
|
locationUrl: 'http://www.wix.com',
|
142
155
|
details: {summary: 'test', additionalInfoUrl: 'http://www.wix.com'},
|
143
|
-
info: { album: { name: 'Wix', id: '1234' } })
|
156
|
+
info: { album: { name: 'Wix', id: '1234' }, artist: {name: 'WIx', id: 'id_123'} })
|
144
157
|
|
145
158
|
new_activity_result = client.new_activity(session_id, activity)
|
146
159
|
|
@@ -152,7 +165,7 @@ describe 'Activities API' do
|
|
152
165
|
type: FACTORY::MUSIC_ALBUM_SHARE.type,
|
153
166
|
locationUrl: 'http://www.wix.com',
|
154
167
|
details: {summary: 'test', additionalInfoUrl: 'http://www.wix.com'},
|
155
|
-
info: { album: { name: 'Wix', id: '1234' }, sharedTo: 'FACEBOOK' })
|
168
|
+
info: { album: { name: 'Wix', id: '1234' }, sharedTo: 'FACEBOOK', artist: {name: 'WIx', id: 'id_123'} })
|
156
169
|
|
157
170
|
new_activity_result = client.new_activity(session_id, activity)
|
158
171
|
|
@@ -164,7 +177,7 @@ describe 'Activities API' do
|
|
164
177
|
type: FACTORY::MUSIC_TRACK_LYRICS.type,
|
165
178
|
locationUrl: 'http://www.wix.com',
|
166
179
|
details: {summary: 'test', additionalInfoUrl: 'http://www.wix.com'},
|
167
|
-
info: { album: { name: 'Wix', id: '1234' }, track: { name: 'Wix', id: '1234' } })
|
180
|
+
info: { album: { name: 'Wix', id: '1234' }, track: { name: 'Wix', id: '1234' }, artist: {name: 'WIx', id: 'id_123'}})
|
168
181
|
|
169
182
|
new_activity_result = client.new_activity(session_id, activity)
|
170
183
|
|
@@ -188,7 +201,7 @@ describe 'Activities API' do
|
|
188
201
|
type: FACTORY::MUSIC_TRACK_PLAYED.type,
|
189
202
|
locationUrl: 'http://www.wix.com',
|
190
203
|
details: {summary: 'test', additionalInfoUrl: 'http://www.wix.com'},
|
191
|
-
info: { album: { name: 'Wix', id: '1234' }, track: { name: 'Wix', id: '1234' } })
|
204
|
+
info: { album: { name: 'Wix', id: '1234' }, track: { name: 'Wix', id: '1234' }, artist: {name: 'WIx', id: 'id_123'} })
|
192
205
|
|
193
206
|
new_activity_result = client.new_activity(session_id, activity)
|
194
207
|
|
@@ -200,7 +213,7 @@ describe 'Activities API' do
|
|
200
213
|
type: FACTORY::MUSIC_TRACK_SKIP.type,
|
201
214
|
locationUrl: 'http://www.wix.com',
|
202
215
|
details: {summary: 'test', additionalInfoUrl: 'http://www.wix.com'},
|
203
|
-
info: { album: { name: 'Wix', id: '1234' }, track: { name: 'Wix', id: '1234' } })
|
216
|
+
info: { album: { name: 'Wix', id: '1234' }, track: { name: 'Wix', id: '1234' }, artist: {name: 'WIx', id: 'id_123'} })
|
204
217
|
|
205
218
|
new_activity_result = client.new_activity(session_id, activity)
|
206
219
|
|
@@ -212,7 +225,7 @@ describe 'Activities API' do
|
|
212
225
|
type: FACTORY::MUSIC_TRACK_SHARE.type,
|
213
226
|
locationUrl: 'http://www.wix.com',
|
214
227
|
details: {summary: 'test', additionalInfoUrl: 'http://www.wix.com'},
|
215
|
-
info: { album: { name: 'Wix', id: '1234' }, track: { name: 'Wix', id: '1234' }, sharedTo: 'FACEBOOK' })
|
228
|
+
info: { album: { name: 'Wix', id: '1234' }, track: { name: 'Wix', id: '1234' }, sharedTo: 'FACEBOOK', artist: {name: 'WIx', id: 'id_123'} })
|
216
229
|
|
217
230
|
new_activity_result = client.new_activity(session_id, activity)
|
218
231
|
|
@@ -220,7 +233,6 @@ describe 'Activities API' do
|
|
220
233
|
end
|
221
234
|
|
222
235
|
it 'HOTELS_CONFIRMATION' do
|
223
|
-
pending 'HAPI-36'
|
224
236
|
guest = { total: 1, adults: 1, children: 0 }
|
225
237
|
|
226
238
|
day_ago = (Time.now - (60 * 60 * 24)).iso8601(3)
|
@@ -240,7 +252,6 @@ describe 'Activities API' do
|
|
240
252
|
end
|
241
253
|
|
242
254
|
it 'HOTELS_CANCEL' do
|
243
|
-
pending 'HAPI-36'
|
244
255
|
refund = {kind: 'FULL', total: 1, currency: 'EUR', destination: 'NYC'}
|
245
256
|
|
246
257
|
guest = { total: 1, adults: 1, children: 0 }
|
@@ -274,8 +285,7 @@ describe 'Activities API' do
|
|
274
285
|
|
275
286
|
tax = {name: 'VAT', total: 1, currency: 'EUR'}
|
276
287
|
|
277
|
-
|
278
|
-
rate = {date: Time.now.iso8601(3), subtotal: '1', total: '1', currency: '1', tax: tax}
|
288
|
+
rate = {date: Time.now.iso8601(3), subtotal: '1', total: '1', currency: 'EUR', taxes: [tax]}
|
279
289
|
|
280
290
|
name = {prefix: 'prefix', first: 'Wix', middle: 'middle', last: 'Cool', suffix: 'suffix'}
|
281
291
|
|
@@ -283,14 +293,13 @@ describe 'Activities API' do
|
|
283
293
|
|
284
294
|
bed = {kind: 'KING', sleeps: 1}
|
285
295
|
|
286
|
-
|
287
|
-
#room = {id: 1, beds: [bed], maxOccupancy: 1}
|
296
|
+
room = {id: 1, beds: [bed], maxOccupancy: 1, amenities: ['fridge']}
|
288
297
|
|
289
298
|
activity = Hive::Activity.new(
|
290
299
|
type: FACTORY::HOTELS_PURCHASE.type,
|
291
300
|
locationUrl: 'http://www.wix.com',
|
292
301
|
details: {summary: 'test', additionalInfoUrl: 'http://www.wix.com'},
|
293
|
-
info: { source: 'GUEST', guests: guest, stay: stay, invoice: invoice, rates: [rate], payment: payment, customer: customer, rooms: [] })
|
302
|
+
info: { source: 'GUEST', guests: guest, stay: stay, invoice: invoice, rates: [rate], payment: payment, customer: customer, rooms: [room] })
|
294
303
|
|
295
304
|
|
296
305
|
new_activity_result = client.new_activity(session_id, activity)
|
@@ -320,11 +329,28 @@ describe 'Activities API' do
|
|
320
329
|
end
|
321
330
|
|
322
331
|
it 'SCHEDULER_APPOINTMENT' do
|
332
|
+
name = {prefix:'sir', first:'mix', middle:'a', last:'lot', suffix:'Sr.'}
|
333
|
+
|
334
|
+
location = {address:'123 meep st.',
|
335
|
+
city:'meepsville',
|
336
|
+
region:'meep',
|
337
|
+
postalCode:'124JKE',
|
338
|
+
country:'USSMEEP',
|
339
|
+
url:'http://www.wix.com'}
|
340
|
+
|
341
|
+
info = { title:'my appointment', description:'write these tests', location: location,
|
342
|
+
time: {start:'2014-09-10T15:21:42.662Z', end:'2014-09-10T15:23:09.062Z', timezone:'ET'},
|
343
|
+
attendees:[ { contactId:'1234', name: name,
|
344
|
+
phone:'555-2234', email:'a@a.com', notes:'things and stuff', self: true},
|
345
|
+
{ contactId:'1246', name: name,
|
346
|
+
phone:'554-2234', email:'b@a.com', notes:'things and stuff'} ]
|
347
|
+
}
|
348
|
+
|
323
349
|
activity = Hive::Activity.new(
|
324
350
|
type: FACTORY::SCHEDULER_APPOINTMENT.type,
|
325
351
|
locationUrl: 'http://www.wix.com',
|
326
352
|
details: {summary: 'test', additionalInfoUrl: 'http://www.wix.com'},
|
327
|
-
info:
|
353
|
+
info: info)
|
328
354
|
|
329
355
|
new_activity_result = client.new_activity(session_id, activity)
|
330
356
|
|
data/e2e/contacts_api_spec.rb
CHANGED
@@ -21,13 +21,14 @@ describe 'Contacts API' do
|
|
21
21
|
contact.add_address(tag: 'home', address: '28208 N Inca St.', neighborhood: 'LODO', city: 'Denver', region: 'CO', country: 'US', postalCode: '80202')
|
22
22
|
contact.add_date(date: Time.now.iso8601(3), tag: 'E2E')
|
23
23
|
contact.add_url(url: 'wix.com', tag: 'site')
|
24
|
-
contact.add_note(content: 'alex')
|
24
|
+
contact.add_note(content: 'alex', modifiedAt: Time.now.iso8601(3))
|
25
25
|
contact.add_custom(field: 'custom1', value: 'custom')
|
26
26
|
expect(client.new_contact(contact)).to include :contactId
|
27
27
|
end
|
28
28
|
|
29
29
|
it '.contact' do
|
30
|
-
|
30
|
+
contact_id, _modified_at = create_base_contact
|
31
|
+
expect(client.contact(contact_id)).to be_a Hive::Contact
|
31
32
|
end
|
32
33
|
|
33
34
|
context '.contacts' do
|
@@ -134,9 +135,9 @@ describe 'Contacts API' do
|
|
134
135
|
it '.update_contact_name' do
|
135
136
|
base_contact.name.first = 'Old_Name'
|
136
137
|
|
137
|
-
contact_id = create_base_contact
|
138
|
+
contact_id, modified_at = create_base_contact
|
138
139
|
|
139
|
-
update_response = client.update_contact_name(contact_id, Hive::Name.new(first: 'New_Name'))
|
140
|
+
update_response = client.update_contact_name(contact_id, Hive::Name.new(first: 'New_Name'), modified_at)
|
140
141
|
|
141
142
|
expect(update_response.name.first).to eq 'New_Name'
|
142
143
|
end
|
@@ -146,12 +147,12 @@ describe 'Contacts API' do
|
|
146
147
|
base_contact.company.name = 'Old_Company'
|
147
148
|
base_contact.company.role = 'CEO'
|
148
149
|
|
149
|
-
contact_id
|
150
|
+
contact_id, modified_at = create_base_contact
|
150
151
|
|
151
152
|
company = Hive::Company.new
|
152
153
|
company.name = 'New_Company'
|
153
154
|
|
154
|
-
update_response = client.update_contact_company(contact_id, company)
|
155
|
+
update_response = client.update_contact_company(contact_id, company, modified_at)
|
155
156
|
|
156
157
|
expect(update_response.company.name).to eq 'New_Company'
|
157
158
|
end
|
@@ -159,11 +160,11 @@ describe 'Contacts API' do
|
|
159
160
|
it '.update_contact_picture' do
|
160
161
|
base_contact.picture = 'http://wix.com/img1.jpg'
|
161
162
|
|
162
|
-
contact_id = create_base_contact
|
163
|
+
contact_id, modified_at = create_base_contact
|
163
164
|
|
164
165
|
updated_picture = 'wix.com'
|
165
166
|
|
166
|
-
update_response = client.update_contact_picture(contact_id, updated_picture)
|
167
|
+
update_response = client.update_contact_picture(contact_id, updated_picture, modified_at)
|
167
168
|
|
168
169
|
expect(update_response.picture).to eq updated_picture
|
169
170
|
end
|
@@ -171,20 +172,20 @@ describe 'Contacts API' do
|
|
171
172
|
it '.update_contact_address' do
|
172
173
|
base_contact.add_address(tag: 'home', address: '28208 N Inca St.', neighborhood: 'LODO', city: 'Denver', region: 'CO', country: 'US', postalCode: '80202')
|
173
174
|
|
174
|
-
contact =
|
175
|
+
contact = create_base_contact_and_return
|
175
176
|
|
176
177
|
updated_address = Hive::Address.new
|
177
178
|
updated_address.tag = 'work'
|
178
179
|
updated_address.address = '1625 Larimer St.'
|
179
180
|
|
180
|
-
update_response = client.update_contact_address(contact.id, contact.addresses.first.id, updated_address)
|
181
|
+
update_response = client.update_contact_address(contact.id, contact.addresses.first.id, updated_address, contact.modifiedAt)
|
181
182
|
|
182
183
|
expect(update_response.addresses.first.tag).to eq updated_address.tag
|
183
184
|
expect(update_response.addresses.first.address).to eq updated_address.address
|
184
185
|
end
|
185
186
|
|
186
187
|
it '.update_contact_email' do
|
187
|
-
contact =
|
188
|
+
contact = create_base_contact_and_return
|
188
189
|
|
189
190
|
expect(contact.emails).not_to be_empty
|
190
191
|
|
@@ -193,20 +194,20 @@ describe 'Contacts API' do
|
|
193
194
|
updated_email.email = 'alex@example.com'
|
194
195
|
updated_email.emailStatus = 'optOut'
|
195
196
|
|
196
|
-
update_response = client.update_contact_email(contact.id, contact.emails.first.id, updated_email)
|
197
|
+
update_response = client.update_contact_email(contact.id, contact.emails.first.id, updated_email, contact.modifiedAt)
|
197
198
|
|
198
199
|
expect(update_response.emails.first.tag).to eq updated_email.tag
|
199
200
|
expect(update_response.emails.first.email).to eq updated_email.email
|
200
201
|
end
|
201
202
|
|
202
203
|
it '.update_contact_phone' do
|
203
|
-
contact =
|
204
|
+
contact = create_base_contact_and_return
|
204
205
|
|
205
206
|
updated_phone = Hive::Phone.new
|
206
207
|
updated_phone.tag = 'work'
|
207
208
|
updated_phone.phone = '18006666'
|
208
209
|
|
209
|
-
update_response = client.update_contact_phone(contact.id, contact.phones.first.id, updated_phone)
|
210
|
+
update_response = client.update_contact_phone(contact.id, contact.phones.first.id, updated_phone, contact.modifiedAt)
|
210
211
|
|
211
212
|
expect(update_response.phones.first.tag).to eq updated_phone.tag
|
212
213
|
expect(update_response.phones.first.phone).to eq updated_phone.phone
|
@@ -215,13 +216,13 @@ describe 'Contacts API' do
|
|
215
216
|
it '.update_contact_date' do
|
216
217
|
base_contact.add_date(date: Time.now.iso8601(3), tag: 'E2E')
|
217
218
|
|
218
|
-
contact =
|
219
|
+
contact = create_base_contact_and_return
|
219
220
|
|
220
221
|
date = Hive::Date.new
|
221
222
|
date.date = Time.now.iso8601(3)
|
222
223
|
date.tag = 'update'
|
223
224
|
|
224
|
-
update_response = client.update_contact_date(contact.id, contact.dates.first.id, date)
|
225
|
+
update_response = client.update_contact_date(contact.id, contact.dates.first.id, date, contact.modifiedAt)
|
225
226
|
|
226
227
|
expect(update_response.dates.first.tag).to eq date.tag
|
227
228
|
#Ignore timezones and all just compare the int values.
|
@@ -229,31 +230,31 @@ describe 'Contacts API' do
|
|
229
230
|
end
|
230
231
|
|
231
232
|
it '.update_contact_note' do
|
232
|
-
|
233
|
-
|
234
|
-
contact = client.contact(create_base_contact)
|
233
|
+
base_contact.add_note(content: 'content', modifiedAt: Time.now.iso8601(3))
|
234
|
+
contact = create_base_contact_and_return
|
235
235
|
|
236
236
|
note = Hive::Note.new
|
237
237
|
note.content = 'Note'
|
238
238
|
note.modifiedAt = Time.now.iso8601(3)
|
239
239
|
|
240
|
-
update_response = client.
|
240
|
+
update_response = client.update_contact_note(contact.id, contact.notes.first.id, note, contact.modifiedAt)
|
241
241
|
|
242
|
-
expect(update_response.notes.first.content).to eq note
|
242
|
+
expect(update_response.notes.first.content).to eq note.content
|
243
|
+
expect(update_response.notes.first.modifiedAt.to_i).to eq note.modifiedAt.to_i
|
243
244
|
end
|
244
245
|
|
245
246
|
it '.update_contact_custom' do
|
246
|
-
|
247
|
-
contact =
|
247
|
+
base_contact.add_custom(field: 'custom', value: 'custom')
|
248
|
+
contact = create_base_contact_and_return
|
248
249
|
|
249
250
|
custom = Hive::Custom.new
|
250
251
|
custom.field = 'custom_update'
|
251
252
|
custom.value = 'custom_value'
|
252
253
|
|
253
|
-
update_response = client.
|
254
|
+
update_response = client.update_contact_custom(contact.id, contact.custom.first.id, custom, contact.modifiedAt)
|
254
255
|
|
255
256
|
expect(update_response.custom.first.field).to eq custom.field
|
256
|
-
expect(update_response.custom.first.
|
257
|
+
expect(update_response.custom.first.value).to eq custom.value
|
257
258
|
end
|
258
259
|
|
259
260
|
it '.add_contact_address' do
|
@@ -261,7 +262,9 @@ describe 'Contacts API' do
|
|
261
262
|
new_address.tag = 'work'
|
262
263
|
new_address.address = '1625 Larimer St.'
|
263
264
|
|
264
|
-
|
265
|
+
contact_id, modified_at = create_base_contact
|
266
|
+
|
267
|
+
add_response = client.add_contact_address(contact_id, new_address, modified_at)
|
265
268
|
|
266
269
|
expect(add_response.addresses.last.tag).to eq new_address.tag
|
267
270
|
expect(add_response.addresses.last.address).to eq new_address.address
|
@@ -273,7 +276,9 @@ describe 'Contacts API' do
|
|
273
276
|
new_email.email = 'alex_new@example.com'
|
274
277
|
new_email.emailStatus = 'optOut'
|
275
278
|
|
276
|
-
|
279
|
+
contact_id, modified_at = create_base_contact
|
280
|
+
|
281
|
+
add_response = client.add_contact_email(contact_id, new_email, modified_at)
|
277
282
|
|
278
283
|
expect(add_response.emails.last.tag).to eq new_email.tag
|
279
284
|
expect(add_response.emails.last.email).to eq new_email.email
|
@@ -284,7 +289,9 @@ describe 'Contacts API' do
|
|
284
289
|
new_phone.tag = 'work_new'
|
285
290
|
new_phone.phone = '18006666'
|
286
291
|
|
287
|
-
|
292
|
+
contact_id, modified_at = create_base_contact
|
293
|
+
|
294
|
+
add_response = client.add_contact_phone(contact_id, new_phone, modified_at)
|
288
295
|
|
289
296
|
expect(add_response.phones.last.tag).to eq new_phone.tag
|
290
297
|
expect(add_response.phones.last.phone).to eq new_phone.phone
|
@@ -293,11 +300,14 @@ describe 'Contacts API' do
|
|
293
300
|
it '.add_contact_note' do
|
294
301
|
note = Hive::Note.new
|
295
302
|
note.content = 'Note'
|
303
|
+
note.modifiedAt = Time.now.iso8601(3)
|
296
304
|
|
297
|
-
|
305
|
+
contact_id, modified_at = create_base_contact
|
306
|
+
|
307
|
+
add_response = client.add_contact_note(contact_id, note, modified_at)
|
298
308
|
|
299
309
|
expect(add_response.notes.last.content).to eq note.content
|
300
|
-
expect(add_response.notes.last.modifiedAt).to eq note.modifiedAt
|
310
|
+
expect(add_response.notes.last.modifiedAt.to_i).to eq note.modifiedAt.to_i
|
301
311
|
end
|
302
312
|
|
303
313
|
it '.add_contact_custom' do
|
@@ -305,7 +315,9 @@ describe 'Contacts API' do
|
|
305
315
|
custom.field = 'custom_update'
|
306
316
|
custom.value = 'custom_value'
|
307
317
|
|
308
|
-
|
318
|
+
contact_id, modified_at = create_base_contact
|
319
|
+
|
320
|
+
add_response = client.add_contact_custom(contact_id, custom, modified_at)
|
309
321
|
|
310
322
|
expect(add_response.custom.last.field).to eq custom.field
|
311
323
|
expect(add_response.custom.last.value).to eq custom.value
|
@@ -315,13 +327,15 @@ describe 'Contacts API' do
|
|
315
327
|
pending 'CE-2312'
|
316
328
|
tags = ['crazy/tag', 'lalala/tag']
|
317
329
|
|
318
|
-
|
330
|
+
contact_id, modified_at = create_base_contact
|
331
|
+
|
332
|
+
add_response = client.add_contact_tags(contact_id, tags, modified_at)
|
319
333
|
|
320
334
|
expect(add_response.tags).to include tags
|
321
335
|
end
|
322
336
|
|
323
337
|
it '.add_contact_activity' do
|
324
|
-
contact_id = create_base_contact
|
338
|
+
contact_id, _modified_at = create_base_contact
|
325
339
|
|
326
340
|
activity = Hive::Activity.new(
|
327
341
|
type: FACTORY::MUSIC_ALBUM_FAN.type,
|
@@ -336,7 +350,7 @@ describe 'Contacts API' do
|
|
336
350
|
end
|
337
351
|
|
338
352
|
it '.contact_activities' do
|
339
|
-
contact_id = create_base_contact
|
353
|
+
contact_id, _modified_at = create_base_contact
|
340
354
|
|
341
355
|
activity = Hive::Activity.new(
|
342
356
|
type: FACTORY::MUSIC_ALBUM_FAN.type,
|
@@ -360,6 +374,14 @@ describe 'Contacts API' do
|
|
360
374
|
|
361
375
|
expect(create_response).to include :contactId
|
362
376
|
|
363
|
-
create_response[:contactId]
|
377
|
+
[create_response[:contactId], client.contact(create_response[:contactId]).modifiedAt]
|
378
|
+
end
|
379
|
+
|
380
|
+
def create_base_contact_and_return
|
381
|
+
create_response = client.new_contact(base_contact)
|
382
|
+
|
383
|
+
expect(create_response).to include :contactId
|
384
|
+
|
385
|
+
client.contact(create_response[:contactId])
|
364
386
|
end
|
365
387
|
end
|