Sha256: 979bc589cefdbe4b63d6440daab04b6a1e0b9bd33dbc9325dc536f1891a71f56

Contents?: true

Size: 1.61 KB

Versions: 5

Compression:

Stored size: 1.61 KB

Contents

# frozen_string_literal: true

require 'base64'
require 'json'
require 'faraday'
require 'fintecture/utils/validation'
require 'fintecture/exceptions'
require 'fintecture/utils/date'
require 'fintecture/utils/constants'

module Fintecture
  module Ressources
    class TestAccounts
      class << self
        # ------------ PUBLIC METHOD ------------
        def get(client, provider_id)
          @client = client

          # Do the request
          _request provider_id
        end

        private

        # ------------ REQUEST ------------
        def _request(provider_id)
          # Get the url request
          url = _endpoint

          # Build additional headers
          additional_headers = {}
          additional_headers['app_id'] = @client.app_id

          # Build uri params
          query_string = ''
          query_string = "?filter[provider_id]=#{provider_id}" if provider_id
          # Do connect request
          Fintecture::Faraday::Authentication::Connection.get(
            url: url + query_string,
            client: @client,
            custom_content_type: 'application/json',
            secure_headers: true,
            additional_headers: additional_headers
          )
        end

        # ------------ API ENDPOINT ------------
        def _endpoint
          "#{_api_base_url}/#{Fintecture::Api::Endpoints::Ressources::TESTACCOUNTS}"
        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/ressources/test_accounts.rb
fintecture-0.5.0 lib/fintecture/api/ressources/test_accounts.rb
fintecture-0.4.1 lib/fintecture/api/ressources/test_accounts.rb
fintecture-0.3.1 lib/fintecture/api/ressources/test_accounts.rb
fintecture-0.3.0 lib/fintecture/api/ressources/test_accounts.rb