Sha256: 66b08a842e95ca681c145210adf0e8593d29f07350af4d889aea07d751f6a93b

Contents?: true

Size: 592 Bytes

Versions: 1

Compression:

Stored size: 592 Bytes

Contents

module Zesty
  class Auth

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

    using Refinements::SnakeCase

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

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

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

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

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
zesty-0.1.0 lib/zesty/auth.rb