Sha256: cd1859d32568d92f6ced979e571e05ed66c84820f967601190302ca23867473f

Contents?: true

Size: 1.55 KB

Versions: 4

Compression:

Stored size: 1.55 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

4 entries across 4 versions & 1 rubygems

Version Path
fintecture-0.6.2 lib/fintecture/api/ressources/test_accounts.rb
fintecture-0.6.1 lib/fintecture/api/ressources/test_accounts.rb
fintecture-0.6.0 lib/fintecture/api/ressources/test_accounts.rb
fintecture-0.4.0 lib/fintecture/api/ressources/test_accounts.rb