mints 0.0.28 → 0.0.30

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