Sha256: b8890c3886a087a62427b37f75dd849881e77c056c5ef7353c44d5aa8f7aa369
Contents?: true
Size: 1.54 KB
Versions: 5
Compression:
Stored size: 1.54 KB
Contents
# frozen_string_literal: true module Fintecture module Pis class Initiate class << self # ------------ PUBLIC METHOD ------------ def generate(client, payload, provider_id, redirect_uri, state) @client = client # Do the _request request _request payload, provider_id, redirect_uri, state end private # ------------ REQUEST ------------ def _request(payload, provider_id, redirect_uri, state) # Get the url request url = _endpoint provider_id # Build uri params params = {} params['state'] = state params['redirect_uri'] = redirect_uri query_string = "?#{params.map { |key, value| "#{key}=#{value}" }.join('&')}" # Do connect request Fintecture::Faraday::Authentication::Connection.post( url: url + query_string, req_body: payload.to_json, client: @client, custom_content_type: 'application/json', bearer: "Bearer #{@client.token}", secure_headers: true ) end # ------------ API ENDPOINT ------------ def _endpoint(provider_id) "#{_api_base_url}/#{Fintecture::Api::Endpoints::Pis::INITIATE}/#{provider_id}/initiate" end # ------------ BASE URL ------------ def _api_base_url Fintecture::Api::BaseUrl::FINTECTURE_API_URL[@client.environment.to_sym] end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems