cxf 0.0.8 → 0.0.10

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: 87b5b469db91be135d0c9d51f542cd8ac55018185fdb483494d7e890c9eb7b02
4
- data.tar.gz: 33c7250ad7a53edf5f3c5edbbf190b10ccfdeb557c7bbfd55c977b6955bd9964
3
+ metadata.gz: 246c5eea21062e4eb7d0e0772e7df0acd2987c357914dee2e54735a29ff5fd85
4
+ data.tar.gz: 34ca8eb356a52c6c0953714c95641146207a41ad0a3e02b8f2b238c21eae624d
5
5
  SHA512:
6
- metadata.gz: 5d1ad4b14251ffdd1d79cad7039811f0c9c21b20a6b9f15717665367dfc6faee96839134866e29f473d4dbddcfb00c74978d57efce0254f11360a1db1d669dbd
7
- data.tar.gz: d8d9e887757172158c488625366459fb54f62960f6069883a08bf8010f7f07ac75d6652f51e471b2662c6bfb2b2da3dedd33b2f1304c5ade9f9cadb9d1cef5ab
6
+ metadata.gz: '06448d601509b4a7e633a94e5cea0385abab18f3cd99016858543b0743f88aa897421b335c3b78f10323d8b4db4d2fc2e400ed4f38f7174b363e980f649e4d30'
7
+ data.tar.gz: b4f3d116ca2aa89d1741cbde9ba6c1e73bd2b3ddb5b09bbca852032868717b1f639036e9773bd85a63032cbd98880b136fcc7815ee17ad54b70328ee65d53aee
data/README.md CHANGED
@@ -25,8 +25,8 @@ class ApplicationController < ActionController::Base
25
25
  include UserAuthHelper # if you log in with a user
26
26
  include ContactAuthHelper # if you log in with a contact
27
27
 
28
- after_action :update_user_tokens # if you haven't run the generator yet and you log in with a user
29
- after_action :update_contact_tokens # if you haven't run the generator yet and you log in with a contact
28
+ after_action :sync_user_cookies # if you haven't run the generator yet and you log in with a user
29
+ after_action :sync_contact_cookies # if you haven't run the generator yet and you log in with a contact
30
30
  end
31
31
  ```
32
32
 
@@ -142,7 +142,8 @@ it to the groups array and set the cache time.
142
142
  # Cxf connection configuration
143
143
  cxf:
144
144
  host: http://your_host_goes_here.com
145
- api_key: your_cxf_api_key_goes_here
145
+ user_api_key: your_cxf_user_api_key_goes_here
146
+ contact_api_key: your_cxf_contact_api_key_goes_here
146
147
  cxf_slug: slug_id #save id and token in redis
147
148
  redis_cache:
148
149
  use_cache: boolean_value_to_enable_and_disable_cache
data/lib/client.rb CHANGED
@@ -13,14 +13,12 @@ module Cxf
13
13
  include CxfHelper
14
14
 
15
15
  attr_reader :host, :mode, :api_key, :scope, :base_url
16
- attr_accessor :session_token, :refresh_token, :contact_token_id, :user_agent
16
+ attr_accessor :contact_token_id, :user_agent, :response_cookies
17
17
 
18
18
  def initialize(
19
19
  host,
20
20
  api_key,
21
21
  scope = nil,
22
- session_token = nil,
23
- refresh_token = nil,
24
22
  contact_token_id = nil,
25
23
  visit_id = nil,
26
24
  debug = false,
@@ -29,12 +27,11 @@ module Cxf
29
27
 
30
28
  @host = host
31
29
  @api_key = api_key
32
- @session_token = session_token
33
- @refresh_token = refresh_token
34
30
  @contact_token_id = contact_token_id
35
31
  @visit_id = visit_id
36
32
  @debug = debug
37
33
  @user_agent = nil
34
+ @response_cookies = nil
38
35
 
39
36
  config = read_config_file('sdk') || {}
40
37
 
@@ -130,21 +127,21 @@ module Cxf
130
127
 
131
128
  unless url_need_cache
132
129
  response = self.send("#{@scope}_#{action}", full_url, nil, compatibility_options)
133
- replace_tokens(response)
130
+ set_cookies(response.headers)
134
131
  end
135
132
 
136
133
  elsif action === 'create' or action === 'post'
137
134
  action = 'post'
138
135
  response = self.send("#{@scope}_#{action}", full_url, data, compatibility_options)
139
- replace_tokens(response)
136
+ set_cookies(response.headers)
140
137
  elsif action === 'put' or action === 'patch' or action === 'update'
141
138
  action = 'put'
142
139
  response = self.send("#{@scope}_#{action}", full_url, data, compatibility_options)
143
- replace_tokens(response)
140
+ set_cookies(response.headers)
144
141
  elsif action === 'delete' or action === 'destroy'
145
142
  action = 'delete'
146
143
  response = self.send("#{@scope}_#{action}", full_url, data, compatibility_options)
147
- replace_tokens(response)
144
+ set_cookies(response.headers)
148
145
  end
149
146
 
150
147
  response = verify_response_status(response, config['sdk']['ignore_http_errors'])
@@ -347,19 +344,28 @@ module Cxf
347
344
  self.http_put(url, set_headers(compatibility_options, headers), data)
348
345
  end
349
346
 
347
+ def get_tokens
348
+ if @scope === 'user'
349
+ return { access_token: @response_cookies['cxf_user_access_token'], refresh_token: @response_cookies['cxf_user_refresh_token'] }
350
+ else
351
+ return { access_token: @response_cookies['cxf_contact_access_token'], refresh_token: @response_cookies['cxf_contact_refresh_token'] }
352
+ end
353
+ end
354
+
350
355
  def set_headers(compatibility_options, headers = nil)
351
356
  h = {
352
357
  'Accept' => 'application/json',
353
358
  'ApiKey' => @api_key,
354
- 'Access-Token' => @session_token || '',
355
- 'Refresh-Token' => @refresh_token || ''
356
359
  }
357
360
  h['Content-Type'] = 'application/json' unless compatibility_options['no_content_type']
358
361
  h['ContactToken'] = @contact_token_id if @contact_token_id
359
362
  h['Visit-Id'] = @visit_id if @visit_id
360
- h['Authorization'] = "Bearer #{@session_token}" if @session_token
361
363
  h['User-Agent'] = @user_agent if @user_agent
362
364
 
365
+ tokens = get_tokens
366
+ h['Access-Token'] = tokens[:access_token]
367
+ h['Refresh-Token'] = tokens[:refresh_token]
368
+
363
369
  if headers
364
370
  headers.each do |k, v|
365
371
  h[k] = v
@@ -441,11 +447,84 @@ module Cxf
441
447
  str.pluralize != str && str.singularize == str
442
448
  end
443
449
 
444
- def replace_tokens(response)
445
- return unless response&.headers
450
+ def set_cookies(headers)
451
+ string_headers = headers['set-cookie'];
452
+ # use parse_cookies_header of rack
453
+ @response_cookies = parse_set_cookies(headers['set-cookie'])
454
+
455
+ # parsed_cookies.each_value do |cookie|
456
+ # Rack::Utils.set_cookie_header!(
457
+ # response.headers,
458
+ # cookie['name'],
459
+ # {
460
+ # value: cookie['value'],
461
+ # expires: cookie['expires'] ? Time.parse(cookie['expires']) : nil,
462
+ # path: cookie['path'] || '/',
463
+ # domain: '', # especificar si necesitas uno
464
+ # secure: cookie['secure'] || false,
465
+ # httponly: cookie['httponly'] || false,
466
+ # same_site: (cookie['samesite'] || 'Lax').capitalize
467
+ # }
468
+ # )
469
+ # end
470
+ end
446
471
 
447
- @session_token = response.headers['Access-Token'] if response.headers.key?('Access-Token')
448
- @refresh_token = response.headers['Refresh-Token'] if response.headers.key?('Refresh-Token')
472
+ # def split_cookie_header(header_string)
473
+ # header_string.scan(/(?:^|, )([^=;]+=[^;]+(?:;[^,]*)*)/).flatten
474
+ # end
475
+
476
+ def parse_set_cookies(header_string)
477
+ return {} unless header_string.is_a?(String)
478
+
479
+ cookies = []
480
+ buffer = ''
481
+ inside_cookie = false
482
+
483
+ # Split cookies
484
+ header_string.split(',').each do |part|
485
+ if part.strip =~ /^[^=]+=/ && !inside_cookie
486
+ buffer = part
487
+ inside_cookie = true
488
+ elsif part.strip.downcase.start_with?('expires=')
489
+ buffer += ',' + part
490
+ elsif inside_cookie && part.strip.include?('=')
491
+ buffer += ',' + part
492
+ cookies << buffer.strip
493
+ buffer = ''
494
+ inside_cookie = false
495
+ else
496
+ buffer += ',' + part
497
+ end
498
+ end
499
+ cookies << buffer.strip unless buffer.empty?
500
+
501
+ parsed = {}
502
+
503
+ cookies.each do |cookie_string|
504
+ parts = cookie_string.split(/;\s*/)
505
+ name_value = parts.shift
506
+ name, value = name_value.split('=', 2)
507
+ next unless name && value
508
+
509
+ cookie = { 'name' => name, 'value' => value }
510
+
511
+ parts.each do |part|
512
+ if part.downcase.start_with?('expires=')
513
+ # Rebuild expires
514
+ cookie['expires'] = part[8..].strip
515
+ elsif part.include?('=')
516
+ k, v = part.split('=', 2)
517
+ cookie[k.strip.downcase] = v.strip
518
+ else
519
+ cookie[part.strip.downcase] = true
520
+ end
521
+ end
522
+
523
+ parsed[name] = cookie
524
+ end
525
+
526
+ parsed
449
527
  end
528
+
450
529
  end
451
530
  end
data/lib/contact.rb CHANGED
@@ -33,8 +33,6 @@ module Cxf
33
33
  def initialize(
34
34
  host,
35
35
  api_key,
36
- session_token = nil,
37
- refresh_token = nil,
38
36
  contact_token_id = nil,
39
37
  debug = false,
40
38
  user_agent = nil,
@@ -45,8 +43,6 @@ module Cxf
45
43
  host,
46
44
  api_key,
47
45
  'contact',
48
- session_token,
49
- refresh_token,
50
46
  contact_token_id,
51
47
  nil,
52
48
  debug,
@@ -74,7 +70,7 @@ module Cxf
74
70
  # }
75
71
  # @cxf_contact.register(data);
76
72
  def register(data)
77
- @client.raw('post', '/contacts/register', nil, data_transform(data))
73
+ @client.raw('post', '/register', nil, data_transform(data))
78
74
  end
79
75
 
80
76
  ##
@@ -92,14 +88,7 @@ module Cxf
92
88
  email: email,
93
89
  password: password
94
90
  }
95
- response = @client.raw('post', '/contacts/login', nil, data_transform(data))
96
-
97
- return response unless response.is_a? Hash
98
- if response.key? 'data' and response['data'].key? 'access_token'
99
- @client.session_token = response['data']['access_token']
100
- @client.refresh_token = response['data']['refresh_token']
101
- end
102
- response
91
+ @client.raw('post', '/login', nil, data_transform(data))
103
92
  end
104
93
 
105
94
  ##
@@ -113,7 +102,7 @@ module Cxf
113
102
  # data = { email: 'email@example.com' }
114
103
  # @cxf_contact.recover_password(data)
115
104
  def recover_password(data)
116
- @client.raw('post', '/contacts/recover-password', nil, data_transform(data))
105
+ @client.raw('post', '/recover-password', nil, data_transform(data))
117
106
  end
118
107
 
119
108
  ##
@@ -132,14 +121,14 @@ module Cxf
132
121
  # }
133
122
  # @cxf_contact.reset_password(data)
134
123
  def reset_password(data)
135
- @client.raw('post', '/contacts/reset-password', nil, data_transform(data))
124
+ @client.raw('post', '/reset-password', nil, data_transform(data))
136
125
  end
137
126
 
138
127
  ##
139
128
  # === OAuth Login.
140
129
  # Login a contact using oauth.
141
130
  def oauth_login(data)
142
- @client.raw('post', '/contacts/oauth-login', nil, data)
131
+ @client.raw('post', '/oauth-login', nil, data)
143
132
  end
144
133
 
145
134
  ##
@@ -154,7 +143,7 @@ module Cxf
154
143
  # 'd8618c6d-a165-41cb-b3ec-d053cbf30059:zm54HtRdfHED8dpILZpjyqjPIceiaXNLfOklqM92fveBS0nDtyPYBlI4CPlPe3zq'
155
144
  # )
156
145
  def magic_link_login(token)
157
- response = @client.raw('get', "/contacts/magic-link-login/#{token}", nil, '/api/v1')
146
+ response = @client.raw('get', "/magic-link-login/#{token}", nil, '/api/v1')
158
147
  @client.session_token = response['session_token'] if response.key? 'session_token'
159
148
 
160
149
  response
@@ -189,7 +178,7 @@ module Cxf
189
178
  else
190
179
  data['email'] = email_or_phone
191
180
  end
192
- @client.raw('post', '/contacts/magic-link', nil, data_transform(data), '/api/v1')
181
+ @client.raw('post', '/magic-link', nil, data_transform(data), '/api/v1')
193
182
  end
194
183
 
195
184
  ### CONTACT/V1 ###
@@ -211,7 +200,7 @@ module Cxf
211
200
  # }
212
201
  # @data = @cxf_contact.me(options)
213
202
  def me(options = nil)
214
- @client.raw('get', '/contacts/me', options, nil)
203
+ @client.raw('get', '/me', options, nil)
215
204
  end
216
205
 
217
206
  ##
@@ -49,7 +49,7 @@ module CxfClients
49
49
 
50
50
  @cxf_pub = Cxf::Pub.new(
51
51
  @host,
52
- @api_key,
52
+ @contact_api_key,
53
53
  contact_token_id,
54
54
  visit_id,
55
55
  @debug,
@@ -62,37 +62,30 @@ module CxfClients
62
62
  # Initialize the contact client and set the contact token
63
63
  def set_cxf_contact_client
64
64
  # Initialize cxf contact client
65
- contact_session_token = cookies["cxf_contact_session_token"]
66
- contact_refresh_token = cookies["cxf_contact_refresh_token"]
67
65
  contact_token_id = cookies[:cxf_contact_id] || nil
68
66
  user_agent = request.user_agent
69
67
  @cxf_contact = Cxf::Contact.new(
70
68
  @host,
71
- @api_key,
72
- contact_session_token,
73
- contact_refresh_token,
69
+ @contact_api_key,
74
70
  contact_token_id,
75
71
  @debug,
76
72
  user_agent
77
73
  )
74
+ @cxf_contact.get_client.response_cookies = cookies
78
75
  end
79
76
 
80
77
  ##
81
78
  # === Set Cxf user client.
82
79
  # Initialize the user client
83
80
  def set_cxf_user_client
84
- # Initialize cxf user client
85
- user_session_token = cookies["cxf_user_session_token"]
86
- user_refresh_token = cookies["cxf_user_refresh_token"]
87
81
  user_agent = request.user_agent
88
82
  @cxf_user = Cxf::User.new(
89
83
  @host,
90
- @api_key,
91
- user_session_token,
92
- user_refresh_token,
84
+ @user_api_key,
93
85
  @debug,
94
86
  user_agent
95
87
  )
88
+ @cxf_user.get_client.response_cookies = cookies
96
89
  end
97
90
 
98
91
  ##
@@ -103,9 +96,7 @@ module CxfClients
103
96
  user_agent = request.user_agent
104
97
  @cxf_service_account = Cxf::User.new(
105
98
  @host,
106
- @api_key, # api token
107
- @api_key, # session token
108
- @api_key, # refresh token
99
+ @user_api_key, # api token
109
100
  @debug,
110
101
  user_agent
111
102
  )
@@ -13,7 +13,8 @@ module ReadConfigFile
13
13
  config = YAML.safe_load template.result(binding)
14
14
 
15
15
  @host = config.dig('cxf', 'host')
16
- @api_key = config.dig('cxf', 'api_key')
16
+ @user_api_key = config.dig('cxf', 'user_api_key')
17
+ @contact_api_key = config.dig('cxf', 'contact_api_key')
17
18
  @debug = !!config.dig('cxf', 'debug')
18
19
  @redis_config = config.dig('cxf', 'redis_cache')
19
20
  @use_cache = config.dig('cxf', 'redis_cache', 'use_cache')
@@ -11,16 +11,12 @@ module ContactAuthHelper
11
11
  # Get session token from response
12
12
  return response unless response.is_a? Hash
13
13
  if response.key? 'data'
14
- session_token = response['data']['access_token']
15
- refresh_token = response['data']['refresh_token']
16
14
  id_token = response['data']['contact_token'] || response['data']['id_token'] || nil
17
15
  end
18
16
 
19
- # Set a permanent cookie with the session token
20
- cookies.permanent["cxf_contact_session_token"] = { value: session_token, secure: true, httponly: true }
21
- cookies.permanent["cxf_contact_refresh_token"] = { value: refresh_token, secure: true, httponly: true }
22
- # cookies.permanent[:cxf_contact_id] = { value: id_token, secure: true, httponly: true }
23
17
  @contact_token = id_token
18
+
19
+ response
24
20
  end
25
21
 
26
22
  ##
@@ -31,15 +27,6 @@ module ContactAuthHelper
31
27
  response = @cxf_contact.magic_link_login(hash)
32
28
 
33
29
  if response['data']
34
- # Get session token from response
35
- session_token = response['data']['session_token']
36
- refresh_token = response['data']['refresh_token']
37
- # id_token = response['data']['contact']['contact_token'] ? response['data']['contact']['contact_token'] : response['data']['contact']['id_token']
38
- # Set a permanent cookie with the session token
39
- cookies.permanent["cxf_contact_session_token"] = { value: session_token, secure: true, httponly: true }
40
- cookies.permanent["cxf_contact_refresh_token"] = { value: refresh_token, secure: true, httponly: true }
41
- # cookies.permanent[:cxf_contact_id] = { value: id_token, secure: true, httponly: true }
42
- # @contact_token = id_token
43
30
  redirect_to response['data']['redirect_url'] || '/' if redirect_in_error
44
31
  else
45
32
  redirect_to '/' if redirect_in_error
@@ -54,7 +41,7 @@ module ContactAuthHelper
54
41
  @cxf_contact.logout
55
42
  # Delete session token and keep the contact token id
56
43
  # Never delete the cxf_contact_id cookie to avoid the creation of ghosts
57
- cookies.delete("cxf_contact_session_token")
44
+ cookies.delete("cxf_contact_access_token")
58
45
  cookies.delete("cxf_contact_refresh_token")
59
46
  @contact_token = nil
60
47
  end
@@ -77,11 +64,18 @@ module ContactAuthHelper
77
64
  status
78
65
  end
79
66
 
80
- def update_contact_tokens
81
- access_token = @cxf_contact.get_client.session_token
82
- refresh_token = @cxf_contact.get_client.refresh_token
67
+ def sync_contact_cookies
68
+ response_cookies = @cxf_contact.get_client.response_cookies
83
69
 
84
- cookies["cxf_contact_session_token"] = { value: access_token, secure: true, httponly: true} if access_token
85
- cookies["cxf_contact_refresh_token"] = { value: refresh_token, secure: true, httponly: true } if refresh_token
70
+ response_cookies.each do |key, cookie|
71
+ cookies[cookie['name']] = {
72
+ value: cookie['value'],
73
+ expires: cookie['expires'] ? Time.parse(cookie['expires']) : nil,
74
+ path: cookie['path'] || '/',
75
+ secure: cookie['secure'] || false,
76
+ httponly: cookie['httponly'] || false,
77
+ same_site: (cookie['samesite'] || 'Lax').downcase.to_sym
78
+ }
79
+ end
86
80
  end
87
81
  end
@@ -23,17 +23,17 @@ module UserAuthHelper
23
23
  # Login in cxf
24
24
  response = @cxf_user.login(email, password)
25
25
  # Get session token from response
26
- return response unless response.is_a? Hash
27
- if response.key? 'data'
28
- session_token = response['data']['access_token']
29
- refresh_token = response['data']['refresh_token']
30
- # session_token_expires_at = Time.parse(response['data']['access_token_expires_at'])
31
- # refresh_token_expires_at = Time.parse(response['data']['refresh_token_expires_at'])
32
- end
26
+ return response # unless response.is_a? Hash
27
+ # if response.key? 'data'
28
+ # session_token = response['data']['access_token']
29
+ # refresh_token = response['data']['refresh_token']
30
+ # session_token_expires_at = Time.parse(response['data']['access_token_expires_at'])
31
+ # refresh_token_expires_at = Time.parse(response['data']['refresh_token_expires_at'])
32
+ # end
33
33
 
34
34
  # Set a permanent cookie with the session token
35
- cookies["cxf_user_session_token"] = { value: session_token, secure: true, httponly: true }
36
- cookies["cxf_user_refresh_token"] = { value: refresh_token, secure: true, httponly: true}
35
+ # cookies["cxf_user_session_token"] = { value: session_token, secure: true, httponly: true }
36
+ # cookies["cxf_user_refresh_token"] = { value: refresh_token, secure: true, httponly: true}
37
37
  end
38
38
 
39
39
  ##
@@ -63,11 +63,18 @@ module UserAuthHelper
63
63
  cookies.delete("cxf_user_refresh_token")
64
64
  end
65
65
 
66
- def update_user_tokens
67
- access_token = @cxf_user.get_client.session_token
68
- refresh_token = @cxf_user.get_client.refresh_token
66
+ def sync_user_cookies
67
+ response_cookies = @cxf_user.get_client.response_cookies
69
68
 
70
- cookies["cxf_user_session_token"] = { value: access_token, secure: true, httponly: true} if access_token
71
- cookies["cxf_user_refresh_token"] = { value: refresh_token, secure: true, httponly: true} if refresh_token
69
+ response_cookies.each do |key, cookie|
70
+ cookies[cookie['name']] = {
71
+ value: cookie['value'],
72
+ expires: cookie['expires'] ? Time.parse(cookie['expires']) : nil,
73
+ path: cookie['path'] || '/',
74
+ secure: cookie['secure'] || false,
75
+ httponly: cookie['httponly'] || false,
76
+ same_site: (cookie['samesite'] || 'Lax').downcase.to_sym
77
+ }
78
+ end
72
79
  end
73
80
  end
@@ -1,7 +1,8 @@
1
1
  # Cxf connection configuration
2
2
  cxf:
3
3
  host: http://your_host_goes_here.com
4
- api_key: your_cxf_api_key_goes_here
4
+ user_api_key: your_cxf_api_key_goes_here
5
+ contact_api_key: your_cxf_api_key_goes_here
5
6
  cxf_slug: slug_id #save id and token in redis
6
7
  redis_cache:
7
8
  use_cache: boolean_value_to_enable_and_disable_cache
@@ -3,11 +3,11 @@
3
3
  ### V1/CONTENT ###
4
4
 
5
5
  require_relative './assets'
6
- require_relative './content_prints'
7
6
  require_relative './print_versions'
7
+ require_relative './content_prints'
8
8
 
9
9
  module PublicContent
10
10
  include PublicAssets
11
- include ContentPrints
12
- include PrintVersions
11
+ include PublicContentPrints
12
+ include PublicPrintVersions
13
13
  end
@@ -1,30 +1,5 @@
1
1
  # frozen_string_literal: true
2
- module ContentPrints
3
- # === Get content print.
4
- # Get a collection of content print.
5
- #
6
- # ==== Parameters
7
- # options:: (Hash) -- List of Resource Collection Options shown above can be used as parameter.
8
- # use_post:: (Boolean) -- Variable to determine if the request is by 'post' or 'get' functions.
9
- #
10
- # ==== First Example
11
- # @data = @cxf_user.get_content_prints
12
- #
13
- # ==== Second Example
14
- # options = {
15
- # fields: 'id, slug'
16
- # }
17
- # @data = @cxf_user.get_content_prints(options)
18
- #
19
- # ==== Third Example
20
- # options = {
21
- # fields: 'id, slug'
22
- # }
23
- # @data = @cxf_user.get_content_prints(options, true)
24
- def get_content_prints(options = nil, use_post = true)
25
- get_query_results('/content/prints', options, use_post)
26
- end
27
-
2
+ module PublicContentPrints
28
3
  # === Get content print.
29
4
  # Get a content print info.
30
5
  #
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module PrintVersions
3
+ module PublicPrintVersions
4
4
  # === Get print versions.
5
5
  # Get a collection of print versions.
6
6
  #
data/lib/pub.rb CHANGED
@@ -94,8 +94,6 @@ module Cxf
94
94
  host,
95
95
  api_key,
96
96
  'public',
97
- nil,
98
- nil,
99
97
  contact_token_id,
100
98
  visit_id,
101
99
  debug,
data/lib/user.rb CHANGED
@@ -50,13 +50,11 @@ module Cxf
50
50
 
51
51
  attr_reader :client
52
52
 
53
- def initialize(host, api_key, session_token = nil, refresh_token = nil, debug = false, user_agent = nil, timeouts = {})
53
+ def initialize(host, api_key, debug = false, user_agent = nil, timeouts = {})
54
54
  @client = Cxf::Client.new(
55
55
  host,
56
56
  api_key,
57
57
  'user',
58
- session_token,
59
- refresh_token,
60
58
  nil,
61
59
  nil,
62
60
  debug,
@@ -69,12 +67,6 @@ module Cxf
69
67
  def login(email, password)
70
68
  data = { email: email, password: password }
71
69
  response = @client.raw('post', '/users/login', nil, data.to_json, '/api/v1', { no_content_type: true })
72
-
73
- return response unless response.is_a? Hash
74
- if response.key? 'data' and response['data'].key? 'access_token'
75
- @client.session_token = response['data']['access_token']
76
- @client.refresh_token = response['data']['refresh_token']
77
- end
78
70
  response
79
71
  end
80
72
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cxf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ruben Gomez Garcia, Omar Mora, Luis Hesiquio