Class: SilverMother::Api

Inherits:
Object
  • Object
show all
Includes:
HTTParty, Singleton
Defined in:
lib/silver_mother/api.rb

Instance Method Summary collapse

Instance Method Details

#delete(path, token, params = {}) ⇒ Object



36
37
38
39
40
41
42
# File 'lib/silver_mother/api.rb', line 36

def delete(path, token, params = {})
  result = HTTParty.delete(SENSE_API_URL + path,
                           add_auth_header(params, token))

  log_request(path, params, result)
  result
end

#get(path, token, params = {}) ⇒ Object

Uncomment for debugging debug_output



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

def get(path, token, params = {})
  result = HTTParty.get(SENSE_API_URL + path,
                        add_auth_header(params, token))

  log_request(path, params, result)
  result
end

#post(path, token, params = {}) ⇒ Object



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

def post(path, token, params = {})
  result = HTTParty.post(SENSE_API_URL + path,
                         add_auth_header(params, token))

  log_request(path, params, result)
  result
end

#put(path, token, params = {}) ⇒ Object



28
29
30
31
32
33
34
# File 'lib/silver_mother/api.rb', line 28

def put(path, token, params = {})
  result = HTTParty.put(SENSE_API_URL + path,
                        add_auth_header(params, token))

  log_request(path, params, result)
  result
end