Sha256: 3ccae082c17bc4b8c83e654ac7f591e8056b9f408f6143e68dd5335924f6c628

Contents?: true

Size: 1.96 KB

Versions: 13

Compression:

Stored size: 1.96 KB

Contents

# frozen_string_literal: true

module IronBank
  # The Zuora configuration class.
  #
  class Configuration
    # middlewares
    attr_accessor :middlewares

    # Logger
    attr_accessor :logger

    # The Zuora domain for our tenant (apisandbox, production, etc.).
    attr_accessor :domain

    # OAuth client ID associated with our platform admin user.
    attr_accessor :client_id

    # OAuth client secret.
    attr_accessor :client_secret

    # Auth type (cookie|token)
    attr_accessor :auth_type

    # Cache store instance, optionally used by certain resources.
    attr_accessor :cache

    # Directory where the XML describe files are located.
    attr_reader :schema_directory

    # Directory where the local records are exported.
    attr_reader :export_directory

    def initialize
      @schema_directory = "./config/schema"
      @export_directory = "./config/export"
      @logger           = IronBank::Logger.new
      @auth_type        = "token"
      @middlewares      = []
    end

    def schema_directory=(value)
      @schema_directory = value

      return unless defined? IronBank::Schema

      IronBank::Schema.reset

      # Call `with_schema` on each resource to redefine accessors
      IronBank::Resources.constants.each do |resource|
        klass = IronBank::Resources.const_get(resource)
        klass.with_schema if klass.is_a?(Class)
      end
    end

    def export_directory=(value)
      @export_directory = value
      return unless defined? IronBank::Product

      IronBank::LocalRecords::RESOURCE_QUERY_FIELDS.keys.each do |resource|
        IronBank::Resources.const_get(resource).reset_store
      end
    end

    def credentials
      {
        domain:        domain,
        client_id:     client_id,
        client_secret: client_secret,
        auth_type:     auth_type
      }
    end

    def credentials?
      credentials.values.all?
    end

    def retry_options
      @retry_options ||= IronBank::Client::DEFAULT_RETRY_OPTIONS
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
iron_bank-3.4.0 lib/iron_bank/configuration.rb
iron_bank-3.3.4 lib/iron_bank/configuration.rb
iron_bank-3.3.3 lib/iron_bank/configuration.rb
iron_bank-3.3.2 lib/iron_bank/configuration.rb
iron_bank-3.3.1 lib/iron_bank/configuration.rb
iron_bank-3.3.0 lib/iron_bank/configuration.rb
iron_bank-3.2.0 lib/iron_bank/configuration.rb
iron_bank-3.1.1 lib/iron_bank/configuration.rb
iron_bank-3.1.0 lib/iron_bank/configuration.rb
iron_bank-3.0.3 lib/iron_bank/configuration.rb
iron_bank-3.0.2 lib/iron_bank/configuration.rb
iron_bank-3.0.1 lib/iron_bank/configuration.rb
iron_bank-3.0.0 lib/iron_bank/configuration.rb