mints 0.0.28 → 0.0.30
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- 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 +14 -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 +132 -0
- data/lib/contact/ecommerce/vouchers.rb +18 -0
- data/lib/contact.rb +54 -603
- data/lib/errors.rb +4 -2
- data/lib/generators/mints_assets_controller.rb +4 -1
- data/lib/generators/mints_contact_controller.rb +4 -1
- data/lib/generators/mints_files_generator.rb +16 -13
- data/lib/generators/mints_link.rb +7 -4
- 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 +5 -3
- 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/config/attributes.rb +13 -0
- data/lib/pub/config/config.rb +15 -0
- data/lib/pub/config/public_folders.rb +51 -0
- data/lib/pub/config/tags.rb +42 -0
- data/lib/pub/config/taxonomies.rb +49 -0
- data/lib/pub/content/assets.rb +16 -0
- data/lib/pub/content/content.rb +22 -0
- data/lib/pub/content/content_bundles.rb +40 -0
- data/lib/pub/content/content_instance_versions.rb +56 -0
- data/lib/pub/content/content_instances.rb +37 -0
- data/lib/pub/content/forms.rb +47 -0
- data/lib/pub/content/stories.rb +44 -0
- data/lib/pub/content/story_versions.rb +46 -0
- data/lib/pub/ecommerce/ecommerce.rb +14 -0
- data/lib/pub/ecommerce/locations.rb +25 -0
- data/lib/pub/ecommerce/orders.rb +31 -0
- data/lib/pub/ecommerce/products.rb +45 -0
- data/lib/pub.rb +22 -461
- 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 +2 -0
- data/lib/user/config/users.rb +2 -0
- data/lib/user/contacts/contacts.rb +2 -0
- data/lib/user/content/assets.rb +3 -3
- data/lib/user/content/content.rb +224 -223
- data/lib/user/content/content_instances.rb +4 -2
- data/lib/user/content/content_templates.rb +2 -0
- data/lib/user/content/conversations.rb +2 -0
- data/lib/user/content/dam.rb +2 -0
- data/lib/user/content/forms.rb +2 -0
- data/lib/user/content/message_templates.rb +2 -0
- data/lib/user/content/messages.rb +2 -0
- data/lib/user/content/pages.rb +4 -2
- data/lib/user/content/stories.rb +3 -3
- data/lib/user/content/story_templates.rb +5 -3
- data/lib/user/content/story_versions.rb +2 -0
- data/lib/user/crm/companies.rb +3 -1
- data/lib/user/crm/contacts.rb +2 -0
- data/lib/user/crm/crm.rb +2 -0
- data/lib/user/crm/deals.rb +2 -0
- data/lib/user/crm/favorites.rb +2 -0
- data/lib/user/crm/segments.rb +2 -0
- data/lib/user/crm/users.rb +2 -0
- data/lib/user/crm/workflow_step_objects.rb +2 -0
- data/lib/user/crm/workflow_steps.rb +2 -0
- data/lib/user/crm/workflows.rb +2 -0
- data/lib/user/ecommerce/ecommerce.rb +4 -0
- data/lib/user/ecommerce/item_prices.rb +2 -0
- data/lib/user/ecommerce/locations.rb +4 -2
- data/lib/user/ecommerce/order_items_groups.rb +5 -2
- data/lib/user/ecommerce/order_statuses.rb +2 -0
- data/lib/user/ecommerce/orders.rb +4 -1
- data/lib/user/ecommerce/price_lists.rb +2 -0
- data/lib/user/ecommerce/product_templates.rb +3 -1
- data/lib/user/ecommerce/product_variations.rb +2 -0
- data/lib/user/ecommerce/products.rb +3 -1
- data/lib/user/ecommerce/skus.rb +2 -0
- data/lib/user/ecommerce/taxes.rb +2 -0
- data/lib/user/ecommerce/variant_options.rb +2 -0
- data/lib/user/ecommerce/variant_values.rb +2 -0
- data/lib/user/ecommerce/vouchers.rb +90 -0
- data/lib/user/helpers/helpers.rb +2 -0
- data/lib/user/helpers/object_activities.rb +2 -0
- data/lib/user/helpers/object_folders.rb +2 -0
- data/lib/user/helpers/user_folders.rb +2 -0
- data/lib/user/marketing/marketing.rb +2 -0
- data/lib/user/profile/profile.rb +2 -0
- data/lib/user.rb +32 -41
- metadata +42 -16
- data/lib/user/config/importers.rb +0 -184
data/lib/pub.rb
CHANGED
@@ -1,6 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'yaml'
|
2
|
-
require_relative './client
|
3
|
-
require_relative './mints/helpers/mints_helper
|
4
|
+
require_relative './client'
|
5
|
+
require_relative './mints/helpers/mints_helper'
|
6
|
+
require_relative './pub/content/content'
|
7
|
+
require_relative './pub/ecommerce/ecommerce'
|
8
|
+
require_relative './pub/config/config'
|
4
9
|
|
5
10
|
module Mints
|
6
11
|
##
|
@@ -22,8 +27,8 @@ module Mints
|
|
22
27
|
# { "include": "events" }
|
23
28
|
# * +attributes+ - [_Boolean_] If present, attributes will be returned for each record in the results. _Example:_
|
24
29
|
# { "attributes": true }
|
25
|
-
# * +
|
26
|
-
# { "
|
30
|
+
# * +taxonomies+ - [_Boolean_] If present, taxonomies will be returned for each record in the results. _Example:_
|
31
|
+
# { "taxonomies": true }
|
27
32
|
# * +tags+ - [_Boolean_] If present, tags will be returned for each record in the results. _Example:_
|
28
33
|
# { "tags": true }
|
29
34
|
# * +fields+ - [_String_] Specify the fields that you want to be returned. If empty, all fields are returned. The object index can also be used to specify specific fields from relations. _Example:_
|
@@ -32,7 +37,7 @@ module Mints
|
|
32
37
|
#
|
33
38
|
# == Resource collections options
|
34
39
|
# * +search+ - [_String_] If present, it will search for records matching the search string. _Example:_
|
35
|
-
# { "search": "
|
40
|
+
# { "search": "search string" }
|
36
41
|
# * +scopes+ - [_String_] If present, it will apply the specified Model's scopes. _Example:_
|
37
42
|
# { "scopes": "approved, recent" }
|
38
43
|
# * +filters+ - [_String_] This is a powerful parameter that allows the data to be filtered by any of its fields. Currently only exact matches are supported. _Example:_
|
@@ -51,27 +56,18 @@ module Mints
|
|
51
56
|
# "operator":"or"
|
52
57
|
# }
|
53
58
|
# options = { "jfilters": jfilter }
|
54
|
-
# * +catfilters+ - [_String_] filter by categories. _Example:_
|
55
|
-
# { "catfilters": "categoryName" }
|
56
|
-
# * +fields+ - [_String_] Specify the fields that you want to be returned. If empty, all fields are returned. The object index can also be used to specify specific fields from relations. _Example:_
|
57
|
-
# { fields: "id, title, slug" }
|
58
|
-
# { "fields[products]": "id, title, slug" }
|
59
59
|
# * +sort+ - [_String_] The name of the field to perform the sort. Prefix the value with a minus sign - for ascending order. _Example:_
|
60
60
|
# { sort: "title" }
|
61
61
|
# { sort: "-title" }
|
62
|
-
# * +include+ - [_String_] Specify additional information to be included in the results from the objects relations. _Example:_
|
63
|
-
# { "include": "events" }
|
64
|
-
# * +attributes+ - [_Boolean_] If present, attributes will be returned for each record in the results. _Example:_
|
65
|
-
# { "attributes": true }
|
66
|
-
# * +categories+ - [_Boolean_] If present, categories will be returned for each record in the results. _Example:_
|
67
|
-
# { "categories": true }
|
68
|
-
# * +taxonomies+ - [_Boolean_] If present, taxonomies will be returned for each record in the results. _Example:_
|
69
|
-
# { "taxonomies": true }
|
70
|
-
# * +tags+ - [_Boolean_] If present, tags will be returned for each record in the results. _Example:_
|
71
|
-
# { "tags": true }
|
72
62
|
|
73
63
|
class Pub
|
74
64
|
attr_reader :client
|
65
|
+
|
66
|
+
include MintsHelper
|
67
|
+
include Content
|
68
|
+
include Ecommerce
|
69
|
+
include Config
|
70
|
+
|
75
71
|
##
|
76
72
|
# === Initialize.
|
77
73
|
# Class constructor.
|
@@ -110,8 +106,8 @@ module Mints
|
|
110
106
|
user_agent: user_agent || request.user_agent,
|
111
107
|
url: url || request.fullpath
|
112
108
|
}
|
113
|
-
|
114
|
-
|
109
|
+
|
110
|
+
@client.raw('post', '/register-visit', nil, data.to_json)
|
115
111
|
end
|
116
112
|
|
117
113
|
##
|
@@ -128,435 +124,6 @@ module Mints
|
|
128
124
|
@client.raw('get', "/register-visit-timer?visit=#{visit}&time=#{time}")
|
129
125
|
end
|
130
126
|
|
131
|
-
### V1/CONTENT ###
|
132
|
-
|
133
|
-
##
|
134
|
-
# === Get Asset Info.
|
135
|
-
# Get a description of an Asset.
|
136
|
-
#
|
137
|
-
# ==== Parameters
|
138
|
-
# slug:: (String) -- It's the string identifier of the asset.
|
139
|
-
#
|
140
|
-
# ==== Example
|
141
|
-
# @data = @mints_pub.get_asset_info("asset_slug")
|
142
|
-
def get_asset_info(slug)
|
143
|
-
@client.raw('get', "/content/asset-info/#{slug}")
|
144
|
-
end
|
145
|
-
|
146
|
-
##
|
147
|
-
# === Get Stories.
|
148
|
-
# Get a collection of stories.
|
149
|
-
#
|
150
|
-
# ==== Parameters
|
151
|
-
# options:: (Hash) -- List of {Resource collection Options}[#class-Mints::Pub-label-Resource+collections+options+] shown above can be used as parameter.
|
152
|
-
# use_post:: (Boolean) -- Variable to determine if the request is by 'post' or 'get' functions.
|
153
|
-
#
|
154
|
-
# ==== First Example
|
155
|
-
# @data = @mints_pub.get_stories
|
156
|
-
#
|
157
|
-
# ==== Second Example
|
158
|
-
# options = {
|
159
|
-
# fields: 'id, slug'
|
160
|
-
# }
|
161
|
-
# @data = @mints_pub.get_stories(options)
|
162
|
-
#
|
163
|
-
# ==== Third Example
|
164
|
-
# options = {
|
165
|
-
# fields: 'id, slug'
|
166
|
-
# }
|
167
|
-
# @data = @mints_pub.get_stories(options, false)
|
168
|
-
def get_stories(options = nil, use_post = true)
|
169
|
-
get_query_results('/content/stories', options, use_post)
|
170
|
-
end
|
171
|
-
|
172
|
-
##
|
173
|
-
# === Get Story.
|
174
|
-
# Get a single story.
|
175
|
-
#
|
176
|
-
# ==== Parameters
|
177
|
-
# slug:: (String) -- It's the string identifier generated by Mints.
|
178
|
-
# options:: (Hash) -- List of {Single Resource Options}[#class-Mints::Pub-label-Single+resource+options] shown above can be used as parameter.
|
179
|
-
#
|
180
|
-
# ==== First Example
|
181
|
-
# @data = @mints_pub.get_story("story_slug")
|
182
|
-
#
|
183
|
-
# ==== Second Example
|
184
|
-
# @data = @mints_pub.get_story("story_slug", options.to_json)
|
185
|
-
def get_story(slug, options = nil)
|
186
|
-
@client.raw('get', "/content/stories/#{slug}", options)
|
187
|
-
end
|
188
|
-
|
189
|
-
##
|
190
|
-
# === Get Story Versions.
|
191
|
-
# Get a collection of story version.
|
192
|
-
#
|
193
|
-
# ==== Parameters
|
194
|
-
# options:: (Hash) -- List of {Resource collection Options}[#class-Mints::Pub-label-Resource+collections+options+] shown above can be used as parameter.
|
195
|
-
# use_post:: (Boolean) -- Variable to determine if the request is by 'post' or 'get' functions.
|
196
|
-
#
|
197
|
-
# ==== First Example
|
198
|
-
# @data = @mints_pub.get_story_versions
|
199
|
-
#
|
200
|
-
# ==== Second Example
|
201
|
-
# options = {
|
202
|
-
# fields: 'id, title'
|
203
|
-
# }
|
204
|
-
# @data = @mints_pub.get_story_versions(options)
|
205
|
-
#
|
206
|
-
# ==== Third Example
|
207
|
-
# options = {
|
208
|
-
# fields: 'id, title'
|
209
|
-
# }
|
210
|
-
# @data = @mints_pub.get_story_versions(options, false)
|
211
|
-
def get_story_versions(options = nil, use_post = true)
|
212
|
-
get_query_results("/content/story-versions", options, use_post)
|
213
|
-
end
|
214
|
-
|
215
|
-
##
|
216
|
-
# === Get Story Version.
|
217
|
-
# Get a single story version.
|
218
|
-
#
|
219
|
-
# ==== Parameters
|
220
|
-
# slug:: (String) -- It's the string identifier generated by Mints.
|
221
|
-
# options:: (Hash) -- List of {Single Resource Options}[#class-Mints::Pub-label-Single+resource+options] shown above can be used as parameter.
|
222
|
-
#
|
223
|
-
# ==== First Example
|
224
|
-
# @data = @mints_pub.get_story_version("story_slug")
|
225
|
-
#
|
226
|
-
# ==== Second Example
|
227
|
-
# @data = @mints_pub.get_story_version("story_slug", options.to_json)
|
228
|
-
def get_story_version(slug, options = nil)
|
229
|
-
@client.raw('get', "/content/story-versions/#{slug}", options)
|
230
|
-
end
|
231
|
-
|
232
|
-
##
|
233
|
-
# === Get Forms.
|
234
|
-
# Get a collection of forms.
|
235
|
-
#
|
236
|
-
# ==== Example
|
237
|
-
# @data = @mints_pub.get_forms
|
238
|
-
def get_forms(options = nil)
|
239
|
-
@client.raw('get', '/content/forms', options)
|
240
|
-
end
|
241
|
-
|
242
|
-
##
|
243
|
-
# === Get Form.
|
244
|
-
# Get a single form.
|
245
|
-
#
|
246
|
-
# ==== Parameters
|
247
|
-
# slug:: (String) -- It's the string identifier generated by Mints.
|
248
|
-
#
|
249
|
-
# ==== Example
|
250
|
-
# @data = @mints_pub.get_form("form_slug")
|
251
|
-
def get_form(slug, options = nil)
|
252
|
-
@client.raw('get', "/content/forms/#{slug}", options)
|
253
|
-
end
|
254
|
-
|
255
|
-
##
|
256
|
-
# === Submit Form.
|
257
|
-
# Submit a form with data.
|
258
|
-
#
|
259
|
-
# ==== Parameters
|
260
|
-
# data:: (Hash) -- Data to be submitted.
|
261
|
-
#
|
262
|
-
# ==== Example
|
263
|
-
# data = {
|
264
|
-
# 'form_slug': 'form_slug',
|
265
|
-
# 'email': 'email@example.com',
|
266
|
-
# 'given_name': 'given_name',
|
267
|
-
# 'f1': 'Field 1 answer',
|
268
|
-
# 'f2': 'Field 2 answer',
|
269
|
-
# 'f3': 'Field 3 answer'
|
270
|
-
# }
|
271
|
-
# @data = @mints_pub.submit_form(data)
|
272
|
-
def submit_form(data)
|
273
|
-
@client.raw('post', "/content/forms/submit", nil, data_transform(data))
|
274
|
-
end
|
275
|
-
|
276
|
-
##
|
277
|
-
# === Get Content Instances.
|
278
|
-
# Get a collection of content instances. _Note:_ Options must be specified.
|
279
|
-
#
|
280
|
-
# ==== Parameters
|
281
|
-
# options:: (Hash) -- List of {Resource collection Options}[#class-Mints::Pub-label-Resource+collections+options+] shown above can be used as parameter.
|
282
|
-
#
|
283
|
-
# ==== First Example
|
284
|
-
# options = {
|
285
|
-
# "template": "content_instance_template_slug"
|
286
|
-
# }
|
287
|
-
# @data = @mints_pub.get_content_instances(options)
|
288
|
-
#
|
289
|
-
# ==== Second Example
|
290
|
-
# options = {
|
291
|
-
# "template": "content_instance_template_slug",
|
292
|
-
# sort: "-id"
|
293
|
-
# }
|
294
|
-
# @data = @mints_pub.get_content_instances(options)
|
295
|
-
def get_content_instances(options = nil)
|
296
|
-
@client.raw('get', "/content/content-instances", options)
|
297
|
-
end
|
298
|
-
|
299
|
-
##
|
300
|
-
# === Get Content Instance.
|
301
|
-
# Get a single content instance.
|
302
|
-
#
|
303
|
-
# ==== Parameters
|
304
|
-
# slug:: (String) -- It's the string identifier generated by Mints.
|
305
|
-
#
|
306
|
-
# ==== Example
|
307
|
-
# @data = @mints_pub.get_content_instance("content_instance_slug")
|
308
|
-
def get_content_instance(slug)
|
309
|
-
@client.raw('get', "/content/content-instances/#{slug}")
|
310
|
-
end
|
311
|
-
|
312
|
-
##
|
313
|
-
# === Get Content Pages.
|
314
|
-
# Get all content pages.
|
315
|
-
#
|
316
|
-
# ==== Parameters
|
317
|
-
# options:: (Hash) -- List of {Resource collection Options}[#class-Mints::Pub-label-Resource+collections+options+] shown above can be used as parameter.
|
318
|
-
def get_content_bundles(options = nil)
|
319
|
-
@client.raw('get', "/content/content-bundles", options)
|
320
|
-
end
|
321
|
-
|
322
|
-
##
|
323
|
-
# === Get Content Page.
|
324
|
-
# Get a single content page.
|
325
|
-
#
|
326
|
-
# ==== Parameters
|
327
|
-
# slug:: (String) -- It's the string identifier generated by Mints.
|
328
|
-
#
|
329
|
-
# ==== Example
|
330
|
-
# @data = @mints_pub.get_content_page("test-page")
|
331
|
-
def get_content_page(slug, options = nil)
|
332
|
-
warn '[DEPRECATED] The get_content_page method is deprecated and will be removed in the future, use get_content_bundle instead'
|
333
|
-
@client.raw('get', "/content/content-pages/#{slug}", options)
|
334
|
-
end
|
335
|
-
|
336
|
-
##
|
337
|
-
# === Get Content Bundle.
|
338
|
-
# Get a single content bundle.
|
339
|
-
#
|
340
|
-
# ==== Parameters
|
341
|
-
# slug:: (String) -- It's the string identifier generated by Mints.
|
342
|
-
#
|
343
|
-
# ==== Example
|
344
|
-
# @data = @mints_pub.get_content_bundle("test-page")
|
345
|
-
def get_content_bundle(slug, options = nil)
|
346
|
-
@client.raw('get', "/content/content-bundles/#{slug}", options)
|
347
|
-
end
|
348
|
-
|
349
|
-
### V1/ECOMMERCE ###
|
350
|
-
|
351
|
-
##
|
352
|
-
# === Get Locations.
|
353
|
-
# Get all locations.
|
354
|
-
#
|
355
|
-
# ==== Parameters
|
356
|
-
# options:: (Hash) -- List of {Resource collection Options}[#class-Mints::Pub-label-Resource+collections+options+] shown above can be used as parameter.
|
357
|
-
# use_post:: (Boolean) -- Variable to determine if the request is by 'post' or 'get' functions.
|
358
|
-
#
|
359
|
-
# ==== First Example
|
360
|
-
# @data = @mints_pub.get_locations
|
361
|
-
#
|
362
|
-
# ==== Second Example
|
363
|
-
# options = { fields: "title" }
|
364
|
-
# @data = @mints_pub.get_locations(options)
|
365
|
-
#
|
366
|
-
# ==== Third Example
|
367
|
-
# options = { fields: "title" }
|
368
|
-
# @data = @mints_pub.get_locations(options, false)
|
369
|
-
def get_locations(options = nil, use_post = true)
|
370
|
-
get_query_results("/ecommerce/locations", options, use_post)
|
371
|
-
end
|
372
|
-
|
373
|
-
##
|
374
|
-
# === Get Products.
|
375
|
-
# Get a collection of products.
|
376
|
-
#
|
377
|
-
# ==== Parameters
|
378
|
-
# options:: (Hash) -- List of {Resource collection Options}[#class-Mints::Pub-label-Resource+collections+options+] shown above can be used as parameter.
|
379
|
-
# use_post:: (Boolean) -- Variable to determine if the request is by 'post' or 'get' functions.
|
380
|
-
#
|
381
|
-
# ==== First Example
|
382
|
-
# @data = @mints_pub.get_products
|
383
|
-
#
|
384
|
-
# ==== Second Example
|
385
|
-
# options = { fields: "title" }
|
386
|
-
# @data = @mints_pub.get_products(options)
|
387
|
-
#
|
388
|
-
# ==== Third Example
|
389
|
-
# options = { fields: "title" }
|
390
|
-
# @data = @mints_pub.get_products(options, false)
|
391
|
-
def get_products(options = nil, use_post = true)
|
392
|
-
get_query_results("/ecommerce/products", options, use_post)
|
393
|
-
end
|
394
|
-
|
395
|
-
##
|
396
|
-
# === Get Product.
|
397
|
-
# Get a single product.
|
398
|
-
#
|
399
|
-
# ==== Parameters
|
400
|
-
# slug:: (String) -- It's the string identifier generated by Mints.
|
401
|
-
# options:: (Hash) -- List of {Single Resource Options}[#class-Mints::Pub-label-Single+resource+options] shown above can be used as parameter.
|
402
|
-
#
|
403
|
-
# ==== First Example
|
404
|
-
# @data = @mints_pub.get_product("product_slug")
|
405
|
-
#
|
406
|
-
# ==== Second Example
|
407
|
-
# options = {
|
408
|
-
# fields: 'id, slug'
|
409
|
-
# }
|
410
|
-
# @data = @mints_pub.get_product("lego-set", options)
|
411
|
-
def get_product(slug, options = nil)
|
412
|
-
@client.raw('get', "/ecommerce/products/#{slug}", options)
|
413
|
-
end
|
414
|
-
|
415
|
-
### V1/CONFIG ###
|
416
|
-
|
417
|
-
##
|
418
|
-
# === Get Public Folders.
|
419
|
-
# Get a collection of public folders.
|
420
|
-
#
|
421
|
-
# ==== Parameters
|
422
|
-
# options:: (Hash) -- List of {Single Resource Options}[#class-Mints::Pub-label-Single+resource+options] shown above can be used as parameter.
|
423
|
-
#
|
424
|
-
# ==== First Example
|
425
|
-
# options = {
|
426
|
-
# "object_type": "products"
|
427
|
-
# }
|
428
|
-
# @data = @mints_pub.get_public_folders(options)
|
429
|
-
#
|
430
|
-
# ==== Second Example
|
431
|
-
# options = {
|
432
|
-
# "object_type": "products",
|
433
|
-
# fields: "id",
|
434
|
-
# sort: "-id"
|
435
|
-
# }
|
436
|
-
# @data = @mints_pub.get_public_folders(options)
|
437
|
-
def get_public_folders(options = nil)
|
438
|
-
@client.raw('get', "/config/public-folders", options)
|
439
|
-
end
|
440
|
-
|
441
|
-
##
|
442
|
-
# === Get Public Folder.
|
443
|
-
# Get a public folder info.
|
444
|
-
#
|
445
|
-
# ==== Parameters
|
446
|
-
# slug:: (String) -- It's the string identifier generated by Mints.
|
447
|
-
# options:: (Hash) -- List of {Single Resource Options}[#class-Mints::Pub-label-Single+resource+options] shown above can be used as parameter.
|
448
|
-
#
|
449
|
-
# ==== First Example
|
450
|
-
# options = {
|
451
|
-
# "object_type": "products"
|
452
|
-
# }
|
453
|
-
# @data = @mints_pub.get_public_folder('yellow', options)
|
454
|
-
#
|
455
|
-
# ==== Second Example
|
456
|
-
# options = {
|
457
|
-
# "object_type": "products",
|
458
|
-
# fields: 'id, title'
|
459
|
-
# }
|
460
|
-
# @data = @mints_pub.get_public_folder('yellow', options)
|
461
|
-
def get_public_folder(slug, options)
|
462
|
-
@client.raw('get', "/config/public-folders/#{slug}", options)
|
463
|
-
end
|
464
|
-
|
465
|
-
##
|
466
|
-
# === Get Tags.
|
467
|
-
# Get a collection of tags.
|
468
|
-
#
|
469
|
-
# ==== Parameters
|
470
|
-
# options:: (Hash) -- List of {Resource collection Options}[#class-Mints::Pub-label-Resource+collections+options+] shown above can be used as parameter.
|
471
|
-
#
|
472
|
-
# ==== First Example
|
473
|
-
# @data = @mints_pub.get_tags
|
474
|
-
#
|
475
|
-
# ==== Second Example
|
476
|
-
# options = {
|
477
|
-
# fields: "id, tag"
|
478
|
-
# }
|
479
|
-
# @data = @mints_pub.get_tags(options)
|
480
|
-
def get_tags(options = nil)
|
481
|
-
@client.raw('get', "/config/tags", options)
|
482
|
-
end
|
483
|
-
|
484
|
-
##
|
485
|
-
# === Get Tag.
|
486
|
-
# Get a single tag.
|
487
|
-
#
|
488
|
-
# ==== Parameters
|
489
|
-
# slug:: (String) -- It's the string identifier generated by Mints.
|
490
|
-
# options:: (Hash) -- List of {Single Resource Options}[#class-Mints::Pub-label-Single+resource+options] shown above can be used as parameter.
|
491
|
-
#
|
492
|
-
# ==== First Example
|
493
|
-
# @data = @mints_pub.get_tag("tag_slug")
|
494
|
-
#
|
495
|
-
# ==== Second Example
|
496
|
-
# options = {
|
497
|
-
# fields: "id, tag"
|
498
|
-
# }
|
499
|
-
# @data = @mints_pub.get_tag("velit-0", options)
|
500
|
-
def get_tag(slug, options = nil)
|
501
|
-
@client.raw('get', "/config/tags/#{slug}", options)
|
502
|
-
end
|
503
|
-
|
504
|
-
##
|
505
|
-
# === Get Taxonomies.
|
506
|
-
# Get a collection of taxonomies.
|
507
|
-
#
|
508
|
-
# ==== Parameters
|
509
|
-
# options:: (Hash) -- List of {Resource collection Options}[#class-Mints::Pub-label-Resource+collections+options+] shown above can be used as parameter.
|
510
|
-
# use_post:: (Boolean) -- Variable to determine if the request is by 'post' or 'get' functions.
|
511
|
-
#
|
512
|
-
# ==== First Example
|
513
|
-
# @data = @mints_pub.get_taxonomies
|
514
|
-
#
|
515
|
-
# ==== Second Example
|
516
|
-
# options = {
|
517
|
-
# fields: 'id, title'
|
518
|
-
# }
|
519
|
-
# @data = @mints_pub.get_taxonomies(options)
|
520
|
-
#
|
521
|
-
# ==== Third Example
|
522
|
-
# options = {
|
523
|
-
# fields: 'id, title'
|
524
|
-
# }
|
525
|
-
# @data = @mints_pub.get_taxonomies(options, false)
|
526
|
-
def get_taxonomies(options = nil, use_post = true)
|
527
|
-
get_query_results("/config/taxonomies", options, use_post)
|
528
|
-
end
|
529
|
-
|
530
|
-
##
|
531
|
-
# === Get Taxonomy.
|
532
|
-
# Get a single taxonomy.
|
533
|
-
#
|
534
|
-
# ==== Parameters
|
535
|
-
# slug:: (String) -- It's the string identifier generated by Mints.
|
536
|
-
# options:: (Hash) -- List of {Single Resource Options}[#class-Mints::Pub-label-Single+resource+options] shown above can be used as parameter.
|
537
|
-
#
|
538
|
-
# ==== First Example
|
539
|
-
# @data = @mints_pub.get_taxonomy("taxonomy_slug")
|
540
|
-
#
|
541
|
-
# ==== Second Example
|
542
|
-
# options = {
|
543
|
-
# fields: "title"
|
544
|
-
# }
|
545
|
-
# @data = @mints_pub.get_taxonomy("taxonomy_slug", options)
|
546
|
-
def get_taxonomy(slug, options = nil)
|
547
|
-
@client.raw('get', "/config/taxonomies/#{slug}", options)
|
548
|
-
end
|
549
|
-
|
550
|
-
##
|
551
|
-
# === Get Attributes.
|
552
|
-
# Get a collection of attributes.
|
553
|
-
#
|
554
|
-
# ==== Example
|
555
|
-
# @data = @mints_pub.get_attributes
|
556
|
-
def get_attributes
|
557
|
-
@client.raw('get', "/config/attributes")
|
558
|
-
end
|
559
|
-
|
560
127
|
def send_user_magic_link(email_or_phone, template_slug, redirect_url = '', life_time = 1440, max_visits = nil, driver = 'email')
|
561
128
|
data = {
|
562
129
|
driver: driver,
|
@@ -565,16 +132,10 @@ module Mints
|
|
565
132
|
redirectUrl: redirect_url,
|
566
133
|
templateId: template_slug
|
567
134
|
}
|
568
|
-
if driver === 'sms' or driver === 'whatsapp'
|
569
|
-
data['phone'] = email_or_phone
|
570
|
-
else
|
571
|
-
data['email'] = email_or_phone
|
572
|
-
end
|
573
|
-
@client.raw('post', "/users/magic-link", nil, { data: data }.to_json, '/api/v1')
|
574
|
-
end
|
575
135
|
|
576
|
-
|
577
|
-
|
578
|
-
|
136
|
+
key = %w[sms whatsapp].include? driver ? 'phone' : 'email'
|
137
|
+
data[key] = email_or_phone
|
138
|
+
@client.raw('post', '/users/magic-link', nil, { data: data }.to_json, '/api/v1')
|
139
|
+
end
|
579
140
|
end
|
580
141
|
end
|
data/lib/user/config/api_keys.rb
CHANGED
@@ -1,65 +1,67 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module ApiKeys
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
4
|
+
##
|
5
|
+
# == Api keys
|
6
|
+
#
|
7
|
+
|
8
|
+
# === Get api keys.
|
9
|
+
# Get a collection of api keys.
|
10
|
+
#
|
11
|
+
# ==== Parameters
|
12
|
+
# options:: (Hash) -- List of Resource Collection Options shown above can be used as parameter.
|
13
|
+
#
|
14
|
+
# ==== First Example
|
15
|
+
# @data = @mints_user.get_api_keys
|
16
|
+
#
|
17
|
+
# ==== Second Example
|
18
|
+
# options = { fields: 'id' }
|
19
|
+
# @data = @mints_user.get_api_keys(options)
|
20
|
+
def get_api_keys(options = nil)
|
21
|
+
@client.raw('get', '/config/api-keys', options)
|
22
|
+
end
|
21
23
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
24
|
+
# === Get api key.
|
25
|
+
# Get an api key info.
|
26
|
+
#
|
27
|
+
# ==== Parameters
|
28
|
+
# id:: (Integer) -- Api key id.
|
29
|
+
# options:: (Hash) -- List of Resource Collection Options shown above can be used as parameter.
|
30
|
+
#
|
31
|
+
# ==== First Example
|
32
|
+
# @data = @mints_user.get_api_key(2)
|
33
|
+
#
|
34
|
+
# ==== Second Example
|
35
|
+
# options = { fields: 'id' }
|
36
|
+
# @data = @mints_user.get_api_key(2, options)
|
37
|
+
def get_api_key(id, options = nil)
|
38
|
+
@client.raw('get', "/config/api-keys/#{id}", options)
|
39
|
+
end
|
38
40
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
41
|
+
# === Create api key.
|
42
|
+
# Create an api key with data.
|
43
|
+
#
|
44
|
+
# ==== Parameters
|
45
|
+
# data:: (Hash) -- Data to be submitted.
|
46
|
+
#
|
47
|
+
# ==== Example
|
48
|
+
# data = {
|
49
|
+
# description: 'New Api Key Description'
|
50
|
+
# }
|
51
|
+
# @data = @mints_user.create_api_key(data)
|
52
|
+
def create_api_key(data)
|
53
|
+
@client.raw('post', '/config/api-keys', nil, data_transform(data))
|
54
|
+
end
|
53
55
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
end
|
56
|
+
# === Delete api key.
|
57
|
+
# Delete an api key.
|
58
|
+
#
|
59
|
+
# ==== Parameters
|
60
|
+
# id:: (Integer) -- Api key id.
|
61
|
+
#
|
62
|
+
# ==== Example
|
63
|
+
# @data = @mints_user.delete_api_key(2)
|
64
|
+
def delete_api_key(id)
|
65
|
+
@client.raw('delete', "/config/api-keys/#{id}")
|
66
|
+
end
|
67
|
+
end
|