mints 0.0.30 → 0.0.31

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 (45) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +290 -32
  3. data/lib/contact/config/appointments.rb +1 -1
  4. data/lib/contact/config/config.rb +2 -2
  5. data/lib/contact/content/content.rb +2 -2
  6. data/lib/contact/content/conversations.rb +2 -2
  7. data/lib/contact/ecommerce/ecommerce.rb +5 -5
  8. data/lib/contact/ecommerce/order_items.rb +1 -1
  9. data/lib/contact/ecommerce/order_items_groups.rb +1 -1
  10. data/lib/contact/ecommerce/orders.rb +1 -1
  11. data/lib/contact/ecommerce/vouchers.rb +2 -2
  12. data/lib/contact.rb +9 -3
  13. data/lib/mints/controllers/concerns/mints_clients.rb +3 -1
  14. data/lib/mints/helpers/proxy_controllers_methods.rb +1 -1
  15. data/lib/pub/config/attributes.rb +1 -1
  16. data/lib/pub/config/config.rb +4 -4
  17. data/lib/pub/config/tags.rb +1 -1
  18. data/lib/pub/config/taxonomies.rb +1 -1
  19. data/lib/pub/content/assets.rb +1 -1
  20. data/lib/pub/content/content.rb +8 -8
  21. data/lib/pub/content/content_bundles.rb +1 -1
  22. data/lib/pub/content/content_instance_versions.rb +1 -1
  23. data/lib/pub/content/content_instances.rb +1 -1
  24. data/lib/pub/content/forms.rb +1 -1
  25. data/lib/pub/content/stories.rb +1 -1
  26. data/lib/pub/content/story_versions.rb +1 -1
  27. data/lib/pub/ecommerce/ecommerce.rb +4 -4
  28. data/lib/pub/ecommerce/locations.rb +1 -1
  29. data/lib/pub/ecommerce/orders.rb +1 -1
  30. data/lib/pub/ecommerce/products.rb +1 -1
  31. data/lib/pub.rb +3 -3
  32. data/lib/user/config/config.rb +1 -1
  33. data/lib/user/config/public_folders.rb +1 -1
  34. data/lib/user/config/users.rb +4 -4
  35. data/lib/user/content/content.rb +0 -55
  36. data/lib/user/content/forms.rb +4 -4
  37. data/lib/user/content/messages.rb +4 -4
  38. data/lib/user/content/stories.rb +8 -5
  39. data/lib/user/content/story_templates.rb +2 -2
  40. data/lib/user/crm/contacts.rb +0 -13
  41. data/lib/user/crm/workflow_steps.rb +4 -4
  42. data/lib/user/crm/workflows.rb +4 -4
  43. data/lib/user/ecommerce/order_items_groups.rb +2 -2
  44. data/lib/user/ecommerce/skus.rb +2 -2
  45. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6a9a445aee572bf7d3208545a3fed7fef5979e0151d7bdacde92b060e1142d6e
4
- data.tar.gz: 14f88f53ccff619b7e3980c0ea606ce05e71461129885f47f7c59dc4a88cb5c4
3
+ metadata.gz: 15db76401dfa74546139b780363014a6502c2d10409f5ba7199d27c16b746d64
4
+ data.tar.gz: 52ad33837204580f17ade75c3777dea6aea97903a508968a8bff0e5cb52f098e
5
5
  SHA512:
6
- metadata.gz: 895fed64e6d46023b5e34c2a26fb751d10ea8f8115c64648b130cde117da07c9fa59cbfc5a343a0850641d9ee8fbcda42addd9583681d4da7135beb2d0e51e4a
7
- data.tar.gz: 9ca24a98b56455221ddb5f56a143debd9f15ecd979a019970d2915bf15ee3a18d2c70c83aa4a94a9f36aad1fee81b84cee905f76b4f793ab9eba59de57c28ccf
6
+ metadata.gz: 4ddb5dda74b294e5d351a6d700e93aa0120b3ef94622203c52020317768c23f88fa855ffe10463efda4bcbb558aca783d8107eb2bc5005102410a0cabcc7f9df
7
+ data.tar.gz: 928bc2bfa825d822b08a7f30f9ea4575f43e4db1888d58caa07eac4a443372499b2b6f75dd4f45189ef9c2870d42ed0aadc9481a95c578e7b345e06f0f65a4d0
data/README.md CHANGED
@@ -5,63 +5,89 @@ This is a library to connect apps built on ruby to Mints.Cloud
5
5
  ## Installation
6
6
 
7
7
  Add gem to the Gemfile
8
+
8
9
  ```bash
9
10
  gem 'mints'
10
11
  ```
11
12
 
12
13
  ## Usage
14
+
13
15
  Using Mints Public API
16
+
14
17
  ```ruby
15
- pub = Mints::Pub.new(mints_url, api_key)
16
- pub.get_stories
18
+ mints_pub = Mints::Pub.new(mints_url, api_key)
19
+ mints_pub.get_stories
17
20
  ```
18
21
 
19
22
  Using Mints Contact API
23
+
20
24
  ```ruby
21
- con = Mints::Contact.new(mints_url, api_key)
22
- con.login(email, password)
23
- con.me
25
+ mints_contact = Mints::Contact.new(mints_url, api_key)
26
+ mints_contact.login(email, password)
27
+ mints_contact.me
24
28
  ```
25
29
 
26
30
  Using Mints User API
31
+
27
32
  ```ruby
28
- con = Mints::User.new(mints_url, api_key)
29
- con.login(email, password)
30
- con.get_contacts
33
+ mints_user = Mints::User.new(mints_url, api_key)
34
+ mints_user.login(email, password)
35
+ mints_user.get_contacts
31
36
  ```
37
+
38
+ Using Mints User API by Service account
39
+
40
+ ```ruby
41
+ # Usually the api_key and the session token are the same, you can go to the service accounts section
42
+ # from your CXF instance and generate your service account api key
43
+ mints_service_account = Mints::User.new(mints_url, api_key, api_key)
44
+ mints_service_account.get_contacts
45
+ ```
46
+
32
47
  ## Generate mints files
33
- This command will generate the mints_config.yml.erb file, API controlles and routes to have available the mints endpoints
48
+
49
+ This command will generate the mints_config.yml.erb file, API controlles and routes to have available the mints
50
+ endpoints
51
+
34
52
  ```bash
35
53
  rails generate mints_files
36
54
  ```
55
+
37
56
  ## Contact tracking usage
57
+
38
58
  Your app controller needs to be inherited from Mints::BaseController
59
+
39
60
  ```ruby
40
61
  # application_controller.rb
41
62
 
42
63
  class ApplicationController < Mints::BaseController
43
64
  end
44
65
  ```
66
+
45
67
  This heritance will make the following class variables available:
46
68
 
47
- | Variable | Description |
48
- | --- | :---: |
49
- | @host | Host defined in mints_config.yml.erb file |
50
- | @api_key | API key defined in mints_config.yml.erb file |
51
- | @mints_pub | An already instanced public client |
52
- | @contact_token | A token used by mints to identify the contact |
53
- | @visit_id | An identifier of the visit registered |
54
- | @mints_contact | An already instanced contact client (not usable until call the contact login method) |
69
+ | Variable | Description |
70
+ |----------------|:------------------------------------------------------------------------------------:|
71
+ | @host | Host defined in mints_config.yml.erb file |
72
+ | @api_key | API key defined in mints_config.yml.erb file |
73
+ | @mints_pub | An already instanced public client |
74
+ | @contact_token | A token used by mints to identify the contact |
75
+ | @visit_id | An identifier of the visit registered |
76
+ | @mints_contact | An already instanced contact client (not usable until call the contact login method) |
55
77
 
56
78
  And the following controller methods:
57
- | Method | Parameters | Return value | Description |
58
- | --- | :---: | :---: | :---: |
59
- | mints_contact_signed_in? | none | boolean | Indicates if the contact has an active session |
60
- | mints_contact_login | email, password| void | Starts a contact session |
61
- | mints_contact_logout | none | void | Ends a contact session |
79
+
80
+ | Method | Parameters | Return value | Description |
81
+ |--------------------------------|:-----------------------:|:------------:|:----------------------------------------------------------------:|
82
+ | mints_contact_signed_in? | none | boolean | Indicates if the contact has an active session |
83
+ | mints_contact_login | email, password | void | Starts a contact session |
84
+ | mints_contact_logout | none | void | Ends a contact session |
85
+ | mints_contact_magic_link_login | hash, redirect_in_error | void | Starts a contact session in mints.cloud and set a session cookie |
62
86
 
63
87
  ## Admin controller usage
64
- If want to have a private section where only a mints user can acces and use the private user api is needed to inherit from the AdminBaseController.
88
+
89
+ If want to have a private section where only a mints user can acces and use the private user api is needed to inherit
90
+ from the AdminBaseController.
65
91
 
66
92
  ```ruby
67
93
  # admin_controller.rb
@@ -71,14 +97,246 @@ end
71
97
  ```
72
98
 
73
99
  This heritance will make the following class variables available:
74
- | Variable | Description |
75
- | --- | :---: |
76
- | @host | Host defined in mints_config.yml.erb file |
77
- | @api_key | API key defined in mints_config.yml.erb file |
78
- | @mints_user | An already instanced user client (not usable until call the user login method) |
100
+
101
+ | Variable | Description |
102
+ |------------------------|:-------------------------------------------------------------------------------:|
103
+ | @host | Host defined in mints_config.yml.erb file |
104
+ | @api_key | API key defined in mints_config.yml.erb file |
105
+ | @mints_user | An already instanced user client (not usable until call the user login method) |
106
+ | @mints_service_account | An already instanced service_account client |
79
107
 
80
108
  And the following controller methods:
81
- | Method | Parameters | Return value | Description |
82
- | --- | :---: | :---: | :---: |
83
- | mints_user_login | email, password| void | Starts a user session |
84
- | mints_user_logout | none | void | Ends a user session |
109
+
110
+ | Method | Parameters | Return value | Description |
111
+ |-----------------------------|:---------------:|:------------:|:-------------------------------------------------------------:|
112
+ | mints_user_login | email, password | void | Starts a user session |
113
+ | mints_user_logout | none | void | Ends a user session |
114
+ | mints_user_signed_in? | none | Boolean | Indicates if the user has an active session |
115
+ | mints_user_magic_link_login | hash | void | Starts a user session in mints.cloud and set a session cookie |
116
+
117
+ ## Mints config file
118
+
119
+ The mints.config.yml file allows to set the CXF instance to which the implementation will access, it can add the host,
120
+ api key for CXF, in addition to setting the cache rules with redis, if you want to add a url to cache , you should add
121
+ it to the groups array and set the cache time.
122
+
123
+ ```yaml
124
+ # Mints connection configuration
125
+ mints:
126
+ host: http://your_host_goes_here.com
127
+ api_key: your_mints_api_key_goes_here
128
+ mints_slug: slug_id #save id and token in redis
129
+ redis_cache:
130
+ use_cache: boolean_value_to_enable_and_disable_cache
131
+ redis_host: your_redis_server_host
132
+ redis_port: your_redis_server_port
133
+ redis_db: your_redis_database
134
+ groups:
135
+ - urls:
136
+ - group_of_urls
137
+ time: time_that_will_be_applied_to_urls_in_seconds
138
+ ```
139
+
140
+ To enable sdk debugging you can change the variable debug.
141
+ Finally, to configure the sharing of cookies between domains, you can configure the "iframe cookies", where you
142
+ establish how long the cookie will have, if it is activated and the domains to share cookies (to have this
143
+ functionality, we recommend the use of the template).
144
+
145
+ ```yaml
146
+ # Mints connection configuration
147
+ sdk:
148
+ debug: false
149
+ cookies_iframe:
150
+ activated: boolean_value_to_enable_and_disable_cookies_iframe
151
+ expire_time: expire_time_of_cookies_iframe_in_hours
152
+ hosts:
153
+ - array_of_host_to_send_cookies
154
+ ```
155
+
156
+ ## Override default clients
157
+
158
+ If you want other clients for admin/base controller, you need to specify them with the "define_mints_clients" method
159
+ Example:
160
+
161
+ ```ruby
162
+ # admin_controller.rb
163
+
164
+ class AdminController < Mints::AdminBaseController
165
+ def define_mints_clients
166
+ %w[contact user pub service_account]
167
+ end
168
+ end
169
+ ```
170
+
171
+ ## Error catching
172
+
173
+ The SDK provides different errors that are identified according to the response provided by CXF,
174
+ the errors can be 404, 401, 422, 500, etc.
175
+ To rescue these errors, it is done as follows:
176
+
177
+ ```ruby
178
+
179
+ # Example 1
180
+ begin
181
+ @mints_pub.client.raw('/invalid-url')
182
+ rescue => Mints::Errors::ResourceNotFoundException
183
+ puts "Error 404"
184
+ end
185
+
186
+ # Example 2
187
+
188
+ begin
189
+ response = @mints_contact.register(data)
190
+ rescue Mints::Errors::ValidationException => e
191
+ response = e.to_h
192
+ # This will return a Hash with the information needed to debug
193
+ # Example:
194
+ {
195
+ :client => sdk_instance,
196
+ # Client instance
197
+ # @host = "https://your_cxf_instance",
198
+ # @api_key = current_api_key,
199
+ # @session_token = current_session_token,
200
+ # @contact_token_id = current_contact_token_id,
201
+ # @visit_id = current_visit_id,
202
+ # @debug = current_debug_flag,
203
+ # @scope = current_scope,
204
+ # @base_url = current_base_url
205
+ :title => "Request failed with status 422",
206
+ :detail => "Unprocessable Entity",
207
+ :http_status => 422,
208
+ :response => { "email" => ["The email has already been taken."] },
209
+ :errors => ["The email has already been taken."]
210
+ }
211
+ end
212
+
213
+ ```
214
+
215
+ The current errors are:
216
+
217
+ | Error | Status | Full error name |
218
+ |---------------------------|:------:|:----------------------------------------:|
219
+ | AccessDeniedException | 401 | Mints::Errors::AccessDeniedException |
220
+ | ResourceNotFoundException | 404 | Mints::Errors::ResourceNotFoundException |
221
+ | MethodNotAllowedException | 405 | Mints::Errors::MethodNotAllowedException |
222
+ | ValidationException | 422 | Mints::Errors::ValidationException |
223
+ | InternalServerException | 500 | Mints::Errors::InternalServerException |
224
+
225
+ <details>
226
+ <summary> Mints::Pub </summary>
227
+
228
+ - Mints::Pub::Config
229
+ - [Mints::Pub::Config::Attributes](doc/pub/config/attributes.md)
230
+ - [Mints::Pub::Config::PublicFolders](doc/pub/config/public_folders.md)
231
+ - [Mints::Pub::Config::Tags](doc/pub/config/tags.md)
232
+ - [Mints::Pub::Config::Taxonomies](doc/pub/config/taxonomies.md)
233
+
234
+
235
+ - Mints::Pub::Content
236
+ - [Mints::Pub::Content::Assets](doc/pub/content/assets.md)
237
+ - [Mints::Pub::Content::ContentBundles](doc/pub/content/content_bundles.md)
238
+ - [Mints::Pub::Content::ContentInstanceVersions](doc/pub/content/content_instance_versions.md)
239
+ - [Mints::Pub::Content::ContentInstances](doc/pub/content/content_instances.md)
240
+ - [Mints::Pub::Content::Forms](doc/pub/content/forms.md)
241
+ - [Mints::Pub::Content::Stories](doc/pub/content/stories.md)
242
+ - [Mints::Pub::Content::StoryVersions](doc/pub/content/story_versions.md)
243
+
244
+ - Mints::Pub::Ecommerce
245
+ - [Mints::Pub::Ecommerce::Locations](doc/pub/ecommerce/locations.md)
246
+ - [Mints::Pub::Ecommerce::Orders](doc/pub/ecommerce/orders.md)
247
+ - [Mints::Pub::Ecommerce::Products](doc/pub/ecommerce/products.md)
248
+
249
+ </details>
250
+
251
+ <details>
252
+ <summary> Mints::Contact </summary>
253
+
254
+ - Mints::Contact::Config
255
+ - [Mints::Contact::Config::Appointments](doc/contact/config/appointments.md)
256
+
257
+
258
+ - Mints::Contact::Content
259
+ - [Mints::Contact::Content::Conversations](doc/contact/content/conversations.md)
260
+
261
+ - Mints::Contact::Ecommerce
262
+ - [Mints::Contact::Ecommerce::OrderItemGroups](doc/contact/ecommerce/order_item_groups.md)
263
+ - [Mints::Contact::Ecommerce::OrderItems](doc/contact/ecommerce/order_items.md)
264
+ - [Mints::Contact::Ecommerce::Orders](doc/contact/ecommerce/orders.md)
265
+ - [Mints::Contact::Ecommerce::Vouchers](doc/contact/ecommerce/vouchers.md)
266
+
267
+ </details>
268
+
269
+ <details>
270
+ <summary> Mints::User </summary>
271
+
272
+ - Mints::User::Config
273
+ - [Mints::User::Config::ApiKey](doc/user/config/api_key.md)
274
+ - [Mints::User::Config::Appointments](doc/user/config/appointments.md)
275
+ - [Mints::User::Config::AttributeGroups](doc/user/config/attribute_groups.md)
276
+ - [Mints::User::Config::Attributes](doc/user/config/attributes.md)
277
+ - [Mints::User::Config::Calendar](doc/user/config/calendar.md)
278
+ - [Mints::User::Config::PublicFolder](doc/user/config/public_folders.md)
279
+ - [Mints::User::Config::Relationships](doc/user/config/relationships.md)
280
+ - [Mints::User::Config::Roles](doc/user/config/roles.md)
281
+ - [Mints::User::Config::Seeds](doc/user/config/seeds.md)
282
+ - [Mints::User::Config::SystemSettings](doc/user/config/system_settings.md)
283
+ - [Mints::User::Config::Tags](doc/user/config/tags.md)
284
+ - [Mints::User::Config::Taxonomies](doc/user/config/taxonomies.md)
285
+ - [Mints::User::Config::Teams](doc/user/config/teams.md)
286
+ - [Mints::User::Config::Users](doc/user/config/users.md)
287
+
288
+ - [Mints::User::Contacts](doc/user/contacts/contacts.md)
289
+
290
+ - [Mints::User::Content](doc/user/content/content.md)
291
+ - [Mints::User::Content::Assets](doc/user/content/assets.md)
292
+ - [Mints::User::Content::ContentInstances](doc/user/content/content_instances.md)
293
+ - [Mints::User::Content::ContentTemplates](doc/user/content/content_templates.md)
294
+ - [Mints::User::Content::Conversations](doc/user/content/conversations.md)
295
+ - [Mints::User::Content::Dam](doc/user/content/dam.md)
296
+ - [Mints::User::Content::Forms](doc/user/content/forms.md)
297
+ - [Mints::User::Content::MessageTemplates](doc/user/content/message_templates.md)
298
+ - [Mints::User::Content::Messages](doc/user/content/messages.md)
299
+ - [Mints::User::Content::Pages](doc/user/content/pages.md)
300
+ - [Mints::User::Content::Stories](doc/user/content/stories.md)
301
+ - [Mints::User::Content::StoryTemplates](doc/user/content/story_templates.md)
302
+ - [Mints::User::Content::StoryVersions](doc/user/content/story_versions.md)
303
+
304
+ - Mints::User::Crm
305
+ - [Mints::User::Crm::Companies](doc/user/crm/companies.md)
306
+ - [Mints::User::Crm::Contacts](doc/user/crm/contacts.md)
307
+ - [Mints::User::Crm::Deals](doc/user/crm/deals.md)
308
+ - [Mints::User::Crm::Favorites](doc/user/crm/favorites.md)
309
+ - [Mints::User::Crm::Segments](doc/user/crm/segments.md)
310
+ - [Mints::User::Crm::Users](doc/user/crm/users.md)
311
+ - [Mints::User::Crm::WorkflowStepObjects](doc/user/crm/workflow_step_objects.md)
312
+ - [Mints::User::Crm::WorkflowSteps](doc/user/crm/workflow_steps.md)
313
+ - [Mints::User::Crm::Workflows](doc/user/crm/workflows.md)
314
+
315
+ - Mints::User::Ecommerce
316
+ - [Mints::User::Ecommerce::ItemPrices](doc/user/ecommerce/item_prices.md)
317
+ - [Mints::User::Ecommerce::Locations](doc/user/ecommerce/locations.md)
318
+ - [Mints::User::Ecommerce::OrderItemGroups](doc/user/ecommerce/order_item_groups.md)
319
+ - [Mints::User::Ecommerce::OrderStatuses](doc/user/ecommerce/order_statuses.md)
320
+
321
+ - [Mints::User::Ecommerce::Orders](doc/user/ecommerce/orders.md)
322
+ - [Mints::User::Ecommerce::PriceList](doc/user/ecommerce/price_list.md)
323
+ - [Mints::User::Ecommerce::ProductTemplates](doc/user/ecommerce/product_templates.md)
324
+ - [Mints::User::Ecommerce::ProductVariations](doc/user/ecommerce/product_variations.md)
325
+ - [Mints::User::Ecommerce::Products](doc/user/ecommerce/products.md)
326
+ - [Mints::User::Ecommerce::Skus](doc/user/ecommerce/skus.md)
327
+ - [Mints::User::Ecommerce::Taxes](doc/user/ecommerce/taxes.md)
328
+ - [Mints::User::Ecommerce::VariantOptions](doc/user/ecommerce/variant_options.md)
329
+ - [Mints::User::Ecommerce::VariantValues](doc/user/ecommerce/variant_values.md)
330
+ - [Mints::User::Ecommerce::Vouchers](doc/user/ecommerce/vouchers.md)
331
+
332
+ - [Mints::User::Helpers](doc/user/helpers/helpers.md)
333
+ - [Mints::User::Helpers::ObjectActivities](doc/user/helpers/object_activities.md)
334
+ - [Mints::User::Helpers::ObjectFolders](doc/user/helpers/object_folders.md)
335
+ - [Mints::User::Helpers::UserFolders](doc/user/helpers/user_folders.md)
336
+
337
+ - [Mints::User::Marketing](doc/user/marketing/marketing.md)
338
+
339
+ - [Mints::User::Profile](doc/user/profile/profile.md)
340
+
341
+ </details>
342
+
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Appointments
3
+ module ContactAppointments
4
4
  # Appointments
5
5
 
6
6
  ##
@@ -2,6 +2,6 @@
2
2
 
3
3
  require_relative './appointments'
4
4
 
5
- module Config
6
- include Appointments
5
+ module ContactConfig
6
+ include ContactAppointments
7
7
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  require_relative './conversations'
4
4
 
5
- module Content
6
- include Conversations
5
+ module ContactContent
6
+ include ContactConversations
7
7
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Conversations
3
+ module ContactConversations
4
4
  ##
5
5
  # === Get Conversations.
6
6
  # Get a collection of conversations.
@@ -66,7 +66,7 @@ module Conversations
66
66
 
67
67
  ##
68
68
  # === Get Conversation Participants.
69
- # Update a conversation participants.
69
+ # Get a conversation participants.
70
70
  #
71
71
  # ==== Parameters
72
72
  # id:: (Integer) -- Conversation id.
@@ -5,10 +5,10 @@ require_relative './order_items'
5
5
  require_relative './orders'
6
6
  require_relative './vouchers'
7
7
 
8
- module Ecommerce
9
- include OrderItemsGroups
10
- include OrderItems
11
- include Orders
12
- include Vouchers
8
+ module ContactEcommerce
9
+ include ContactOrderItemsGroups
10
+ include ContactOrderItems
11
+ include ContactOrders
12
+ include ContactVouchers
13
13
 
14
14
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module OrderItems
3
+ module ContactOrderItems
4
4
  ##
5
5
  # === Get Order Items.
6
6
  # Get a collection of order items.
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module OrderItemsGroups
3
+ module ContactOrderItemsGroups
4
4
  ##
5
5
  # === Get Order Item Groups.
6
6
  # Get a collection of order item groups.
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Orders
3
+ module ContactOrders
4
4
  ##
5
5
  # === Get Orders.
6
6
  # Get a collection of orders.
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Vouchers
3
+ module ContactVouchers
4
4
  ##
5
- # === Apply voucher.
5
+ # === Apply voucher.Contact
6
6
  # Apply voucher code to the existing order, only applies to sale orders.
7
7
  #
8
8
  # ==== Parameters
data/lib/contact.rb CHANGED
@@ -10,7 +10,13 @@ include ActionController::Cookies
10
10
 
11
11
  module Mints
12
12
  class Contact
13
+ include ContactConfig
14
+ include ContactContent
15
+ include ContactEcommerce
16
+ include MintsHelper
17
+
13
18
  attr_reader :client
19
+
14
20
  ##
15
21
  # === Initialize.
16
22
  # Class constructor.
@@ -71,7 +77,7 @@ module Mints
71
77
 
72
78
  ##
73
79
  # === Recover Password.
74
- # Send a email that contains a token to a contact. That token will be used in reset_password to establish a new password.
80
+ # Send a email that contains a token to a contact. That token will be used in reset_password to establish a new password.
75
81
  #
76
82
  # ==== Parameters
77
83
  # data:: (Hash) -- It's a data key where will be hosted the destination email.
@@ -172,10 +178,10 @@ module Mints
172
178
  # @data = @mints_contact.me
173
179
  #
174
180
  # ==== Second Example
175
- # options = {
181
+ # options = {
176
182
  # attributes: true,
177
183
  # taxonomies: true
178
- # }
184
+ # }
179
185
  # @data = @mints_contact.me(options)
180
186
  def me(options = nil)
181
187
  @client.raw('get', '/me', options, nil, @contact_v1_url)
@@ -22,7 +22,9 @@ module MintsClients
22
22
  # === Set mints clients (pub, user and contact)
23
23
  # Initialize all clients from mints
24
24
  def set_mints_clients
25
- clients = define_mints_clients
25
+ valid_clients = %w[contact user pub service_account]
26
+
27
+ clients = define_mints_clients&.select { |client| valid_clients.include? client } || []
26
28
 
27
29
  if @debug
28
30
  puts "Clients to initialize:", clients
@@ -35,7 +35,7 @@ module ProxyControllersMethods
35
35
  full_url = request.original_url
36
36
  url_need_cache, time = url_need_cache?(full_url)
37
37
 
38
- if @debug or true
38
+ if @debug
39
39
  puts "URL: #{full_url}"
40
40
  puts "URL need cache: #{url_need_cache}"
41
41
  puts "URL time cache: #{time}"
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Attributes
3
+ module PublicAttributes
4
4
  ##
5
5
  # === Get Attributes.
6
6
  # Get a collection of attributes.
@@ -7,9 +7,9 @@ require_relative './public_folders'
7
7
  require_relative './tags'
8
8
  require_relative './taxonomies'
9
9
 
10
- module Config
11
- include Attributes
10
+ module PublicConfig
11
+ include PublicAttributes
12
12
  include PublicFolders
13
- include Tags
14
- include Taxonomies
13
+ include PublicTags
14
+ include PublicTaxonomies
15
15
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Tags
3
+ module PublicTags
4
4
  ##
5
5
  # === Get Tags.
6
6
  # Get a collection of tags.
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Taxonomies
3
+ module PublicTaxonomies
4
4
  ##
5
5
  # === Get Taxonomies.
6
6
  # Get a collection of taxonomies.
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Assets
3
+ module PublicAssets
4
4
  ##
5
5
  # === Get Asset Info.
6
6
  # Get a description of an Asset.
@@ -10,13 +10,13 @@ require_relative './forms'
10
10
  require_relative './stories'
11
11
  require_relative './story_versions'
12
12
 
13
- module Content
14
- include Assets
15
- include ContentBundles
16
- include ContentInstanceVersions
17
- include ContentInstances
18
- include Forms
19
- include Stories
20
- include StoryVersions
13
+ module PublicContent
14
+ include PublicAssets
15
+ include PublicContentBundles
16
+ include PublicContentInstanceVersions
17
+ include PublicContentInstances
18
+ include PublicForms
19
+ include PublicStories
20
+ include PublicStoryVersions
21
21
 
22
22
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module ContentBundles
3
+ module PublicContentBundles
4
4
  ##
5
5
  # === Get Content Pages.
6
6
  # Get all content pages.
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module ContentInstanceVersions
3
+ module PublicContentInstanceVersions
4
4
  ##
5
5
  # === Get Content Instance Versions.
6
6
  # Get a collection of content instance versions.
@@ -1,4 +1,4 @@
1
- module ContentInstances
1
+ module PublicContentInstances
2
2
  ##
3
3
  # === Get Content Instances.
4
4
  # Get a collection of content instances. _Note:_ Options must be specified.
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Forms
3
+ module PublicForms
4
4
  ##
5
5
  # === Get Forms.
6
6
  # Get a collection of forms.
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Stories
3
+ module PublicStories
4
4
  ##
5
5
  # === Get Stories.
6
6
  # Get a collection of stories.
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module StoryVersions
3
+ module PublicStoryVersions
4
4
  ##
5
5
  # === Get Story Versions.
6
6
  # Get a collection of story version.
@@ -6,9 +6,9 @@ require_relative './locations'
6
6
  require_relative './products'
7
7
  require_relative './orders'
8
8
 
9
- module Ecommerce
10
- include Locations
11
- include Products
12
- include Orders
9
+ module PublicEcommerce
10
+ include PublicLocations
11
+ include PublicProducts
12
+ include PublicOrders
13
13
 
14
14
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Locations
3
+ module PublicLocations
4
4
  ##
5
5
  # === Get Locations.
6
6
  # Get all locations.
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Orders
3
+ module PublicOrders
4
4
  ##
5
5
  # === Get My Shopping Cart.
6
6
  # Get a collection of items in the shopping cart.
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Products
3
+ module PublicProducts
4
4
  ##
5
5
  # === Get Products.
6
6
  # Get a collection of products.
data/lib/pub.rb CHANGED
@@ -64,9 +64,9 @@ module Mints
64
64
  attr_reader :client
65
65
 
66
66
  include MintsHelper
67
- include Content
68
- include Ecommerce
69
- include Config
67
+ include PublicContent
68
+ include PublicEcommerce
69
+ include PublicConfig
70
70
 
71
71
  ##
72
72
  # === Initialize.
@@ -21,7 +21,7 @@ module Config
21
21
  include AttributeGroups
22
22
  include Attributes
23
23
  include Calendars
24
- include PublicFolders
24
+ include UserPublicFolders
25
25
  include Relationships
26
26
  include Roles
27
27
  include Seeds
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module PublicFolders
3
+ module UserPublicFolders
4
4
  ##
5
5
  # == Public Folders
6
6
  #
@@ -51,8 +51,8 @@ module Users
51
51
  # is_coach: false
52
52
  # }
53
53
  # @data = @mints_user.create_user(data)
54
- def create_user(data)
55
- @client.raw('post', '/config/users', nil, data_transform(data))
54
+ def create_user(data, options = nil)
55
+ @client.raw('post', '/config/users', options, data_transform(data))
56
56
  end
57
57
 
58
58
  # === Update user.
@@ -71,7 +71,7 @@ module Users
71
71
  # roles: ''
72
72
  # }
73
73
  # @data = @mints_user.update_user(14, data)
74
- def update_user(id, data)
75
- @client.raw('put', "/config/users/#{id}", nil, data_transform(data))
74
+ def update_user(id, data, options = nil)
75
+ @client.raw('put', "/config/users/#{id}", options, data_transform(data))
76
76
  end
77
77
  end
@@ -36,61 +36,6 @@ module Content
36
36
  @client.raw('get', '/content/public-images-url')
37
37
  end
38
38
 
39
- ##
40
- # == Authors
41
- #
42
-
43
- # === Get authors.
44
- # Get authors.
45
- #
46
- # ==== Example
47
- # @data = @mints_user.get_authors
48
- def get_authors
49
- @client.raw('get', '/content/authors')
50
- end
51
-
52
- # === Get author.
53
- # Get an author.
54
- #
55
- # ==== Parameters
56
- # id:: (Integer) -- Author id.
57
- #
58
- # ==== Example
59
- # @data = @mints_user.get_author(1)
60
- def get_author(id)
61
- @client.raw('get', "/content/authors/#{id}")
62
- end
63
-
64
- # === Create author.
65
- # Create an author with data.
66
- #
67
- # ==== Parameters
68
- # data:: (Hash) -- Data to be submitted.
69
- #
70
- # ==== Example
71
- # data = {
72
- # title: 'Howard Phillips Lovecraft',
73
- # slug: 'howard-phillips-lovecraft'
74
- # }
75
- # @data = @mints_user.create_author(data.to_json)
76
- def create_author(data)
77
- @client.raw('post', '/content/authors', nil, data)
78
- end
79
-
80
- # === Update author.
81
- # Update an author info.
82
- #
83
- # ==== Parameters
84
- # id:: (Integer) -- Author id.
85
- # data:: (Hash) -- Data to be submitted.
86
- #
87
- # ==== Example
88
- #
89
- def update_author(id, data)
90
- # FIXME: Author controller doesnt receive data
91
- @client.raw('put', "/content/authors/#{id}", nil, data)
92
- end
93
-
94
39
  ##
95
40
  # == Keywords
96
41
  #
@@ -173,8 +173,8 @@ module Forms
173
173
  # slug: 'new-form-slug'
174
174
  # }
175
175
  # @data = @mints_user.create_form(data)
176
- def create_form(data)
177
- @client.raw('post', '/content/forms', nil, data_transform(data))
176
+ def create_form(data, options = nil)
177
+ @client.raw('post', '/content/forms', options, data_transform(data))
178
178
  end
179
179
 
180
180
  # === Update form.
@@ -190,8 +190,8 @@ module Forms
190
190
  # slug: 'new-form-slug'
191
191
  # }
192
192
  # @data = @mints_user.update_form(3, data)
193
- def update_form(id, data)
194
- @client.raw('put', "/content/forms/#{id}", nil, data_transform(data))
193
+ def update_form(id, data, options = nil)
194
+ @client.raw('put', "/content/forms/#{id}", options, data_transform(data))
195
195
  end
196
196
 
197
197
  # === Delete form.
@@ -56,8 +56,8 @@ module Messages
56
56
  # }
57
57
  # }
58
58
  # @data = @mints_user.create_message(data)
59
- def create_message(data)
60
- @client.raw('post', '/content/messages', nil, data_transform(data))
59
+ def create_message(data, options = nil)
60
+ @client.raw('post', '/content/messages', options, data_transform(data))
61
61
  end
62
62
 
63
63
  # === Update message.
@@ -74,8 +74,8 @@ module Messages
74
74
  # }
75
75
  # }
76
76
  # @data = @mints_user.update_message(102, data)
77
- def update_message(id, data)
78
- @client.raw('put', "/content/messages/#{id}", nil, data_transform(data))
77
+ def update_message(id, data, options = nil)
78
+ @client.raw('put', "/content/messages/#{id}", options, data_transform(data))
79
79
  end
80
80
 
81
81
  # === Delete message.
@@ -71,9 +71,12 @@ module Stories
71
71
  # slug: "new-story",
72
72
  # story_template_id: 1
73
73
  # }
74
- # @data = @mints_user.create_story(data)
75
- def create_story(data)
76
- @client.raw('post', '/content/stories', nil, data_transform(data))
74
+ #
75
+ # options = { fields: 'id,slug' }
76
+ #
77
+ # @data = @mints_user.create_story(data, options)
78
+ def create_story(data, options = nil)
79
+ @client.raw('post', '/content/stories', options, data_transform(data))
77
80
  end
78
81
 
79
82
  # === Update story.
@@ -89,8 +92,8 @@ module Stories
89
92
  # slug: 'new-story'
90
93
  # }
91
94
  # @data = @mints_user.update_story(5, data)
92
- def update_story(id, data)
93
- @client.raw('put', "/content/stories/#{id}", nil, data_transform(data))
95
+ def update_story(id, data, options = nil)
96
+ @client.raw('put', "/content/stories/#{id}", options, data_transform(data))
94
97
  end
95
98
 
96
99
  # === Delete story.
@@ -75,8 +75,8 @@ module StoryTemplates
75
75
  # slug: 'new-story-template-slug'
76
76
  # }
77
77
  # @data = @mints_user.create_story_template(data)
78
- def create_story_template(data)
79
- @client.raw('post', '/content/story-templates', nil, data_transform(data))
78
+ def create_story_template(data, options = nil)
79
+ @client.raw('post', '/content/story-templates', options, data_transform(data))
80
80
  end
81
81
 
82
82
  # === Update story template.
@@ -238,19 +238,6 @@ module Contacts
238
238
  @client.raw('get', "/crm/contacts/#{contact_id}/tags")
239
239
  end
240
240
 
241
- ##
242
- # === Get contact magic links.
243
- # Get magic links of a contact.
244
- #
245
- # ==== Parameters
246
- # contact_id:: (Integer) -- Contact id.
247
- #
248
- # ==== Example
249
- # @data = @mints_user.get_contact_magic_links(150)
250
- def get_contact_magic_links(contact_id)
251
- @client.raw('get', "/crm/contacts/#{contact_id}/magic-links")
252
- end
253
-
254
241
  ##
255
242
  # === Create contact merge.
256
243
  # Merge contacts.
@@ -17,8 +17,8 @@ module WorkFlowSteps
17
17
  # workflowId: 1
18
18
  # }
19
19
  # @data = @mints_user.create_workflow_step(data.to_json)
20
- def create_workflow_step(data)
21
- @client.raw('post', '/crm/steps', nil, data)
20
+ def create_workflow_step(data, options = nil)
21
+ @client.raw('post', '/crm/steps', options, data)
22
22
  end
23
23
 
24
24
  # === Update workflow step.
@@ -33,8 +33,8 @@ module WorkFlowSteps
33
33
  # stepTitle: 'Step Title Modified'
34
34
  # }
35
35
  # @data = @mints_user.update_workflow_step(23, data)
36
- def update_workflow_step(id, data)
37
- @client.raw('put', "/crm/steps/#{id}", nil, data)
36
+ def update_workflow_step(id, data, options = nil)
37
+ @client.raw('put', "/crm/steps/#{id}", options, data)
38
38
  end
39
39
 
40
40
  # === Delete workflow step.
@@ -50,8 +50,8 @@ module Workflows
50
50
  # object_type: 'deals'
51
51
  # }
52
52
  # @data = @mints_user.create_workflow(data.to_json)
53
- def create_workflow(data)
54
- @client.raw('post', '/crm/workflows/', nil, data)
53
+ def create_workflow(data, options = nil)
54
+ @client.raw('post', '/crm/workflows/', options, data)
55
55
  end
56
56
 
57
57
  # === Update workflow.
@@ -66,7 +66,7 @@ module Workflows
66
66
  # title: 'New Workflow Modified'
67
67
  # }
68
68
  # @data = @mints_user.update_workflow(7, data)
69
- def update_workflow(id, data)
70
- @client.raw('put', "/crm/workflows/#{id}", nil, correct_json(data))
69
+ def update_workflow(id, data, options = nil)
70
+ @client.raw('put', "/crm/workflows/#{id}", options, correct_json(data))
71
71
  end
72
72
  end
@@ -96,8 +96,8 @@ module OrderItemsGroups
96
96
  # name: 'New Order Item Group Modified'
97
97
  # }
98
98
  # @data = @mints_user.update_order_item_group(147, data)
99
- def update_order_item_group(id, data)
100
- @client.raw('put', "/ecommerce/order-items-groups/#{id}", nil, data_transform(data))
99
+ def update_order_item_group(id, data, options = nil)
100
+ @client.raw('put', "/ecommerce/order-items-groups/#{id}", options, data_transform(data))
101
101
  end
102
102
 
103
103
  # === Delete order item group.
@@ -56,8 +56,8 @@ module Skus
56
56
  # product_id: 1
57
57
  # }
58
58
  # @data = @mints_user.create_sku(data)
59
- def create_sku(data)
60
- @client.raw('post', '/ecommerce/skus', nil, data_transform(data))
59
+ def create_sku(data, options = nil)
60
+ @client.raw('post', '/ecommerce/skus', options, data_transform(data))
61
61
  end
62
62
 
63
63
  # === Update sku.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mints
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.30
4
+ version: 0.0.31
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ruben Gomez Garcia, Omar Mora, Luis Payan, Oscar Castillo, Fabian Garcia
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-03-29 00:00:00.000000000 Z
11
+ date: 2023-05-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable