Module: Revolut::Api::Private::Auth

Included in:
Client
Defined in:
lib/revolut/api/private/auth.rb

Instance Method Summary collapse

Instance Method Details

#confirm_signin(phone:, code:) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/revolut/api/private/auth.rb', line 20

def (phone:, code:)
  data          =     {
    phone:    phone,
    code:     code.gsub("-", "")
  }
  
  options       =     {
    check_configuration: false,
    authenticate:        false
  }
  
  response      =   post("signin/confirm", data: data, options: options)
  
  auth_data     =   {id: response&.dig("user", "id"), access_token: response&.fetch("accessToken", nil)}
  auth_data.delete_if { |key, value| value.to_s.empty? }
  
  if !auth_data.empty?
    self.configuration.user_id        =   auth_data.fetch(:id, nil)
    self.configuration.access_token   =   auth_data.fetch(:access_token, nil)
  else
    auth_data   =   nil
  end
  
  return auth_data
end

#signin(phone:, password:) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/revolut/api/private/auth.rb', line 6

def (phone:, password:)
  data          =     {
    phone:    phone,
    password: password
  }
  
  options       =     {
    check_configuration: false,
    authenticate:        false
  }
  
  post("signin", data: data, options: options)
end