mints 0.0.2 → 0.0.3

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/contact.rb +47 -3
  3. data/lib/pub.rb +191 -4
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cf8cfd66c96475748e1eaa88e97ee51b2c3fc7b2a682fc558f4bb7eda98d31ea
4
- data.tar.gz: 5175fb3ceaa8f4c9c607b76d90ff2cec26eec6a11e487f91e7d99645dd36687f
3
+ metadata.gz: 327d7dc897b313289564ea62d790eca41f338394b7d3285a54044004d73c4949
4
+ data.tar.gz: 311fef416ffe4b8009752185f7ca974e6ebe4c887692608c03bee69e7432100c
5
5
  SHA512:
6
- metadata.gz: e4e6b98fa27ba280d9f912b91c4c8f0da3ebd8f1750c2ee8d06429d1983c56dbad0cb34c8f9d3b6595155ebced1af354c8c36a39104e412cb04d2ea9628d5684
7
- data.tar.gz: 9f1952c50204dde682a49fc1c9039f3e3f2da84078f711f227f236b8b9969c795cbebf9bba9a0350ba205dee403762789413e9381c3912c107a602494e781d16
6
+ metadata.gz: 132622f7ce07aed342c56e2c1bf3bc1a15be585fbf747c603b822e184ef55f7fb914d6216ad5b7e7c33d0831cbf33caf6b2927fa46eace7938e40ede898e86cf
7
+ data.tar.gz: c5531bb9f2be7d66f8dd2b9951957b90e85b43c3d1e1527b462a3978f05ee9e768177f83aa6313d768d07c3062bee261add211d8dcbc5d5895f4dcf0f8c11ab2
data/lib/contact.rb CHANGED
@@ -2,10 +2,18 @@ require_relative "./client.rb"
2
2
  module Mints
3
3
  class Contact
4
4
  attr_reader :client
5
+ ##
6
+ # === Initialize.
7
+ # Class constructor
8
+ #
5
9
  def initialize(host, api_key, session_token = nil)
6
10
  @client = Mints::Client.new(host, api_key, "contact", session_token)
7
11
  end
8
12
 
13
+ ##
14
+ # === Register.
15
+ # Register a new contact
16
+ #
9
17
  def register(given_name, last_name, email, password)
10
18
  data = {
11
19
  given_name: given_name,
@@ -16,6 +24,10 @@ module Mints
16
24
  return @client.raw("post", "/contacts/register", nil, {data: data})
17
25
  end
18
26
 
27
+ ##
28
+ # === Login.
29
+ # Starts a contact session
30
+ #
19
31
  def login(email, password)
20
32
  data = {
21
33
  email: email,
@@ -28,39 +40,71 @@ module Mints
28
40
  return response
29
41
  end
30
42
 
43
+ ##
44
+ # === Logout.
45
+ # Ends a contact session
46
+ #
31
47
  def logout
32
48
  response = @client.raw("post", "/contacts/logout") if session_token?
33
49
  if response["success"]
34
50
  @client.session_token = nil
35
- end
51
+ end
36
52
  return response
37
53
  end
38
54
 
55
+ ##
56
+ # === Change Password.
57
+ # Change password
58
+ #
39
59
  def change_password(data)
40
60
  return @client.raw("post", "/contacts/change-password", nil, data)
41
61
  end
42
62
 
63
+ ##
64
+ # === Recover Password.
65
+ # Recover password
66
+ #
43
67
  def recover_password(data)
44
68
  return @client.raw("post", "/contacts/recover-password", nil, data)
45
69
  end
46
70
 
71
+ ##
72
+ # === Reset Password.
73
+ # Reset password
74
+ #
47
75
  def reset_password(data)
48
76
  return @client.raw("post", "/contacts/reset-password", nil, data)
49
77
  end
50
78
 
51
- def auth_login(data)
79
+ ##
80
+ # === OAuth Login.
81
+ # Login a contact using oauth
82
+ #
83
+ def oauth_login(data)
52
84
  return @client.raw("post", "/contacts/oauth-login", nil, data)
53
85
  end
54
86
 
87
+ ##
88
+ # === Me.
89
+ # Get contact logged info
90
+ #
55
91
  def me
56
92
  return @client.raw("get", "/contacts/me")
57
93
  end
58
94
 
95
+ ##
96
+ # === Status.
97
+ # Get contact logged status
98
+ #
59
99
  def status
60
100
  return @client.raw("get", "/contacts/status")
61
101
  end
62
102
 
63
- def update
103
+ ##
104
+ # === Update.
105
+ # Update logged contact attributes
106
+ #
107
+ def update(data)
64
108
  return @client.raw("put", "/contacts/update", nil, data)
65
109
  end
66
110
 
data/lib/pub.rb CHANGED
@@ -1,11 +1,55 @@
1
1
  require_relative './client.rb'
2
2
  module Mints
3
+
4
+ ##
5
+ # == Public context API
6
+ # Pub class contains functions that needs only an API key as authentication
7
+ # == Usage example
8
+ # Initialize
9
+ # pub = Mints::Pub.new(mints_url, api_key)
10
+ # Call any function
11
+ # pub.get_products
12
+ # == Single resource options
13
+ # * +include+ - [String] include a relationship
14
+ # * +attributes+ - [Boolean] attach attributes to response
15
+ # * +categories+ - [Boolean] attach categories to response
16
+ # * +tags+ - [Boolean] attach tags to response
17
+ # == Resource collections options
18
+ # * +search+ - [String] filter by a search word
19
+ # * +scopes+ - [String] filter by a scope
20
+ # * +filters+ - [String] filter by where clauses
21
+ # * +jfilters+ - [String] filter using complex condition objects
22
+ # * +catfilters+ - [String] filter by categories
23
+ # * +fields+ - [String] indicates the columns that will be selected
24
+ # * +sort+ - [String] indicates the columns that will be selected
25
+ # * +include+ - [String] include a relationship
26
+ # * +attributes+ - [Boolean] attach attributes to response
27
+ # * +categories+ - [Boolean] attach categories to response
28
+ # * +tags+ - [Boolean] attach tags to response
3
29
  class Pub
4
30
  attr_reader :client
31
+
32
+ ##
33
+ # === Initialize.
34
+ # Class constructor
35
+ #
36
+ # ==== Parameters
37
+ # * +host+ - [String] It's the visitor IP
38
+ # * +api_key+ - [String] Mints instance api key
39
+ # ==== Return
40
+ # Returns a Client object
5
41
  def initialize(host, api_key)
6
42
  @client = Mints::Client.new(host, api_key)
7
43
  end
8
44
 
45
+ ##
46
+ # === Register Visit.
47
+ # Register a ghost/contact visit in Mints.Cloud
48
+ #
49
+ # ==== Parameters
50
+ # * +ip+ - [String] It's the visitor IP
51
+ # * +user_agent+ - The visitor's browser user agent
52
+ # * +url+ - [String] URL visited
9
53
  def register_visit(ip, user_agent, url)
10
54
  data = {
11
55
  ip_address: ip,
@@ -15,91 +59,234 @@ module Mints
15
59
  return @client.raw("post", "/register-visit-timer", nil, data)
16
60
  end
17
61
 
18
- def register_visit_timer
19
- return @client.raw("get", "/register-visit-timer")
62
+ ##
63
+ # === Register Visit timer.
64
+ # Register a page visit time
65
+ #
66
+ # ==== Parameters
67
+ # * +visit+ - [String] It's the visitor IP
68
+ # * +time+ - [Integer] The visitor's browser user agent
69
+ def register_visit_timer(visit, time)
70
+ return @client.raw("get", "/register-visit-timer?visit=#{visit}&time=#{time}")
20
71
  end
21
72
 
73
+ ##
74
+ # === Get Content Page.
75
+ # Get a single content page
76
+ #
77
+ # ==== Parameters
78
+ # * +slug+ - [String] It's the slug
79
+ # * +options+ - [Hash] List of {Single Resource Options}[#class-Mints::Pub-label-Single+resource+options] shown above can be used as parameter
22
80
  def get_content_page(slug, options = nil)
23
- return @client.raw("get", "/content-pages/#{slug}", options)
81
+ return @client.raw("get", "/content/content-pages/#{slug}", options)
24
82
  end
25
83
 
84
+ ##
85
+ # === Get Content Templates.
86
+ # Get a collection of content templates
87
+ #
88
+ # ==== Parameters
89
+ # * +options+ - [Hash] List of {Resource collection Options}[#class-Mints::Pub-label-Resource+collections+options+] shown above can be used as parameter
26
90
  def get_content_templates(options = nil)
27
91
  return @client.raw("get", "/content/content-templates")
28
92
  end
29
93
 
94
+ ##
95
+ # === Get Content Template.
96
+ # Get a single content template.
97
+ #
98
+ # ==== Parameters
99
+ # * +slug+ - [String] It's the string identifier generated by Mints
100
+ # * +options+ - [Hash] List of {Single Resource Options}[#class-Mints::Pub-label-Single+resource+options] shown above can be used as parameter
30
101
  def get_content_template(slug, options = nil)
31
102
  return @client.raw("get", "/content/content-templates/#{slug}", options)
32
103
  end
33
104
 
105
+ ##
106
+ # === Get Content Instances.
107
+ # Get a collection of content instances
108
+ #
109
+ # ==== Parameters
110
+ # * +options+ - [Hash] List of {Resource collection Options}[#class-Mints::Pub-label-Resource+collections+options+] shown above can be used as parameter
34
111
  def content_instances(options)
35
112
  return @client.raw("get", "/content/content-instances", options)
36
113
  end
37
114
 
115
+ ##
116
+ # === Get Content Instance.
117
+ # Get a single content instance.
118
+ #
119
+ # ==== Parameters
120
+ # * +slug+ - [String] It's the string identifier generated by Mints
121
+ # * +options+ - [Hash] List of {Single Resource Options}[#class-Mints::Pub-label-Single+resource+options] shown above can be used as parameter
38
122
  def content_instance(slug, options = nil)
39
123
  return @client.raw("get", "/content/content-instances/#{slug}", options)
40
124
  end
41
125
 
126
+ ##
127
+ # === Get Stories.
128
+ # Get a collection of stories
129
+ #
130
+ # ==== Parameters
131
+ # * +options+ - [Hash] List of {Resource collection Options}[#class-Mints::Pub-label-Resource+collections+options+] shown above can be used as parameter
42
132
  def get_stories(options = nil)
43
133
  return @client.raw("get", "/content/stories", options)
44
134
  end
45
135
 
136
+ ##
137
+ # === Get Story.
138
+ # Get a single story.
139
+ #
140
+ # ==== Parameters
141
+ # * +slug+ - [String] It's the string identifier generated by Mints
142
+ # * +options+ - [Hash] List of {Single Resource Options}[#class-Mints::Pub-label-Single+resource+options] shown above can be used as parameter
46
143
  def get_story(slug, options = nil)
47
-
48
144
  return @client.raw("get", "/content/stories/#{slug}", options)
49
145
  end
50
146
 
147
+ ##
148
+ # === Get Forms.
149
+ # Get a collection of forms.
150
+ #
151
+ # ==== Parameters
152
+ # * +slug+ - [String] It's the string identifier generated by Mints
153
+ # * +options+ - [Hash] List of {Resource collection Options}[#class-Mints::Pub-label-Resource+collections+options+] shown above can be used as parameter
51
154
  def get_forms(options = nil)
52
155
  return @client.raw("get", "/content/forms/{slug}", options)
53
156
  end
54
157
 
158
+ ##
159
+ # === Get Form.
160
+ # Get a single form.
161
+ #
162
+ # ==== Parameters
163
+ # * +slug+ - [String] It's the string identifier generated by Mints
164
+ # * +options+ - [Hash] List of {Single Resource Options}[#class-Mints::Pub-label-Single+resource+options] shown above can be used as parameter
55
165
  def get_form(slug, options = nil)
56
166
  return @client.raw("get", "/content/forms/{slug}", options)
57
167
  end
58
168
 
169
+ ##
170
+ # === Submit Form.
171
+ # Submit a form.
172
+ #
173
+ # ==== Parameters
174
+ # * +data+ - [Hash] Data to be submited
59
175
  def submit_form(data)
60
176
  return @client.raw("post", "/forms/store", nil, data)
61
177
  end
62
178
 
179
+ ##
180
+ # === Get Products.
181
+ # Get a collection of products.
182
+ #
183
+ # ==== Parameters
184
+ # * +options+ - [Hash] List of {Resource collection Options}[#class-Mints::Pub-label-Resource+collections+options+] shown above can be used as parameter
63
185
  def get_products(options = nil)
64
186
  return @client.raw("get", "/ecommerce/products", options)
65
187
  end
66
188
 
189
+ ##
190
+ # === Get Product.
191
+ # Get a single product.
192
+ #
193
+ # ==== Parameters
194
+ # * +slug+ - [String] It's the string identifier generated by Mints
195
+ # * +options+ - [Hash] List of {Single Resource Options}[#class-Mints::Pub-label-Single+resource+options] shown above can be used as parameter
67
196
  def get_product(slug, options = nil)
68
197
  return @client.raw("get", "/ecommerce/products/#{slug}", options)
69
198
  end
70
199
 
200
+ ##
201
+ # === Get Product Brands.
202
+ # Get a collection of product brands.
203
+ #
204
+ # ==== Parameters
205
+ # * +options+ - [Hash] List of {Resource collection Options}[#class-Mints::Pub-label-Resource+collections+options+] shown above can be used as parameter
71
206
  def get_product_brands(options = nil)
72
207
  return @client.raw("get", "/ecommerce/product-brands", options)
73
208
  end
74
209
 
210
+ ##
211
+ # === Get Product Brand.
212
+ # Get a product brand.
213
+ #
214
+ # ==== Parameters
215
+ # * +slug+ - [String] It's the string identifier generated by Mints
216
+ # * +options+ - [Hash] List of {Single Resource Options}[#class-Mints::Pub-label-Single+resource+options] shown above can be used as parameter
75
217
  def get_product_brand(slug, options = nil)
76
218
  return @client.raw("get", "/ecommerce/product-brands/#{slug}", options)
77
219
  end
78
220
 
221
+ ##
222
+ # === Get SKUs.
223
+ # Get a collection of SKUs.
224
+ #
225
+ # ==== Parameters
226
+ # * +options+ - [Hash] List of {Resource collection Options}[#class-Mints::Pub-label-Resource+collections+options+] shown above can be used as parameter
79
227
  def get_skus(options = nil)
80
228
  return @client.raw("get", "/ecommerce/skus", options)
81
229
  end
82
230
 
231
+ ##
232
+ # === Get SKU.
233
+ # Get a single SKU.
234
+ #
235
+ # ==== Parameters
236
+ # * +slug+ - [String] It's the string identifier generated by Mints
237
+ # * +options+ - [Hash] List of {Single Resource Options}[#class-Mints::Pub-label-Single+resource+options] shown above can be used as parameter
83
238
  def get_sku(slug, options = nil)
84
239
  return @client.raw("get", "/ecommerce/skus/#{slug}", options)
85
240
  end
86
241
 
242
+ ##
243
+ # === Get categories.
244
+ # Get a collection of categories.
245
+ #
246
+ # ==== Parameters
247
+ # * +options+ - [Hash] List of {Resource collection Options}[#class-Mints::Pub-label-Resource+collections+options+] shown above can be used as parameter
87
248
  def get_categories(options = nil)
88
249
  return @client.raw("get", "/config/categories", options)
89
250
  end
90
251
 
252
+ ##
253
+ # === Get Category.
254
+ # Get a single category
255
+ #
256
+ # ==== Parameters
257
+ # * +slug+ - [String] It's the string identifier generated by Mints
258
+ # * +options+ - [Hash] List of {Single Resource Options}[#class-Mints::Pub-label-Single+resource+options] shown above can be used as parameter
91
259
  def get_category(slug, options = nil)
92
260
  return @client.raw("get", "/config/categories/#{slug}", options)
93
261
  end
94
262
 
263
+ ##
264
+ # === Get Tags.
265
+ # Get a collection of tags.
266
+ #
267
+ # ==== Parameters
268
+ # * +options+ - [Hash] List of {Resource collection Options}[#class-Mints::Pub-label-Resource+collections+options+] shown above can be used as parameter
95
269
  def get_tags(options)
96
270
  return @client.raw("get", "/config/tags", options)
97
271
  end
98
272
 
273
+ ##
274
+ # === Get Tag.
275
+ # Get a single tag
276
+ #
277
+ # ==== Parameters
278
+ # * +slug+ - [String] It's the string identifier generated by Mints
279
+ # * +options+ - [Hash] List of {Single Resource Options}[#class-Mints::Pub-label-Single+resource+options] shown above can be used as parameter
99
280
  def get_tag(slug, options = nil)
100
281
  return @client.raw("get", "/config/tags/#{slug}", options)
101
282
  end
102
283
 
284
+ ##
285
+ # === Get Attributes.
286
+ # Get a collection of attributes.
287
+ #
288
+ # ==== Parameters
289
+ # * +options+ - [Hash] List of {Resource collection Options}[#class-Mints::Pub-label-Resource+collections+options+] shown above can be used as parameter
103
290
  def get_attributes(options = nil)
104
291
  return @client.raw("get", "/config/attributes", options)
105
292
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mints
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ruben Gomez Garcia, Omar Mora
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-03 00:00:00.000000000 Z
11
+ date: 2020-04-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json