mints 0.0.17 → 0.0.21

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +2 -1
  3. data/lib/client.rb +96 -37
  4. data/lib/contact.rb +659 -94
  5. data/lib/generators/mints_files_generator.rb +6 -0
  6. data/lib/generators/mints_link.rb +61 -0
  7. data/lib/generators/short_link_controller.rb +41 -0
  8. data/lib/mints/controllers/admin_base_controller.rb +2 -2
  9. data/lib/mints/controllers/base_api_controller.rb +12 -11
  10. data/lib/mints/controllers/base_controller.rb +38 -9
  11. data/lib/mints_helper.rb +47 -0
  12. data/lib/pub.rb +258 -139
  13. data/lib/user/config/api_keys.rb +65 -0
  14. data/lib/user/config/appointments.rb +221 -0
  15. data/lib/user/config/attribute_groups.rb +77 -0
  16. data/lib/user/config/attributes.rb +86 -0
  17. data/lib/user/config/calendars.rb +89 -0
  18. data/lib/user/config/config.rb +65 -0
  19. data/lib/user/config/importers.rb +184 -0
  20. data/lib/user/config/public_folders.rb +108 -0
  21. data/lib/user/config/relationships.rb +138 -0
  22. data/lib/user/config/roles.rb +84 -0
  23. data/lib/user/config/seeds.rb +14 -0
  24. data/lib/user/config/system_settings.rb +53 -0
  25. data/lib/user/config/tags.rb +63 -0
  26. data/lib/user/config/taxonomies.rb +124 -0
  27. data/lib/user/config/teams.rb +70 -0
  28. data/lib/user/config/users.rb +76 -0
  29. data/lib/user/contacts/contacts.rb +21 -0
  30. data/lib/user/content/assets.rb +260 -0
  31. data/lib/user/content/content.rb +235 -0
  32. data/lib/user/content/content_instances.rb +147 -0
  33. data/lib/user/content/content_templates.rb +111 -0
  34. data/lib/user/content/conversations.rb +174 -0
  35. data/lib/user/content/dam.rb +88 -0
  36. data/lib/user/content/forms.rb +168 -0
  37. data/lib/user/content/message_templates.rb +162 -0
  38. data/lib/user/content/messages.rb +90 -0
  39. data/lib/user/content/pages.rb +81 -0
  40. data/lib/user/content/stories.rb +164 -0
  41. data/lib/user/content/story_templates.rb +95 -0
  42. data/lib/user/crm/companies.rb +111 -0
  43. data/lib/user/crm/contacts.rb +312 -0
  44. data/lib/user/crm/crm.rb +21 -0
  45. data/lib/user/crm/deals.rb +111 -0
  46. data/lib/user/crm/favorites.rb +17 -0
  47. data/lib/user/crm/segments.rb +132 -0
  48. data/lib/user/crm/users.rb +22 -0
  49. data/lib/user/crm/workflow_step_objects.rb +89 -0
  50. data/lib/user/crm/workflow_steps.rb +49 -0
  51. data/lib/user/crm/workflows.rb +70 -0
  52. data/lib/user/ecommerce/ecommerce.rb +29 -0
  53. data/lib/user/ecommerce/item_prices.rb +86 -0
  54. data/lib/user/ecommerce/locations.rb +166 -0
  55. data/lib/user/ecommerce/order_items_groups.rb +109 -0
  56. data/lib/user/ecommerce/order_statuses.rb +26 -0
  57. data/lib/user/ecommerce/orders.rb +258 -0
  58. data/lib/user/ecommerce/price_lists.rb +73 -0
  59. data/lib/user/ecommerce/product_templates.rb +104 -0
  60. data/lib/user/ecommerce/product_variations.rb +129 -0
  61. data/lib/user/ecommerce/products.rb +169 -0
  62. data/lib/user/ecommerce/skus.rb +88 -0
  63. data/lib/user/ecommerce/taxes.rb +82 -0
  64. data/lib/user/ecommerce/variant_options.rb +69 -0
  65. data/lib/user/ecommerce/variant_values.rb +72 -0
  66. data/lib/user/helpers/helpers.rb +113 -0
  67. data/lib/user/helpers/object_activities.rb +83 -0
  68. data/lib/user/helpers/object_folders.rb +82 -0
  69. data/lib/user/helpers/user_folders.rb +83 -0
  70. data/lib/user/marketing/marketing.rb +120 -0
  71. data/lib/user/profile/profile.rb +111 -0
  72. data/lib/user.rb +24 -368
  73. metadata +64 -2
data/lib/contact.rb CHANGED
@@ -1,51 +1,119 @@
1
1
  require_relative "./client.rb"
2
+ require_relative "./mints_helper.rb"
2
3
  include ActionController::Cookies
3
4
  module Mints
4
5
  class Contact
5
6
  attr_reader :client
6
7
  ##
7
8
  # === Initialize.
8
- # Class constructor
9
+ # Class constructor.
9
10
  #
11
+ # ==== Parameters
12
+ # host:: (String) -- It's the visitor IP.
13
+ # api_key:: (String) -- Mints instance api key.
14
+ # contact_token_id:: (Integer) -- Cookie 'mints_contact_id' value (mints_contact_token).
15
+ #
16
+ # ==== Return
17
+ # Returns a Contact object
10
18
  def initialize(host, api_key, session_token = nil, contact_token_id = nil, debug = false)
11
- @client = Mints::Client.new(host, api_key, "contact", session_token, contact_token_id, debug)
19
+ @contact_v1_url = '/api/contact/v1'
20
+ @client = Mints::Client.new(host, api_key, "contact", session_token, contact_token_id, nil, debug)
12
21
  end
13
22
 
23
+ ### V1/CONTACTS ###
24
+
14
25
  ##
15
- # === Login.
16
- # Starts a contact session
26
+ # === Register.
27
+ # Register a contact.
17
28
  #
18
- # ==== Parameters:
19
- # * +email+ - [_String_] The email that will be logged.
20
- # * +password+ - [_String_] The password of the email.
29
+ # ==== Parameters
30
+ # data:: (Hash) -- It's the register data.
21
31
  #
22
32
  # ==== Example
23
- # @mints_contact.login("brown.abigail@dubuque.com", "helloword")
33
+ # data = {
34
+ # "email": "email@example.com",
35
+ # "given_name": "Given Name",
36
+ # "last_name": "Last Name",
37
+ # "password": "password"
38
+ # }
39
+ # @mints_contact.register(data);
40
+ def register(data)
41
+ return @client.raw("post", "/contacts/register", nil, data_transform(data))
42
+ end
43
+
44
+ ##
45
+ # === Login.
46
+ # Starts a contact session.
47
+ #
48
+ # ==== Parameters
49
+ # email:: (String) -- The email that will be logged.
50
+ # password:: (String) -- The password of the email.
24
51
  #
52
+ # ==== Example
53
+ # @mints_contact.login("email@example.com", "password")
25
54
  def login(email, password)
26
55
  data = {
27
56
  email: email,
28
57
  password: password
29
58
  }
30
- response = @client.raw("post", "/contacts/login", nil, {data: data})
59
+ response = @client.raw("post", "/contacts/login", nil, {data: data}.to_json)
31
60
  if response.key? "session_token"
32
61
  @client.session_token = response["session_token"]
33
62
  end
34
63
  return response
35
64
  end
36
65
 
66
+ ##
67
+ # === Recover Password.
68
+ # Send a email that contains a token to a contact. That token will be used in reset_password to establish a new password.
69
+ #
70
+ # ==== Parameters
71
+ # data:: (Hash) -- It's a data key where will be hosted the destination email.
72
+ #
73
+ # ==== Example
74
+ # data = { "email": "email@example.com" }
75
+ # @mints_contact.recover_password(data)
76
+ def recover_password(data)
77
+ return @client.raw("post", "/contacts/recover-password", nil, data_transform(data))
78
+ end
79
+
80
+ ##
81
+ # === Reset Password.
82
+ # Reset password using a token. The token is obtained by recover_password method.
83
+ #
84
+ # ==== Parameters
85
+ # data:: (Hash) -- It's a set of data which contains all the information to reset a contact password.
86
+ #
87
+ # ==== Example
88
+ # data = {
89
+ # "email": "email@example.com",
90
+ # "password": "password",
91
+ # "password_confirmation": "password",
92
+ # "token": "644aa3aa0831d782cc42e42b11aedea9a2234389af4f429a8d96651295ecfa09"
93
+ # }
94
+ # @mints_contact.reset_password(data)
95
+ def reset_password(data)
96
+ return @client.raw("post", "/contacts/reset-password", nil, data_transform(data))
97
+ end
98
+
99
+ ##
100
+ # === OAuth Login.
101
+ # Login a contact using oauth.
102
+ def oauth_login(data)
103
+ return @client.raw("post", "/contacts/oauth-login", nil, data)
104
+ end
105
+
37
106
  ##
38
107
  # === Magic Link Login.
39
108
  # Starts a contact session with a token received in the contact email. The token will be received by send_magic_link method.
40
109
  #
41
- # ==== Parameters:
42
- # * +token+ - [_String_] The email that will be logged.
110
+ # ==== Parameters
111
+ # token:: (String) -- The email token that will be used to log in.
43
112
  #
44
113
  # ==== Example
45
114
  # @mints_contact.magic_link_login(
46
115
  # "d8618c6d-a165-41cb-b3ec-d053cbf30059:zm54HtRdfHED8dpILZpjyqjPIceiaXNLfOklqM92fveBS0nDtyPYBlI4CPlPe3zq"
47
116
  # )
48
- #
49
117
  def magic_link_login(token)
50
118
  response = @client.raw("get", "/contacts/magic-link-login/#{token}", nil, '/api/v1')
51
119
  if response.key? "session_token"
@@ -55,22 +123,21 @@ module Mints
55
123
  end
56
124
 
57
125
  ##
58
- # === Send Magic Link
126
+ # === Send Magic Link.
59
127
  # Send magic link to contact by email. That magic link will be used in magic_link_login method.
60
128
  #
61
- # ==== Parameters:
62
- # * +email+ - [_String_] Contact's email.
63
- # * +template_slug+ - [_String_] Email template's slug to be used in the email.
64
- # * +redirectUrl+ - [_String_] Url to be redirected in the implemented page.
65
- # * +lifeTime+ - [_Integer_] Maximum time of use in minutes.
66
- # * +maxVisits+ - [_Integer_] The maximum number of uses of a token.
129
+ # ==== Parameters
130
+ # email:: (String) -- Contact's email.
131
+ # template_slug:: (String) -- Email template's slug to be used in the email.
132
+ # redirectUrl:: (String) -- Url to be redirected in the implemented page.
133
+ # lifeTime:: (Integer) -- Maximum time of use in minutes.
134
+ # maxVisits:: (Integer) -- The maximum number of uses of a token.
67
135
  #
68
136
  # ==== First Example
69
- # @mints_contact.send_magic_link("brown.abigail@dubuque.com", "")
137
+ # @mints_contact.send_magic_link("email@example.com", "template_slug")
70
138
  #
71
139
  # ==== Second Example
72
- # @mints_contact.send_magic_link("brown.abigail@dubuque.com", "", "", 1440, 3)
73
- #
140
+ # @mints_contact.send_magic_link("email@example.com", "template_slug", "", 1440, 3)
74
141
  def send_magic_link(email, template_slug, redirectUrl = '', lifeTime = 1440, maxVisits = nil)
75
142
  data = {
76
143
  email: email,
@@ -79,20 +146,67 @@ module Mints
79
146
  redirectUrl: redirectUrl,
80
147
  templateId: template_slug
81
148
  }
82
- response = @client.raw("post", "/contacts/magic-link", nil, { data: data }, '/api/v1')
149
+ response = @client.raw("post", "/contacts/magic-link", nil, { data: data }.to_json, '/api/v1')
83
150
  return response
84
151
  end
85
152
 
153
+ ### CONTACT/V1 ###
154
+
155
+ ##
156
+ # === Me.
157
+ # Get contact logged info.
158
+ #
159
+ # ==== Parameters
160
+ # # options:: (Hash) -- List of {Resource collection Options}[#class-Mints::Pub-label-Resource+collections+options+] shown above can be used as parameter.
161
+ #
162
+ # ==== First Example
163
+ # @data = @mints_contact.me
164
+ #
165
+ # ==== Second Example
166
+ # options = {
167
+ # "attributes": true,
168
+ # "taxonomies": true
169
+ # }
170
+ # @data = @mints_contact.me(options)
171
+ def me(options = nil)
172
+ return @client.raw("get", "/me", options, nil, @contact_v1_url)
173
+ end
174
+
175
+ ##
176
+ # === Status.
177
+ # Get contact logged status.
178
+ #
179
+ # ==== Example
180
+ # @data = @mints_contact.status
181
+ def status
182
+ return @client.raw("get", "/status", nil, nil, @contact_v1_url)
183
+ end
184
+
185
+ ##
186
+ # === Update.
187
+ # Update logged contact attributes.
188
+ #
189
+ # ==== Parameters
190
+ # data:: (Hash) -- It's the data to update with a session active.
191
+ #
192
+ # ==== Example
193
+ # data = {
194
+ # "given_name": "Given Name",
195
+ # "last_name": "Last Name"
196
+ # }
197
+ # @data = @mints_contact.update(data)
198
+ def update(data)
199
+ return @client.raw("put", "/update", nil, data_transform(data), @contact_v1_url)
200
+ end
201
+
86
202
  ##
87
203
  # === Logout.
88
204
  # Ends a contact session previously logged.
89
205
  #
90
206
  # ==== Example
91
- # @mints_contact.login('brown.abigail@dubuque.com', 'helloword')
92
- # @mints_contact.logout
93
- #
207
+ # @data = @mints_contact.logout
94
208
  def logout
95
- response = @client.raw("post", "/contacts/logout") if session_token?
209
+ response = @client.raw("post", "/logout", nil, nil, @contact_v1_url) if session_token?
96
210
  if response["success"]
97
211
  @client.session_token = nil
98
212
  end
@@ -103,124 +217,575 @@ module Mints
103
217
  # === Change Password.
104
218
  # Change password without email. To change the password a contact must be logged.
105
219
  #
106
- # ==== Parameters:
107
- # * +data+ - [] A new password allocated in a data key.
220
+ # ==== Parameters
221
+ # data:: (Hash) -- A new password allocated in a data key.
108
222
  #
109
223
  # ==== Example
110
- # @mints_contact.login('brown.abigail@dubuque.com', 'helloword')
111
- # data = { "data": { "password": "123456" } }
112
- # @mints_contact.change_password(data)
113
- #
224
+ # data = { "password": "new_password" }
225
+ # @data = @mints_contact.change_password(data)
114
226
  def change_password(data)
115
- return @client.raw("post", "/contacts/change-password", nil, data)
227
+ return @client.raw("post", "/change-password", nil, data_transform(data), @contact_v1_url)
116
228
  end
117
229
 
230
+ # Conversations
231
+
118
232
  ##
119
- # === Recover Password.
120
- # Send a email that contains a token to a contact. That token will be used in reset_password to establish a new password.
233
+ # === Get Conversations.
234
+ # Get a collection of conversations.
235
+ #
236
+ # ==== Parameters
237
+ # options:: (Hash) -- List of Resource Collection Options shown above can be used as parameter.
238
+ # FIXME: This method doesn't return data.
239
+ def get_conversations(options = nil)
240
+ return @client.raw("get", "/content/conversations", options, nil, @contact_v1_url)
241
+ end
242
+
243
+ ##
244
+ # === Get Conversation.
245
+ # Get a conversation info.
246
+ #
247
+ # ==== Parameters
248
+ # id:: (Integer) -- Conversation id.
249
+ # options:: (Hash) -- List of Resource Collection Options shown above can be used as parameter.
250
+ # FIXME: This method doesn't return data.
251
+ def get_conversation(id, options = nil)
252
+ return @client.raw("get", "/content/conversations/#{id}", options, nil, @contact_v1_url)
253
+ end
254
+
255
+ ##
256
+ # === Create Conversation.
257
+ # Create a conversation with data.
121
258
  #
122
- # ==== Parameters:
123
- # * +data+ - [] It's a data key where will be hosted the destination email.
259
+ # ==== Parameters
260
+ # data:: (Hash) -- Data to be submited.
124
261
  #
125
262
  # ==== Example
126
- # data = { "data": { "email": "brown.abigail@dubuque.com" } }
127
- # @mints_contact.recover_password(data)
263
+ # data = {
264
+ # "title": "New Conversation To Test"
265
+ # }
266
+ # @data = @mints_contact.create_conversation(data)
267
+ def create_conversation(data)
268
+ return @client.raw("post", "/content/conversations", nil, data_transform(data), @contact_v1_url)
269
+ end
270
+
271
+ ##
272
+ # === Update Conversation.
273
+ # Update a location template info.
274
+ #
275
+ # ==== Parameters
276
+ # id:: (Integer) -- Conversation id.
277
+ # data:: (Hash) -- Data to be submited.
278
+ # FIXME: This method doesn't locate conversation id to be updated.
279
+ def update_conversation(id, data)
280
+ return @client.raw("put", "/content/conversations/#{id}", nil, data_transform(data), @contact_v1_url)
281
+ end
282
+
283
+ ##
284
+ # === Update Conversation Status.
285
+ # Update a conversation status.
286
+ #
287
+ # ==== Parameters
288
+ # id:: (Integer) -- Conversation id.
289
+ # data:: (Hash) -- Data to be submited.
290
+ # FIXME: This method doesn't locate conversation id to be updated.
291
+ def update_conversation_status(id, data)
292
+ return @client.raw("put", "/content/conversations/#{id}/status", nil, data_transform(data), @contact_v1_url)
293
+ end
294
+
295
+ ##
296
+ # === Get Conversation Participants.
297
+ # Update a conversation participants.
298
+ #
299
+ # ==== Parameters
300
+ # id:: (Integer) -- Conversation id.
301
+ # FIXME: This method doesn't locate conversation id to be updated.
302
+ def get_conversation_participants(id)
303
+ #TODO: Test if this method needs data in options.
304
+ return @client.raw("get", "/content/conversations/#{id}/participants", nil, nil, @contact_v1_url)
305
+ end
306
+
307
+ ##
308
+ # === Get Messages.
309
+ # Get a collection of messages.
310
+ #
311
+ # ==== Parameters
312
+ # options:: (Hash) -- List of Resource Collection Options shown above can be used as parameter.
313
+ # FIXME: This method doesn't return data.
314
+ def get_messages(options = nil)
315
+ return @client.raw("get", "/content/messages", options, nil, @contact_v1_url)
316
+ end
317
+
318
+ ##
319
+ # === Get Message.
320
+ # Get a message info.
321
+ #
322
+ # ==== Parameters
323
+ # id:: (Integer) -- Message id.
324
+ # options:: (Hash) -- List of Resource Collection Options shown above can be used as parameter.
325
+ # FIXME: This method doesn't return data.
326
+ def get_message(id, options = nil)
327
+ return @client.raw("get", "/content/messages/#{id}", options, nil, @contact_v1_url)
328
+ end
329
+
330
+ ##
331
+ # === Create Message.
332
+ # Create a message with data.
128
333
  #
129
- def recover_password(data)
130
- return @client.raw("post", "/contacts/recover-password", nil, data)
334
+ # ==== Parameters
335
+ # data:: (Hash) -- Data to be submited.
336
+ #
337
+ # ==== Example
338
+ # data = {
339
+ # "conversation_id": 3,
340
+ # "type": "text",
341
+ # "value": {
342
+ # "text": "Message Text"
343
+ # }
344
+ # }
345
+ # @data = @mints_contact.create_message(data)
346
+ def create_message(data)
347
+ return @client.raw("post", "/content/messages", nil, data_transform(data), @contact_v1_url)
131
348
  end
132
349
 
350
+ # Appointments
351
+
133
352
  ##
134
- # === Reset Password.
135
- # Reset password using a token. The token is obtained by recover_password method.
353
+ # === Get Appointments.
354
+ # Get a collection of appointments.
355
+ #
356
+ # ==== Parameters
357
+ # options:: (Hash) -- List of Resource Collection Options shown above can be used as parameter.
358
+ #
359
+ # ==== First Example
360
+ # @data = @mints_contact.get_appointments
361
+ #
362
+ # ==== Second Example
363
+ # options = {
364
+ # "fields": "id, created_at"
365
+ # }
366
+ # @data = @mints_contact.get_appointments(options)
367
+ def get_appointments(options = nil)
368
+ return @client.raw("get", "/contacts/appointments", options)
369
+ end
370
+
371
+ ##
372
+ # === Get Appointment.
373
+ # Get an appointment info.
374
+ #
375
+ # ==== Parameters
376
+ # options:: (Hash) -- List of Resource Collection Options shown above can be used as parameter.
377
+ #
378
+ # ==== First Example
379
+ # @data = @mints_contact.get_appointment(1)
380
+ #
381
+ # ==== Second Example
382
+ # options = {
383
+ # "fields": "id, created_at"
384
+ # }
385
+ # @data = @mints_contact.get_appointment(1, options)
386
+ def get_appointment(id, options = nil)
387
+ return @client.raw("get", "/contacts/appointments/#{id}", options)
388
+ end
389
+
390
+ ##
391
+ # === Create Appointment.
392
+ # Create an appointment with data.
136
393
  #
137
- # ==== Parameters:
138
- # * +data+ - [] It's a set of data which contains all the information to reset a contact password.
394
+ # ==== Parameters
395
+ # data:: (Hash) -- Data to be submited.
139
396
  #
140
397
  # ==== Example
141
- # data = { "data": {
142
- # "email": "brown.abigail@dubuque.com",
143
- # "password": "helloword",
144
- # "password_confirmation": "helloword",
145
- # "token": "644aa3aa0831d782cc42e42b11aedea9a2234389af4f429a8d96651295ecfa09"
146
- # } }
147
- # @mints_contact.reset_password(data)
398
+ # data = {
399
+ # "object_model": "products",
400
+ # "object_id": 1,
401
+ # "title": "New Appointment",
402
+ # "start": "2021-11-25T14:15:00+00:00",
403
+ # "end": "2022-01-01T13:00:00+00:00"
404
+ # }
405
+ # @data = @mints_contact.create_appointment(data)
406
+ def create_appointment(data)
407
+ return @client.raw("post", "/contacts/appointments", nil, data_transform(data))
408
+ end
409
+
410
+ ##
411
+ # === Update Appointment.
412
+ # Update an appointment info.
148
413
  #
149
- def reset_password(data)
150
- return @client.raw("post", "/contacts/reset-password", nil, data)
414
+ # ==== Parameters
415
+ # id:: (Integer) -- Appointment id.
416
+ # data:: (Hash) -- Data to be submited.
417
+ #
418
+ # ==== Example
419
+ # data = {
420
+ # "object_id": 2
421
+ # }
422
+ # @data = @mints_contact.update_appointment(1, data)
423
+ def update_appointment(id, data)
424
+ return @client.raw("put", "/contacts/appointments/#{id}", nil, data_transform(data))
151
425
  end
152
426
 
153
427
  ##
154
- # === OAuth Login.
155
- # Login a contact using oauth
428
+ # === Scheduled Appointments.
429
+ # Get a collection of appointments filtering by object_type, object_id and dates range.
156
430
  #
157
- def oauth_login(data)
158
- return @client.raw("post", "/contacts/oauth-login", nil, data)
431
+ # ==== Parameters
432
+ # data:: (Hash) -- Data to be submited.
433
+ #
434
+ # ==== Example
435
+ # data = {
436
+ # "object_model": "products",
437
+ # "object_id": 2,
438
+ # "start": "2021-11-25T14:15:00+00:00",
439
+ # "end": "2022-01-01T13:00:00+00:00"
440
+ # }
441
+ # @data = @mints_contact.scheduled_appointments(data)
442
+ def scheduled_appointments(data)
443
+ return @client.raw("post", "/contacts/appointments/scheduled-appointments", nil, data_transform(data))
444
+ end
445
+
446
+ ##
447
+ # === Attach Invitee.
448
+ # Attach invitee to an appointment.
449
+ #
450
+ # ==== Parameters
451
+ # data:: (Hash) -- Data to be submited.
452
+ #
453
+ # ==== Example
454
+ # data = {
455
+ # "appointment_id": 1,
456
+ # "invitee_ids": 1
457
+ # }
458
+ # @data = @mints_contact.attach_invitee(data)
459
+ def attach_invitee(data)
460
+ return @client.raw("post", "/contacts/appointments/attach-invitee", nil, data_transform(data))
159
461
  end
160
462
 
161
463
  ##
162
- # === Me.
163
- # Get contact logged info.
464
+ # === Attach Follower.
465
+ # Attach follower to an appointment.
466
+ #
467
+ # ==== Parameters
468
+ # data:: (Hash) -- Data to be submited.
164
469
  #
165
470
  # ==== Example
166
- # @mints_contact.me
471
+ # data = {
472
+ # "appointment_id": 1,
473
+ # "follower_ids": 1
474
+ # }
475
+ # @data = @mints_contact.attach_follower(data)
476
+ def attach_follower(data)
477
+ return @client.raw("post", "/contacts/appointments/attach-follower", nil, data_transform(data))
478
+ end
479
+
480
+ ##
481
+ # === Detach Invitee.
482
+ # Detach invitee from an appointment.
483
+ #
484
+ # ==== Parameters
485
+ # data:: (Hash) -- Data to be submited.
167
486
  #
168
- def me
169
- return @client.raw("get", "/contacts/me")
487
+ # ==== Example
488
+ # data = {
489
+ # "appointment_id": 1,
490
+ # "invitee_ids": 1
491
+ # }
492
+ # @data = @mints_contact.detach_invitee(data)
493
+ def detach_invitee(data)
494
+ return @client.raw("post", "/contacts/appointments/detach-invitee", nil, data_transform(data))
170
495
  end
171
496
 
172
497
  ##
173
- # === Status.
174
- # Get contact logged status.
498
+ # === Detach Follower.
499
+ # Detach follower from an appointment.
500
+ #
501
+ # ==== Parameters
502
+ # data:: (Hash) -- Data to be submited.
175
503
  #
176
504
  # ==== Example
177
- # @mints_contact.status
505
+ # data = {
506
+ # "appointment_id": 1,
507
+ # "follower_ids": 1
508
+ # }
509
+ # @data = @mints_contact.detach_follower(data)
510
+ def detach_follower(data)
511
+ return @client.raw("post", "/contacts/appointments/detach-follower", nil, data_transform(data))
512
+ end
513
+
514
+ ##
515
+ # === Sync Invitee.
516
+ # Sync an invitee from an appointment.
178
517
  #
179
- def status
180
- return @client.raw("get", "/contacts/status")
518
+ # ==== Parameters
519
+ # data:: (Hash) -- Data to be submited.
520
+ #
521
+ # ==== Example
522
+ # data = {
523
+ # "appointment_id": 1,
524
+ # "invitee_ids": 1
525
+ # }
526
+ # @data = @mints_contact.sync_invitee(data)
527
+ def sync_invitee(data)
528
+ return @client.raw("post", "/contacts/appointments/sync-invitee", nil, data_transform(data))
181
529
  end
182
530
 
183
531
  ##
184
- # === Update.
185
- # Update logged contact attributes.
532
+ # === Sync Follower.
533
+ # Sync a follower from an appointment.
186
534
  #
187
- # ==== Parameters:
188
- # * +data+ - [] It's the data to update with a session active.
535
+ # ==== Parameters
536
+ # data:: (Hash) -- Data to be submited.
189
537
  #
190
538
  # ==== Example
191
- # @mints_contact.login("brown.abigail@dubuque.com", "helloword")
192
- # data = { "data": {
193
- # "given_name": "Alonso",
194
- # "last_name": "Garcia"
195
- # } }
196
- # @mints_contact.update(data)
539
+ # data = {
540
+ # "appointment_id": 1,
541
+ # "follower_ids": 1
542
+ # }
543
+ # @data = @mints_contact.sync_follower(data)
544
+ def sync_follower(data)
545
+ return @client.raw("post", "/contacts/appointments/sync-follower", nil, data_transform(data))
546
+ end
547
+
548
+ ##
549
+ # === Get Orders.
550
+ # Get a collection of orders.
197
551
  #
198
- def update(data)
199
- return @client.raw("put", "/contacts/update", nil, data)
552
+ # ==== Parameters
553
+ # options:: (Hash) -- List of Resource Collection Options shown above can be used as parameter.
554
+ # use_post:: (Boolean) -- Variable to determine if the request is by 'post' or 'get' functions.
555
+ #
556
+ # ==== First Example
557
+ # @data = @mints_pub.get_orders
558
+ #
559
+ # ==== Second Example
560
+ # options = { "fields": "title" }
561
+ # @data = @mints_pub.get_orders(options)
562
+ #
563
+ # ==== Third Example
564
+ # options = { "fields": "title" }
565
+ # @data = @mints_pub.get_orders(options, false)
566
+ def get_orders(options = nil, use_post = true)
567
+ if use_post
568
+ return @client.raw("post", "/ecommerce/orders/query", options, nil, @contact_v1_url)
569
+ else
570
+ return @client.raw("get", "/ecommerce/orders", options, nil, @contact_v1_url)
571
+ end
200
572
  end
201
573
 
202
574
  ##
203
- # === Register.
204
- # Register a contact.
575
+ # === Get Order.
576
+ # Get an order info.
205
577
  #
206
- # ==== Parameters:
207
- # * +data+ - [] It's the register data.
578
+ # ==== Parameters
579
+ # id:: (Integer) -- Order id.
580
+ # options:: (Hash) -- List of Resource Collection Options shown above can be used as parameter.
581
+ #
582
+ # ==== First Example
583
+ # @data = @mints_pub.get_product(25)
584
+ #
585
+ # ==== Second Example
586
+ # options = {
587
+ # "fields": "title"
588
+ # }
589
+ # @data = @mints_pub.get_product(25, options)
590
+ def get_order(id, options = nil)
591
+ return @client.raw("get", "/ecommerce/orders/#{id}", options, nil, @contact_v1_url)
592
+ end
593
+
594
+ ##
595
+ # === Create Order.
596
+ # Create a order with data.
597
+ #
598
+ # ==== Parameters
599
+ # data:: (Hash) -- Data to be submited.
208
600
  #
209
601
  # ==== Example
210
- # data = { "data": {
211
- # "email": "carlos@mints.cloud",
212
- # "given_name": "Carlos",
213
- # "last_name": "Fernandez",
214
- # "password": "123456"
215
- # } }
216
- # @mints_contact.register(data);
602
+ # data = {
603
+ # "order_template_id": 1,
604
+ # "order_status_id": 1,
605
+ # "sales_channel_id": 1
606
+ # }
607
+ # @data = @mints_pub.create_order(data)
608
+ def create_order(data)
609
+ return @client.raw("post", "/ecommerce/orders", nil, data_transform(data), @contact_v1_url)
610
+ end
611
+
612
+ ##
613
+ # === Update Order.
614
+ # Update an order info.
615
+ #
616
+ # ==== Parameters
617
+ # id:: (Integer) -- Order Id
618
+ # data:: (Hash) -- Data to be submited.
619
+ # FIXME: This method doesnt update an order.
620
+ def update_order(id, data)
621
+ return @client.raw("put", "/ecommerce/orders/#{id}", nil, data_transform(data), @contact_v1_url)
622
+ end
623
+
624
+ #TODO: No tested
625
+ # === Detach Order Item From Order Item Group.
626
+ # Detach an order item from an order item group.
217
627
  #
218
- def register(data)
219
- return @client.raw("post", "/contacts/register", nil, data)
628
+ # ==== Parameters
629
+ # orderItemId:: (Integer) -- Order item id.
630
+ # groupId:: (Integer) -- Order items group id.
631
+ #
632
+ def detach_order_item_from_order_item_group(orderItemId, groupId)
633
+ return @client.raw("put", "/ecommerce/order-items/detach/#{orderItemId}/order-items-groups/#{groupId}", nil, nil, @contact_v1_url)
634
+ end
635
+
636
+ #TODO: No tested
637
+ # === Update Order Item From Order Item Group.
638
+ # Update an order item data from an order item group.
639
+ #
640
+ # ==== Parameters
641
+ # orderItemId:: (Integer) -- Order item id.
642
+ # groupId:: (Integer) -- Order items group id.
643
+ #
644
+ def update_order_item_from_order_item_group(orderItemId, groupId, data)
645
+ return @client.raw("put", "/ecommerce/order-items/update/#{orderItemId}/order-items-groups/#{groupId}", nil, data_transform(data), @contact_v1_url)
646
+ end
647
+
648
+ ##
649
+ # === Get My Shopping Cart.
650
+ # Get a collection of items in the shopping cart.
651
+ #
652
+ # ==== Example
653
+ # @data = @mints_contact.get_my_shopping_cart
654
+ # FIXME: This method returns a nil data.
655
+ def get_my_shopping_cart
656
+ return @client.raw("get", "/ecommerce/my-shopping-cart", nil, nil, @contact_v1_url)
657
+ end
658
+
659
+ ##
660
+ # === Add Item To Shopping Cart.
661
+ # Add an item into a shopping cart.
662
+ #
663
+ # ==== Parameters
664
+ # data:: (Hash) -- Data to be submited.
665
+ #
666
+ # ==== Example
667
+ # data = {
668
+ # "quantity": 1,
669
+ # "sku_id": 1,
670
+ # "price_list_id": 1
671
+ # }
672
+ # @data = @mints_contact.add_item_to_shopping_cart(data)
673
+ def add_item_to_shopping_cart(data)
674
+ return @client.raw("post", "/ecommerce/shopping-cart", nil, data_transform(data), @contact_v1_url)
675
+ end
676
+
677
+ ##
678
+ # === Get Order Items.
679
+ # Get a collection of order items.
680
+ #TODO: Find a way to show order items.
681
+ def get_order_items(options = nil)
682
+ return @client.raw("get", "/ecommerce/order-items", options, nil, @contact_v1_url)
683
+ end
684
+
685
+ ##
686
+ # === Get Order Item.
687
+ # Get an order item info.
688
+ #TODO: Find a way to show order items.
689
+ def get_order_item(id, options = nil)
690
+ return @client.raw("get", "/ecommerce/order-items/#{id}", options, nil, @contact_v1_url)
691
+ end
692
+
693
+ ##
694
+ # === Get Order Item Groups.
695
+ # Get a collection of order item groups.
696
+ #
697
+ # ==== Parameters
698
+ # options:: (Hash) -- List of Resource Collection Options shown above can be used as parameter.
699
+ #
700
+ # ==== First Example
701
+ # @data = @mints_contact.get_order_item_groups
702
+ #
703
+ # ==== Second Example
704
+ # options = {
705
+ # "fields": "id"
706
+ # }
707
+ # @data = @mints_contact.get_order_item_groups(options)
708
+ def get_order_item_groups(options = nil)
709
+ return @client.raw("get", "/ecommerce/order-items-groups", options, nil, @contact_v1_url)
710
+ end
711
+
712
+ ##
713
+ # === Get Order Item Group.
714
+ # Get an order item group info.
715
+ #
716
+ # ==== Parameters
717
+ # id:: (Integer) -- Order Item Group Id.
718
+ # options:: (Hash) -- List of Resource Collection Options shown above can be used as parameter.
719
+ #
720
+ # ==== First Example
721
+ # @data = @mints_contact.get_order_item_group(130)
722
+ #
723
+ # ==== Second Example
724
+ # options = {
725
+ # "fields": "id"
726
+ # }
727
+ # @data = @mints_contact.get_order_item_group(130, options)
728
+ def get_order_item_group(id, options = nil)
729
+ return @client.raw("get", "/ecommerce/order-items-groups/#{id}", options, nil, @contact_v1_url)
730
+ end
731
+
732
+ ##
733
+ # === Create Order Item Group.
734
+ # Create an order item group with data if you are related to that order.
735
+ #
736
+ # ==== Parameters
737
+ # data:: (Hash) -- Data to be submited.
738
+ #
739
+ # ==== First Example
740
+ # data = {
741
+ # "name": "New Order Item Group",
742
+ # "quantity": 1,
743
+ # "order_id": 1,
744
+ # "on_sale_price": 100
745
+ # }
746
+ # @data = @mints_contact.create_order_item_group(data)
747
+ #
748
+ # ==== Second Example
749
+ # data = {
750
+ # "name": "",
751
+ # "quantity": 1,
752
+ # "order_id": 1,
753
+ # "sku_id": 1
754
+ # }
755
+ # @data = @mints_contact.create_order_item_group(data)
756
+ def create_order_item_group(data)
757
+ return @client.raw("post", "/ecommerce/order-items-groups", nil, data_transform(data), @contact_v1_url)
758
+ end
759
+
760
+ ##
761
+ # === Update Order Item Group.
762
+ # Update an order item group info if you are related to that order.
763
+ #
764
+ # ==== Parameters
765
+ # id:: (Integer) -- Order Item Group Id.
766
+ # data:: (Hash) -- Data to be submited.
767
+ #
768
+ # ==== First Example
769
+ # data = {
770
+ # "name": "New Order Item Group Name Updated"
771
+ # }
772
+ # @data = @mints_contact.update_order_item_group(130, data)
773
+ def update_order_item_group(id, data)
774
+ return @client.raw("put", "/ecommerce/order-items-groups/#{id}", nil, data_transform(data), @contact_v1_url)
775
+ end
776
+
777
+ ##
778
+ # === Delete Order Item Group.
779
+ # Delete an order item group.
780
+ # FIXME: This method doesn't work. Throw no action error.
781
+ def delete_order_item_group(id)
782
+ return @client.raw("delete", "/ecommerce/order-items-groups/#{id}", nil, nil, @contact_v1_url)
220
783
  end
221
784
 
222
785
  private
223
786
 
787
+ include MintsHelper
788
+
224
789
  def session_token?
225
790
  if @client.session_token
226
791
  return true