Sha256: 61bc8d0f7841bfeaadf73214beaf9b65019652a7aeebadea196e61328090afde

Contents?: true

Size: 948 Bytes

Versions: 2

Compression:

Stored size: 948 Bytes

Contents

# frozen_string_literal: true

require_relative '../components/http'
require_relative '../logic/dangerous_override'

require_relative 'dsl'
require_relative 'api'

module Flare
  module Controllers
    class Client
      attr_reader :dangerously_override

      def initialize(config)
        @http_client = HTTP::Client.new(config)

        @dangerously_override = (config[:dangerously_override] || {}).freeze
      end

      def meta(debug: nil)
        request('meta', request_method: 'GET', debug:)
      end

      def api
        @api ||= API.new(self)
      end

      def dsl
        @dsl ||= DSL.new(self)
      end

      def request(path, payload = nil, debug:, request_method: 'POST')
        @http_client.request(
          path,
          DangerousOverrideLogic.apply_dangerous_overrides_to_payload(
            path, dangerously_override, payload
          ),
          request_method:, debug:
        )
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
datomic-flare-1.0.1 controllers/client.rb
datomic-flare-1.0.0 controllers/client.rb