mints 0.0.19 → 0.0.22
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/Gemfile +2 -1
- data/lib/client.rb +394 -362
- data/lib/contact.rb +633 -73
- data/lib/generators/mints_files_generator.rb +6 -0
- data/lib/generators/mints_link.rb +61 -0
- data/lib/generators/short_link_controller.rb +41 -0
- data/lib/mints/controllers/base_api_controller.rb +2 -1
- data/lib/mints/controllers/base_controller.rb +7 -2
- data/lib/mints_helper.rb +2 -2
- data/lib/pub.rb +208 -77
- data/lib/user/content/assets.rb +196 -34
- data/lib/user/content/pages.rb +7 -7
- data/lib/user.rb +1 -1
- metadata +21 -26
@@ -7,6 +7,8 @@ class MintsFilesGenerator < Rails::Generators::Base
|
|
7
7
|
copy_file 'mints_contact_controller.rb', './app/controllers/api/v1/mints_contact_controller.rb'
|
8
8
|
copy_file 'mints_public_controller.rb', './app/controllers/api/v1/mints_public_controller.rb'
|
9
9
|
copy_file 'mints_assets_controller.rb', './app/controllers/mints_assets_controller.rb'
|
10
|
+
copy_file 'short_link_controller.rb', './app/controllers/short_link_controller.rb'
|
11
|
+
copy_file 'mints_link.rb', './config/initializers/mints_link.rb'
|
10
12
|
route <<-eos
|
11
13
|
# Mints auto-generated routes (proxy to send request to mints.cloud)
|
12
14
|
match '/public-assets/*path' => 'mints_assets#index', via: [:get, :post, :put, :patch, :delete]
|
@@ -18,6 +20,10 @@ class MintsFilesGenerator < Rails::Generators::Base
|
|
18
20
|
match '/*path' => 'mints_public#index', via: [:get, :post, :put, :patch, :delete]
|
19
21
|
end
|
20
22
|
end
|
23
|
+
# Mints short link
|
24
|
+
get '/sl/visits', to: 'short_link#visits'
|
25
|
+
post '/sl/generate', to: 'short_link#generate'
|
26
|
+
get '/sl/:code', to: 'short_link#redirect'
|
21
27
|
eos
|
22
28
|
end
|
23
29
|
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
class MintsLink
|
2
|
+
def initialize
|
3
|
+
@host = ENV['MONGO_HOST'] || '127.0.0.1'
|
4
|
+
@database = ENV['MONGO_DATABASE'] || 'mints'
|
5
|
+
@port = ENV['MONGO_PORT'] || '27017'
|
6
|
+
@client = Mongo::Client.new([ "#{@host}:#{@port}" ], :database => @database)
|
7
|
+
@short_links = @client[:short_links]
|
8
|
+
@sl_visits = @client[:sl_visits]
|
9
|
+
generate_indexes
|
10
|
+
end
|
11
|
+
|
12
|
+
def generate(url)
|
13
|
+
code = random_string.upcase
|
14
|
+
collection = @short_links
|
15
|
+
doc = {
|
16
|
+
url: url,
|
17
|
+
code: code
|
18
|
+
}
|
19
|
+
|
20
|
+
result = collection.insert_one(doc)
|
21
|
+
if result.n === 1
|
22
|
+
code
|
23
|
+
else
|
24
|
+
false
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def get_url(code)
|
29
|
+
collection = @short_links
|
30
|
+
record = collection.find( { 'code' => code } ).first
|
31
|
+
record["url"]
|
32
|
+
end
|
33
|
+
|
34
|
+
def visit(code, url, contact_id, user_agent, ip)
|
35
|
+
collection = @sl_visits
|
36
|
+
doc = {
|
37
|
+
code: code,
|
38
|
+
url: url,
|
39
|
+
contact_id: contact_id,
|
40
|
+
user_agent: user_agent,
|
41
|
+
ip: ip
|
42
|
+
}
|
43
|
+
result = collection.insert_one(doc)
|
44
|
+
result.n === 1
|
45
|
+
end
|
46
|
+
|
47
|
+
def get_visits(filter, page = 1, pageSize = 1000)
|
48
|
+
collection = @sl_visits
|
49
|
+
collection.find(filter).sort( {_id: 1}).skip(page * pageSize - pageSize).limit(pageSize)
|
50
|
+
end
|
51
|
+
|
52
|
+
private
|
53
|
+
def random_string(length = 6)
|
54
|
+
rand(32**length).to_s(32)
|
55
|
+
end
|
56
|
+
|
57
|
+
def generate_indexes
|
58
|
+
collection = @short_links
|
59
|
+
collection.indexes.create_one({ code: 1 }, {unique: true })
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
class ShortLinkController < Mints::BaseController
|
2
|
+
skip_before_action :verify_authenticity_token
|
3
|
+
def redirect
|
4
|
+
code = params[:code]
|
5
|
+
mints_link = MintsLink.new
|
6
|
+
url = mints_link.get_url(code)
|
7
|
+
contact_id = cookies[:mints_contact_id]
|
8
|
+
user_agent = request.user_agent
|
9
|
+
ip = request.remote_ip
|
10
|
+
mints_link.visit(code, url, contact_id, user_agent, ip)
|
11
|
+
redirect_to url
|
12
|
+
end
|
13
|
+
|
14
|
+
def generate
|
15
|
+
url = params[:url]
|
16
|
+
if url =~ /(https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|www\.[a-zA-Z0-9][a-zA-Z0-9-]+[a-zA-Z0-9]\.[^\s]{2,}|https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9]+\.[^\s]{2,}|www\.[a-zA-Z0-9]+\.[^\s]{2,})/
|
17
|
+
mints_link = MintsLink.new
|
18
|
+
code = mints_link.generate(url)
|
19
|
+
render json: { code: code }
|
20
|
+
else
|
21
|
+
render json: false
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def visits
|
26
|
+
code = params[:code]
|
27
|
+
contact_id = params[:contact_id]
|
28
|
+
page = params[:page] ? params[:page].to_i : 1
|
29
|
+
page_size = params[:page_size] ? params[:page_size].to_i : 1000
|
30
|
+
filter = {}
|
31
|
+
if code
|
32
|
+
filter['code'] = code
|
33
|
+
end
|
34
|
+
if contact_id
|
35
|
+
filter['contact_id'] = contact_id
|
36
|
+
end
|
37
|
+
mints_link = MintsLink.new
|
38
|
+
visits = mints_link.get_visits(filter, page, page_size)
|
39
|
+
render json: { data: {visits: visits }}
|
40
|
+
end
|
41
|
+
end
|
@@ -116,7 +116,8 @@ module Mints
|
|
116
116
|
def set_mints_pub_client
|
117
117
|
|
118
118
|
# Initialize mints pub client, credentials taken from mints_config.yml.erb file
|
119
|
-
@
|
119
|
+
@visit_id = cookies[:mints_visit_id] ? cookies[:mints_visit_id] : nil
|
120
|
+
@mints_pub = Mints::Pub.new(@host, @api_key, nil, @visit_id, @debug)
|
120
121
|
# Set contact token from cookie
|
121
122
|
@mints_pub.client.session_token = @contact_token
|
122
123
|
end
|
@@ -73,7 +73,7 @@ module Mints
|
|
73
73
|
puts "FULLPATH REQUEST: #{request.fullpath}"
|
74
74
|
puts "HEADERS REQUEST: #{request.headers}"
|
75
75
|
puts "IP REQUEST: #{request.ip}"
|
76
|
-
puts "REQUEST IP
|
76
|
+
puts "REQUEST IP ADDRESS: #{request['ip_address']}"
|
77
77
|
puts "REQUEST REMOTE IP: #{request['remote_ip']}"
|
78
78
|
end
|
79
79
|
response = @mints_pub.register_visit(request)
|
@@ -82,7 +82,11 @@ module Mints
|
|
82
82
|
end
|
83
83
|
@contact_token = response['contact_token'] ? response['contact_token'] : response['user_token']
|
84
84
|
@visit_id = response['visit_id']
|
85
|
+
if @debug
|
86
|
+
puts "VISIT ID: #{@visit_id}"
|
87
|
+
end
|
85
88
|
cookies.permanent[:mints_contact_id] = { value: @contact_token, secure: true, httponly: true }
|
89
|
+
cookies.permanent[:mints_visit_id] = { value: @visit_id, secure: true, httponly: true }
|
86
90
|
end
|
87
91
|
|
88
92
|
##
|
@@ -99,7 +103,8 @@ module Mints
|
|
99
103
|
raise 'MintsBadCredentialsError'
|
100
104
|
end
|
101
105
|
# Initialize mints pub client, credentials taken from mints_config.yml.erb file
|
102
|
-
@
|
106
|
+
@visit_id = cookies[:mints_visit_id] ? cookies[:mints_visit_id] : nil
|
107
|
+
@mints_pub = Mints::Pub.new(@host, @api_key, @contact_token, @visit_id, @debug)
|
103
108
|
# Set contact token from cookie
|
104
109
|
@mints_pub.client.session_token = @contact_token
|
105
110
|
end
|
data/lib/mints_helper.rb
CHANGED
@@ -10,9 +10,9 @@ module MintsHelper
|
|
10
10
|
#
|
11
11
|
def get_query_results(url, options = nil, use_post = true)
|
12
12
|
if use_post
|
13
|
-
|
13
|
+
return @client.raw("post", "#{url}/query", options)
|
14
14
|
else
|
15
|
-
|
15
|
+
return @client.raw("get", url, options)
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
data/lib/pub.rb
CHANGED
@@ -83,8 +83,8 @@ module Mints
|
|
83
83
|
#
|
84
84
|
# ==== Return
|
85
85
|
# Returns a Client object.
|
86
|
-
def initialize(host, api_key, contact_token_id = nil,
|
87
|
-
@client = Mints::Client.new(host, api_key, 'public', nil, contact_token_id, debug)
|
86
|
+
def initialize(host, api_key, contact_token_id = nil, visit_id = nil, debug = false)
|
87
|
+
@client = Mints::Client.new(host, api_key, 'public', nil, contact_token_id, visit_id, debug)
|
88
88
|
end
|
89
89
|
|
90
90
|
##
|
@@ -103,7 +103,7 @@ module Mints
|
|
103
103
|
# "user_agent" => "User Agent",
|
104
104
|
# "fullpath" => "https://fullpath/example"
|
105
105
|
# }
|
106
|
-
# @mints_pub.register_visit(request, request["remote_ip"], request["user_agent"], request["fullpath"])
|
106
|
+
# @data = @mints_pub.register_visit(request, request["remote_ip"], request["user_agent"], request["fullpath"])
|
107
107
|
def register_visit(request, ip = nil, user_agent = nil, url = nil)
|
108
108
|
data = {
|
109
109
|
ip_address: ip || request.remote_ip,
|
@@ -123,11 +123,13 @@ module Mints
|
|
123
123
|
# time:: (Integer) -- The visitor's browser user agent.
|
124
124
|
#
|
125
125
|
# ==== Example
|
126
|
-
# @mints_pub.register_visit_timer("60da2325d29acc7e55684472", 4)
|
126
|
+
# @data = @mints_pub.register_visit_timer("60da2325d29acc7e55684472", 4)
|
127
127
|
def register_visit_timer(visit, time)
|
128
128
|
return @client.raw("get", "/register-visit-timer?visit=#{visit}&time=#{time}")
|
129
129
|
end
|
130
130
|
|
131
|
+
### V1/CONTENT ###
|
132
|
+
|
131
133
|
##
|
132
134
|
# === Get Asset Info.
|
133
135
|
# Get a description of an Asset.
|
@@ -136,22 +138,35 @@ module Mints
|
|
136
138
|
# slug:: (String) -- It's the string identifier of the asset.
|
137
139
|
#
|
138
140
|
# ==== Example
|
139
|
-
# @mints_pub.get_asset_info("asset_slug")
|
141
|
+
# @data = @mints_pub.get_asset_info("asset_slug")
|
140
142
|
def get_asset_info(slug)
|
141
143
|
return @client.raw("get", "/content/asset-info/#{slug}")
|
142
144
|
end
|
143
|
-
|
145
|
+
|
144
146
|
##
|
145
147
|
# === Get Stories.
|
146
148
|
# Get a collection of stories.
|
147
149
|
#
|
148
150
|
# ==== Parameters
|
149
151
|
# options:: (Hash) -- List of {Resource collection Options}[#class-Mints::Pub-label-Resource+collections+options+] shown above can be used as parameter.
|
152
|
+
# use_post:: (Boolean) -- Variable to determine if the request is by 'post' or 'get' functions.
|
150
153
|
#
|
151
|
-
# ==== Example
|
152
|
-
# @mints_pub.get_stories
|
153
|
-
|
154
|
-
|
154
|
+
# ==== First Example
|
155
|
+
# @data = @mints_pub.get_stories
|
156
|
+
#
|
157
|
+
# ==== Second Example
|
158
|
+
# options = {
|
159
|
+
# "fields": "id, title"
|
160
|
+
# }
|
161
|
+
# @data = @mints_pub.get_stories(options)
|
162
|
+
#
|
163
|
+
# ==== Third Example
|
164
|
+
# options = {
|
165
|
+
# "fields": "id, title"
|
166
|
+
# }
|
167
|
+
# @data = @mints_pub.get_stories(options, false)
|
168
|
+
def get_stories(options = nil, use_post = true)
|
169
|
+
return get_query_results("/content/stories", options, use_post)
|
155
170
|
end
|
156
171
|
|
157
172
|
##
|
@@ -162,23 +177,23 @@ module Mints
|
|
162
177
|
# slug:: (String) -- It's the string identifier generated by Mints.
|
163
178
|
# options:: (Hash) -- List of {Single Resource Options}[#class-Mints::Pub-label-Single+resource+options] shown above can be used as parameter.
|
164
179
|
#
|
165
|
-
# ==== Example
|
166
|
-
# @mints_pub.get_story("story_slug")
|
180
|
+
# ==== First Example
|
181
|
+
# @data = @mints_pub.get_story("story_slug")
|
182
|
+
#
|
183
|
+
# ==== Second Example
|
184
|
+
# @data = @mints_pub.get_story("story_slug", options.to_json)
|
167
185
|
def get_story(slug, options = nil)
|
168
|
-
return @client.raw("get", "/content/stories/#{slug}", options)
|
186
|
+
return @client.raw("get", "/content/stories/#{slug}", options, nil, nil, nil, true)
|
169
187
|
end
|
170
188
|
|
171
189
|
##
|
172
190
|
# === Get Forms.
|
173
191
|
# Get a collection of forms.
|
174
192
|
#
|
175
|
-
# ==== Parameters
|
176
|
-
# options:: (Hash) -- List of {Resource collection Options}[#class-Mints::Pub-label-Resource+collections+options+] shown above can be used as parameter.
|
177
|
-
#
|
178
193
|
# ==== Example
|
179
|
-
# @mints_pub.get_forms
|
180
|
-
def get_forms
|
181
|
-
return @client.raw("get", "/content/forms"
|
194
|
+
# @data = @mints_pub.get_forms
|
195
|
+
def get_forms
|
196
|
+
return @client.raw("get", "/content/forms")
|
182
197
|
end
|
183
198
|
|
184
199
|
##
|
@@ -187,12 +202,11 @@ module Mints
|
|
187
202
|
#
|
188
203
|
# ==== Parameters
|
189
204
|
# slug:: (String) -- It's the string identifier generated by Mints.
|
190
|
-
# options:: (Hash) -- List of {Single Resource Options}[#class-Mints::Pub-label-Single+resource+options] shown above can be used as parameter.
|
191
205
|
#
|
192
206
|
# ==== Example
|
193
|
-
# @mints_pub.get_form("form_slug")
|
194
|
-
def get_form(slug
|
195
|
-
return @client.raw("get", "/content/forms/#{slug}",
|
207
|
+
# @data = @mints_pub.get_form("form_slug")
|
208
|
+
def get_form(slug)
|
209
|
+
return @client.raw("get", "/content/forms/#{slug}", nil, nil, nil, nil, true)
|
196
210
|
end
|
197
211
|
|
198
212
|
##
|
@@ -222,7 +236,20 @@ module Mints
|
|
222
236
|
#
|
223
237
|
# ==== Parameters
|
224
238
|
# options:: (Hash) -- List of {Resource collection Options}[#class-Mints::Pub-label-Resource+collections+options+] shown above can be used as parameter.
|
225
|
-
|
239
|
+
#
|
240
|
+
# ==== First Example
|
241
|
+
# options = {
|
242
|
+
# "template": "content_instance_template_slug"
|
243
|
+
# }
|
244
|
+
# @data = @mints_pub.get_content_instances(options)
|
245
|
+
#
|
246
|
+
# ==== Second Example
|
247
|
+
# options = {
|
248
|
+
# "template": "content_instance_template_slug",
|
249
|
+
# "sort": "-id"
|
250
|
+
# }
|
251
|
+
# @data = @mints_pub.get_content_instances(options)
|
252
|
+
def get_content_instances(options)
|
226
253
|
return @client.raw("get", "/content/content-instances", options)
|
227
254
|
end
|
228
255
|
|
@@ -232,23 +259,23 @@ module Mints
|
|
232
259
|
#
|
233
260
|
# ==== Parameters
|
234
261
|
# slug:: (String) -- It's the string identifier generated by Mints.
|
235
|
-
# options:: (Hash) -- List of {Single Resource Options}[#class-Mints::Pub-label-Single+resource+options] shown above can be used as parameter.
|
236
262
|
#
|
237
263
|
# ==== Example
|
238
|
-
# @mints_pub.get_content_instance("content_instance_slug")
|
239
|
-
def get_content_instance(slug
|
240
|
-
return @client.raw("get", "/content/content-instances/#{slug}"
|
264
|
+
# @data = @mints_pub.get_content_instance("content_instance_slug")
|
265
|
+
def get_content_instance(slug)
|
266
|
+
return @client.raw("get", "/content/content-instances/#{slug}")
|
241
267
|
end
|
242
268
|
|
269
|
+
#Note: This method is commented for future use
|
243
270
|
##
|
244
271
|
# === Get Content Pages.
|
245
272
|
# Get all content pages.
|
246
273
|
#
|
247
274
|
# ==== Parameters
|
248
275
|
# options:: (Hash) -- List of {Resource collection Options}[#class-Mints::Pub-label-Resource+collections+options+] shown above can be used as parameter.
|
249
|
-
def get_content_pages(options = nil)
|
250
|
-
return @client.raw("get", "/content/content-pages", options)
|
251
|
-
end
|
276
|
+
# def get_content_pages(options = nil)
|
277
|
+
#return @client.raw("get", "/content/content-pages", options)
|
278
|
+
#end
|
252
279
|
|
253
280
|
##
|
254
281
|
# === Get Content Page.
|
@@ -256,38 +283,57 @@ module Mints
|
|
256
283
|
#
|
257
284
|
# ==== Parameters
|
258
285
|
# slug:: (String) -- It's the string identifier generated by Mints.
|
259
|
-
# options:: (Hash) -- List of {Single Resource Options}[#class-Mints::Pub-label-Single+resource+options] shown above can be used as parameter.
|
260
286
|
#
|
261
287
|
# ==== Example
|
262
|
-
# @mints_pub.get_content_page("test-page")
|
263
|
-
def get_content_page(slug
|
264
|
-
return @client.raw("get", "/content/content-pages/#{slug}",
|
288
|
+
# @data = @mints_pub.get_content_page("test-page")
|
289
|
+
def get_content_page(slug)
|
290
|
+
return @client.raw("get", "/content/content-pages/#{slug}", nil, nil, nil, nil, true)
|
265
291
|
end
|
266
292
|
|
293
|
+
### V1/ECOMMERCE ###
|
294
|
+
|
267
295
|
##
|
268
296
|
# === Get Locations.
|
269
297
|
# Get all locations.
|
270
298
|
#
|
271
299
|
# ==== Parameters
|
272
300
|
# options:: (Hash) -- List of {Resource collection Options}[#class-Mints::Pub-label-Resource+collections+options+] shown above can be used as parameter.
|
301
|
+
# use_post:: (Boolean) -- Variable to determine if the request is by 'post' or 'get' functions.
|
273
302
|
#
|
274
|
-
# ==== Example
|
275
|
-
# @mints_pub.get_locations
|
276
|
-
|
277
|
-
|
303
|
+
# ==== First Example
|
304
|
+
# @data = @mints_pub.get_locations
|
305
|
+
#
|
306
|
+
# ==== Second Example
|
307
|
+
# options = { "fields": "title" }
|
308
|
+
# @data = @mints_pub.get_locations(options)
|
309
|
+
#
|
310
|
+
# ==== Third Example
|
311
|
+
# options = { "fields": "title" }
|
312
|
+
# @data = @mints_pub.get_locations(options, false)
|
313
|
+
def get_locations(options = nil, use_post = true)
|
314
|
+
return get_query_results("/ecommerce/locations", options, use_post)
|
278
315
|
end
|
279
|
-
|
316
|
+
|
280
317
|
##
|
281
318
|
# === Get Products.
|
282
319
|
# Get a collection of products.
|
283
320
|
#
|
284
321
|
# ==== Parameters
|
285
322
|
# options:: (Hash) -- List of {Resource collection Options}[#class-Mints::Pub-label-Resource+collections+options+] shown above can be used as parameter.
|
323
|
+
# use_post:: (Boolean) -- Variable to determine if the request is by 'post' or 'get' functions.
|
286
324
|
#
|
287
|
-
# ==== Example
|
288
|
-
# @mints_pub.get_products
|
289
|
-
|
290
|
-
|
325
|
+
# ==== First Example
|
326
|
+
# @data = @mints_pub.get_products
|
327
|
+
#
|
328
|
+
# ==== Second Example
|
329
|
+
# options = { "fields": "title" }
|
330
|
+
# @data = @mints_pub.get_products(options)
|
331
|
+
#
|
332
|
+
# ==== Third Example
|
333
|
+
# options = { "fields": "title" }
|
334
|
+
# @data = @mints_pub.get_products(options, false)
|
335
|
+
def get_products(options = nil, use_post = true)
|
336
|
+
return get_query_results("/ecommerce/products", options, use_post)
|
291
337
|
end
|
292
338
|
|
293
339
|
##
|
@@ -298,43 +344,66 @@ module Mints
|
|
298
344
|
# slug:: (String) -- It's the string identifier generated by Mints.
|
299
345
|
# options:: (Hash) -- List of {Single Resource Options}[#class-Mints::Pub-label-Single+resource+options] shown above can be used as parameter.
|
300
346
|
#
|
301
|
-
# ==== Example
|
302
|
-
# @mints_pub.get_product("product_slug")
|
347
|
+
# ==== First Example
|
348
|
+
# @data = @mints_pub.get_product("product_slug")
|
349
|
+
#
|
350
|
+
# ==== Second Example
|
351
|
+
# options = {
|
352
|
+
# "fields": "id, slug"
|
353
|
+
# }
|
354
|
+
# @data = @mints_pub.get_product("lego-set", options)
|
303
355
|
def get_product(slug, options = nil)
|
304
|
-
return @client.raw("get", "/ecommerce/products/#{slug}", options)
|
356
|
+
return @client.raw("get", "/ecommerce/products/#{slug}", options, nil, nil, nil, true)
|
305
357
|
end
|
306
358
|
|
359
|
+
### V1/CONFIG ###
|
360
|
+
|
307
361
|
##
|
308
|
-
# === Get
|
309
|
-
# Get a collection of
|
362
|
+
# === Get Public Folders.
|
363
|
+
# Get a collection of public folders.
|
310
364
|
#
|
311
365
|
# ==== Parameters
|
312
|
-
# options:: (Hash) -- List of {Resource
|
366
|
+
# options:: (Hash) -- List of {Single Resource Options}[#class-Mints::Pub-label-Single+resource+options] shown above can be used as parameter.
|
313
367
|
#
|
314
|
-
# ==== Example
|
368
|
+
# ==== First Example
|
315
369
|
# options = {
|
316
|
-
# "object_type": "
|
370
|
+
# "object_type": "products"
|
371
|
+
# }
|
372
|
+
# @data = @mints_pub.get_public_folders(options)
|
373
|
+
#
|
374
|
+
# ==== Second Example
|
375
|
+
# options = {
|
376
|
+
# "object_type": "products",
|
377
|
+
# "fields": "id",
|
378
|
+
# "sort": "-id"
|
317
379
|
# }
|
318
|
-
# @mints_pub.
|
319
|
-
def
|
320
|
-
return @client.raw("get", "/config/
|
380
|
+
# @data = @mints_pub.get_public_folders(options)
|
381
|
+
def get_public_folders(options)
|
382
|
+
return @client.raw("get", "/config/public-folders", options)
|
321
383
|
end
|
322
384
|
|
323
385
|
##
|
324
|
-
# === Get
|
325
|
-
# Get a
|
386
|
+
# === Get Public Folder.
|
387
|
+
# Get a public folder info.
|
326
388
|
#
|
327
389
|
# ==== Parameters
|
328
390
|
# slug:: (String) -- It's the string identifier generated by Mints.
|
329
391
|
# options:: (Hash) -- List of {Single Resource Options}[#class-Mints::Pub-label-Single+resource+options] shown above can be used as parameter.
|
330
392
|
#
|
331
|
-
# ==== Example
|
393
|
+
# ==== First Example
|
332
394
|
# options = {
|
333
|
-
# "object_type": "
|
395
|
+
# "object_type": "products"
|
334
396
|
# }
|
335
|
-
# @mints_pub.
|
336
|
-
|
337
|
-
|
397
|
+
# @data = @mints_pub.get_public_folder('yellow', options)
|
398
|
+
#
|
399
|
+
# ==== Second Example
|
400
|
+
# options = {
|
401
|
+
# "object_type": "products",
|
402
|
+
# "fields": "id, title"
|
403
|
+
# }
|
404
|
+
# @data = @mints_pub.get_public_folder('yellow', options)
|
405
|
+
def get_public_folder(slug, options)
|
406
|
+
return @client.raw("get", "/config/public-folders/#{slug}", options)
|
338
407
|
end
|
339
408
|
|
340
409
|
##
|
@@ -344,8 +413,14 @@ module Mints
|
|
344
413
|
# ==== Parameters
|
345
414
|
# options:: (Hash) -- List of {Resource collection Options}[#class-Mints::Pub-label-Resource+collections+options+] shown above can be used as parameter.
|
346
415
|
#
|
347
|
-
# ==== Example
|
348
|
-
# @mints_pub.get_tags
|
416
|
+
# ==== First Example
|
417
|
+
# @data = @mints_pub.get_tags
|
418
|
+
#
|
419
|
+
# ==== Second Example
|
420
|
+
# options = {
|
421
|
+
# "fields": "id, tag"
|
422
|
+
# }
|
423
|
+
# @data = @mints_pub.get_tags(options)
|
349
424
|
def get_tags(options = nil)
|
350
425
|
return @client.raw("get", "/config/tags", options)
|
351
426
|
end
|
@@ -358,23 +433,42 @@ module Mints
|
|
358
433
|
# slug:: (String) -- It's the string identifier generated by Mints.
|
359
434
|
# options:: (Hash) -- List of {Single Resource Options}[#class-Mints::Pub-label-Single+resource+options] shown above can be used as parameter.
|
360
435
|
#
|
361
|
-
# ==== Example
|
362
|
-
# @mints_pub.get_tag("tag_slug")
|
436
|
+
# ==== First Example
|
437
|
+
# @data = @mints_pub.get_tag("tag_slug")
|
438
|
+
#
|
439
|
+
# ==== Second Example
|
440
|
+
# options = {
|
441
|
+
# "fields": "id, tag"
|
442
|
+
# }
|
443
|
+
# @data = @mints_pub.get_tag("velit-0", options)
|
363
444
|
def get_tag(slug, options = nil)
|
364
445
|
return @client.raw("get", "/config/tags/#{slug}", options)
|
365
446
|
end
|
366
|
-
|
447
|
+
|
367
448
|
##
|
368
449
|
# === Get Taxonomies.
|
369
450
|
# Get a collection of taxonomies.
|
370
451
|
#
|
371
452
|
# ==== Parameters
|
372
453
|
# options:: (Hash) -- List of {Resource collection Options}[#class-Mints::Pub-label-Resource+collections+options+] shown above can be used as parameter.
|
454
|
+
# use_post:: (Boolean) -- Variable to determine if the request is by 'post' or 'get' functions.
|
373
455
|
#
|
374
|
-
# ==== Example
|
375
|
-
# @mints_pub.get_taxonomies
|
376
|
-
|
377
|
-
|
456
|
+
# ==== First Example
|
457
|
+
# @data = @mints_pub.get_taxonomies
|
458
|
+
#
|
459
|
+
# ==== Second Example
|
460
|
+
# options = {
|
461
|
+
# "fields": "id, title"
|
462
|
+
# }
|
463
|
+
# @data = @mints_pub.get_taxonomies(options)
|
464
|
+
#
|
465
|
+
# ==== Third Example
|
466
|
+
# options = {
|
467
|
+
# "fields": "id, title"
|
468
|
+
# }
|
469
|
+
# @data = @mints_pub.get_taxonomies(options, false)
|
470
|
+
def get_taxonomies(options = nil, use_post = true)
|
471
|
+
return get_query_results("/config/taxonomies", options, use_post)
|
378
472
|
end
|
379
473
|
|
380
474
|
##
|
@@ -385,8 +479,14 @@ module Mints
|
|
385
479
|
# slug:: (String) -- It's the string identifier generated by Mints.
|
386
480
|
# options:: (Hash) -- List of {Single Resource Options}[#class-Mints::Pub-label-Single+resource+options] shown above can be used as parameter.
|
387
481
|
#
|
388
|
-
# ==== Example
|
389
|
-
# @mints_pub.get_taxonomy("taxonomy_slug")
|
482
|
+
# ==== First Example
|
483
|
+
# @data = @mints_pub.get_taxonomy("taxonomy_slug")
|
484
|
+
#
|
485
|
+
# ==== Second Example
|
486
|
+
# options = {
|
487
|
+
# "fields": "title"
|
488
|
+
# }
|
489
|
+
# @data = @mints_pub.get_taxonomy("taxonomy_slug", options)
|
390
490
|
def get_taxonomy(slug, options = nil)
|
391
491
|
return @client.raw("get", "/config/taxonomies/#{slug}", options)
|
392
492
|
end
|
@@ -395,14 +495,45 @@ module Mints
|
|
395
495
|
# === Get Attributes.
|
396
496
|
# Get a collection of attributes.
|
397
497
|
#
|
498
|
+
# ==== Example
|
499
|
+
# @data = @mints_pub.get_attributes
|
500
|
+
def get_attributes
|
501
|
+
return @client.raw("get", "/config/attributes")
|
502
|
+
end
|
503
|
+
|
504
|
+
# Methods deleted
|
505
|
+
##
|
506
|
+
# === Get categories.
|
507
|
+
# Get a collection of categories.
|
508
|
+
#
|
398
509
|
# ==== Parameters
|
399
510
|
# options:: (Hash) -- List of {Resource collection Options}[#class-Mints::Pub-label-Resource+collections+options+] shown above can be used as parameter.
|
400
511
|
#
|
401
512
|
# ==== Example
|
402
|
-
#
|
403
|
-
|
404
|
-
|
405
|
-
|
513
|
+
# options = {
|
514
|
+
# "object_type": "stories"
|
515
|
+
# }
|
516
|
+
# @data = @mints_pub.get_categories(options)
|
517
|
+
#def get_categories(options = nil)
|
518
|
+
# return @client.raw("get", "/config/categories", options)
|
519
|
+
#end
|
520
|
+
|
521
|
+
##
|
522
|
+
# === Get Category.
|
523
|
+
# Get a single category.
|
524
|
+
#
|
525
|
+
# ==== Parameters
|
526
|
+
# slug:: (String) -- It's the string identifier generated by Mints.
|
527
|
+
# options:: (Hash) -- List of {Single Resource Options}[#class-Mints::Pub-label-Single+resource+options] shown above can be used as parameter.
|
528
|
+
#
|
529
|
+
# ==== Example
|
530
|
+
# options = {
|
531
|
+
# "object_type": "locations"
|
532
|
+
# }
|
533
|
+
# @data = @mints_pub.get_category("asset_slug", options)
|
534
|
+
#def get_category(slug, options = nil)
|
535
|
+
# return @client.raw("get", "/config/categories/#{slug}", options)
|
536
|
+
#end
|
406
537
|
|
407
538
|
private
|
408
539
|
|