Sha256: 84d605787bf77801003274754e11187d56ed4c468c6253ca070bef3ae1d4f950

Contents?: true

Size: 860 Bytes

Versions: 1

Compression:

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

    CONFIGURATION_FIELDS = %i[
      token
      host
    ].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

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

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
monday_ruby-0.2.0 lib/monday/configuration.rb