Class: ZohoBooks::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/zoho_books/connection.rb

Class Method Summary collapse

Class Method Details

.delete(url) ⇒ Object



31
32
33
34
35
36
37
# File 'lib/zoho_books/connection.rb', line 31

def self.delete(url)
  response = HTTParty.delete(url, headers: headers)

  return render_error(response) if response.code != 200

  response
end

.get(url) ⇒ Object



7
8
9
10
11
12
13
# File 'lib/zoho_books/connection.rb', line 7

def self.get(url)
  response = HTTParty.get(url, headers: headers)

  return ZohoBooks::Error.new(response.code, response["error"]) if response.code != 200

  response
end

.post(url, body) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/zoho_books/connection.rb', line 15

def self.post(url, body)
  response = HTTParty.post(url, body: body, headers: headers)

  return render_error(response) if response.code != 201

  response
end

.put(url, body) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/zoho_books/connection.rb', line 23

def self.put(url, body)
  response = HTTParty.put(url, body: body, headers: headers)

  return render_error(response) if response.code != 200

  response
end