Sha256: a1cbad4e5a94a2573e7bf3926280902a10b837a139adf2dc7ae5d98e48cf1df9

Contents?: true

Size: 1.4 KB

Versions: 1

Compression:

Stored size: 1.4 KB

Contents

# frozen_string_literal: true

require 'jwt'

module Minty
  module Api
    module AuthenticationEndpoints
      def sign_in_url
        response = request_with_retry(:get, '/sign_in_url')
        response['redirect_url']
      end

      def sign_up_url
        response = request_with_retry(:get, '/sign_up_url')
        response['redirect_url']
      end

      def forgot_password_url
        response = request_with_retry(:get, '/forgot_password_url')
        response['redirect_url']
      end

      def sign_in(email, password)
        request_with_retry(:post, '/sign_in', { email: email, password: password })
      end

      def sign_up(name, email, password)
        request_with_retry(:post, '/sign_up', { name: name, email: email, password: password })
      end

      def sign_out(token)
        request_with_retry(:delete, '/sign_out', { token: token })
      end

      def forgot_password(email)
        request_with_retry(:post, '/forgot_password', { email: email })
      end

      def validate_token(token)
        request_with_retry(:get, '/validate_token', { token: token })
      end

      def application_user(token)
        response = request_with_retry(:get, '/application_user', { token: token })
        response['application_user']
      end

      private

      def to_query(hash)
        hash.map { |k, v| "#{k}=#{CGI.escape(v)}" unless v.nil? }.reject(&:nil?).join('&')
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
minty-1.0.1 lib/minty/api/authentication_endpoints.rb