Sha256: 97ff112cdbdeb0e4401a819d47abf11cc1b9dcdcfb6e7dacc7cae8f72e1c8088

Contents?: true

Size: 924 Bytes

Versions: 2

Compression:

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

2 entries across 2 versions & 1 rubygems

Version Path
truelayer-0.1.2 lib/truelayer/configuration.rb
truelayer-0.1.1 lib/truelayer/configuration.rb