Class: QuickeyRubySdk::Auth

Inherits:
Object
  • Object
show all
Defined in:
lib/quickey_ruby_sdk/auth.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_key: nil) ⇒ Auth

Returns a new instance of Auth.



9
10
11
12
# File 'lib/quickey_ruby_sdk/auth.rb', line 9

def initialize(api_key: nil)
  @api_key = api_key
  @api_base = QuickeyRubySdk::API_BASE
end

Instance Attribute Details

#api_baseObject (readonly)

Returns the value of attribute api_base.



6
7
8
# File 'lib/quickey_ruby_sdk/auth.rb', line 6

def api_base
  @api_base
end

#api_keyObject (readonly)

Returns the value of attribute api_key.



7
8
9
# File 'lib/quickey_ruby_sdk/auth.rb', line 7

def api_key
  @api_key
end

Instance Method Details

#getAccessTokenByEmail(email, provider) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/quickey_ruby_sdk/auth.rb', line 14

def getAccessTokenByEmail(email, provider)
  response = JSON.parse HTTParty.post(@api_base+"/loginCustomer",
    body: {
        "email": email,
        "provider": provider
    },
    headers: {
        "Authorization": @api_key
    }).body
  response
end

#getAccessTokenByPhone(phone, provider, otpCode) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/quickey_ruby_sdk/auth.rb', line 26

def getAccessTokenByPhone(phone, provider, otpCode)
  response = JSON.parse HTTParty.post(@api_base+"/loginCustomer",
    body: {
        "phone": phone,
        "provider": provider,
        "otpCode": otpCode
    },
    headers: {
        "Authorization": @api_key
    }).body
  response
end

#linkPhoneToEmail(phone, provider) ⇒ Object



50
51
52
53
54
55
56
57
58
59
60
# File 'lib/quickey_ruby_sdk/auth.rb', line 50

def linkPhoneToEmail(phone, provider)
  response = JSON.parse HTTParty.post(@api_base+"/otp/linkToEmail",
      body: {
          "phone": phone,
          "provider": provider
      },
      headers: {
          "Authorization": @api_key
      }).body
    response
end

#verifyToken(token) ⇒ Object



39
40
41
42
43
44
45
46
47
48
# File 'lib/quickey_ruby_sdk/auth.rb', line 39

def verifyToken(token)
  response = JSON.parse HTTParty.post(@api_base+"/auth/verifyToken",
    body: {
        "token": token
    },
    headers: {
        "Authorization": @api_key
    }).body
  response
end