Sha256: 43996c1b4f2f78e3c7046758c0fc70f1f7465fd37e973e3e2f2557446a5b4adc

Contents?: true

Size: 669 Bytes

Versions: 3

Compression:

Stored size: 669 Bytes

Contents

require 'httparty'
require 'json'

module Outliner
  class Client
    include HTTParty

    def initialize(base_uri)
      self.class.base_uri (base_uri + "/api")
      @token = ENV['OUTLINE_TOKEN']
    end

    def method_missing(method_name, params = {})
      method_name = '/' + method_name.to_s.sub('_', '.')
      body = {token: @token}.merge(params).to_json
      options = { 
        body: body,
        headers: {
          'Accept'=>'application/json',
          'Content-Type': 'application/json',
          'User-Agent': "Outliner/#{Outliner::VERSION}"
        },
        format: :json
      }

      self.class.post(method_name, options)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
outliner-0.2.0 lib/outliner/client.rb
outliner-0.1.1 lib/outliner/client.rb
outliner-0.1.0 lib/outliner/client.rb