mints 0.0.33 → 0.0.35
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 +31 -1
- data/lib/client.rb +61 -5
- data/lib/contact.rb +11 -2
- data/lib/generators/mints_config.yml.erb +6 -0
- data/lib/mints/controllers/concerns/mints_clients.rb +26 -4
- data/lib/mints/controllers/concerns/read_config_file.rb +4 -4
- data/lib/pub/ecommerce/ecommerce.rb +2 -2
- data/lib/pub/ecommerce/{products.rb → product_versions.rb} +10 -10
- data/lib/pub.rb +11 -2
- data/lib/user/content/content.rb +2 -0
- data/lib/user/content/conversation_templates.rb +148 -0
- data/lib/user/content/conversations.rb +0 -31
- data/lib/user/ecommerce/ecommerce.rb +2 -0
- data/lib/user/ecommerce/locations.rb +2 -2
- data/lib/user/ecommerce/product_versions.rb +107 -0
- data/lib/user/ecommerce/products.rb +0 -16
- data/lib/user.rb +11 -2
- metadata +18 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9f15395fdd433a83877c1dc1c0bd51909e7898c5dbcd63e10b79edf3bcb94c9c
|
4
|
+
data.tar.gz: c6b8098b3b55b3bc481a8ce40be5a8c45999f3c64c27f5ecba8eacb207809488
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dbd80b3833430004a88b50067b765f2c41dcc053f2ce306a8788cb4a3b8b0929d091865f8d2e2ae6e15c959149ff7f2d2f9d0126b5424b0dfcac27041875f3d5
|
7
|
+
data.tar.gz: ff8a428b1d4cd73d94db4f1553add818fb837c4713fffe4be89452a30a930bc8c98443295205574e340db6bf8a521cd7cd664087f20506b8d557ddec5604f6e8
|
data/README.md
CHANGED
@@ -135,6 +135,14 @@ it to the groups array and set the cache time.
|
|
135
135
|
- urls:
|
136
136
|
- group_of_urls
|
137
137
|
time: time_that_will_be_applied_to_urls_in_seconds
|
138
|
+
sdk:
|
139
|
+
debug: false
|
140
|
+
# Timeout is specified in seconds
|
141
|
+
default_http_timeout: 30 # Allows setting a default timeout for all HTTP calls.
|
142
|
+
get_http_timeout: 30 # Allows setting a default timeout for all GET calls.
|
143
|
+
post_http_timeout: 30 # Allows setting a default timeout for all POST calls.
|
144
|
+
put_http_timeout: 30 # Allows setting a default timeout for all PUT calls.
|
145
|
+
delete_http_timeout: 30 # Allows setting a default timeout for all DELETE calls.
|
138
146
|
```
|
139
147
|
|
140
148
|
To enable sdk debugging you can change the variable debug.
|
@@ -156,6 +164,7 @@ functionality, we recommend the use of the template).
|
|
156
164
|
## Override default clients
|
157
165
|
|
158
166
|
If you want other clients for admin/base controller, you need to specify them with the "define_mints_clients" method
|
167
|
+
|
159
168
|
Example:
|
160
169
|
|
161
170
|
```ruby
|
@@ -168,6 +177,28 @@ class AdminController < Mints::AdminBaseController
|
|
168
177
|
end
|
169
178
|
```
|
170
179
|
|
180
|
+
## Override default timeouts
|
181
|
+
|
182
|
+
If you want specific timeouts per instance, you can define mints_sdk_timeouts_config
|
183
|
+
|
184
|
+
Example:
|
185
|
+
|
186
|
+
```ruby
|
187
|
+
# admin_controller.rb
|
188
|
+
|
189
|
+
class AdminController < Mints::AdminBaseController
|
190
|
+
def mints_sdk_timeouts_config
|
191
|
+
{
|
192
|
+
default: 30,
|
193
|
+
get: 50,
|
194
|
+
post: 40,
|
195
|
+
put: 30,
|
196
|
+
delete: 10
|
197
|
+
}
|
198
|
+
end
|
199
|
+
end
|
200
|
+
```
|
201
|
+
|
171
202
|
## Error catching
|
172
203
|
|
173
204
|
The SDK provides different errors that are identified according to the response provided by CXF,
|
@@ -244,7 +275,6 @@ The current errors are:
|
|
244
275
|
- Mints::Pub::Ecommerce
|
245
276
|
- [Mints::Pub::Ecommerce::Locations](doc/pub/ecommerce/locations.md)
|
246
277
|
- [Mints::Pub::Ecommerce::Orders](doc/pub/ecommerce/orders.md)
|
247
|
-
- [Mints::Pub::Ecommerce::Products](doc/pub/ecommerce/products.md)
|
248
278
|
|
249
279
|
</details>
|
250
280
|
|
data/lib/client.rb
CHANGED
@@ -4,9 +4,11 @@ require 'httparty'
|
|
4
4
|
require 'json'
|
5
5
|
require 'addressable'
|
6
6
|
require 'redis'
|
7
|
+
require_relative './mints/controllers/concerns/read_config_file'
|
7
8
|
|
8
9
|
module Mints
|
9
10
|
class Client
|
11
|
+
extend ActiveSupport::Concern
|
10
12
|
|
11
13
|
attr_reader :host
|
12
14
|
attr_reader :api_key
|
@@ -15,7 +17,17 @@ module Mints
|
|
15
17
|
attr_accessor :session_token
|
16
18
|
attr_accessor :contact_token_id
|
17
19
|
|
18
|
-
def initialize(
|
20
|
+
def initialize(
|
21
|
+
host,
|
22
|
+
api_key,
|
23
|
+
scope = nil,
|
24
|
+
session_token = nil,
|
25
|
+
contact_token_id = nil,
|
26
|
+
visit_id = nil,
|
27
|
+
debug = false,
|
28
|
+
timeouts = {}
|
29
|
+
)
|
30
|
+
|
19
31
|
@host = host
|
20
32
|
@api_key = api_key
|
21
33
|
@session_token = session_token
|
@@ -23,6 +35,14 @@ module Mints
|
|
23
35
|
@visit_id = visit_id
|
24
36
|
@debug = debug
|
25
37
|
|
38
|
+
config = read_config_file('sdk') || {}
|
39
|
+
|
40
|
+
@default_http_timeout = timeouts.fetch(:default, config.fetch('default_http_timeout', 30))
|
41
|
+
@get_http_timeout = timeouts.fetch(:get, config.fetch('get_http_timeout', @default_http_timeout))
|
42
|
+
@post_http_timeout = timeouts.fetch(:post, config.fetch('post_http_timeout', @default_http_timeout))
|
43
|
+
@put_http_timeout = timeouts.fetch(:put, config.fetch('put_http_timeout', @default_http_timeout))
|
44
|
+
@delete_http_timeout = timeouts.fetch(:delete, config.fetch('delete_http_timeout', @default_http_timeout))
|
45
|
+
|
26
46
|
self.set_scope(scope)
|
27
47
|
end
|
28
48
|
|
@@ -222,22 +242,22 @@ module Mints
|
|
222
242
|
##### HTTP CLIENTS ######
|
223
243
|
# Simple HTTP GET
|
224
244
|
def http_get(url, headers = nil)
|
225
|
-
HTTParty.get(url, headers: headers)
|
245
|
+
HTTParty.get(url, headers: headers, timeout: @get_http_timeout)
|
226
246
|
end
|
227
247
|
|
228
248
|
# Simple HTTP POST
|
229
249
|
def http_post(url, headers = nil, data = nil)
|
230
|
-
HTTParty.post(url, headers: headers, body: data)
|
250
|
+
HTTParty.post(url, headers: headers, body: data, timeout: @post_http_timeout)
|
231
251
|
end
|
232
252
|
|
233
253
|
# Simple HTTP PUT
|
234
254
|
def http_put(url, headers = nil, data = nil)
|
235
|
-
HTTParty.put(url, headers: headers, body: data)
|
255
|
+
HTTParty.put(url, headers: headers, body: data, timeout: @put_http_timeout)
|
236
256
|
end
|
237
257
|
|
238
258
|
# Simple HTTP DELETE
|
239
259
|
def http_delete(url, headers = nil, data = nil)
|
240
|
-
HTTParty.delete(url, headers: headers, body: data)
|
260
|
+
HTTParty.delete(url, headers: headers, body: data, timeout: @delete_http_timeout)
|
241
261
|
end
|
242
262
|
|
243
263
|
# Start contact context
|
@@ -332,5 +352,41 @@ module Mints
|
|
332
352
|
end
|
333
353
|
end
|
334
354
|
|
355
|
+
# Timeouts methods
|
356
|
+
|
357
|
+
def timeout
|
358
|
+
{
|
359
|
+
default: @default_http_timeout,
|
360
|
+
get: @get_http_timeout,
|
361
|
+
post: @post_http_timeout,
|
362
|
+
put: @put_http_timeout,
|
363
|
+
delete: @delete_http_timeout
|
364
|
+
}
|
365
|
+
end
|
366
|
+
|
367
|
+
def timeout=(t)
|
368
|
+
if t.kind_of? Hash
|
369
|
+
t = t.with_indifferent_access
|
370
|
+
@default_http_timeout = t[:default] if t[:default]
|
371
|
+
@get_http_timeout = t[:get] if t[:get]
|
372
|
+
@post_http_timeout = t[:post] if t[:post]
|
373
|
+
@put_http_timeout = t[:put] if t[:put]
|
374
|
+
@delete_http_timeout = t[:delete] if t[:delete]
|
375
|
+
elsif t.kind_of? Integer
|
376
|
+
@default_http_timeout = t
|
377
|
+
@get_http_timeout = t
|
378
|
+
@post_http_timeout = t
|
379
|
+
@put_http_timeout = t
|
380
|
+
@delete_http_timeout = t
|
381
|
+
end
|
382
|
+
end
|
383
|
+
|
384
|
+
def read_config_file(config_key = nil)
|
385
|
+
template = ERB.new File.new("#{Rails.root}/mints_config.yml.erb").read
|
386
|
+
config = YAML.safe_load template.result(binding)
|
387
|
+
config_key ? config[config_key] : config
|
388
|
+
rescue StandardError
|
389
|
+
nil
|
390
|
+
end
|
335
391
|
end
|
336
392
|
end
|
data/lib/contact.rb
CHANGED
@@ -30,9 +30,18 @@ module Mints
|
|
30
30
|
#
|
31
31
|
# ==== Return
|
32
32
|
# Returns a Contact object
|
33
|
-
def initialize(host, api_key, session_token = nil, contact_token_id = nil, debug = false)
|
33
|
+
def initialize(host, api_key, session_token = nil, contact_token_id = nil, debug = false, timeouts = {})
|
34
34
|
@contact_v1_url = '/api/contact/v1'
|
35
|
-
@client = Mints::Client.new(
|
35
|
+
@client = Mints::Client.new(
|
36
|
+
host,
|
37
|
+
api_key,
|
38
|
+
'contact',
|
39
|
+
session_token,
|
40
|
+
contact_token_id,
|
41
|
+
nil,
|
42
|
+
debug,
|
43
|
+
timeouts
|
44
|
+
)
|
36
45
|
end
|
37
46
|
|
38
47
|
### V1/CONTACTS ###
|
@@ -14,6 +14,12 @@ redis_cache:
|
|
14
14
|
time: time_that_will_be_applied_to_urls_in_seconds
|
15
15
|
sdk:
|
16
16
|
debug: false
|
17
|
+
# Timeout is specified in seconds
|
18
|
+
default_http_timeout: 30 # Allows setting a default timeout for all HTTP calls.
|
19
|
+
get_http_timeout: 30 # Allows setting a default timeout for all GET calls.
|
20
|
+
post_http_timeout: 30 # Allows setting a default timeout for all POST calls.
|
21
|
+
put_http_timeout: 30 # Allows setting a default timeout for all PUT calls.
|
22
|
+
delete_http_timeout: 30 # Allows setting a default timeout for all DELETE calls.
|
17
23
|
cookies_iframe:
|
18
24
|
activated: boolean_value_to_enable_and_disable_cookies_iframe
|
19
25
|
expire_time: expire_time_of_cookies_iframe_in_hours
|
@@ -46,7 +46,13 @@ module MintsClients
|
|
46
46
|
visit_id = cookies[:mints_visit_id]
|
47
47
|
contact_token_id = cookies[:mints_contact_id]
|
48
48
|
|
49
|
-
@mints_pub = Mints::Pub.new(
|
49
|
+
@mints_pub = Mints::Pub.new(
|
50
|
+
@host,
|
51
|
+
@api_key,
|
52
|
+
contact_token_id,
|
53
|
+
visit_id,
|
54
|
+
@debug
|
55
|
+
)
|
50
56
|
end
|
51
57
|
|
52
58
|
##
|
@@ -56,7 +62,13 @@ module MintsClients
|
|
56
62
|
# Initialize mints contact client
|
57
63
|
contact_session_token = cookies[:mints_contact_session_token]
|
58
64
|
contact_token_id = cookies[:mints_contact_id]
|
59
|
-
@mints_contact = Mints::Contact.new(
|
65
|
+
@mints_contact = Mints::Contact.new(
|
66
|
+
@host,
|
67
|
+
@api_key,
|
68
|
+
contact_session_token,
|
69
|
+
contact_token_id,
|
70
|
+
@debug
|
71
|
+
)
|
60
72
|
end
|
61
73
|
|
62
74
|
##
|
@@ -65,7 +77,12 @@ module MintsClients
|
|
65
77
|
def set_mints_user_client
|
66
78
|
# Initialize mints user client
|
67
79
|
user_session_token = cookies[:mints_user_session_token]
|
68
|
-
@mints_user = Mints::User.new(
|
80
|
+
@mints_user = Mints::User.new(
|
81
|
+
@host,
|
82
|
+
@api_key,
|
83
|
+
user_session_token,
|
84
|
+
@debug
|
85
|
+
)
|
69
86
|
end
|
70
87
|
|
71
88
|
##
|
@@ -73,6 +90,11 @@ module MintsClients
|
|
73
90
|
# Initialize the service account client
|
74
91
|
def set_mints_service_account_client
|
75
92
|
# Initialize service account client
|
76
|
-
@mints_service_account = Mints::User.new(
|
93
|
+
@mints_service_account = Mints::User.new(
|
94
|
+
@host,
|
95
|
+
@api_key,
|
96
|
+
@api_key,
|
97
|
+
@debug
|
98
|
+
)
|
77
99
|
end
|
78
100
|
end
|
@@ -9,12 +9,12 @@ module ReadConfigFile
|
|
9
9
|
|
10
10
|
def set_config_variables
|
11
11
|
if File.exists?("#{Rails.root}/mints_config.yml.erb")
|
12
|
-
|
13
12
|
template = ERB.new File.new("#{Rails.root}/mints_config.yml.erb").read
|
14
13
|
config = YAML.safe_load template.result(binding)
|
15
|
-
|
16
|
-
@
|
17
|
-
@
|
14
|
+
|
15
|
+
@host = config['mints']['host']
|
16
|
+
@api_key = config['mints']['api_key']
|
17
|
+
@debug = !!config['sdk']['debug']
|
18
18
|
@redis_config = config['redis_cache']
|
19
19
|
@use_cache = config['redis_cache']['use_cache']
|
20
20
|
|
@@ -3,12 +3,12 @@
|
|
3
3
|
### V1/ECOMMERCE ###
|
4
4
|
|
5
5
|
require_relative './locations'
|
6
|
-
require_relative './
|
6
|
+
require_relative './product_versions'
|
7
7
|
require_relative './orders'
|
8
8
|
|
9
9
|
module PublicEcommerce
|
10
10
|
include PublicLocations
|
11
|
-
include
|
11
|
+
include PublicProductVersions
|
12
12
|
include PublicOrders
|
13
13
|
|
14
14
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
module
|
3
|
+
module PublicProductVersions
|
4
4
|
##
|
5
5
|
# === Get Products.
|
6
6
|
# Get a collection of products.
|
@@ -10,17 +10,17 @@ module PublicProducts
|
|
10
10
|
# use_post:: (Boolean) -- Variable to determine if the request is by 'post' or 'get' functions.
|
11
11
|
#
|
12
12
|
# ==== First Example
|
13
|
-
# @data = @mints_pub.
|
13
|
+
# @data = @mints_pub.get_product_versions
|
14
14
|
#
|
15
15
|
# ==== Second Example
|
16
16
|
# options = { fields: "title" }
|
17
|
-
# @data = @mints_pub.
|
17
|
+
# @data = @mints_pub.get_product_versions(options)
|
18
18
|
#
|
19
19
|
# ==== Third Example
|
20
20
|
# options = { fields: "title" }
|
21
|
-
# @data = @mints_pub.
|
22
|
-
def
|
23
|
-
get_query_results('/ecommerce/
|
21
|
+
# @data = @mints_pub.get_product_versions(options, false)
|
22
|
+
def get_product_versions(options = nil, use_post = true)
|
23
|
+
get_query_results('/ecommerce/product-versions', options, use_post)
|
24
24
|
end
|
25
25
|
|
26
26
|
##
|
@@ -32,14 +32,14 @@ module PublicProducts
|
|
32
32
|
# options:: (Hash) -- List of {Single Resource Options}[#class-Mints::Pub-label-Single+resource+options] shown above can be used as parameter.
|
33
33
|
#
|
34
34
|
# ==== First Example
|
35
|
-
# @data = @mints_pub.
|
35
|
+
# @data = @mints_pub.get_product_version("product_slug")
|
36
36
|
#
|
37
37
|
# ==== Second Example
|
38
38
|
# options = {
|
39
39
|
# fields: 'id, slug'
|
40
40
|
# }
|
41
|
-
# @data = @mints_pub.
|
42
|
-
def
|
43
|
-
@client.raw('get', "/ecommerce/
|
41
|
+
# @data = @mints_pub.get_product_version("lego-set", options)
|
42
|
+
def get_product_version(slug, options = nil)
|
43
|
+
@client.raw('get', "/ecommerce/product-versions/#{slug}", options)
|
44
44
|
end
|
45
45
|
end
|
data/lib/pub.rb
CHANGED
@@ -81,8 +81,17 @@ module Mints
|
|
81
81
|
#
|
82
82
|
# ==== Return
|
83
83
|
# Returns a Client object.
|
84
|
-
def initialize(host, api_key, contact_token_id = nil, visit_id = nil, debug = false)
|
85
|
-
@client = Mints::Client.new(
|
84
|
+
def initialize(host, api_key, contact_token_id = nil, visit_id = nil, debug = false, timeouts = {})
|
85
|
+
@client = Mints::Client.new(
|
86
|
+
host,
|
87
|
+
api_key,
|
88
|
+
'public',
|
89
|
+
nil,
|
90
|
+
contact_token_id,
|
91
|
+
visit_id,
|
92
|
+
debug,
|
93
|
+
timeouts
|
94
|
+
)
|
86
95
|
end
|
87
96
|
|
88
97
|
##
|
data/lib/user/content/content.rb
CHANGED
@@ -4,6 +4,7 @@ require_relative './assets'
|
|
4
4
|
require_relative './content_instances'
|
5
5
|
require_relative './content_templates'
|
6
6
|
require_relative './conversations'
|
7
|
+
require_relative './conversation_templates'
|
7
8
|
require_relative './dam'
|
8
9
|
require_relative './forms'
|
9
10
|
require_relative './message_templates'
|
@@ -18,6 +19,7 @@ module Content
|
|
18
19
|
include ContentInstances
|
19
20
|
include ContentTemplates
|
20
21
|
include Conversations
|
22
|
+
include ConversationTemplates
|
21
23
|
include DAM
|
22
24
|
include Forms
|
23
25
|
include MessageTemplates
|
@@ -0,0 +1,148 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ConversationTemplates
|
4
|
+
##
|
5
|
+
# == Conversation templates
|
6
|
+
#
|
7
|
+
|
8
|
+
###
|
9
|
+
# === Get conversation templates.
|
10
|
+
# Get a collection of conversation templates.
|
11
|
+
#
|
12
|
+
# ==== Parameters
|
13
|
+
# options:: (Hash) -- List of Resource Collection Options shown above can be used as parameter.
|
14
|
+
#
|
15
|
+
# ==== First Example
|
16
|
+
# @data = @mints_user.get_conversations
|
17
|
+
#
|
18
|
+
# ==== Second Example
|
19
|
+
# options = { fields: 'title' }
|
20
|
+
# @data = @mints_user.get_conversation_templates(options)
|
21
|
+
def get_conversation_templates(options = nil)
|
22
|
+
@client.raw('get', '/content/conversation-templates', options)
|
23
|
+
end
|
24
|
+
|
25
|
+
# === Get conversation template.
|
26
|
+
# Get a conversation template info.
|
27
|
+
#
|
28
|
+
# ==== Parameters
|
29
|
+
# id:: (Integer) -- Conversation id.
|
30
|
+
# options:: (Hash) -- List of Resource Collection Options shown above can be used as parameter.
|
31
|
+
#
|
32
|
+
# ==== First Example
|
33
|
+
# @data = @mints_user.get_conversation_template(1)
|
34
|
+
#
|
35
|
+
# ==== Second Example
|
36
|
+
# options = { fields: 'title' }
|
37
|
+
# @data = @mints_user.get_conversation_template(1, options)
|
38
|
+
def get_conversation_template(id, options = nil)
|
39
|
+
@client.raw('get', "/content/conversation-templates/#{id}", options)
|
40
|
+
end
|
41
|
+
|
42
|
+
# === Create conversation template.
|
43
|
+
# Create a conversation template with data.
|
44
|
+
#
|
45
|
+
# ==== Parameters
|
46
|
+
# data:: (Hash) -- Data to be submitted.
|
47
|
+
#
|
48
|
+
# ==== Example
|
49
|
+
# data = {
|
50
|
+
# title: 'New Conversation Template',
|
51
|
+
# slug: 'new-conversation-template'
|
52
|
+
# }
|
53
|
+
# @data = @mints_user.create_conversation_template(data)
|
54
|
+
def create_conversation_template(data, options = nil)
|
55
|
+
@client.raw('post', '/content/conversation-templates', options, data_transform(data))
|
56
|
+
end
|
57
|
+
|
58
|
+
# === Update conversation template.
|
59
|
+
# Update a conversation template info.
|
60
|
+
#
|
61
|
+
# ==== Parameters
|
62
|
+
# id:: (Integer) -- Conversation template id.
|
63
|
+
# data:: (Hash) -- Data to be submitted.
|
64
|
+
#
|
65
|
+
# ==== Example
|
66
|
+
# data = {
|
67
|
+
# title: 'Conversation Template'
|
68
|
+
# slug: 'conversation-template'
|
69
|
+
# }
|
70
|
+
# @data = @mints_user.update_conversation_template(13, data)
|
71
|
+
def update_conversation_template(id, data, options = nil)
|
72
|
+
@client.raw('put', "/content/conversation-templates/#{id}", options, data_transform(data))
|
73
|
+
end
|
74
|
+
|
75
|
+
# === Delete conversation template.
|
76
|
+
# Delete a conversation template.
|
77
|
+
#
|
78
|
+
# ==== Parameters
|
79
|
+
# id:: (Integer) -- Conversation template id.
|
80
|
+
#
|
81
|
+
# ==== Example
|
82
|
+
# @data = @mints_user.delete_conversation_template(11)
|
83
|
+
def delete_conversation_template(id)
|
84
|
+
@client.raw('delete', "/content/conversation-templates/#{id}")
|
85
|
+
end
|
86
|
+
|
87
|
+
# === Duplicate conversation template.
|
88
|
+
# Duplicate a conversation template.
|
89
|
+
#
|
90
|
+
# ==== Parameters
|
91
|
+
# id:: (Integer) -- Conversation template id.
|
92
|
+
# data:: (Hash) -- Data to be submitted.
|
93
|
+
#
|
94
|
+
# ==== Example
|
95
|
+
# data = {
|
96
|
+
# title: 'Duplicated conversation template'
|
97
|
+
# }
|
98
|
+
# @data = @mints_user.duplicate_conversation_template(13, data)
|
99
|
+
def duplicate_conversation_template(id, data)
|
100
|
+
@client.raw('put', "/content/conversation-templates/#{id}/duplicate", nil, data_transform(data))
|
101
|
+
end
|
102
|
+
|
103
|
+
# === Update activation words.
|
104
|
+
# Update activation words in a conversation template.
|
105
|
+
#
|
106
|
+
# ==== Parameters
|
107
|
+
# conversation_template_id:: (Integer) -- Conversation template id.
|
108
|
+
# data:: (Hash) -- Data to be submitted.
|
109
|
+
#
|
110
|
+
# ==== Example
|
111
|
+
# data = {
|
112
|
+
# activationWords: %w[ hello world ],
|
113
|
+
# formId: 1
|
114
|
+
# }
|
115
|
+
# @data = @mints_user.attach_user_in_conversation(13, data)
|
116
|
+
def update_activation_words(conversation_template_id, data)
|
117
|
+
url = "/content/conversation-templates/#{conversation_template_id}/activation-words"
|
118
|
+
@client.raw('post', url, nil, data_transform(data))
|
119
|
+
end
|
120
|
+
|
121
|
+
# === Attach form in conversation template.
|
122
|
+
# Attach a form in the conversation template.
|
123
|
+
#
|
124
|
+
# ==== Parameters
|
125
|
+
# id:: (Integer) -- Conversation template id.
|
126
|
+
# data:: (Hash) -- Data to be submitted.
|
127
|
+
#
|
128
|
+
# ==== Example
|
129
|
+
# data = {
|
130
|
+
# form_id: 2
|
131
|
+
# }
|
132
|
+
# @data = @mints_user.attach_form_in_conversation_template(13, data)
|
133
|
+
def attach_form_in_conversation_template(id, data)
|
134
|
+
@client.raw('post', "/content/conversation-templates/#{id}/attach-form", nil, data_transform(data))
|
135
|
+
end
|
136
|
+
|
137
|
+
# === Detach form in conversation template.
|
138
|
+
# Detach a form in a conversation template.
|
139
|
+
#
|
140
|
+
# ==== Parameters
|
141
|
+
# id:: (Integer) -- Conversation template id.
|
142
|
+
#
|
143
|
+
# ==== Example
|
144
|
+
# @data = @mints_user.detach_form_in_conversation_template(conversation_id, form_id)
|
145
|
+
def detach_form_in_conversation_template(id, form_id)
|
146
|
+
@client.raw('delete', "/content/conversation-templates/#{id}/detach-form/#{form_id}")
|
147
|
+
end
|
148
|
+
end
|
@@ -174,35 +174,4 @@ module Conversations
|
|
174
174
|
@client.raw('post', "/content/conversations/#{id}/detach-contact", nil, data_transform(data))
|
175
175
|
end
|
176
176
|
|
177
|
-
# === Attach form in conversation.
|
178
|
-
# Attach a form in a conversation.
|
179
|
-
#
|
180
|
-
# ==== Parameters
|
181
|
-
# id:: (Integer) -- Conversation id.
|
182
|
-
# data:: (Hash) -- Data to be submitted.
|
183
|
-
#
|
184
|
-
# ==== Example
|
185
|
-
# data = {
|
186
|
-
# form_id: 2
|
187
|
-
# }
|
188
|
-
# @data = @mints_user.attach_form_in_conversation(1, data)
|
189
|
-
def attach_form_in_conversation(id, data)
|
190
|
-
@client.raw('post', "/content/conversations/#{id}/attach-form", nil, data_transform(data))
|
191
|
-
end
|
192
|
-
|
193
|
-
# === Detach form in conversation.
|
194
|
-
# Detach a form in a conversation.
|
195
|
-
#
|
196
|
-
# ==== Parameters
|
197
|
-
# id:: (Integer) -- Contact id.
|
198
|
-
# data:: (Hash) -- Data to be submitted.
|
199
|
-
#
|
200
|
-
# ==== Example
|
201
|
-
# data = {
|
202
|
-
# form_id: 2
|
203
|
-
# }
|
204
|
-
# @data = @mints_user.detach_form_in_conversation(1, data)
|
205
|
-
def detach_form_in_conversation(id, data)
|
206
|
-
@client.raw('post', "/content/conversations/#{id}/detach-form", nil, data_transform(data))
|
207
|
-
end
|
208
177
|
end
|
@@ -9,6 +9,7 @@ require_relative './price_lists'
|
|
9
9
|
require_relative './product_templates'
|
10
10
|
require_relative './product_variations'
|
11
11
|
require_relative './products'
|
12
|
+
require_relative './product_versions'
|
12
13
|
require_relative './skus'
|
13
14
|
require_relative './taxes'
|
14
15
|
require_relative './variant_options'
|
@@ -25,6 +26,7 @@ module Ecommerce
|
|
25
26
|
include ProductTemplates
|
26
27
|
include ProductVariations
|
27
28
|
include Products
|
29
|
+
include ProductVersions
|
28
30
|
include Skus
|
29
31
|
include Taxes
|
30
32
|
include VariantOptions
|
@@ -62,9 +62,9 @@ module Locations
|
|
62
62
|
# data = {
|
63
63
|
# title: 'New Location Modified'
|
64
64
|
# }
|
65
|
-
# @data = @mints_user.update_location(5, data
|
65
|
+
# @data = @mints_user.update_location(5, data)
|
66
66
|
def update_location(id, data, options = nil)
|
67
|
-
@client.raw('put', "/ecommerce/locations/#{id}", options, data)
|
67
|
+
@client.raw('put', "/ecommerce/locations/#{id}", options, data_transform(data))
|
68
68
|
end
|
69
69
|
|
70
70
|
# === Delete location.
|
@@ -0,0 +1,107 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ProductVersions
|
4
|
+
##
|
5
|
+
# === Get Product versions.
|
6
|
+
# Get a collection of product versions.
|
7
|
+
#
|
8
|
+
# ==== Parameters
|
9
|
+
# options:: (Hash) -- List of {Resource collection Options}[#class-Mints::Pub-label-Resource+collections+options+] shown above can be used as parameter.
|
10
|
+
# use_post:: (Boolean) -- Variable to determine if the request is by 'post' or 'get' functions.
|
11
|
+
#
|
12
|
+
# ==== First Example
|
13
|
+
# @data = @mints_user.get_product_versions
|
14
|
+
#
|
15
|
+
# ==== Second Example
|
16
|
+
# options = { fields: "title" }
|
17
|
+
# @data = @mints_user.get_product_versions(options)
|
18
|
+
#
|
19
|
+
# ==== Third Example
|
20
|
+
# options = { fields: "title" }
|
21
|
+
# @data = @mints_user.get_product_versions(options, false)
|
22
|
+
def get_product_versions(options = nil, use_post = true)
|
23
|
+
get_query_results('/ecommerce/product-versions', options, use_post)
|
24
|
+
end
|
25
|
+
|
26
|
+
##
|
27
|
+
# === Get Product version.
|
28
|
+
# Get a single product version.
|
29
|
+
#
|
30
|
+
# ==== Parameters
|
31
|
+
# slug:: (String) -- It's the string identifier generated by Mints.
|
32
|
+
# options:: (Hash) -- List of {Single Resource Options}[#class-Mints::Pub-label-Single+resource+options] shown above can be used as parameter.
|
33
|
+
#
|
34
|
+
# ==== First Example
|
35
|
+
# @data = @mints_user.get_product_version("product_slug")
|
36
|
+
#
|
37
|
+
# ==== Second Example
|
38
|
+
# options = {
|
39
|
+
# fields: 'id, slug'
|
40
|
+
# }
|
41
|
+
# @data = @mints_user.get_product_version("lego-set", options)
|
42
|
+
def get_product_version(slug, options = nil)
|
43
|
+
@client.raw('get', "/ecommerce/product-versions/#{slug}", options)
|
44
|
+
end
|
45
|
+
|
46
|
+
# === Create product version.
|
47
|
+
# Create a product version with data.
|
48
|
+
#
|
49
|
+
# ==== Parameters
|
50
|
+
# data:: (Hash) -- Data to be submitted.
|
51
|
+
#
|
52
|
+
# ==== Example
|
53
|
+
# data = {
|
54
|
+
# title: 'New Product Version',
|
55
|
+
# slug: 'new-product-version',
|
56
|
+
# product_id: 1
|
57
|
+
# }
|
58
|
+
# @data = @mints_user.create_product_version(data)
|
59
|
+
def create_product_version(data, options = nil)
|
60
|
+
@client.raw('post', '/ecommerce/product-versions', options, data_transform(data))
|
61
|
+
end
|
62
|
+
|
63
|
+
# === Update product version.
|
64
|
+
# Update a product version info.
|
65
|
+
#
|
66
|
+
# ==== Parameters
|
67
|
+
# id:: (Integer) -- Product version id.
|
68
|
+
# data:: (Hash) -- Data to be submitted.
|
69
|
+
#
|
70
|
+
# ==== Example
|
71
|
+
# data = {
|
72
|
+
# title: 'New Product Version Modified',
|
73
|
+
# slug: 'new-product-version',
|
74
|
+
# product_id: 1
|
75
|
+
# }
|
76
|
+
# @data = @mints_user.update_product_version(9, data)
|
77
|
+
def update_product_version(id, data, options = nil)
|
78
|
+
@client.raw('put', "/ecommerce/product-versions/#{id}", options, data_transform(data))
|
79
|
+
end
|
80
|
+
|
81
|
+
# === Delete product version.
|
82
|
+
# Delete a product version.
|
83
|
+
#
|
84
|
+
# ==== Parameters
|
85
|
+
# id:: (Integer) -- Product version id.
|
86
|
+
#
|
87
|
+
def delete_product_version(id)
|
88
|
+
@client.raw('delete', "/ecommerce/product-versions/#{id}")
|
89
|
+
end
|
90
|
+
|
91
|
+
# === Publish product version.
|
92
|
+
# Publish a product version.
|
93
|
+
#
|
94
|
+
# ==== Parameters
|
95
|
+
# id:: (Integer) -- Product version id.
|
96
|
+
# data:: (Hash) -- Data to be submitted.
|
97
|
+
#
|
98
|
+
# ==== Example
|
99
|
+
# data = {
|
100
|
+
# title: 'New Publish'
|
101
|
+
# }
|
102
|
+
# @data = @mints_user.publish_product_version(2, data)
|
103
|
+
def publish_product_version(id, data)
|
104
|
+
@client.raw('put', "/ecommerce/product-versions/#{id}/publish", nil, data_transform(data))
|
105
|
+
end
|
106
|
+
|
107
|
+
end
|
@@ -36,22 +36,6 @@ module Products
|
|
36
36
|
@client.raw('delete', "/ecommerce/products/#{id}")
|
37
37
|
end
|
38
38
|
|
39
|
-
# === Publish product.
|
40
|
-
# Publish a product.
|
41
|
-
#
|
42
|
-
# ==== Parameters
|
43
|
-
# id:: (Integer) -- Product id.
|
44
|
-
# data:: (Hash) -- Data to be submitted.
|
45
|
-
#
|
46
|
-
# ==== Example
|
47
|
-
# data = {
|
48
|
-
# title: 'New Publish'
|
49
|
-
# }
|
50
|
-
# @data = @mints_user.publish_product(2, data)
|
51
|
-
def publish_product(id, data)
|
52
|
-
@client.raw('put', "/ecommerce/products/#{id}/publish", nil, data_transform(data))
|
53
|
-
end
|
54
|
-
|
55
39
|
# === Schedule product.
|
56
40
|
# Schedule a product.
|
57
41
|
#
|
data/lib/user.rb
CHANGED
@@ -51,8 +51,17 @@ module Mints
|
|
51
51
|
|
52
52
|
attr_reader :client
|
53
53
|
|
54
|
-
def initialize(host, api_key, session_token = nil, debug = false)
|
55
|
-
@client = Mints::Client.new(
|
54
|
+
def initialize(host, api_key, session_token = nil, debug = false, timeouts = {})
|
55
|
+
@client = Mints::Client.new(
|
56
|
+
host,
|
57
|
+
api_key,
|
58
|
+
'user',
|
59
|
+
session_token,
|
60
|
+
nil,
|
61
|
+
nil,
|
62
|
+
debug,
|
63
|
+
timeouts
|
64
|
+
)
|
56
65
|
end
|
57
66
|
|
58
67
|
def login(email, password)
|
metadata
CHANGED
@@ -1,33 +1,33 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mints
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.35
|
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-
|
11
|
+
date: 2023-10-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 2.7.0
|
20
|
-
- - "
|
20
|
+
- - "~>"
|
21
21
|
- !ruby/object:Gem::Version
|
22
22
|
version: 2.7.0
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
|
-
- - "
|
27
|
+
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: 2.7.0
|
30
|
-
- - "
|
30
|
+
- - "~>"
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: 2.7.0
|
33
33
|
- !ruby/object:Gem::Dependency
|
@@ -68,40 +68,40 @@ dependencies:
|
|
68
68
|
name: rails-reverse-proxy
|
69
69
|
requirement: !ruby/object:Gem::Requirement
|
70
70
|
requirements:
|
71
|
-
- - "
|
71
|
+
- - ">="
|
72
72
|
- !ruby/object:Gem::Version
|
73
73
|
version: 0.9.1
|
74
|
-
- - "
|
74
|
+
- - "~>"
|
75
75
|
- !ruby/object:Gem::Version
|
76
76
|
version: 0.9.1
|
77
77
|
type: :runtime
|
78
78
|
prerelease: false
|
79
79
|
version_requirements: !ruby/object:Gem::Requirement
|
80
80
|
requirements:
|
81
|
-
- - "
|
81
|
+
- - ">="
|
82
82
|
- !ruby/object:Gem::Version
|
83
83
|
version: 0.9.1
|
84
|
-
- - "
|
84
|
+
- - "~>"
|
85
85
|
- !ruby/object:Gem::Version
|
86
86
|
version: 0.9.1
|
87
87
|
- !ruby/object:Gem::Dependency
|
88
88
|
name: redis
|
89
89
|
requirement: !ruby/object:Gem::Requirement
|
90
90
|
requirements:
|
91
|
-
- - "
|
91
|
+
- - ">="
|
92
92
|
- !ruby/object:Gem::Version
|
93
93
|
version: 4.2.2
|
94
|
-
- - "
|
94
|
+
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: 4.2.2
|
97
97
|
type: :runtime
|
98
98
|
prerelease: false
|
99
99
|
version_requirements: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- - "
|
101
|
+
- - ">="
|
102
102
|
- !ruby/object:Gem::Version
|
103
103
|
version: 4.2.2
|
104
|
-
- - "
|
104
|
+
- - "~>"
|
105
105
|
- !ruby/object:Gem::Version
|
106
106
|
version: 4.2.2
|
107
107
|
- !ruby/object:Gem::Dependency
|
@@ -177,7 +177,7 @@ files:
|
|
177
177
|
- lib/pub/ecommerce/ecommerce.rb
|
178
178
|
- lib/pub/ecommerce/locations.rb
|
179
179
|
- lib/pub/ecommerce/orders.rb
|
180
|
-
- lib/pub/ecommerce/
|
180
|
+
- lib/pub/ecommerce/product_versions.rb
|
181
181
|
- lib/user.rb
|
182
182
|
- lib/user/config/api_keys.rb
|
183
183
|
- lib/user/config/appointments.rb
|
@@ -199,6 +199,7 @@ files:
|
|
199
199
|
- lib/user/content/content.rb
|
200
200
|
- lib/user/content/content_instances.rb
|
201
201
|
- lib/user/content/content_templates.rb
|
202
|
+
- lib/user/content/conversation_templates.rb
|
202
203
|
- lib/user/content/conversations.rb
|
203
204
|
- lib/user/content/dam.rb
|
204
205
|
- lib/user/content/forms.rb
|
@@ -227,6 +228,7 @@ files:
|
|
227
228
|
- lib/user/ecommerce/price_lists.rb
|
228
229
|
- lib/user/ecommerce/product_templates.rb
|
229
230
|
- lib/user/ecommerce/product_variations.rb
|
231
|
+
- lib/user/ecommerce/product_versions.rb
|
230
232
|
- lib/user/ecommerce/products.rb
|
231
233
|
- lib/user/ecommerce/skus.rb
|
232
234
|
- lib/user/ecommerce/taxes.rb
|
@@ -258,7 +260,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
258
260
|
- !ruby/object:Gem::Version
|
259
261
|
version: '0'
|
260
262
|
requirements: []
|
261
|
-
rubygems_version: 3.1
|
263
|
+
rubygems_version: 3.0.3.1
|
262
264
|
signing_key:
|
263
265
|
specification_version: 4
|
264
266
|
summary: MINTS gem allows to connect your Rails App to MINTS.CLOUD
|