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