Sha256: 347961dba9bd88a264142948773baf015577ca774f584d1947e9fcfadee80e51

Contents?: true

Size: 1.15 KB

Versions: 4

Compression:

Stored size: 1.15 KB

Contents

require 'faraday'
require 'faraday/multipart'

require_relative 'magicwrite/http'
require_relative 'magicwrite/client'
require_relative 'magicwrite/agents'
require_relative 'magicwrite/companies'
require_relative 'magicwrite/completions'
require_relative 'magicwrite/ingestions'
require_relative 'magicwrite/version'

module MagicWrite
  class Error < StandardError; end
  class ConfigurationError < Error; end

  class Configuration
    attr_writer :access_token
    attr_accessor :uri_base, :request_timeout

    DEFAULT_URI_BASE = 'https://api.magicwrite.ai/rest/'.freeze
    DEFAULT_REQUEST_TIMEOUT = 120

    def initialize
      @access_token = nil
      @uri_base = DEFAULT_URI_BASE
      @request_timeout = DEFAULT_REQUEST_TIMEOUT
    end

    def access_token
      return @access_token if @access_token

      error_text = 'MagicWrite access token missing! See https://github.com/kykocamp/ruby-magicwrite#usage'
      raise ConfigurationError, error_text
    end
  end

  class << self
    attr_writer :configuration
  end

  def self.configuration
    @configuration ||= MagicWrite::Configuration.new
  end

  def self.configure
    yield(configuration)
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ruby-magicwrite-0.1.3 lib/magicwrite.rb
ruby-magicwrite-0.1.2 lib/magicwrite.rb
ruby-magicwrite-0.1.1 lib/magicwrite.rb
ruby-magicwrite-0.1.0 lib/magicwrite.rb