Sha256: d238d241f979a68820d0db5583ef5b9034e3eab3cdbd2a1bc71062078345a7bb

Contents?: true

Size: 972 Bytes

Versions: 6

Compression:

Stored size: 972 Bytes

Contents

# frozen_string_literal: true

module Monday
  # Encapsulates configuration for the Monday.com API.
  #
  # Configuration options:
  #
  # token: used to authenticate the requests
  # host: defaults to https://api.monday.com/v2
  class Configuration
    DEFAULT_HOST = "https://api.monday.com/v2"
    DEFAULT_TOKEN = nil
    DEFAULT_VERSION = "2023-07"

    CONFIGURATION_FIELDS = %i[
      token
      host
      version
    ].freeze

    attr_accessor(*CONFIGURATION_FIELDS)

    def initialize(**config_args)
      invalid_keys = config_args.keys - CONFIGURATION_FIELDS
      raise ArgumentError, "Unknown arguments: #{invalid_keys}" unless invalid_keys.empty?

      @host = DEFAULT_HOST
      @token = DEFAULT_TOKEN
      @version = DEFAULT_VERSION

      config_args.each do |key, value|
        public_send("#{key}=", value)
      end
    end

    def reset
      @token = DEFAULT_TOKEN
      @host = DEFAULT_HOST
      @version = DEFAULT_VERSION
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
monday_ruby-1.0.0 lib/monday/configuration.rb
monday_ruby-0.6.2 lib/monday/configuration.rb
monday_ruby-0.6.1 lib/monday/configuration.rb
monday_ruby-0.6.0 lib/monday/configuration.rb
monday_ruby-0.4.0 lib/monday/configuration.rb
monday_ruby-0.3.0 lib/monday/configuration.rb