module Teapi

Constants

VERSION

Attributes

configuration[W]
sender[RW]

Public Class Methods

configuration() click to toggle source

Gets the current configuration

# File lib/teapi.rb, line 24
def configuration
  @configuration ||= Configuration.new
end
configure() { |configuration| ... } click to toggle source

Sets the configuration options. Teapi.configure do |config|

config.host = 'HOST'
config.sync_key = 'KEY'
config.sync_secret = 'SECRET'

end

# File lib/teapi.rb, line 18
def configure
  yield(configuration)
  self.sender = Sender.new(configuration)
end
delete(resource, body) click to toggle source

Issues a DELETE request to the teapi.io service @param resource [Symbol] name of resource @param body [String] to send to the service

# File lib/teapi.rb, line 47
def delete(resource, body)
  assert_configured()
  sender.request(:delete, resource, {body: body})
end
post(resource, body) click to toggle source

Issues a POST request to the teapi.io service @param resource [Symbol] name of resource @param body [String] to send to the service

# File lib/teapi.rb, line 31
def post(resource, body)
  assert_configured()
  sender.request(:post, resource, {body: body})
end
put(resource, body) click to toggle source

Issues a PUT request to the teapi.io service @param resource [Symbol] name of resource @param body [String] to send to the service

# File lib/teapi.rb, line 39
def put(resource, body)
  assert_configured()
  sender.request(:put, resource, {body: body})
end

Private Class Methods

assert_configured() click to toggle source
# File lib/teapi.rb, line 53
def assert_configured()
  raise 'teapi invalid configuration' if @configuration.nil?
  raise 'teapi invalid sync_key' if @configuration.sync_key.nil?
  raise 'teapi invalid sync_secret' if @configuration.sync_secret.nil?
  raise 'teapi invalid host' if @configuration.host.nil?
end