Class: TortoiseLabs::Client

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

Class Method Summary collapse

Class Method Details

.auth_optionsObject



20
21
22
23
24
25
26
# File 'lib/tortoiselabs/client.rb', line 20

def self.auth_options
  if @username.nil? or @password.nil?
    raise NotAuthenticated
  end
  
  {:basic_auth => {:username => @username, :password => @password}}
end

.base_uriObject



4
5
6
# File 'lib/tortoiselabs/client.rb', line 4

def self.base_uri
  @base_uri ||= "https://manage.tortois.es"
end

.base_uri=(value) ⇒ Object



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

def self.base_uri=(value)
  @base_uri = value.to_s.chomp("/")
end

.get(path, options = {}) ⇒ Object



28
29
30
# File 'lib/tortoiselabs/client.rb', line 28

def self.get(path, options = {})
  HTTParty.get(base_uri + path, options.merge(auth_options))
end

.password=(value) ⇒ Object



16
17
18
# File 'lib/tortoiselabs/client.rb', line 16

def self.password=(value)
  @password = value
end

.post(path, options) ⇒ Object



32
33
34
35
# File 'lib/tortoiselabs/client.rb', line 32

def self.post(path, options)
  options = {:body => options}.merge(auth_options)
  HTTParty.post(base_uri + path, options)
end

.username=(value) ⇒ Object



12
13
14
# File 'lib/tortoiselabs/client.rb', line 12

def self.username=(value)
  @username = value
end