mints 0.0.16 → 0.0.17

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d9cce05094ead82499622fb1f66d7caa52848d7940c484917218563d32defa16
4
- data.tar.gz: 88e34ca4adfe1f77097206463f6c24a6479b63f2cfdf92bf3106152c00b8dd5a
3
+ metadata.gz: 5f269f998c9cc9cb3dc69f3ec70cc2ff4522a97c14a9da0bfb6ca4cba40b0654
4
+ data.tar.gz: e6b867ce7e3623b05c7aad402462f09b0b1a71a3750549c669407bcff6d2aa2b
5
5
  SHA512:
6
- metadata.gz: fbd81e5fed7023a5b3d489c66bbcc1efa3304d2fe6a7492aef0f0c72f51ad98c2c77635377858e19df92d61fd5a1c26d7d7758d0fde57c223ee9c9968faf0337
7
- data.tar.gz: 6f8672d582a57aa9f2128b73b6fb8133387ea604082557b146eadc321cd9fbcd55a9da4bbba4ac9541cfc3225edcc6826858f314b104abea0bf887bd87bc5a0c
6
+ metadata.gz: 1128997e3df23340e780e4dcc9bb84389df6062eaae3683dff653b440887a5c4d04059141e8472e3762c3ce856df795c26ef7e376c72c38e494880aef5ab830b
7
+ data.tar.gz: '09b6774bb218dc40cd0083fc54428225999736f5452911c7b482a22b928d41dea91fe343ecbab96543be6c602393f6f13aaa9d9d1ee489b8e4a697bf61eda20f'
data/lib/client.rb CHANGED
@@ -246,7 +246,7 @@ module Mints
246
246
  "ContactToken" => @contact_token_id
247
247
  }
248
248
  headers["Authorization"] = "Bearer #{@session_token}" if @session_token
249
- return self.http_post(url, headers, data)
249
+ return self.http_put(url, headers, data)
250
250
  end
251
251
 
252
252
  # Start User context
data/lib/contact.rb CHANGED
@@ -15,6 +15,13 @@ module Mints
15
15
  # === Login.
16
16
  # Starts a contact session
17
17
  #
18
+ # ==== Parameters:
19
+ # * +email+ - [_String_] The email that will be logged.
20
+ # * +password+ - [_String_] The password of the email.
21
+ #
22
+ # ==== Example
23
+ # @mints_contact.login("brown.abigail@dubuque.com", "helloword")
24
+ #
18
25
  def login(email, password)
19
26
  data = {
20
27
  email: email,
@@ -29,7 +36,15 @@ module Mints
29
36
 
30
37
  ##
31
38
  # === Magic Link Login.
32
- # Starts a contact session
39
+ # Starts a contact session with a token received in the contact email. The token will be received by send_magic_link method.
40
+ #
41
+ # ==== Parameters:
42
+ # * +token+ - [_String_] The email that will be logged.
43
+ #
44
+ # ==== Example
45
+ # @mints_contact.magic_link_login(
46
+ # "d8618c6d-a165-41cb-b3ec-d053cbf30059:zm54HtRdfHED8dpILZpjyqjPIceiaXNLfOklqM92fveBS0nDtyPYBlI4CPlPe3zq"
47
+ # )
33
48
  #
34
49
  def magic_link_login(token)
35
50
  response = @client.raw("get", "/contacts/magic-link-login/#{token}", nil, '/api/v1')
@@ -40,7 +55,22 @@ module Mints
40
55
  end
41
56
 
42
57
  ##
43
- # === Send magic link to contact
58
+ # === Send Magic Link
59
+ # Send magic link to contact by email. That magic link will be used in magic_link_login method.
60
+ #
61
+ # ==== Parameters:
62
+ # * +email+ - [_String_] Contact's email.
63
+ # * +template_slug+ - [_String_] Email template's slug to be used in the email.
64
+ # * +redirectUrl+ - [_String_] Url to be redirected in the implemented page.
65
+ # * +lifeTime+ - [_Integer_] Maximum time of use in minutes.
66
+ # * +maxVisits+ - [_Integer_] The maximum number of uses of a token.
67
+ #
68
+ # ==== First Example
69
+ # @mints_contact.send_magic_link("brown.abigail@dubuque.com", "")
70
+ #
71
+ # ==== Second Example
72
+ # @mints_contact.send_magic_link("brown.abigail@dubuque.com", "", "", 1440, 3)
73
+ #
44
74
  def send_magic_link(email, template_slug, redirectUrl = '', lifeTime = 1440, maxVisits = nil)
45
75
  data = {
46
76
  email: email,
@@ -55,7 +85,11 @@ module Mints
55
85
 
56
86
  ##
57
87
  # === Logout.
58
- # Ends a contact session
88
+ # Ends a contact session previously logged.
89
+ #
90
+ # ==== Example
91
+ # @mints_contact.login('brown.abigail@dubuque.com', 'helloword')
92
+ # @mints_contact.logout
59
93
  #
60
94
  def logout
61
95
  response = @client.raw("post", "/contacts/logout") if session_token?
@@ -67,7 +101,15 @@ module Mints
67
101
 
68
102
  ##
69
103
  # === Change Password.
70
- # Change password
104
+ # Change password without email. To change the password a contact must be logged.
105
+ #
106
+ # ==== Parameters:
107
+ # * +data+ - [] A new password allocated in a data key.
108
+ #
109
+ # ==== Example
110
+ # @mints_contact.login('brown.abigail@dubuque.com', 'helloword')
111
+ # data = { "data": { "password": "123456" } }
112
+ # @mints_contact.change_password(data)
71
113
  #
72
114
  def change_password(data)
73
115
  return @client.raw("post", "/contacts/change-password", nil, data)
@@ -75,7 +117,14 @@ module Mints
75
117
 
76
118
  ##
77
119
  # === Recover Password.
78
- # Recover password
120
+ # Send a email that contains a token to a contact. That token will be used in reset_password to establish a new password.
121
+ #
122
+ # ==== Parameters:
123
+ # * +data+ - [] It's a data key where will be hosted the destination email.
124
+ #
125
+ # ==== Example
126
+ # data = { "data": { "email": "brown.abigail@dubuque.com" } }
127
+ # @mints_contact.recover_password(data)
79
128
  #
80
129
  def recover_password(data)
81
130
  return @client.raw("post", "/contacts/recover-password", nil, data)
@@ -83,7 +132,19 @@ module Mints
83
132
 
84
133
  ##
85
134
  # === Reset Password.
86
- # Reset password
135
+ # Reset password using a token. The token is obtained by recover_password method.
136
+ #
137
+ # ==== Parameters:
138
+ # * +data+ - [] It's a set of data which contains all the information to reset a contact password.
139
+ #
140
+ # ==== Example
141
+ # data = { "data": {
142
+ # "email": "brown.abigail@dubuque.com",
143
+ # "password": "helloword",
144
+ # "password_confirmation": "helloword",
145
+ # "token": "644aa3aa0831d782cc42e42b11aedea9a2234389af4f429a8d96651295ecfa09"
146
+ # } }
147
+ # @mints_contact.reset_password(data)
87
148
  #
88
149
  def reset_password(data)
89
150
  return @client.raw("post", "/contacts/reset-password", nil, data)
@@ -99,7 +160,10 @@ module Mints
99
160
 
100
161
  ##
101
162
  # === Me.
102
- # Get contact logged info
163
+ # Get contact logged info.
164
+ #
165
+ # ==== Example
166
+ # @mints_contact.me
103
167
  #
104
168
  def me
105
169
  return @client.raw("get", "/contacts/me")
@@ -107,7 +171,10 @@ module Mints
107
171
 
108
172
  ##
109
173
  # === Status.
110
- # Get contact logged status
174
+ # Get contact logged status.
175
+ #
176
+ # ==== Example
177
+ # @mints_contact.status
111
178
  #
112
179
  def status
113
180
  return @client.raw("get", "/contacts/status")
@@ -115,12 +182,43 @@ module Mints
115
182
 
116
183
  ##
117
184
  # === Update.
118
- # Update logged contact attributes
185
+ # Update logged contact attributes.
186
+ #
187
+ # ==== Parameters:
188
+ # * +data+ - [] It's the data to update with a session active.
189
+ #
190
+ # ==== Example
191
+ # @mints_contact.login("brown.abigail@dubuque.com", "helloword")
192
+ # data = { "data": {
193
+ # "given_name": "Alonso",
194
+ # "last_name": "Garcia"
195
+ # } }
196
+ # @mints_contact.update(data)
119
197
  #
120
198
  def update(data)
121
199
  return @client.raw("put", "/contacts/update", nil, data)
122
200
  end
123
201
 
202
+ ##
203
+ # === Register.
204
+ # Register a contact.
205
+ #
206
+ # ==== Parameters:
207
+ # * +data+ - [] It's the register data.
208
+ #
209
+ # ==== Example
210
+ # data = { "data": {
211
+ # "email": "carlos@mints.cloud",
212
+ # "given_name": "Carlos",
213
+ # "last_name": "Fernandez",
214
+ # "password": "123456"
215
+ # } }
216
+ # @mints_contact.register(data);
217
+ #
218
+ def register(data)
219
+ return @client.raw("post", "/contacts/register", nil, data)
220
+ end
221
+
124
222
  private
125
223
 
126
224
  def session_token?
@@ -84,7 +84,7 @@ module Mints
84
84
  raise 'MintsBadCredentialsError'
85
85
  end
86
86
  # Initialize mints pub client, credentials taken from mints_config.yml.erb file
87
- @mints_pub = Mints::Pub.new(@host, @api_key, nil, @debug)
87
+ @mints_pub = Mints::Pub.new(@host, @api_key, @contact_token, @debug)
88
88
  # Set contact token from cookie
89
89
  @mints_pub.client.session_token = @contact_token
90
90
  end
data/lib/pub.rb CHANGED
@@ -94,6 +94,15 @@ module Mints
94
94
  # * +ip+ - [String] It's the visitor IP
95
95
  # * +user_agent+ - The visitor's browser user agent
96
96
  # * +url+ - [String] URL visited
97
+ #
98
+ # ==== Example
99
+ # request = {
100
+ # "remote_ip" => "http://864.401.156.12/",
101
+ # "user_agent" => "User Agent",
102
+ # "fullpath" => "https://mints.cloud/blog"
103
+ # }
104
+ # @mints_pub.register_visit(request, request["remote_ip"], request["user_agent"], request["fullpath"])
105
+ #
97
106
  def register_visit(request, ip = nil, user_agent = nil, url = nil)
98
107
  data = {
99
108
  ip_address: ip || request.remote_ip,
@@ -111,6 +120,10 @@ module Mints
111
120
  # ==== Parameters
112
121
  # * +visit+ - [String] It's the visitor IP
113
122
  # * +time+ - [Integer] The visitor's browser user agent
123
+ #
124
+ # ==== Example
125
+ # @mints_pub.register_visit_timer("60da2325d29acc7e55684472", 4)
126
+ #
114
127
  def register_visit_timer(visit, time)
115
128
  return @client.raw("get", "/register-visit-timer?visit=#{visit}&time=#{time}")
116
129
  end
@@ -121,6 +134,10 @@ module Mints
121
134
  #
122
135
  # ==== Parameters
123
136
  # * +slug+ - [String] It's the string identifier of the asset.
137
+ #
138
+ # ==== Example
139
+ # @mints_pub.get_asset_info("quaerat")
140
+ #
124
141
  def get_asset_info(slug)
125
142
  return @client.raw("get", "/content/asset-info/#{slug}")
126
143
  end
@@ -131,6 +148,10 @@ module Mints
131
148
  #
132
149
  # ==== Parameters
133
150
  # * +options+ - [Hash] List of {Resource collection Options}[#class-Mints::Pub-label-Resource+collections+options+] shown above can be used as parameter
151
+ #
152
+ # ==== Example
153
+ # @mints_pub.get_stories
154
+ #
134
155
  def get_stories(options = nil)
135
156
  return @client.raw("get", "/content/stories", options)
136
157
  end
@@ -142,6 +163,10 @@ module Mints
142
163
  # ==== Parameters
143
164
  # * +slug+ - [String] It's the string identifier generated by Mints
144
165
  # * +options+ - [Hash] List of {Single Resource Options}[#class-Mints::Pub-label-Single+resource+options] shown above can be used as parameter
166
+ #
167
+ # ==== Example
168
+ # @mints_pub.get_story("getting-ready-for-e3")
169
+ #
145
170
  def get_story(slug, options = nil)
146
171
  return @client.raw("get", "/content/stories/#{slug}", options)
147
172
  end
@@ -152,6 +177,10 @@ module Mints
152
177
  #
153
178
  # ==== Parameters
154
179
  # * +options+ - [Hash] List of {Resource collection Options}[#class-Mints::Pub-label-Resource+collections+options+] shown above can be used as parameter
180
+ #
181
+ # ==== Example
182
+ # @mints_pub.get_forms
183
+ #
155
184
  def get_forms(options = nil)
156
185
  return @client.raw("get", "/content/forms", options)
157
186
  end
@@ -163,6 +192,10 @@ module Mints
163
192
  # ==== Parameters
164
193
  # * +slug+ - [String] It's the string identifier generated by Mints
165
194
  # * +options+ - [Hash] List of {Single Resource Options}[#class-Mints::Pub-label-Single+resource+options] shown above can be used as parameter
195
+ #
196
+ # ==== Example
197
+ # @mints_pub.get_form("survey")
198
+ #
166
199
  def get_form(slug, options = nil)
167
200
  return @client.raw("get", "/content/forms/#{slug}", options)
168
201
  end
@@ -173,13 +206,24 @@ module Mints
173
206
  #
174
207
  # ==== Parameters
175
208
  # * +data+ - [Hash] Data to be submited
209
+ #
210
+ # ==== Example
211
+ # data_form = {
212
+ # "data": {
213
+ # 'form_slug': 'formulario',
214
+ # 'email': 'oscar@mints.cloud',
215
+ # 'ingrese-un-texto': 'hola'
216
+ # }
217
+ # }
218
+ # @mints_pub.submit_form(data_form.to_json)
219
+ #
176
220
  def submit_form(data)
177
221
  return @client.raw("post", "/content/forms/submit", nil, data)
178
222
  end
179
223
 
180
224
  ##
181
225
  # === Get Content Instances.
182
- # Get a collection of content instances
226
+ # Get a collection of content instances. _Note:_ Options must be specified.
183
227
  #
184
228
  # ==== Parameters
185
229
  # * +options+ - [Hash] List of {Resource collection Options}[#class-Mints::Pub-label-Resource+collections+options+] shown above can be used as parameter
@@ -194,6 +238,10 @@ module Mints
194
238
  # ==== Parameters
195
239
  # * +slug+ - [String] It's the string identifier generated by Mints
196
240
  # * +options+ - [Hash] List of {Single Resource Options}[#class-Mints::Pub-label-Single+resource+options] shown above can be used as parameter
241
+ #
242
+ # ==== Example
243
+ # @mints_pub.get_content_instance("bill-gates")
244
+ #
197
245
  def get_content_instance(slug, options = nil)
198
246
  return @client.raw("get", "/content/content-instances/#{slug}", options)
199
247
  end
@@ -215,6 +263,10 @@ module Mints
215
263
  # ==== Parameters
216
264
  # * +slug+ - [String] It's the slug
217
265
  # * +options+ - [Hash] List of {Single Resource Options}[#class-Mints::Pub-label-Single+resource+options] shown above can be used as parameter
266
+ #
267
+ # ==== Example
268
+ # @mints_pub.get_content_page("test-page")
269
+ #
218
270
  def get_content_page(slug, options = nil)
219
271
  return @client.raw("get", "/content/content-pages/#{slug}", options)
220
272
  end
@@ -225,6 +277,10 @@ module Mints
225
277
  #
226
278
  # ==== Parameters
227
279
  # * +options+ - [Hash] List of {Resource collection Options}[#class-Mints::Pub-label-Resource+collections+options+] shown above can be used as parameter
280
+ #
281
+ # ==== Example
282
+ # @mints_pub.get_locations
283
+ #
228
284
  def get_locations(options = nil)
229
285
  return @client.raw("get", "/ecommerce/locations", options)
230
286
  end
@@ -235,6 +291,10 @@ module Mints
235
291
  #
236
292
  # ==== Parameters
237
293
  # * +options+ - [Hash] List of {Resource collection Options}[#class-Mints::Pub-label-Resource+collections+options+] shown above can be used as parameter
294
+ #
295
+ # ==== Example
296
+ # @mints_pub.get_products
297
+ #
238
298
  def get_products(options = nil)
239
299
  return @client.raw("get", "/ecommerce/products", options)
240
300
  end
@@ -246,6 +306,10 @@ module Mints
246
306
  # ==== Parameters
247
307
  # * +slug+ - [String] It's the string identifier generated by Mints
248
308
  # * +options+ - [Hash] List of {Single Resource Options}[#class-Mints::Pub-label-Single+resource+options] shown above can be used as parameter
309
+ #
310
+ # ==== Example
311
+ # @mints_pub.get_product("batman-shirt")
312
+ #
249
313
  def get_product(slug, options = nil)
250
314
  return @client.raw("get", "/ecommerce/products/#{slug}", options)
251
315
  end
@@ -256,6 +320,12 @@ module Mints
256
320
  #
257
321
  # ==== Parameters
258
322
  # * +options+ - [Hash] List of {Resource collection Options}[#class-Mints::Pub-label-Resource+collections+options+] shown above can be used as parameter
323
+ #
324
+ # ==== Example
325
+ # options = {
326
+ # "object_type": "stories"
327
+ # }
328
+ # @mints_pub.get_categories(options)
259
329
  def get_categories(options = nil)
260
330
  return @client.raw("get", "/config/categories", options)
261
331
  end
@@ -267,6 +337,13 @@ module Mints
267
337
  # ==== Parameters
268
338
  # * +slug+ - [String] It's the string identifier generated by Mints
269
339
  # * +options+ - [Hash] List of {Single Resource Options}[#class-Mints::Pub-label-Single+resource+options] shown above can be used as parameter
340
+ #
341
+ # ==== Example
342
+ # options = {
343
+ # "object_type": "locations"
344
+ # }
345
+ # @mints_pub.get_category("atm", options)
346
+ #
270
347
  def get_category(slug, options = nil)
271
348
  return @client.raw("get", "/config/categories/#{slug}", options)
272
349
  end
@@ -277,6 +354,10 @@ module Mints
277
354
  #
278
355
  # ==== Parameters
279
356
  # * +options+ - [Hash] List of {Resource collection Options}[#class-Mints::Pub-label-Resource+collections+options+] shown above can be used as parameter
357
+ #
358
+ # ==== Example
359
+ # @mints_pub.get_tags
360
+ #
280
361
  def get_tags(options = nil)
281
362
  return @client.raw("get", "/config/tags", options)
282
363
  end
@@ -288,6 +369,10 @@ module Mints
288
369
  # ==== Parameters
289
370
  # * +slug+ - [String] It's the string identifier generated by Mints
290
371
  # * +options+ - [Hash] List of {Single Resource Options}[#class-Mints::Pub-label-Single+resource+options] shown above can be used as parameter
372
+ #
373
+ # ==== Example
374
+ # @mints_pub.get_tag("ad-0")
375
+ #
291
376
  def get_tag(slug, options = nil)
292
377
  return @client.raw("get", "/config/tags/#{slug}", options)
293
378
  end
@@ -298,6 +383,10 @@ module Mints
298
383
  #
299
384
  # ==== Parameters
300
385
  # * +options+ - [Hash] List of {Resource collection Options}[#class-Mints::Pub-label-Resource+collections+options+] shown above can be used as parameter
386
+ #
387
+ # ==== Example
388
+ # @mints_pub.get_taxonomies
389
+ #
301
390
  def get_taxonomies(options = nil)
302
391
  return @client.raw("get", "/config/taxonomies", options)
303
392
  end
@@ -309,6 +398,10 @@ module Mints
309
398
  # ==== Parameters
310
399
  # * +slug+ - [String] It's the string identifier generated by Mints
311
400
  # * +options+ - [Hash] List of {Single Resource Options}[#class-Mints::Pub-label-Single+resource+options] shown above can be used as parameter
401
+ #
402
+ # ==== Example
403
+ # @mints_pub.get_taxonomy("unit_pricing_measure")
404
+ #
312
405
  def get_taxonomy(slug, options = nil)
313
406
  return @client.raw("get", "/config/taxonomies/#{slug}", options)
314
407
  end
@@ -319,6 +412,10 @@ module Mints
319
412
  #
320
413
  # ==== Parameters
321
414
  # * +options+ - [Hash] List of {Resource collection Options}[#class-Mints::Pub-label-Resource+collections+options+] shown above can be used as parameter
415
+ #
416
+ # ==== Example
417
+ # @mints_pub.get_attributes
418
+ #
322
419
  def get_attributes(options = nil)
323
420
  return @client.raw("get", "/config/attributes", options)
324
421
  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.16
4
+ version: 0.0.17
5
5
  platform: ruby
6
6
  authors:
7
- - Ruben Gomez Garcia, Omar Mora, Luis Payan
7
+ - Ruben Gomez Garcia, Omar Mora, Luis Payan, Oscar Castillo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-07-19 00:00:00.000000000 Z
11
+ date: 2021-08-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json