Class: Zesty::Auth

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

Constant Summary collapse

AUTH_URL =
"https://auth.api.zesty.io"

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**options) ⇒ Auth

Returns a new instance of Auth.



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

def initialize(**options)
  @options = options
end

Class Method Details

.get_token(email, password) ⇒ Object



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

def self.get_token(email, password)
  self.new.(email, password).dig(:meta, :token)
end

Instance Method Details

#login(email, password) ⇒ Object



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

def (email, password)
  Request.post_form(
    "#{AUTH_URL}/login",
    params: {
      email: email,
      password: password
    }
  )
end

#verify_token(token) ⇒ Object



24
25
26
# File 'lib/zesty/auth.rb', line 24

def verify_token(token)
  Request.get("#{AUTH_URL}/verify", headers: { Authorization: "Bearer #{token}" })
end