Sha256: 5f31f8c94387392f3e635d31c9f1ee69e58b2efd9318810cb9cde2eae5b04051
Contents?: true
Size: 1.77 KB
Versions: 1
Compression:
Stored size: 1.77 KB
Contents
# frozen_string_literal: true require 'httparty' module Fuser class Request def self.call(*args) new(*args).call end def initialize(action, params:) @action = action @params = params end def call HTTParty.post( Fuser::Endpoint.for(action), body: request_body.to_json, headers: default_request_headers ) end private attr_accessor :action, :params def default_request_headers { 'Content-Type': 'application/json' } end def request_body case action when :verify_token then { 'idToken': params[:token], 'returnSecureToken': true } when :refresh_token then { 'grant_type': 'refresh_token', 'refresh_token': params[:token] } when :sign_in, :sign_up then { 'email': params[:email], 'password': params[:password], 'returnSecureToken': true } when :anonymous_sign_in then { 'returnSecureToken': true } when :reset_password then { 'email': params[:email], 'requestType': 'PASSWORD_RESET' } when :verify_reset_password then { 'oobCode': params[:oob_code] } when :confirm_reset_password then { 'oobCode': params[:oob_code], 'newPassword': params[:new_password] } when :change_email then { 'idToken': params[:token], 'email': params[:new_email], 'returnSecureToken': true } when :change_password then { 'idToken': params[:token], 'email': params[:new_password], 'returnSecureToken': true } end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
fuser-0.1.0 | lib/fuser/request.rb |