Sha256: 7744a7d46b0dfeea0997d33a8f192d78889d139aa9904e6deea26eb6c3419595

Contents?: true

Size: 923 Bytes

Versions: 1

Compression:

Stored size: 923 Bytes

Contents

# frozen_string_literal: true

require 'truelayer/faraday_auth'

module Truelayer
  class Configuration
    BASE_URLS = {
      production: 'https://api.truelayer.com',
      sandbox: 'https://api.truelayer-sandbox.com'
    }.freeze
    AUTH_URLS = {
      production: 'https://auth.truelayer.com',
      sandbox: 'https://auth.truelayer-sandbox.com'
    }.freeze

    attr_accessor :client_id, :client_secret, :environment, :debug, :verbose

    def initialize
      @client_id = ''
      @client_secret = ''
      @environment = :sandbox # can be either :sandbox or :production
      @debug = false
      @verbose = false

      return if Faraday::Request.fetch_middleware(:truelayer_auth)
      Faraday::Request.register_middleware truelayer_auth: -> { Truelayer::FaradayAuth }
    end

    def base_url
      BASE_URLS[environment.to_sym]
    end

    def auth_url
      AUTH_URLS[environment.to_sym]
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
truelayer-0.1.0 lib/truelayer/configuration.rb