Class: Hook::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/hook-client/client.rb

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Client

Returns a new instance of Client.



13
14
15
16
17
18
19
20
# File 'lib/hook-client/client.rb', line 13

def initialize options = {}
  @app_id = options.delete(:app_id)
  @key = options.delete(:key)
  @endpoint = options.delete(:endpoint) || options.delete(:url)
  @endpoint = "#{@endpoint}/" unless @endpoint.end_with? "/"

  @logger = options.delete(:logger)
end

Class Attribute Details

.instanceObject (readonly)

Returns the value of attribute instance.



7
8
9
# File 'lib/hook-client/client.rb', line 7

def instance
  @instance
end

Class Method Details

.configure(options = {}) ⇒ Object



8
9
10
# File 'lib/hook-client/client.rb', line 8

def configure(options = {})
  @instance = self.new(options)
end

Instance Method Details

#authObject



26
27
28
# File 'lib/hook-client/client.rb', line 26

def auth
  Auth.new
end

#channel(name, options = {}) ⇒ Object



42
43
44
45
# File 'lib/hook-client/client.rb', line 42

def channel(name, options = {})
  throw NotImplementedError.new("channels not implemented")
  Channel.create(self, name, options)
end

#collection(name) ⇒ Object



34
35
36
# File 'lib/hook-client/client.rb', line 34

def collection(name)
  Collection.new(:name => name, :client => self)
end

#filesObject



30
31
32
# File 'lib/hook-client/client.rb', line 30

def files
  Files.new
end

#get(segments, data = {}) ⇒ Object



51
52
53
# File 'lib/hook-client/client.rb', line 51

def get segments, data = {}
  request :get, segments, data
end

#keysObject



22
23
24
# File 'lib/hook-client/client.rb', line 22

def keys
  Keys.new
end

#logger=(logger) ⇒ Object



38
39
40
# File 'lib/hook-client/client.rb', line 38

def logger=(logger)
  @logger = logger
end

#post(segments, data) ⇒ Object



47
48
49
# File 'lib/hook-client/client.rb', line 47

def post segments, data
  request :post, segments, data
end

#put(segments, data) ⇒ Object



55
56
57
# File 'lib/hook-client/client.rb', line 55

def put segments, data
  request :put, segments, data
end

#remove(segments, data = {}) ⇒ Object Also known as: delete



59
60
61
# File 'lib/hook-client/client.rb', line 59

def remove segments, data = {}
  request :delete, segments, data
end