Sha256: cd530fc437ab897e62c19366adbad56613c2c5a30a543752bc9c20b5a8e32071

Contents?: true

Size: 1.2 KB

Versions: 2

Compression:

Stored size: 1.2 KB

Contents

# frozen_string_literal: true

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

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

          # Do the get_payments request
          _request settlement_id
        end

        private

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

          Fintecture::Faraday::Authentication::Connection.get(
            url: "#{url}/#{settlement_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::SETTLEMENTS}"
        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

2 entries across 2 versions & 1 rubygems

Version Path
fintecture-0.3.1 lib/fintecture/api/pis/settlements.rb
fintecture-0.3.0 lib/fintecture/api/pis/settlements.rb