Sha256: 649423961091fbf4f8aa35d6fbaee1cd4a1ccbd1d146b5f34258b78ae2ab88ef

Contents?: true

Size: 1.18 KB

Versions: 5

Compression:

Stored size: 1.18 KB

Contents

# frozen_string_literal: true

require 'json'
require 'faraday'
require 'fintecture/endpoints/pis'
require 'fintecture/base_url'

module Fintecture
  module Pis
    class Payments
      class << self
        # ------------ PUBLIC METHOD ------------
        def get(client, session_id)
          @client = client

          # Do the get_payments request
          _request session_id
        end

        private

        # ------------ REQUEST ------------
        def _request(session_id)
          url = _endpoint

          Fintecture::Faraday::Authentication::Connection.get(
            url: "#{url}/#{session_id}",
            client: @client,
            custom_content_type: 'application/json',
            bearer: "Bearer #{@client.token}",
            secure_headers: true
          )
        end

        # ------------ API ENDPOINT ------------
        def _endpoint
          "#{_api_base_url}/#{Fintecture::Api::Endpoints::Pis::PAYMENTS}"
        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

Version Path
fintecture-0.5.1 lib/fintecture/api/pis/payments.rb
fintecture-0.5.0 lib/fintecture/api/pis/payments.rb
fintecture-0.4.1 lib/fintecture/api/pis/payments.rb
fintecture-0.3.1 lib/fintecture/api/pis/payments.rb
fintecture-0.3.0 lib/fintecture/api/pis/payments.rb