Sha256: 60d571c54fea7ea3d28e6c2ae2ad2388e16093370ece28d06b7b76cb2cc5057f

Contents?: true

Size: 618 Bytes

Versions: 2

Compression:

Stored size: 618 Bytes

Contents

# frozen_string_literal: true

module FinApps
  module REST
    class Sessions < FinAppsCore::REST::Resources # :nodoc:
      LOGOUT = 'logout'

      def create(params, path = nil)
        return super nil, path if path == LOGOUT
        raise FinAppsCore::InvalidArgumentsError, 'Invalid argument: params.' unless validates params

        path ||= 'login'

        super params, path
      end

      def destroy
        create nil, LOGOUT
      end

      private

      def validates(params)
        params.key?(:email) && params[:email] && params.key?(:password) && params[:password]
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
finapps-4.0.5 lib/finapps/rest/sessions.rb
finapps-4.0.4 lib/finapps/rest/sessions.rb