mints 0.0.14 → 0.0.15

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 (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/client.rb +3 -0
  3. data/lib/pub.rb +108 -102
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3deabf302a32fac1452e45f7ab9753ec0a1ee7973535b0371b9c67a25cb60cc7
4
- data.tar.gz: 9589dacb58814ad17c5a2826f866b929f862d7ce7ce3fc745dcd3e191c2f19c9
3
+ metadata.gz: 18200f38cd58f4884a1e3391f28523b15dcad0db6f1a40038d3dd77bbc7b5826
4
+ data.tar.gz: 1a80da693aa4121af008dfc9d2816f5d09963e84d61f5274824593910786664e
5
5
  SHA512:
6
- metadata.gz: d1bc7c183bc20b9dbe25f4f5d7770ee0492d0f2e773cdfb6934af7afe0056bf8f38f7277440a821e71f22a4abda51c11f7b8c2dd5f6279e22b9c68c7fe703d82
7
- data.tar.gz: 2f7ebc2b2f8977f5009bafc4e42348cc4a7494729fb1aa15ccf69a8e7937c9872120a2bc81711fcd22153fa5cb05e71c462dc0c67645f350c5e5021f1e7a71f9
6
+ metadata.gz: aa64a73af10be175c08a0833e6178b654ea8cda3713e49e1533fdc12fa89d3c4be51974ac41c558463d11aa5d0c50e621d774a9b77bd61e554c4dda0a7cb0019
7
+ data.tar.gz: 525ef4e71004bc3705f36eb4d1f165044da08dba2af45eff3185e4686206f746dc4d0072ce97cd811ce1489c9de17f7737354d3a437eddbd9d90ffc164e4c6d2
data/lib/client.rb CHANGED
@@ -24,6 +24,9 @@ module Mints
24
24
  base_url = @base_url if !base_url
25
25
  uri = ""
26
26
  if (options && options.class == Hash)
27
+ if (options[:jfilters] && options[:jfilters].class == Hash)
28
+ options[:jfilters] = Base64.encode64(JSON.generate(options[:jfilters]))
29
+ end
27
30
  uri = Addressable::URI.new
28
31
  uri.query_values = options
29
32
  end
data/lib/pub.rb CHANGED
@@ -5,6 +5,10 @@ module Mints
5
5
  # == Public context API
6
6
  # Pub class contains functions that needs only an API key as authentication
7
7
  # == Usage example
8
+ # === For Mints::BaseController inheritance:
9
+ # If the controller is inheriting from Mints::BaseController, Only use the class variable *mints_pub* _Example:_
10
+ # @mints_pub.get_stories
11
+ # === For standalone usage:
8
12
  # Initialize
9
13
  # pub = Mints::Pub.new(mints_url, api_key)
10
14
  # or if host and api_key are provided by mints_config.yml.erb
@@ -12,23 +16,58 @@ module Mints
12
16
  # Call any function
13
17
  # pub.get_products
14
18
  # == Single resource options
15
- # * +include+ - [String] include a relationship
16
- # * +attributes+ - [Boolean] attach attributes to response
17
- # * +categories+ - [Boolean] attach categories to response
18
- # * +tags+ - [Boolean] attach tags to response
19
+ # * +include+ - [_String_] Specify additional information to be included in the results from the objects relations. _Example:_
20
+ # { "include": "events" }
21
+ # * +attributes+ - [_Boolean_] If present, attributes will be returned for each record in the results. _Example:_
22
+ # { "attributes": true }
23
+ # * +categories+ - [_Boolean_] If present, categories will be returned for each record in the results. _Example:_
24
+ # { "categories": true }
25
+ # * +tags+ - [_Boolean_] If present, tags will be returned for each record in the results. _Example:_
26
+ # { "tags": true }
27
+ # * +fields+ - [_String_] Specify the fields that you want to be returned. If empty, all fields are returned. The object index can also be used to specify specific fields from relations. _Example:_
28
+ # { "fields": "id, title, slug" }
29
+ # { "fields[products]": "id, title, slug" }
30
+ #
19
31
  # == Resource collections options
20
- # * +search+ - [String] filter by a search word
21
- # * +scopes+ - [String] filter by a scope
22
- # * +filters+ - [String] filter by where clauses
23
- # * +jfilters+ - [String] filter using complex condition objects
24
- # * +catfilters+ - [String] filter by categories
25
- # * +fields+ - [String] indicates the columns that will be selected
26
- # * +sort+ - [String] indicates the columns that will be selected
27
- # * +include+ - [String] include a relationship
28
- # * +attributes+ - [Boolean] attach attributes to response
29
- # * +categories+ - [Boolean] attach categories to response
30
- # * +taxonomies+ - [Boolean] attach categories to response
31
- # * +tags+ - [Boolean] attach tags to response
32
+ # * +search+ - [_String_] If present, it will search for records matching the search string. _Example:_
33
+ # { "search": "searchstring" }
34
+ # * +scopes+ - [_String_] If present, it will apply the specified Model's scopes. _Example:_
35
+ # { "scopes": "approved, recent" }
36
+ # * +filters+ - [_String_] This is a powerful parameter that allows the data to be filtered by any of its fields. Currently only exact matches are supported. _Example:_
37
+ # { "filters[title]": "titleToFilter" }
38
+ # * +jfilters+ - [_String_] A complex filter configuration, as used in segments, in JSON format, base64 encoded and URLencoded. _Example:_
39
+ # jfilter = {
40
+ # "type":"group",
41
+ # "items":[
42
+ # {
43
+ # "type":"attribute",
44
+ # "operator":"==",
45
+ # "slug":"title",
46
+ # "value":"Action movies"
47
+ # }
48
+ # ],
49
+ # "operator":"or"
50
+ # }
51
+ # options = { "jfilters": jfilter }
52
+ # * +catfilters+ - [_String_] filter by categories. _Example:_
53
+ # { "catfilters": "categoryName" }
54
+ # * +fields+ - [_String_] Specify the fields that you want to be returned. If empty, all fields are returned. The object index can also be used to specify specific fields from relations. _Example:_
55
+ # { "fields": "id, title, slug" }
56
+ # { "fields[products]": "id, title, slug" }
57
+ # * +sort+ - [_String_] The name of the field to perform the sort. Prefix the value with a minus sign - for ascending order. _Example:_
58
+ # { "sort": "title" }
59
+ # { "sort": "-title" }
60
+ # * +include+ - [_String_] Specify additional information to be included in the results from the objects relations. _Example:_
61
+ # { "include": "events" }
62
+ # * +attributes+ - [_Boolean_] If present, attributes will be returned for each record in the results. _Example:_
63
+ # { "attributes": true }
64
+ # * +categories+ - [_Boolean_] If present, categories will be returned for each record in the results. _Example:_
65
+ # { "categories": true }
66
+ # * +taxonomies+ - [_Boolean_] If present, taxonomies will be returned for each record in the results. _Example:_
67
+ # { "taxonomies": true }
68
+ # * +tags+ - [_Boolean_] If present, tags will be returned for each record in the results. _Example:_
69
+ # { "tags": true }
70
+
32
71
  class Pub
33
72
  attr_reader :client
34
73
 
@@ -77,58 +116,15 @@ module Mints
77
116
  end
78
117
 
79
118
  ##
80
- # === Get Content Page.
81
- # Get a single content page
82
- #
83
- # ==== Parameters
84
- # * +slug+ - [String] It's the slug
85
- # * +options+ - [Hash] List of {Single Resource Options}[#class-Mints::Pub-label-Single+resource+options] shown above can be used as parameter
86
- def get_content_page(slug, options = nil)
87
- return @client.raw("get", "/content/content-pages/#{slug}", options)
88
- end
89
-
90
- ##
91
- # === Get Content Templates.
92
- # Get a collection of content templates
93
- #
94
- # ==== Parameters
95
- # * +options+ - [Hash] List of {Resource collection Options}[#class-Mints::Pub-label-Resource+collections+options+] shown above can be used as parameter
96
- def get_content_templates(options = nil)
97
- return @client.raw("get", "/content/content-templates", options)
98
- end
99
-
100
- ##
101
- # === Get Content Template.
102
- # Get a single content template.
103
- #
104
- # ==== Parameters
105
- # * +slug+ - [String] It's the string identifier generated by Mints
106
- # * +options+ - [Hash] List of {Single Resource Options}[#class-Mints::Pub-label-Single+resource+options] shown above can be used as parameter
107
- def get_content_template(slug, options = nil)
108
- return @client.raw("get", "/content/content-templates/#{slug}", options)
109
- end
110
-
111
- ##
112
- # === Get Content Instances.
113
- # Get a collection of content instances
119
+ # === Get Asset Info.
120
+ # Get a description of an Asset
114
121
  #
115
122
  # ==== Parameters
116
- # * +options+ - [Hash] List of {Resource collection Options}[#class-Mints::Pub-label-Resource+collections+options+] shown above can be used as parameter
117
- def get_content_instances(options)
118
- return @client.raw("get", "/content/content-instances", options)
123
+ # * +slug+ - [String] It's the string identifier of the asset.
124
+ def get_asset_info(slug)
125
+ return @client.raw("get", "/content/asset-info/#{slug}")
119
126
  end
120
-
121
- ##
122
- # === Get Content Instance.
123
- # Get a single content instance.
124
- #
125
- # ==== Parameters
126
- # * +slug+ - [String] It's the string identifier generated by Mints
127
- # * +options+ - [Hash] List of {Single Resource Options}[#class-Mints::Pub-label-Single+resource+options] shown above can be used as parameter
128
- def get_content_instance(slug, options = nil)
129
- return @client.raw("get", "/content/content-instances/#{slug}", options)
130
- end
131
-
127
+
132
128
  ##
133
129
  # === Get Stories.
134
130
  # Get a collection of stories
@@ -179,71 +175,81 @@ module Mints
179
175
  # * +data+ - [Hash] Data to be submited
180
176
  def submit_form(data)
181
177
  return @client.raw("post", "/content/forms/submit", nil, data)
182
- end
178
+ end
183
179
 
184
180
  ##
185
- # === Get Products.
186
- # Get a collection of products.
181
+ # === Get Content Instances.
182
+ # Get a collection of content instances
187
183
  #
188
184
  # ==== Parameters
189
185
  # * +options+ - [Hash] List of {Resource collection Options}[#class-Mints::Pub-label-Resource+collections+options+] shown above can be used as parameter
190
- def get_products(options = nil)
191
- return @client.raw("get", "/ecommerce/products", options)
186
+ def get_content_instances(options = nil)
187
+ return @client.raw("get", "/content/content-instances", options)
192
188
  end
193
189
 
194
190
  ##
195
- # === Get Product.
196
- # Get a single product.
191
+ # === Get Content Instance.
192
+ # Get a single content instance.
197
193
  #
198
194
  # ==== Parameters
199
195
  # * +slug+ - [String] It's the string identifier generated by Mints
200
196
  # * +options+ - [Hash] List of {Single Resource Options}[#class-Mints::Pub-label-Single+resource+options] shown above can be used as parameter
201
- def get_product(slug, options = nil)
202
- return @client.raw("get", "/ecommerce/products/#{slug}", options)
197
+ def get_content_instance(slug, options = nil)
198
+ return @client.raw("get", "/content/content-instances/#{slug}", options)
203
199
  end
204
200
 
205
201
  ##
206
- # === Get Product Brands.
207
- # Get a collection of product brands.
202
+ # === Get Content Pages.
203
+ # Get all content pages.
208
204
  #
209
205
  # ==== Parameters
210
206
  # * +options+ - [Hash] List of {Resource collection Options}[#class-Mints::Pub-label-Resource+collections+options+] shown above can be used as parameter
211
- def get_product_brands(options = nil)
212
- return @client.raw("get", "/ecommerce/product-brands", options)
207
+ def get_content_pages(options = nil)
208
+ return @client.raw("get", "/content/content-pages", options)
213
209
  end
214
210
 
215
211
  ##
216
- # === Get Product Brand.
217
- # Get a product brand.
212
+ # === Get Content Page.
213
+ # Get a single content page
218
214
  #
219
215
  # ==== Parameters
220
- # * +slug+ - [String] It's the string identifier generated by Mints
216
+ # * +slug+ - [String] It's the slug
221
217
  # * +options+ - [Hash] List of {Single Resource Options}[#class-Mints::Pub-label-Single+resource+options] shown above can be used as parameter
222
- def get_product_brand(slug, options = nil)
223
- return @client.raw("get", "/ecommerce/product-brands/#{slug}", options)
218
+ def get_content_page(slug, options = nil)
219
+ return @client.raw("get", "/content/content-pages/#{slug}", options)
220
+ end
221
+
222
+ ##
223
+ # === Get Locations.
224
+ # Get all locations.
225
+ #
226
+ # ==== Parameters
227
+ # * +options+ - [Hash] List of {Resource collection Options}[#class-Mints::Pub-label-Resource+collections+options+] shown above can be used as parameter
228
+ def get_locations(options = nil)
229
+ return @client.raw("get", "/ecommerce/locations", options)
224
230
  end
225
231
 
226
232
  ##
227
- # === Get SKUs.
228
- # Get a collection of SKUs.
233
+ # === Get Products.
234
+ # Get a collection of products.
229
235
  #
230
236
  # ==== Parameters
231
237
  # * +options+ - [Hash] List of {Resource collection Options}[#class-Mints::Pub-label-Resource+collections+options+] shown above can be used as parameter
232
- def get_skus(options = nil)
233
- return @client.raw("get", "/ecommerce/skus", options)
238
+ def get_products(options = nil)
239
+ return @client.raw("get", "/ecommerce/products", options)
234
240
  end
235
241
 
236
242
  ##
237
- # === Get SKU.
238
- # Get a single SKU.
243
+ # === Get Product.
244
+ # Get a single product.
239
245
  #
240
246
  # ==== Parameters
241
247
  # * +slug+ - [String] It's the string identifier generated by Mints
242
248
  # * +options+ - [Hash] List of {Single Resource Options}[#class-Mints::Pub-label-Single+resource+options] shown above can be used as parameter
243
- def get_sku(slug, options = nil)
244
- return @client.raw("get", "/ecommerce/skus/#{slug}", options)
249
+ def get_product(slug, options = nil)
250
+ return @client.raw("get", "/ecommerce/products/#{slug}", options)
245
251
  end
246
-
252
+
247
253
  ##
248
254
  # === Get categories.
249
255
  # Get a collection of categories.
@@ -286,16 +292,6 @@ module Mints
286
292
  return @client.raw("get", "/config/tags/#{slug}", options)
287
293
  end
288
294
 
289
- ##
290
- # === Get Attributes.
291
- # Get a collection of attributes.
292
- #
293
- # ==== Parameters
294
- # * +options+ - [Hash] List of {Resource collection Options}[#class-Mints::Pub-label-Resource+collections+options+] shown above can be used as parameter
295
- def get_attributes(options = nil)
296
- return @client.raw("get", "/config/attributes", options)
297
- end
298
-
299
295
  ##
300
296
  # === Get Taxonomies.
301
297
  # Get a collection of taxonomies.
@@ -316,5 +312,15 @@ module Mints
316
312
  def get_taxonomy(slug, options = nil)
317
313
  return @client.raw("get", "/config/taxonomies/#{slug}", options)
318
314
  end
315
+
316
+ ##
317
+ # === Get Attributes.
318
+ # Get a collection of attributes.
319
+ #
320
+ # ==== Parameters
321
+ # * +options+ - [Hash] List of {Resource collection Options}[#class-Mints::Pub-label-Resource+collections+options+] shown above can be used as parameter
322
+ def get_attributes(options = nil)
323
+ return @client.raw("get", "/config/attributes", options)
324
+ end
319
325
  end
320
326
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mints
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.14
4
+ version: 0.0.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ruben Gomez Garcia, Omar Mora, Luis Payan