wix-hive-ruby 0.9.0

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.
Files changed (78) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +20 -0
  3. data/.rubocop.yml +487 -0
  4. data/.yardopts +6 -0
  5. data/Gemfile +4 -0
  6. data/Guardfile +11 -0
  7. data/LICENSE.txt +22 -0
  8. data/README.md +641 -0
  9. data/Rakefile +33 -0
  10. data/e2e/activities_api_spec.rb +334 -0
  11. data/e2e/contacts_api_spec.rb +364 -0
  12. data/e2e/e2e_helper.rb +35 -0
  13. data/e2e/insights_api_spec.rb +29 -0
  14. data/lib/hive/activities/contact/contact_create_activity.rb +109 -0
  15. data/lib/hive/activities/contact/contact_form_activity.rb +31 -0
  16. data/lib/hive/activities/conversion/conversion_complete_activity.rb +33 -0
  17. data/lib/hive/activities/e_commerce/purchase_activity.rb +150 -0
  18. data/lib/hive/activities/factory.rb +71 -0
  19. data/lib/hive/activities/hotels/hotels_cancel_activity.rb +52 -0
  20. data/lib/hive/activities/hotels/hotels_confirmation_activity.rb +133 -0
  21. data/lib/hive/activities/hotels/hotels_purchase_activity.rb +48 -0
  22. data/lib/hive/activities/hotels/hotels_purchase_failed_activity.rb +59 -0
  23. data/lib/hive/activities/messaging/send_activity.rb +75 -0
  24. data/lib/hive/activities/music/album_fan_activity.rb +36 -0
  25. data/lib/hive/activities/music/album_share_activity.rb +23 -0
  26. data/lib/hive/activities/music/track_lyrics_activity.rb +38 -0
  27. data/lib/hive/activities/music/track_play_activity.rb +31 -0
  28. data/lib/hive/activities/music/track_played_activity.rb +31 -0
  29. data/lib/hive/activities/music/track_share_activity.rb +32 -0
  30. data/lib/hive/activities/music/track_skipped_activity.rb +31 -0
  31. data/lib/hive/activities/scheduler/scheduler_appointment_activity.rb +73 -0
  32. data/lib/hive/activity.rb +60 -0
  33. data/lib/hive/activity_summary.rb +24 -0
  34. data/lib/hive/connect/request/wix_api_request.rb +92 -0
  35. data/lib/hive/connect/response/error.rb +88 -0
  36. data/lib/hive/connect/response/parse_json.rb +29 -0
  37. data/lib/hive/connect/response/raise_error.rb +17 -0
  38. data/lib/hive/connect/wix_client.rb +148 -0
  39. data/lib/hive/contact.rb +153 -0
  40. data/lib/hive/cursor.rb +48 -0
  41. data/lib/hive/errors.rb +5 -0
  42. data/lib/hive/extensions/hashie_hash.rb +16 -0
  43. data/lib/hive/extensions/hashie_validate_enum.rb +11 -0
  44. data/lib/hive/rest/activities.rb +55 -0
  45. data/lib/hive/rest/api.rb +13 -0
  46. data/lib/hive/rest/contacts.rb +114 -0
  47. data/lib/hive/rest/insights.rb +17 -0
  48. data/lib/hive/util.rb +20 -0
  49. data/lib/hive/version.rb +14 -0
  50. data/lib/wix-hive-ruby.rb +5 -0
  51. data/samples/quick_start.rb +49 -0
  52. data/spec/hive/activities/contact/contact_create_activity_spec.rb +25 -0
  53. data/spec/hive/activities/contact/contact_form_activity_spec.rb +9 -0
  54. data/spec/hive/activities/conversion/conversion_complete_activity_spec.rb +9 -0
  55. data/spec/hive/activities/e_commerce/purchase_activity_spec.rb +19 -0
  56. data/spec/hive/activities/factory_spec.rb +78 -0
  57. data/spec/hive/activities/hotels/hotels_cancel_activity_spec.rb +22 -0
  58. data/spec/hive/activities/hotels/hotels_confirmation_activity_spec.rb +34 -0
  59. data/spec/hive/activities/hotels/hotels_purchase_activity_spec.rb +22 -0
  60. data/spec/hive/activities/hotels/hotels_purchase_failed_activity_spec.rb +22 -0
  61. data/spec/hive/activities/messaging/send_activity_spec.rb +13 -0
  62. data/spec/hive/activities/scheduler/scheduler_appointment_activity_spec.rb +10 -0
  63. data/spec/hive/activity_spec.rb +18 -0
  64. data/spec/hive/connect/request/wix_api_request_spec.rb +54 -0
  65. data/spec/hive/connect/response/error_spec.rb +31 -0
  66. data/spec/hive/connect/response/parse_json_spec.rb +28 -0
  67. data/spec/hive/connect/response/raise_error_spec.rb +19 -0
  68. data/spec/hive/connect/wix_client_spec.rb +103 -0
  69. data/spec/hive/contact_spec.rb +148 -0
  70. data/spec/hive/cursor_spec.rb +75 -0
  71. data/spec/hive/hashie_hash_spec.rb +23 -0
  72. data/spec/hive/rest/activities_spec.rb +87 -0
  73. data/spec/hive/rest/contacts_spec.rb +225 -0
  74. data/spec/hive/rest/insights_spec.rb +17 -0
  75. data/spec/hive/util_spec.rb +36 -0
  76. data/spec/spec_helper.rb +59 -0
  77. data/wix-hive-ruby.gemspec +38 -0
  78. metadata +392 -0
@@ -0,0 +1,6 @@
1
+ --no-private
2
+ --protected
3
+ --markup markdown
4
+ -
5
+ LICENSE.md
6
+ README.md
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in wix-hive-ruby.gemspec
4
+ gemspec
@@ -0,0 +1,11 @@
1
+ guard :rspec, cmd: 'rspec --color --format=doc' do
2
+ # watch /lib/ files
3
+ watch(%r{^lib/(.+).rb$}) do |m|
4
+ "spec/#{m[1]}_spec.rb"
5
+ end
6
+
7
+ # watch /spec/ files
8
+ watch(%r{^spec/(.+).rb$}) do |m|
9
+ "spec/#{m[1]}.rb"
10
+ end
11
+ end
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 David Zuckerman
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,641 @@
1
+ # Wix-Hive-Ruby
2
+
3
+ A Ruby interface to the Wix Hive API.
4
+
5
+ ### Table of Contents
6
+ 1. **[Prerequisites](#prerequisites)**
7
+ 2. **[Installation](#installation)**
8
+ 3. **[Quick Start](#quick-start)**
9
+ 4. **[Manual](#manual)**
10
+ * **[Configuration](#configuration)**
11
+ * **[Basic configuration](#the-basic-configuration-is)**
12
+ * **[Advanced configuration](#advanced-configuration-options-include)**
13
+ * **[Hive DTOs](#hive-dtos)**
14
+ * **[Constructing request data](#constructing-request-data)**
15
+ * **[Accessing response data](#accessing-response-data)**
16
+ * **[Hive Cursored Data](#hive-cursored-data)**
17
+ * **[Hive Errors](#hive-errors)**
18
+ * **[Response Errors](#response-errors)**
19
+ * **[Other Errors](#other-errors)**
20
+ * **[Contacts API](#contacts-api)**
21
+ * **[client.new_contact](#clientnew_contact)**
22
+ * **[client.contact](#clientcontact)**
23
+ * **[client.update_contact (PENDING)](#clientupdate_contact-pending)**
24
+ * **[client.contacts_tags (PENDING)](#clientcontacts_tags-pending)**
25
+ * **[client.contacts_subscribers (PENDING)](#clientcontacts_subscribers-pending)**
26
+ * **[client.update_contact_name](#clientupdate_contact_name)**
27
+ * **[client.update_contact_company](#clientupdate_contact_company)**
28
+ * **[client.update_contact_picture](#clientupdate_contact_picture)**
29
+ * **[client.update_contact_address](#clientupdate_contact_address)**
30
+ * **[client.update_contact_email](#clientupdate_contact_email)**
31
+ * **[client.update_contact_phone](#clientupdate_contact_phone)**
32
+ * **[client.update_contact_date](#clientupdate_contact_date)**
33
+ * **[client.update_contact_note (PENDING)](#clientupdate_contact_note-pending)**
34
+ * **[client.update_contact_custom (PENDING)](#clientupdate_contact_custom-pending)**
35
+ * **[client.add_contact_address](#clientadd_contact_address)**
36
+ * **[client.add_contact_email](#clientadd_contact_email)**
37
+ * **[client.add_contact_phone](#clientadd_contact_phone)**
38
+ * **[client.add_contact_note](#clientadd_contact_note)**
39
+ * **[client.add_contact_custom](#clientadd_contact_custom)**
40
+ * **[client.add_contact_tags (PENDING)](#clientadd_contact_tags-pending)**
41
+ * **[client.add_contact_activity](#clientadd_contact_activity)**
42
+ * **[client.contact_activities](#clientcontact_activities)**
43
+ * **[client.contacts](#clientcontacts)**
44
+ * **[client.upsert_contact](#clientupsert_contact)**
45
+ * **[Activities API](#activities-api)**
46
+ * **[client.new_activity](#clientnew_activity)**
47
+ * **[client.activity](#clientactivity)**
48
+ * **[client.activities](#clientactivities)**
49
+ * **[Insights API](#insights-api)**
50
+ * **[client.activities_summary](#clientactivities_summary)**
51
+ * **[client.contact_activities_summary](#clientcontact_activities_summary)**
52
+ 5. **[Contributing](#contributing)**
53
+ * **[Submitting an Issue](#submitting-an-issue)**
54
+ * **[Submitting a Pull Request](#submitting-a-pull-request)**
55
+
56
+ ## Prerequisites
57
+ - **Read about** [developing a third party app for the Wix platform](http://dev.wix.com/docs/display/DRAF/Third+Party+Apps+-+Introduction).
58
+ - **Register your app** [here](http://dev.wix.com/docs/display/DRAF/Dev+Center+Registration+Guide) to **obtain** your **APP_KEY** and **APP_SECRET**
59
+
60
+ ## Installation
61
+
62
+ Add this line to your application's Gemfile:
63
+
64
+ gem 'wix-hive-ruby'
65
+
66
+ And then execute:
67
+
68
+ $ bundle
69
+
70
+ Or install it yourself as:
71
+
72
+ $ gem install wix-hive-ruby
73
+
74
+ ## Quick Start
75
+
76
+ ``` ruby
77
+ require 'sinatra'
78
+ require 'wix-hive-ruby'
79
+
80
+ SECRET_KEY = 'YOUR_SECRET_KEY'
81
+ APP_ID = 'YOUR_APP_ID'
82
+
83
+ # The route should match the app endpoint set during registration
84
+ get '/' do
85
+ # The GET request to your app endpoint will contain an instance parameter for you to parse
86
+ instance = params.delete('instance')
87
+
88
+ # Parse the instance parameter
89
+ wixInstance = Hive::Client.parse_instance_data(instance, SECRET_KEY)
90
+
91
+ # Create a Wix Hive Client
92
+ client = Hive::Client.new do |config|
93
+ config.secret_key = SECRET_KEY
94
+ config.app_id = APP_ID
95
+ config.instance_id = wixInstance.instanceId
96
+ end
97
+
98
+ contact = Hive::Contact.new
99
+ contact.name.first = 'Quick'
100
+ contact.name.last = 'Start'
101
+ contact.add_email(email: 'quick.start@example.com', tag: 'work')
102
+ contact.add_phone(phone: '123456789', tag: 'work')
103
+ contact.add_url(url: 'wix.com', tag: 'site')
104
+
105
+ # Create a new contact
106
+ contact_res = client.new_contact(contact)
107
+
108
+ FACTORY = Hive::Activities
109
+ activity = Hive::Activity.new(
110
+ type: FACTORY::MUSIC_ALBUM_FAN.type,
111
+ locationUrl: 'http://www.wix.com',
112
+ details: { summary: 'test', additionalInfoUrl: 'http://www.wix.com' },
113
+ info: { album: { name: 'Wix', id: '1234' } })
114
+
115
+ # Add an activity to the contact
116
+ activity_res = client.add_contact_activity(contact_res.contactId, activity)
117
+
118
+ body "Contact created: #{contact_res.contactId}.
119
+ Activity created: #{activity_res.activityId}
120
+ Thank you!"
121
+ end
122
+
123
+ after do
124
+ headers({ 'X-Frame-Options' => 'ALLOW-FROM wix.com' })
125
+ end
126
+ ```
127
+ ## Manual
128
+
129
+ ### Configuration
130
+ The entry point to the Wix Hive API is the `Hive::Client`. You can initialize the class by passing it a configuration block.
131
+
132
+ ####The basic configuration is:
133
+ ``` ruby
134
+ Hive::Client.new do |config|
135
+ config.secret_key = 'SECRET-KEY'
136
+ config.app_id = 'APP-ID'
137
+ config.instance_id = 'INSTANCE-ID'
138
+ end
139
+ ```
140
+
141
+ 1. The `config.secret_key` and `config.app_id` are obtained by registering an app as it is outlined [here](http://dev.wix.com/docs/display/DRAF/Dev+Center+Registration+Guide)
142
+ 2. The `config.instance_id` is obtained by decoding the signed app instance. Learn more about this [here](http://dev.wix.com/docs/display/DRAF/Using+the+Signed+App+Instance)
143
+ * Note: The Hive client has a utility method that parses the instance data. Example usage:
144
+ ``` ruby
145
+ wixInstance = Hive::Client.parse_instance_data(INSTANCE, SECRET-KEY)
146
+ wixInstance.demoMode
147
+ wixInstance.instanceId
148
+ wixInstance.ipAndPort
149
+ wixInstance.permissions
150
+ wixInstance.signDate
151
+ wixInstance.uid
152
+ wixInstance.vendorProductId
153
+ ```
154
+
155
+ ####Advanced configuration options include:
156
+
157
+ 1. `config.logger` options:
158
+ * `:stdout` logs the request and response data to the STDOUT.
159
+ * `:file` logs the request and response data to hive.log.
160
+ 2. `config.request_config` appends items to the default [Faraday](https://github.com/lostisland/faraday) request configuration.
161
+ * Example:
162
+ ``` ruby
163
+ config.request_config = { open_timeout: 10, timeout: 30 }
164
+ ```
165
+ 3. `config.headers` appends items to the default request headers.
166
+ * Example:
167
+ ``` ruby
168
+ config.headers = { custom-header: 'custom' }
169
+ ```
170
+ 4. `config.api_family` global api family version defaults to `v1`.
171
+ 5. `config.api_version` global api version defaults to `1.0.0`.
172
+ 6. `config.api_base` global api version defaults to `https://openapi.wix.com`.
173
+
174
+ ### Hive DTOs
175
+ The Hive DTOs are based on [Hashie](https://github.com/intridea/hashie) which in essence means that they are hashes with extra functionality.
176
+
177
+ ####Constructing request data
178
+
179
+ #####There are two ways of doing it:
180
+
181
+ 1. The "OO way" which is basically creating objects and composing them together.
182
+ * Example:
183
+ ``` ruby
184
+ contact = Hive::Contact.new
185
+ contact.name.first = 'E2E'
186
+ contact.name.last = 'Cool'
187
+ contact.company.name = 'Wix'
188
+ contact.company.role = 'CEO'
189
+ contact.add_email(email: 'alext@wix.com', tag: 'work')
190
+ contact.add_phone(phone: '123456789', tag: 'work')
191
+ contact.add_address(tag: 'home', address: '28208 N Inca St.', neighborhood: 'LODO', city: 'Denver', region: 'CO', country: 'US', postalCode: '80202')
192
+ contact.add_date(date: Time.now.iso8601(3), tag: 'E2E')
193
+ contact.add_url(url: 'wix.com', tag: 'site')
194
+ ```
195
+ 2. The "dynamic way" which means creating hashes and wiring them together. (Note: these will be transformed to objects 'under the hood'.)
196
+ * Example:
197
+ ``` ruby
198
+ guest = { total: 1, adults: 1, children: 0 }
199
+
200
+ day_ago = (Time.now - (60 * 60 * 24)).iso8601(3)
201
+ stay = { checkin: day_ago, checkout: Time.now.iso8601(3) }
202
+
203
+ invoice = {total: '1', subtotal: '1', currency: 'EUR'}
204
+
205
+ payment = {total: '1', subtotal: '1', currency: 'EUR', source: 'Cash'}
206
+
207
+ activity = Hive::Activity.new(
208
+ type: FACTORY::HOTELS_PURCHASE.type,
209
+ locationUrl: 'http://www.wix.com',
210
+ details: {summary: 'test', additionalInfoUrl: 'http://www.wix.com'},
211
+ info: { source: 'GUEST', guests: guest, stay: stay, invoice: invoice, payment: payment })
212
+ ```
213
+
214
+ ###Accessing response data
215
+
216
+ The response JSON is transformed into a DTO object. And can be accessed as shown in the example below:
217
+
218
+ * Example JSON response:
219
+ ``` json
220
+ {
221
+ "createdAt": "2014-09-02T04:57:43.081-05:00",
222
+ "emails": [
223
+ {
224
+ "contactSubscriptionStatus": "notSet",
225
+ "email": "alext@wix.com",
226
+ "emailStatus": "transactional",
227
+ "id": 1,
228
+ "siteOwnerSubscriptionStatus": "notSet",
229
+ "tag": "work"
230
+ }
231
+ ],
232
+ "id": "9e2c4236-2b81-4800-b7bd-d0365c9a391e",
233
+ "name": {
234
+ "first": "Wix",
235
+ "last": "Cool",
236
+ "middle": "",
237
+ "prefix": "",
238
+ "suffix": ""
239
+ },
240
+ "notes": [],
241
+ "phones": [
242
+ {
243
+ "id": 1,
244
+ "phone": "123456789",
245
+ "tag": "work"
246
+ }
247
+ ],
248
+ "tags": [
249
+ "contacts/create",
250
+ "contacts_server/new",
251
+ "contacts_server/show"
252
+ ],
253
+ "urls": []
254
+ }
255
+ ```
256
+
257
+ * Example accessing data:
258
+
259
+ ``` ruby
260
+ contact.id # "9e2c4236-2b81-4800-b7bd-d0365c9a391e"
261
+ contact.createdAt # "2014-09-02T04:57:43.081-05:00"
262
+ contact.name.first # "Wix"
263
+ contact.name.last # "Cool"
264
+ contact.phones.first.id # 1
265
+ contact.phones.first.phone # 123456789
266
+ contact.phones.first.tag # work
267
+ contact.tags.first # "contacts/create"
268
+ contact.emails.first.email # "alext@wix.com"
269
+ ```
270
+
271
+ ### Hive Cursored Data
272
+ A cursored response JSON looks like:
273
+ ``` json
274
+ {
275
+ "nextCursor": "fd14d5ef831fb9d2e43da26b2c8fe74b704d3fd9ab8be9a251540ecea236f28fa532c035b4ca796387ab114aa37fef098b5cddf114fca450f8868b27e3393299",
276
+ "pageSize": 25,
277
+ "results": [......],
278
+ "total": 1749
279
+ }
280
+ ```
281
+
282
+ That gets mapped to a `Hive::Cursor` object and can be accessed in the same way as the DTOs.(Note: the results objects are also transformed to DTOs)
283
+ Here is a list of methods that the cursor object contains:
284
+ ```
285
+ .next?
286
+ .previous?
287
+ .next_page
288
+ .previous_page
289
+ ```
290
+
291
+ ### Hive Errors
292
+ #### Response Errors
293
+ ``` ruby
294
+ 400 => Hive::Response::Error::BadRequest,
295
+ 403 => Hive::Response::Error::Forbidden,
296
+ 404 => Hive::Response::Error::NotFound,
297
+ 408 => Hive::Response::Error::RequestTimeout,
298
+ 429 => Hive::Response::Error::TooManyRequests,
299
+ 500 => Hive::Response::Error::InternalServerError,
300
+ 502 => Hive::Response::Error::BadGateway,
301
+ 503 => Hive::Response::Error::ServiceUnavailable,
302
+ 504 => Hive::Response::Error::GatewayTimeout
303
+ ```
304
+ #### Other Errors
305
+ ``` ruby
306
+ Hive::CursorOperationError
307
+ Hive::ConfigurationError
308
+ Hive::SignatureError
309
+ ```
310
+
311
+ ### Contacts API
312
+
313
+ #### client.new_contact
314
+
315
+ **Example:**
316
+ ``` ruby
317
+ contact = Hive::Contact.new
318
+ contact.name.first = 'E2E'
319
+ contact.name.last = 'Cool'
320
+ contact.company.name = 'Wix'
321
+ contact.company.role = 'CEO'
322
+ contact.add_email(email: 'alext@wix.com', tag: 'work')
323
+ contact.add_phone(phone: '123456789', tag: 'work')
324
+ contact.add_address(tag: 'home', address: '28208 N Inca St.', neighborhood: 'LODO', city: 'Denver', region: 'CO', country: 'US', postalCode: '80202')
325
+ contact.add_date(date: Time.now.iso8601(3), tag: 'E2E')
326
+ contact.add_url(url: 'wix.com', tag: 'site')
327
+ # PENDING
328
+ # contact.add_note(content: 'alex', modifiedAt: '2014-08-05T13:59:37.873Z')
329
+ # contact.add_custom(field: 'custom1', value: 'custom')
330
+ client.new_contact(contact)
331
+ ```
332
+
333
+ #### client.contact
334
+
335
+ **Example:**
336
+ ``` ruby
337
+ client.contact(CONTACT_ID)
338
+ ```
339
+
340
+ #### client.update_contact (PENDING)
341
+
342
+ **Example:**
343
+ ``` ruby
344
+ contact.add_email(email: 'wow@wix.com', tag: 'wow')
345
+ contact.add_address(tag: 'home2', address: '1625 Larimer', neighborhood: 'LODO', city: 'Denver', region: 'CO', country: 'US', postalCode: '80202')
346
+ contact.add_date(date: Time.now.iso8601(3), tag: 'E2E UPDATE')
347
+ contact.add_url(url: 'wix.com', tag: 'site')
348
+
349
+ # PENDING
350
+ client.update_contact(CONTACT_ID, contact)
351
+ ```
352
+
353
+ #### client.contacts_tags (PENDING)
354
+
355
+ **Example:**
356
+ ``` ruby
357
+ client.contacts_tags
358
+ ```
359
+
360
+ #### client.contacts_subscribers (PENDING)
361
+
362
+ **Example:**
363
+ ``` ruby
364
+ client.contacts_subscribers
365
+ ```
366
+
367
+ #### client.update_contact_name
368
+
369
+ **Example:**
370
+ ``` ruby
371
+ client.update_contact_name(CONTACT_ID, Hive::Name.new(first: 'New_Name'))
372
+ ```
373
+
374
+ #### client.update_contact_company
375
+
376
+ **Example:**
377
+ ``` ruby
378
+ company = Hive::Company.new
379
+ company.name = 'New_Company'
380
+
381
+ client.update_contact_company(CONTACT_ID, company)
382
+ ```
383
+
384
+ #### client.update_contact_picture
385
+
386
+ **Example:**
387
+ ``` ruby
388
+ client.update_contact_picture(CONTACT_ID, 'wix.com/example.jpg')
389
+ ```
390
+
391
+ #### client.update_contact_address
392
+
393
+ **Example:**
394
+ ``` ruby
395
+ updated_address = Hive::Address.new
396
+ updated_address.tag = 'work'
397
+ updated_address.address = '1625 Larimer St.'
398
+
399
+ client.update_contact_address(CONTACT_ID, ADDRESS_ID, updated_address)
400
+ ```
401
+
402
+ #### client.update_contact_email
403
+
404
+ **Example:**
405
+ ``` ruby
406
+ updated_email = Hive::Email.new
407
+ updated_email.tag = 'work'
408
+ updated_email.email = 'alex@example.com'
409
+ updated_email.emailStatus = 'optOut'
410
+
411
+ client.update_contact_email(CONTACT_ID, EMAIL_ID, updated_email)
412
+ ```
413
+
414
+ #### client.update_contact_phone
415
+
416
+ **Example:**
417
+ ``` ruby
418
+ updated_phone = Hive::Phone.new
419
+ updated_phone.tag = 'work'
420
+ updated_phone.phone = '18006666'
421
+
422
+ client.update_contact_phone(CONTACT_ID, PHONE_ID, updated_phone)
423
+ ```
424
+
425
+ #### client.update_contact_date
426
+
427
+ **Example:**
428
+ ``` ruby
429
+ date = Hive::Date.new
430
+ date.date = Time.now.iso8601(3)
431
+ date.tag = 'update'
432
+
433
+ client.update_contact_date(CONTACT_ID, DATE_ID, date)
434
+ ```
435
+
436
+ #### client.update_contact_note (PENDING)
437
+
438
+ **Example:**
439
+ ``` ruby
440
+ note = Hive::Note.new
441
+ note.content = 'Note'
442
+ note.modifiedAt = Time.now.iso8601(3)
443
+
444
+ client.update_contact_phone(CONTACT_ID, NOTE_ID, note)
445
+ ```
446
+
447
+ #### client.update_contact_custom (PENDING)
448
+
449
+ **Example:**
450
+ ``` ruby
451
+ custom = Hive::Custom.new
452
+ custom.field = 'custom_update'
453
+ custom.value = 'custom_value'
454
+
455
+ client.update_contact_phone(CONTACT_ID, CUSTOM_ID, custom)
456
+ ```
457
+
458
+ #### client.add_contact_address
459
+
460
+ **Example:**
461
+ ``` ruby
462
+ new_address = Hive::Address.new
463
+ new_address.tag = 'work'
464
+ new_address.address = '1625 Larimer St.'
465
+
466
+ client.add_contact_address(CONTACT_ID, new_address)
467
+ ```
468
+
469
+ #### client.add_contact_email
470
+
471
+ **Example:**
472
+ ``` ruby
473
+ new_email = Hive::Email.new
474
+ new_email.tag = 'work_new'
475
+ new_email.email = 'alex_new@example.com'
476
+ new_email.emailStatus = 'optOut'
477
+
478
+ client.add_contact_email(CONTACT_ID, new_email)
479
+ ```
480
+
481
+ #### client.add_contact_phone
482
+
483
+ **Example:**
484
+ ``` ruby
485
+ new_phone = Hive::Phone.new
486
+ new_phone.tag = 'work_new'
487
+ new_phone.phone = '18006666'
488
+
489
+ client.add_contact_phone(CONTACT_ID, new_phone)
490
+ ```
491
+
492
+ #### client.add_contact_note
493
+ **Example:**
494
+ ``` ruby
495
+ note = Hive::Note.new
496
+ note.content = 'Note'
497
+
498
+ client.add_contact_note(CONTACT_ID, note)
499
+ ```
500
+
501
+ #### client.add_contact_custom
502
+
503
+ **Example:**
504
+ ``` ruby
505
+ custom = Hive::Custom.new
506
+ custom.field = 'custom_update'
507
+ custom.value = 'custom_value'
508
+
509
+ client.add_contact_custom(CONTACT_ID, custom)
510
+ ```
511
+
512
+ #### client.add_contact_tags (PENDING)
513
+
514
+ **Example:**
515
+ ``` ruby
516
+ tags = ['tag1/tag', 'tag2/tag']
517
+
518
+ client.add_contact_tags(CONTACT_ID, tags)
519
+ ```
520
+
521
+ #### client.add_contact_activity
522
+
523
+ **Example:**
524
+ ``` ruby
525
+ FACTORY = Hive::Activities
526
+ activity = Hive::Activity.new(
527
+ type: FACTORY::MUSIC_ALBUM_FAN.type,
528
+ locationUrl: 'http://www.wix.com',
529
+ details: { summary: 'test', additionalInfoUrl: 'http://www.wix.com' },
530
+ info: { album: { name: 'Wix', id: '1234' } })
531
+
532
+ client.add_contact_activity(CONTACT_ID, activity)
533
+ ```
534
+
535
+ #### client.contact_activities
536
+
537
+ **Example:**
538
+ ``` ruby
539
+ client.contact_activities(CONTACT_ID)
540
+ ```
541
+
542
+ #### client.contacts
543
+
544
+ **Examples:**
545
+ ``` ruby
546
+ client.contacts
547
+ client.contacts( pageSize: 50 )
548
+ client.contacts( tag: 'contacts_server/new' )
549
+ client.contacts( email: 'alex@example.com' )
550
+ client.contacts( phone: '123456789' )
551
+ client.contacts( firstName: 'E2E' )
552
+ client.contacts( lastName:'Cool' )
553
+ ```
554
+
555
+ #### client.upsert_contact
556
+
557
+ **Examples:**
558
+ ``` ruby
559
+ client.upsert_contact( phone: '123456789' )
560
+ client.upsert_contact( email: 'alex@example.com' )
561
+ client.upsert_contact( phone: '123456789', email: 'alex@example.com' )
562
+ ```
563
+
564
+ ### Activities API
565
+ **Note**: Activity info is created via a factory: 'FACTORY = Hive::Activities'
566
+
567
+ #### client.new_activity
568
+
569
+ **Example:**
570
+ ``` ruby
571
+ Hive::Activity.new(
572
+ type: FACTORY::MUSIC_ALBUM_FAN.type,
573
+ locationUrl: 'http://www.wix.com',
574
+ details: { summary: 'test', additionalInfoUrl: 'http://www.wix.com' },
575
+ info: { album: { name: 'Wix', id: '1234' } })
576
+
577
+ client.new_activity(SESSION_ID, base_activity)
578
+ ```
579
+
580
+ #### client.activity
581
+
582
+ **Example:**
583
+
584
+ ``` ruby
585
+ client.activity(ACTIVITY_ID)
586
+ ```
587
+
588
+ #### client.activities
589
+
590
+ **Examples:**
591
+ ``` ruby
592
+ client.activities
593
+ client.activities(activityTypes: Hive::Activities::MUSIC_ALBUM_FAN.type)
594
+ client.activities(from: Time.now.iso8601(3), until: Time.now.iso8601(3))
595
+ ```
596
+
597
+ ### Insights API
598
+
599
+ #### client.activities_summary
600
+
601
+ **Example:**
602
+ ``` ruby
603
+ client.activities_summary
604
+ ```
605
+
606
+ #### client.contact_activities_summary
607
+
608
+ **Example:**
609
+ ``` ruby
610
+ client.contact_activities_summary(CONTACT_ID)
611
+ ```
612
+ ## Contributing
613
+
614
+ **Everyone** is encouraged to help **improve** this gem. Some of the ways you can contribute include:
615
+
616
+ 1. Use alpha, beta, and pre-release versions.
617
+ 2. Report bugs.
618
+ 3. Suggest new features.
619
+ 4. Write or edit documentation.
620
+ 5. Write specifications.
621
+ 6. Write code (**no patch is too small**: fix typos, clean up inconsistent whitespace).
622
+ 7. Refactor code.
623
+ 8. Fix [issues](https://github.com/wix/wix-hive-ruby/issues).
624
+ 9. Submitt an Issue
625
+
626
+ ### Submitting an Issue
627
+
628
+ We use the GitHub issue tracker to track bugs and features. Before submitting a bug report or feature request, check to make sure it hasn't already been submitted. When submitting a bug report, please include a Gist that includes a stack trace and any details that may be necessary to reproduce the bug, including your gem version, Ruby version, and operating system. Ideally, a bug report should include a pull request with failing specs.
629
+
630
+ ### Submitting a Pull Request
631
+
632
+ 1. Fork it ( https://github.com/[my-github-username]/wix-hive-ruby/fork )
633
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
634
+ 3. Add specs for your unimplemented feature or bug fix. (**Note:** When developing a new API a `e2e` test is mandatory.)
635
+ 4. Run `bundle exec rake spec`. If your specs pass, return to step 3. (**Note:** When developing a new API run `bundle exec rake e2e` first. This will record a [VCR Cassette](https://relishapp.com/vcr/vcr/v/2-9-2/docs/getting-started) the first time you run it.)
636
+ 5. Implement your feature or bug fix.
637
+ 6. Run `bundle exec rake`. If your specs fail, return to step 5. (**Note:** Fix any rubocop issues that were not automatically fixed.)
638
+ 7. Run open coverage/index.html. If your changes are not completely covered by your tests, return to step 3.
639
+ 8. Commit your changes (`git commit -am 'Add some feature'`)
640
+ 9. Push to the branch (`git push origin my-new-feature`)
641
+ 10. Create a new [Pull Request](http://help.github.com/send-pull-requests/)