mints 0.0.29 → 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 (51) 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 +6 -4
  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 -2
  11. data/lib/contact/ecommerce/vouchers.rb +18 -0
  12. data/lib/contact.rb +9 -3
  13. data/lib/errors.rb +1 -1
  14. data/lib/mints/controllers/concerns/mints_clients.rb +3 -1
  15. data/lib/mints/helpers/contact_auth_helper.rb +2 -2
  16. data/lib/mints/helpers/proxy_controllers_methods.rb +1 -1
  17. data/lib/pub/config/attributes.rb +13 -0
  18. data/lib/pub/config/config.rb +15 -0
  19. data/lib/pub/config/public_folders.rb +51 -0
  20. data/lib/pub/config/tags.rb +42 -0
  21. data/lib/pub/config/taxonomies.rb +49 -0
  22. data/lib/pub/content/assets.rb +16 -0
  23. data/lib/pub/content/content.rb +22 -0
  24. data/lib/pub/content/content_bundles.rb +40 -0
  25. data/lib/pub/content/content_instance_versions.rb +56 -0
  26. data/lib/pub/content/content_instances.rb +37 -0
  27. data/lib/pub/content/forms.rb +47 -0
  28. data/lib/pub/content/stories.rb +44 -0
  29. data/lib/pub/content/story_versions.rb +46 -0
  30. data/lib/pub/ecommerce/ecommerce.rb +14 -0
  31. data/lib/pub/ecommerce/locations.rb +25 -0
  32. data/lib/pub/ecommerce/orders.rb +31 -0
  33. data/lib/pub/ecommerce/products.rb +45 -0
  34. data/lib/pub.rb +6 -427
  35. data/lib/user/config/config.rb +1 -1
  36. data/lib/user/config/public_folders.rb +1 -1
  37. data/lib/user/config/users.rb +4 -4
  38. data/lib/user/content/content.rb +0 -55
  39. data/lib/user/content/forms.rb +4 -4
  40. data/lib/user/content/messages.rb +4 -4
  41. data/lib/user/content/stories.rb +8 -5
  42. data/lib/user/content/story_templates.rb +2 -2
  43. data/lib/user/crm/contacts.rb +0 -13
  44. data/lib/user/crm/workflow_steps.rb +4 -4
  45. data/lib/user/crm/workflows.rb +4 -4
  46. data/lib/user/ecommerce/ecommerce.rb +2 -0
  47. data/lib/user/ecommerce/locations.rb +2 -2
  48. data/lib/user/ecommerce/order_items_groups.rb +2 -2
  49. data/lib/user/ecommerce/skus.rb +2 -2
  50. data/lib/user/ecommerce/vouchers.rb +90 -0
  51. metadata +21 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7a43644b57a99c773dba9934104719cad9bd4c4605f1cc801783a7cf7dd1d8dc
4
- data.tar.gz: d97a25f0d2414ef4e97fc9d5b516b5d9773bfd4a5867cf92e4940d51c722c11a
3
+ metadata.gz: 15db76401dfa74546139b780363014a6502c2d10409f5ba7199d27c16b746d64
4
+ data.tar.gz: 52ad33837204580f17ade75c3777dea6aea97903a508968a8bff0e5cb52f098e
5
5
  SHA512:
6
- metadata.gz: fb667cc4ec647580977fa48e0e164dc96aaa389c27f9ab258772632fa85888ddddc1d93c63c1c7cc9bd51682879d86cb599898d2fad8471dac0ee244779291e8
7
- data.tar.gz: 405f7d336e2b135fba5d07a5195d5e2a82bd4976d55d59110dd9bb71026aa6236dff49ec8c25e02086f494011dfef8f0f31dc1c25b4676589665ff3dd53bad0a
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.
@@ -3,10 +3,12 @@
3
3
  require_relative './order_items_groups'
4
4
  require_relative './order_items'
5
5
  require_relative './orders'
6
+ require_relative './vouchers'
6
7
 
7
- module Ecommerce
8
- include OrderItemsGroups
9
- include OrderItems
10
- include Orders
8
+ module ContactEcommerce
9
+ include ContactOrderItemsGroups
10
+ include ContactOrderItems
11
+ include ContactOrders
12
+ include ContactVouchers
11
13
 
12
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.
@@ -108,7 +108,6 @@ module Orders
108
108
  #
109
109
  # ==== Example
110
110
  # @data = @mints_contact.get_my_shopping_cart
111
- # FIXME: This method returns a nil data.
112
111
  def get_my_shopping_cart(options = nil)
113
112
  @client.raw('get', '/ecommerce/my-shopping-cart', options, nil, @contact_v1_url)
114
113
  end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ContactVouchers
4
+ ##
5
+ # === Apply voucher.Contact
6
+ # Apply voucher code to the existing order, only applies to sale orders.
7
+ #
8
+ # ==== Parameters
9
+ # order_id:: (Integer) -- Order id.
10
+ # data:: (Hash) -- Data to be submitted.
11
+ #
12
+ # ==== Example
13
+ # data = { description: 'This is the transaction description', voucher_code: 'XAZWQ12MP' }
14
+ # @data = @mints_contact.apply_voucher(1, data)
15
+ def apply_voucher(order_id, data)
16
+ @client.raw('post', "/ecommerce/orders/#{order_id}/voucher", nil, data_transform(data))
17
+ end
18
+ end
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)
data/lib/errors.rb CHANGED
@@ -11,7 +11,7 @@ module Mints
11
11
  '401' => 'AccessDeniedException',
12
12
  '404' => 'ResourceNotFoundException',
13
13
  '422' => 'ValidationException',
14
- '405' => 'MethodNotAllowed',
14
+ '405' => 'MethodNotAllowedException',
15
15
  'default' => 'InternalServerException',
16
16
  }
17
17
 
@@ -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
@@ -43,9 +43,9 @@ module ContactAuthHelper
43
43
  def mints_contact_logout
44
44
  # Logout from mints
45
45
  @mints_contact.logout
46
- # Delete local cookie
46
+ # Delete session token and keep the contact token id
47
+ # Never delete the mints_contact_id cookie to avoid the creation of ghosts
47
48
  cookies.delete(:mints_contact_session_token)
48
- cookies.delete(:mints_contact_id)
49
49
  @contact_token = nil
50
50
  end
51
51
 
@@ -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}"
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PublicAttributes
4
+ ##
5
+ # === Get Attributes.
6
+ # Get a collection of attributes.
7
+ #
8
+ # ==== Example
9
+ # @data = @mints_pub.get_attributes
10
+ def get_attributes
11
+ @client.raw('get', '/config/attributes')
12
+ end
13
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ ### V1/CONFIG ###
4
+
5
+ require_relative './attributes'
6
+ require_relative './public_folders'
7
+ require_relative './tags'
8
+ require_relative './taxonomies'
9
+
10
+ module PublicConfig
11
+ include PublicAttributes
12
+ include PublicFolders
13
+ include PublicTags
14
+ include PublicTaxonomies
15
+ end
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PublicFolders
4
+ ##
5
+ # === Get Public Folders.
6
+ # Get a collection of public folders.
7
+ #
8
+ # ==== Parameters
9
+ # options:: (Hash) -- List of {Single Resource Options}[#class-Mints::Pub-label-Single+resource+options] shown above can be used as parameter.
10
+ #
11
+ # ==== First Example
12
+ # options = {
13
+ # object_type: "products"
14
+ # }
15
+ # @data = @mints_pub.get_public_folders(options)
16
+ #
17
+ # ==== Second Example
18
+ # options = {
19
+ # object_type: "products",
20
+ # fields: "id",
21
+ # sort: "-id"
22
+ # }
23
+ # @data = @mints_pub.get_public_folders(options)
24
+ def get_public_folders(options = nil)
25
+ @client.raw('get', '/config/public-folders', options)
26
+ end
27
+
28
+ ##
29
+ # === Get Public Folder.
30
+ # Get a public folder info.
31
+ #
32
+ # ==== Parameters
33
+ # slug:: (String) -- It's the string identifier generated by Mints.
34
+ # options:: (Hash) -- List of {Single Resource Options}[#class-Mints::Pub-label-Single+resource+options] shown above can be used as parameter.
35
+ #
36
+ # ==== First Example
37
+ # options = {
38
+ # object_type: "products"
39
+ # }
40
+ # @data = @mints_pub.get_public_folder('yellow', options)
41
+ #
42
+ # ==== Second Example
43
+ # options = {
44
+ # object_type: "products",
45
+ # fields: 'id, title'
46
+ # }
47
+ # @data = @mints_pub.get_public_folder('yellow', options)
48
+ def get_public_folder(slug, options)
49
+ @client.raw('get', "/config/public-folders/#{slug}", options)
50
+ end
51
+ end