mints 0.0.28 → 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.
Files changed (95) 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 +12 -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 +133 -0
  11. data/lib/contact.rb +54 -603
  12. data/lib/errors.rb +3 -1
  13. data/lib/generators/mints_assets_controller.rb +4 -1
  14. data/lib/generators/mints_contact_controller.rb +4 -1
  15. data/lib/generators/mints_files_generator.rb +16 -13
  16. data/lib/generators/mints_link.rb +7 -4
  17. data/lib/generators/mints_public_controller.rb +4 -1
  18. data/lib/generators/mints_user_controller.rb +3 -0
  19. data/lib/generators/short_link_controller.rb +4 -1
  20. data/lib/mints/controllers/admin_base_controller.rb +5 -3
  21. data/lib/mints/controllers/base_api_controller.rb +6 -4
  22. data/lib/mints/controllers/base_controller.rb +5 -3
  23. data/lib/mints/controllers/concerns/mints_clients.rb +4 -2
  24. data/lib/mints/controllers/concerns/read_config_file.rb +3 -1
  25. data/lib/mints/controllers/contact_api_controller.rb +12 -10
  26. data/lib/mints/controllers/public_api_controller.rb +10 -8
  27. data/lib/mints/controllers/user_api_controller.rb +11 -9
  28. data/lib/mints/helpers/contact_auth_helper.rb +3 -1
  29. data/lib/mints/helpers/mints_helper.rb +39 -38
  30. data/lib/mints/helpers/proxy_controllers_methods.rb +24 -24
  31. data/lib/mints/helpers/user_auth_helper.rb +5 -3
  32. data/lib/mints.rb +12 -10
  33. data/lib/pub.rb +35 -53
  34. data/lib/user/config/api_keys.rb +63 -61
  35. data/lib/user/config/appointments.rb +217 -215
  36. data/lib/user/config/attribute_groups.rb +74 -72
  37. data/lib/user/config/attributes.rb +83 -81
  38. data/lib/user/config/calendars.rb +88 -86
  39. data/lib/user/config/config.rb +31 -63
  40. data/lib/user/config/public_folders.rb +105 -104
  41. data/lib/user/config/relationships.rb +135 -132
  42. data/lib/user/config/roles.rb +76 -79
  43. data/lib/user/config/seeds.rb +52 -51
  44. data/lib/user/config/system_settings.rb +50 -49
  45. data/lib/user/config/tags.rb +57 -59
  46. data/lib/user/config/taxonomies.rb +115 -119
  47. data/lib/user/config/teams.rb +2 -0
  48. data/lib/user/config/users.rb +2 -0
  49. data/lib/user/contacts/contacts.rb +2 -0
  50. data/lib/user/content/assets.rb +3 -3
  51. data/lib/user/content/content.rb +224 -223
  52. data/lib/user/content/content_instances.rb +4 -2
  53. data/lib/user/content/content_templates.rb +2 -0
  54. data/lib/user/content/conversations.rb +2 -0
  55. data/lib/user/content/dam.rb +2 -0
  56. data/lib/user/content/forms.rb +2 -0
  57. data/lib/user/content/message_templates.rb +2 -0
  58. data/lib/user/content/messages.rb +2 -0
  59. data/lib/user/content/pages.rb +4 -2
  60. data/lib/user/content/stories.rb +3 -3
  61. data/lib/user/content/story_templates.rb +5 -3
  62. data/lib/user/content/story_versions.rb +2 -0
  63. data/lib/user/crm/companies.rb +3 -1
  64. data/lib/user/crm/contacts.rb +2 -0
  65. data/lib/user/crm/crm.rb +2 -0
  66. data/lib/user/crm/deals.rb +2 -0
  67. data/lib/user/crm/favorites.rb +2 -0
  68. data/lib/user/crm/segments.rb +2 -0
  69. data/lib/user/crm/users.rb +2 -0
  70. data/lib/user/crm/workflow_step_objects.rb +2 -0
  71. data/lib/user/crm/workflow_steps.rb +2 -0
  72. data/lib/user/crm/workflows.rb +2 -0
  73. data/lib/user/ecommerce/ecommerce.rb +2 -0
  74. data/lib/user/ecommerce/item_prices.rb +2 -0
  75. data/lib/user/ecommerce/locations.rb +2 -0
  76. data/lib/user/ecommerce/order_items_groups.rb +5 -2
  77. data/lib/user/ecommerce/order_statuses.rb +2 -0
  78. data/lib/user/ecommerce/orders.rb +4 -1
  79. data/lib/user/ecommerce/price_lists.rb +2 -0
  80. data/lib/user/ecommerce/product_templates.rb +3 -1
  81. data/lib/user/ecommerce/product_variations.rb +2 -0
  82. data/lib/user/ecommerce/products.rb +3 -1
  83. data/lib/user/ecommerce/skus.rb +2 -0
  84. data/lib/user/ecommerce/taxes.rb +2 -0
  85. data/lib/user/ecommerce/variant_options.rb +2 -0
  86. data/lib/user/ecommerce/variant_values.rb +2 -0
  87. data/lib/user/helpers/helpers.rb +2 -0
  88. data/lib/user/helpers/object_activities.rb +2 -0
  89. data/lib/user/helpers/object_folders.rb +2 -0
  90. data/lib/user/helpers/user_folders.rb +2 -0
  91. data/lib/user/marketing/marketing.rb +2 -0
  92. data/lib/user/profile/profile.rb +2 -0
  93. data/lib/user.rb +32 -41
  94. metadata +23 -16
  95. data/lib/user/config/importers.rb +0 -184
data/lib/pub.rb CHANGED
@@ -1,6 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'yaml'
2
- require_relative './client.rb'
3
- require_relative './mints/helpers/mints_helper.rb'
4
+ require_relative './client'
5
+ require_relative './mints/helpers/mints_helper'
4
6
 
5
7
  module Mints
6
8
  ##
@@ -22,8 +24,8 @@ module Mints
22
24
  # { "include": "events" }
23
25
  # * +attributes+ - [_Boolean_] If present, attributes will be returned for each record in the results. _Example:_
24
26
  # { "attributes": true }
25
- # * +categories+ - [_Boolean_] If present, categories will be returned for each record in the results. _Example:_
26
- # { "categories": true }
27
+ # * +taxonomies+ - [_Boolean_] If present, taxonomies will be returned for each record in the results. _Example:_
28
+ # { "taxonomies": true }
27
29
  # * +tags+ - [_Boolean_] If present, tags will be returned for each record in the results. _Example:_
28
30
  # { "tags": true }
29
31
  # * +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 +34,7 @@ module Mints
32
34
  #
33
35
  # == Resource collections options
34
36
  # * +search+ - [_String_] If present, it will search for records matching the search string. _Example:_
35
- # { "search": "searchstring" }
37
+ # { "search": "search string" }
36
38
  # * +scopes+ - [_String_] If present, it will apply the specified Model's scopes. _Example:_
37
39
  # { "scopes": "approved, recent" }
38
40
  # * +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 +53,15 @@ module Mints
51
53
  # "operator":"or"
52
54
  # }
53
55
  # 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
56
  # * +sort+ - [_String_] The name of the field to perform the sort. Prefix the value with a minus sign - for ascending order. _Example:_
60
57
  # { sort: "title" }
61
58
  # { 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
59
 
73
60
  class Pub
74
61
  attr_reader :client
62
+
63
+ include MintsHelper
64
+
75
65
  ##
76
66
  # === Initialize.
77
67
  # Class constructor.
@@ -110,8 +100,8 @@ module Mints
110
100
  user_agent: user_agent || request.user_agent,
111
101
  url: url || request.fullpath
112
102
  }
113
- response = @client.raw('post', "/register-visit", nil, data.to_json)
114
- return response
103
+
104
+ @client.raw('post', '/register-visit', nil, data.to_json)
115
105
  end
116
106
 
117
107
  ##
@@ -155,9 +145,7 @@ module Mints
155
145
  # @data = @mints_pub.get_stories
156
146
  #
157
147
  # ==== Second Example
158
- # options = {
159
- # fields: 'id, slug'
160
- # }
148
+ # options = { fields: 'id, slug' }
161
149
  # @data = @mints_pub.get_stories(options)
162
150
  #
163
151
  # ==== Third Example
@@ -209,7 +197,7 @@ module Mints
209
197
  # }
210
198
  # @data = @mints_pub.get_story_versions(options, false)
211
199
  def get_story_versions(options = nil, use_post = true)
212
- get_query_results("/content/story-versions", options, use_post)
200
+ get_query_results('/content/story-versions', options, use_post)
213
201
  end
214
202
 
215
203
  ##
@@ -270,7 +258,7 @@ module Mints
270
258
  # }
271
259
  # @data = @mints_pub.submit_form(data)
272
260
  def submit_form(data)
273
- @client.raw('post', "/content/forms/submit", nil, data_transform(data))
261
+ @client.raw('post', '/content/forms/submit', nil, data_transform(data))
274
262
  end
275
263
 
276
264
  ##
@@ -293,7 +281,7 @@ module Mints
293
281
  # }
294
282
  # @data = @mints_pub.get_content_instances(options)
295
283
  def get_content_instances(options = nil)
296
- @client.raw('get', "/content/content-instances", options)
284
+ @client.raw('get', '/content/content-instances', options)
297
285
  end
298
286
 
299
287
  ##
@@ -316,7 +304,7 @@ module Mints
316
304
  # ==== Parameters
317
305
  # options:: (Hash) -- List of {Resource collection Options}[#class-Mints::Pub-label-Resource+collections+options+] shown above can be used as parameter.
318
306
  def get_content_bundles(options = nil)
319
- @client.raw('get', "/content/content-bundles", options)
307
+ @client.raw('get', '/content/content-bundles', options)
320
308
  end
321
309
 
322
310
  ##
@@ -367,7 +355,7 @@ module Mints
367
355
  # options = { fields: "title" }
368
356
  # @data = @mints_pub.get_locations(options, false)
369
357
  def get_locations(options = nil, use_post = true)
370
- get_query_results("/ecommerce/locations", options, use_post)
358
+ get_query_results('/ecommerce/locations', options, use_post)
371
359
  end
372
360
 
373
361
  ##
@@ -389,7 +377,7 @@ module Mints
389
377
  # options = { fields: "title" }
390
378
  # @data = @mints_pub.get_products(options, false)
391
379
  def get_products(options = nil, use_post = true)
392
- get_query_results("/ecommerce/products", options, use_post)
380
+ get_query_results('/ecommerce/products', options, use_post)
393
381
  end
394
382
 
395
383
  ##
@@ -423,19 +411,19 @@ module Mints
423
411
  #
424
412
  # ==== First Example
425
413
  # options = {
426
- # "object_type": "products"
414
+ # object_type: "products"
427
415
  # }
428
416
  # @data = @mints_pub.get_public_folders(options)
429
417
  #
430
418
  # ==== Second Example
431
419
  # options = {
432
- # "object_type": "products",
420
+ # object_type: "products",
433
421
  # fields: "id",
434
422
  # sort: "-id"
435
423
  # }
436
424
  # @data = @mints_pub.get_public_folders(options)
437
425
  def get_public_folders(options = nil)
438
- @client.raw('get', "/config/public-folders", options)
426
+ @client.raw('get', '/config/public-folders', options)
439
427
  end
440
428
 
441
429
  ##
@@ -448,13 +436,13 @@ module Mints
448
436
  #
449
437
  # ==== First Example
450
438
  # options = {
451
- # "object_type": "products"
439
+ # object_type: "products"
452
440
  # }
453
441
  # @data = @mints_pub.get_public_folder('yellow', options)
454
442
  #
455
443
  # ==== Second Example
456
444
  # options = {
457
- # "object_type": "products",
445
+ # object_type: "products",
458
446
  # fields: 'id, title'
459
447
  # }
460
448
  # @data = @mints_pub.get_public_folder('yellow', options)
@@ -478,7 +466,7 @@ module Mints
478
466
  # }
479
467
  # @data = @mints_pub.get_tags(options)
480
468
  def get_tags(options = nil)
481
- @client.raw('get', "/config/tags", options)
469
+ @client.raw('get', '/config/tags', options)
482
470
  end
483
471
 
484
472
  ##
@@ -496,7 +484,7 @@ module Mints
496
484
  # options = {
497
485
  # fields: "id, tag"
498
486
  # }
499
- # @data = @mints_pub.get_tag("velit-0", options)
487
+ # @data = @mints_pub.get_tag("tag-example", options)
500
488
  def get_tag(slug, options = nil)
501
489
  @client.raw('get', "/config/tags/#{slug}", options)
502
490
  end
@@ -524,7 +512,7 @@ module Mints
524
512
  # }
525
513
  # @data = @mints_pub.get_taxonomies(options, false)
526
514
  def get_taxonomies(options = nil, use_post = true)
527
- get_query_results("/config/taxonomies", options, use_post)
515
+ get_query_results('/config/taxonomies', options, use_post)
528
516
  end
529
517
 
530
518
  ##
@@ -536,13 +524,13 @@ module Mints
536
524
  # options:: (Hash) -- List of {Single Resource Options}[#class-Mints::Pub-label-Single+resource+options] shown above can be used as parameter.
537
525
  #
538
526
  # ==== First Example
539
- # @data = @mints_pub.get_taxonomy("taxonomy_slug")
527
+ # @data = @mints_pub.get_taxonomy('taxonomy_slug')
540
528
  #
541
529
  # ==== Second Example
542
530
  # options = {
543
- # fields: "title"
531
+ # fields: 'title'
544
532
  # }
545
- # @data = @mints_pub.get_taxonomy("taxonomy_slug", options)
533
+ # @data = @mints_pub.get_taxonomy('taxonomy_slug', options)
546
534
  def get_taxonomy(slug, options = nil)
547
535
  @client.raw('get', "/config/taxonomies/#{slug}", options)
548
536
  end
@@ -554,7 +542,7 @@ module Mints
554
542
  # ==== Example
555
543
  # @data = @mints_pub.get_attributes
556
544
  def get_attributes
557
- @client.raw('get', "/config/attributes")
545
+ @client.raw('get', '/config/attributes')
558
546
  end
559
547
 
560
548
  def send_user_magic_link(email_or_phone, template_slug, redirect_url = '', life_time = 1440, max_visits = nil, driver = 'email')
@@ -565,16 +553,10 @@ module Mints
565
553
  redirectUrl: redirect_url,
566
554
  templateId: template_slug
567
555
  }
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
556
 
576
- private
577
-
578
- include MintsHelper
557
+ key = %w[sms whatsapp].include? driver ? 'phone' : 'email'
558
+ data[key] = email_or_phone
559
+ @client.raw('post', '/users/magic-link', nil, { data: data }.to_json, '/api/v1')
560
+ end
579
561
  end
580
562
  end
@@ -1,65 +1,67 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ApiKeys
2
- ##
3
- # == Api keys
4
- #
5
-
6
- # === Get api keys.
7
- # Get a collection of api keys.
8
- #
9
- # ==== Parameters
10
- # options:: (Hash) -- List of Resource Collection Options shown above can be used as parameter.
11
- #
12
- # ==== First Example
13
- # @data = @mints_user.get_api_keys
14
- #
15
- # ==== Second Example
16
- # options = { fields: "id" }
17
- # @data = @mints_user.get_api_keys(options)
18
- def get_api_keys(options = nil)
19
- @client.raw('get', "/config/api-keys", options)
20
- end
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
- # === Get api key.
23
- # Get an api key info.
24
- #
25
- # ==== Parameters
26
- # id:: (Integer) -- Api key id.
27
- # options:: (Hash) -- List of Resource Collection Options shown above can be used as parameter.
28
- #
29
- # ==== First Example
30
- # @data = @mints_user.get_api_key(2)
31
- #
32
- # ==== Second Example
33
- # options = { fields: "id" }
34
- # @data = @mints_user.get_api_key(2, options)
35
- def get_api_key(id, options = nil)
36
- @client.raw('get', "/config/api-keys/#{id}", options)
37
- end
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
- # === Create api key.
40
- # Create an api key with data.
41
- #
42
- # ==== Parameters
43
- # data:: (Hash) -- Data to be submitted.
44
- #
45
- # ==== Example
46
- # data = {
47
- # description: "New Api Key Description"
48
- # }
49
- # @data = @mints_user.create_api_key(data)
50
- def create_api_key(data)
51
- @client.raw('post', "/config/api-keys", nil, data_transform(data))
52
- end
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
- # === Delete api key.
55
- # Delete an api key.
56
- #
57
- # ==== Parameters
58
- # id:: (Integer) -- Api key id.
59
- #
60
- # ==== Example
61
- # @data = @mints_user.delete_api_key(2)
62
- def delete_api_key(id)
63
- @client.raw('delete', "/config/api-keys/#{id}")
64
- end
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