mints 0.0.7 → 0.0.8

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0d223884b10724746bee9c19bca2cfb4bed7678c48401fa5d5ff06424c81cf76
4
- data.tar.gz: 80476fdc59a576a8d13a99176a0b2c91980fce8bb47b2a86d71201d751fe4004
3
+ metadata.gz: d5412170b7e05b67da59931e6af7972b56e329d302012392cfc9d97235e0b9de
4
+ data.tar.gz: ba661a85b759c89e2e6c24b10509bd551a127ec46bf6861855352af474384eb3
5
5
  SHA512:
6
- metadata.gz: 5a948225647c432423b0ed981f3e0ddd0605e0e4d5237fa2fa54836a21561cc63cb4dc77f4f5e368f4943210095265c38f0c94cdc4395c38e236611f5289af54
7
- data.tar.gz: 9d2959b4c166326e63de097993a8d06184fc53e3fbee80c3d85357f644ab25873d1e23932880b458765606def346aaaee5dea0ce382a3e014dd852371128c290
6
+ metadata.gz: 67cad01ac699e1c98f5498cbb4f50fce4195abb6fadced35326c9d5e6d9564d10a0d3b406873b43f67430e9b908409f93fcbae021f99bf1265d01f931ea83d3f
7
+ data.tar.gz: d1bea2eac77eda19886a5e97c9c007137131192409036c1c87e36fefd569ccb36e00a40de621749d21f213e77f7899856f2b998187f321518917d9664dfb3899
@@ -26,8 +26,8 @@ module Mints
26
26
  end
27
27
 
28
28
  full_url = "#{@host}#{base_url}#{url}#{uri}"
29
- if action === 'get'
30
- response = self.send("#{@scope}_#{action}", "#{full_url}")
29
+ if action === 'get'
30
+ response = self.send("#{@scope}_#{action}", "#{full_url}")
31
31
  elsif action === 'create' or action === 'post'
32
32
  action = 'post'
33
33
  response = self.send("#{@scope}_#{action}", "#{full_url}", data)
@@ -183,7 +183,8 @@ module Mints
183
183
  def contact_get(url)
184
184
  headers = {
185
185
  "ApiKey" => @api_key,
186
- "Accept" => "application/json"
186
+ "Accept" => "application/json",
187
+ "ContactToken" => @contact_token
187
188
  }
188
189
  headers["Authorization"] = "Bearer #{@session_token}" if @session_token
189
190
  return self.http_get(url, headers)
@@ -192,7 +193,8 @@ module Mints
192
193
  def contact_post(url, data)
193
194
  headers = {
194
195
  "ApiKey" => @api_key,
195
- "Accept" => "application/json"
196
+ "Accept" => "application/json",
197
+ "ContactToken" => @contact_token
196
198
  }
197
199
  headers["Authorization"] = "Bearer #{@session_token}" if @session_token
198
200
  return self.http_post(url, headers, data)
@@ -201,7 +203,8 @@ module Mints
201
203
  def contact_put(url, data)
202
204
  headers = {
203
205
  "ApiKey" => @api_key,
204
- "Accept" => "application/json"
206
+ "Accept" => "application/json",
207
+ "ContactToken" => @contact_token
205
208
  }
206
209
  headers["Authorization"] = "Bearer #{@session_token}" if @session_token
207
210
  return self.http_post(url, headers, data)
@@ -241,9 +244,9 @@ module Mints
241
244
  h = {
242
245
  "Accept" => "application/json",
243
246
  "Content-Type" => "application/json",
244
- "ApiKey" => @api_key,
245
- "ContactToken" => @session_token
247
+ "ApiKey" => @api_key
246
248
  }
249
+ h["ContactToken"] = @contact_token if @contact_token
247
250
  if headers
248
251
  headers.each do |k,v|
249
252
  h[k] = v
@@ -256,9 +259,9 @@ module Mints
256
259
  h = {
257
260
  "Accept" => "application/json",
258
261
  "Content-Type" => "application/json",
259
- "ApiKey" => @api_key,
260
- "ContactToken" => @session_token
262
+ "ApiKey" => @api_key
261
263
  }
264
+ h["ContactToken"] = @session_token if @session_token
262
265
  if headers
263
266
  headers.each do |k,v|
264
267
  h[k] = v
@@ -271,9 +274,9 @@ module Mints
271
274
  h = {
272
275
  "Accept" => "application/json",
273
276
  "Content-Type" => "application/json",
274
- "ApiKey" => @api_key,
275
- "ContactToken" => @session_token
277
+ "ApiKey" => @api_key
276
278
  }
279
+ h["ContactToken"] = @contact_token if @contact_token
277
280
  if headers
278
281
  headers.each do |k,v|
279
282
  h[k] = v
@@ -1,4 +1,5 @@
1
1
  require_relative "./client.rb"
2
+ include ActionController::Cookies
2
3
  module Mints
3
4
  class Contact
4
5
  attr_reader :client
@@ -10,20 +11,6 @@ module Mints
10
11
  @client = Mints::Client.new(host, api_key, "contact", session_token, debug)
11
12
  end
12
13
 
13
- ##
14
- # === Register.
15
- # Register a new contact
16
- #
17
- def register(given_name, last_name, email, password)
18
- data = {
19
- given_name: given_name,
20
- last_name: last_name,
21
- email: email,
22
- password: password
23
- }
24
- return @client.raw("post", "/contacts/register", nil, {data: data})
25
- end
26
-
27
14
  ##
28
15
  # === Login.
29
16
  # Starts a contact session
@@ -24,8 +24,11 @@ module Mints
24
24
  response = @mints_contact.login(email, password)
25
25
  # Get session token from response
26
26
  session_token = response['session_token']
27
+ id_token = response['contact']['id_token']
27
28
  # Set a permanent cookie with the session token
28
29
  cookies.permanent[:mints_contact_session_token] = session_token
30
+ cookies.permanent[:mints_contact_id] = id_token
31
+ @contact_token = id_token
29
32
  end
30
33
 
31
34
  ##
@@ -36,6 +39,8 @@ module Mints
36
39
  @mints_contact.logout
37
40
  # Delete local cookie
38
41
  cookies.delete(:mints_contact_session_token)
42
+ cookies.delete(:mints_contact_id)
43
+ @contact_token = nil
39
44
  end
40
45
 
41
46
  private
@@ -21,7 +21,10 @@ module Mints
21
21
  reverse_proxy "#{@host}", headers: headers, verify_ssl: false do |config|
22
22
  # We got a 404!
23
23
  config.on_missing do |code, response|
24
- raise ActionController::RoutingError.new('Not Found')
24
+ # We got a 404!
25
+ if code == 404
26
+ raise ActionController::RoutingError.new('Not Found')
27
+ end
25
28
  end
26
29
  end
27
30
  end
@@ -13,9 +13,12 @@ module Mints
13
13
  'Accept'=> 'application/json'
14
14
  }
15
15
  reverse_proxy "#{@host}", headers: headers, verify_ssl: false do |config|
16
- # We got a 404!
16
+ # Request failed!
17
17
  config.on_missing do |code, response|
18
- raise ActionController::RoutingError.new('Not Found')
18
+ # We got a 404!
19
+ if code == 404
20
+ raise ActionController::RoutingError.new('Not Found')
21
+ end
19
22
  end
20
23
  end
21
24
  end
@@ -19,9 +19,12 @@ module Mints
19
19
  headers["Authorization"] = "Bearer #{session_token}"
20
20
  end
21
21
  reverse_proxy "#{@host}", headers: headers, verify_ssl: false do |config|
22
- # We got a 404!
22
+ # Request failed!
23
23
  config.on_missing do |code, response|
24
- raise ActionController::RoutingError.new('Not Found')
24
+ # We got a 404!
25
+ if code == 404
26
+ raise ActionController::RoutingError.new('Not Found')
27
+ end
25
28
  end
26
29
  end
27
30
  end
data/lib/pub.rb CHANGED
@@ -61,7 +61,7 @@ module Mints
61
61
  user_agent: user_agent || request.user_agent,
62
62
  url: url || request.fullpath
63
63
  }
64
- response = @client.raw("post", "/register-visit", nil, data)
64
+ response = @client.raw("post", "/register-visit", nil, data.to_json)
65
65
  return response
66
66
  end
67
67
 
metadata CHANGED
@@ -1,10 +1,10 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mints
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
- - Ruben Gomez Garcia, Omar Mora
7
+ - Ruben Gomez Garcia, Omar Mora, Luis Payan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []