Class: Zunnit::Api

Inherits:
Object
  • Object
show all
Defined in:
lib/zunnit/api.rb

Overview

API Class

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize {|_self| ... } ⇒ Api

Returns a new instance of Api.

Yields:

  • (_self)

Yield Parameters:

  • _self (Zunnit::Api)

    the object that the method was called on



12
13
14
15
16
17
18
# File 'lib/zunnit/api.rb', line 12

def initialize
  self.client = Zunnit.client
  self.key = Zunnit.key
  self.version = Zunnit.version		

  yield self if block_given?
end

Instance Attribute Details

#clientObject

Returns the value of attribute client.



10
11
12
# File 'lib/zunnit/api.rb', line 10

def client
  @client
end

#keyObject

Returns the value of attribute key.



10
11
12
# File 'lib/zunnit/api.rb', line 10

def key
  @key
end

#versionObject

Returns the value of attribute version.



10
11
12
# File 'lib/zunnit/api.rb', line 10

def version
  @version
end

Instance Method Details

#get(action, options = {}) ⇒ Object

Make a GET request to Zunnit’s API



25
26
27
# File 'lib/zunnit/api.rb', line 25

def get(action, options={})
  request(:get, action, options)
end

#post(action, options = {}) ⇒ Object

Make a POST request to Zunnit’s API



30
31
32
# File 'lib/zunnit/api.rb', line 30

def post(action, options={})
  request(:post, action, options)
end

#urlObject



20
21
22
# File 'lib/zunnit/api.rb', line 20

def url
  "http://#{self.client}.zunnit.com/"
end