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.
- checksums.yaml +4 -4
- data/README.md +290 -32
- data/lib/contact/config/appointments.rb +1 -1
- data/lib/contact/config/config.rb +2 -2
- data/lib/contact/content/content.rb +2 -2
- data/lib/contact/content/conversations.rb +2 -2
- data/lib/contact/ecommerce/ecommerce.rb +6 -4
- data/lib/contact/ecommerce/order_items.rb +1 -1
- data/lib/contact/ecommerce/order_items_groups.rb +1 -1
- data/lib/contact/ecommerce/orders.rb +1 -2
- data/lib/contact/ecommerce/vouchers.rb +18 -0
- data/lib/contact.rb +9 -3
- data/lib/errors.rb +1 -1
- data/lib/mints/controllers/concerns/mints_clients.rb +3 -1
- data/lib/mints/helpers/contact_auth_helper.rb +2 -2
- data/lib/mints/helpers/proxy_controllers_methods.rb +1 -1
- 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 +6 -427
- data/lib/user/config/config.rb +1 -1
- data/lib/user/config/public_folders.rb +1 -1
- data/lib/user/config/users.rb +4 -4
- data/lib/user/content/content.rb +0 -55
- data/lib/user/content/forms.rb +4 -4
- data/lib/user/content/messages.rb +4 -4
- data/lib/user/content/stories.rb +8 -5
- data/lib/user/content/story_templates.rb +2 -2
- data/lib/user/crm/contacts.rb +0 -13
- data/lib/user/crm/workflow_steps.rb +4 -4
- data/lib/user/crm/workflows.rb +4 -4
- data/lib/user/ecommerce/ecommerce.rb +2 -0
- data/lib/user/ecommerce/locations.rb +2 -2
- data/lib/user/ecommerce/order_items_groups.rb +2 -2
- data/lib/user/ecommerce/skus.rb +2 -2
- data/lib/user/ecommerce/vouchers.rb +90 -0
- metadata +21 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 15db76401dfa74546139b780363014a6502c2d10409f5ba7199d27c16b746d64
|
4
|
+
data.tar.gz: 52ad33837204580f17ade75c3777dea6aea97903a508968a8bff0e5cb52f098e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
16
|
-
|
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
|
-
|
22
|
-
|
23
|
-
|
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
|
-
|
29
|
-
|
30
|
-
|
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
|
-
|
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
|
48
|
-
|
49
|
-
| @host
|
50
|
-
| @api_key
|
51
|
-
| @mints_pub
|
52
|
-
| @contact_token
|
53
|
-
| @visit_id
|
54
|
-
| @mints_contact
|
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
|
-
|
58
|
-
|
|
59
|
-
|
60
|
-
|
|
61
|
-
|
|
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
|
-
|
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
|
-
|
75
|
-
|
|
76
|
-
|
77
|
-
| @
|
78
|
-
| @
|
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
|
-
|
82
|
-
|
|
83
|
-
|
84
|
-
|
|
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
|
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
|
-
#
|
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
|
8
|
-
include
|
9
|
-
include
|
10
|
-
include
|
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
|
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
@@ -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
|
-
|
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
|
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
|
|
@@ -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
|