Sha256: f8ffc5adb2c8776946769583893d3a6d11e359dbf2f2850a721569f1486f2402

Contents?: true

Size: 662 Bytes

Versions: 1

Compression:

Stored size: 662 Bytes

Contents

require "json"
require "excon"

module Onebot
  class Client
    require_relative "client/api_helper"
    include ApiHelper

    attr_reader :client, :server

    def initialize(host, token = nil, **options)
      @server = host || "http://localhost:5700"
      @token = token || options[:token]
      Excon.defaults[:headers].merge({"Authorization" => "Bearer #{@token}"}) if @token
      @client = Excon.new(@server)
    end

    def request(action, body = {})
      pp body
      response = client.get(path: action, query: body)
      # raise self.class.error_for_response(response) if response.status >= 300
      JSON.parse(response.body)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
onebot-0.1.0 lib/onebot/client.rb