zoho_books 0.0.43 → 0.0.44
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/zoho_books/connection.rb +56 -0
- data/lib/zoho_books/item.rb +25 -0
- metadata +3 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e76d1d637412b1e8f174f90271f8e2686835129f855236de63f876a9da7d1704
|
|
4
|
+
data.tar.gz: 3eb099f98a8d04440c21b823f7c8de1512608b2e17e84bce33dd90be327fa307
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e17662205e551f90e5818d362e025b3364e1bc2f3869ce00b846a6c117e8167c64f55175fbb2ab2333df1d5657a3d3b2ed3386ab2ec534303162204610fdab96
|
|
7
|
+
data.tar.gz: '0936852502fb0220d0a771acbfc3fca397567cc639d0055244d4b55634d4ddf66660cca07c7ee5283cdcb18f175ebfef88af39bbf507747f3be2a7e3da06f74f'
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
require 'httparty'
|
|
3
|
+
|
|
4
|
+
module ZohoBooks
|
|
5
|
+
class Connection
|
|
6
|
+
|
|
7
|
+
def self.get(url)
|
|
8
|
+
response = HTTParty.get(url, headers: headers)
|
|
9
|
+
|
|
10
|
+
return ZohoBooks::Error.new(response.code, response["error"]) if response.code != 200
|
|
11
|
+
|
|
12
|
+
response
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def self.post(url, body)
|
|
16
|
+
response = HTTParty.post(url, body: body, headers: headers)
|
|
17
|
+
|
|
18
|
+
return ZohoBooks::Error.new(response.code, response["error"]) if response.code != 201
|
|
19
|
+
|
|
20
|
+
response
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def self.put(url, body)
|
|
24
|
+
response = HTTParty.put(url, body: body, headers: headers)
|
|
25
|
+
|
|
26
|
+
return ZohoBooks::Error.new(response.code, response["error"]) if response.code != 200
|
|
27
|
+
|
|
28
|
+
response
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def self.delete(url)
|
|
32
|
+
response = HTTParty.delete(url, headers: headers)
|
|
33
|
+
|
|
34
|
+
return ZohoBooks::Error.new(response.code, response["error"]) if response.code != 200
|
|
35
|
+
|
|
36
|
+
response
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
private
|
|
40
|
+
|
|
41
|
+
def self.headers
|
|
42
|
+
{
|
|
43
|
+
'Authorization' => "Zoho-oauthtoken #{access_token}",
|
|
44
|
+
'Content-Type' => 'application/json'
|
|
45
|
+
}
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def self.access_token
|
|
49
|
+
if ZohoBooks.config.access_token_expires_at.nil? || ZohoBooks.config.access_token_expires_at >= Time.now.to_i
|
|
50
|
+
ZohoBooks::Auth.refresh_access_token
|
|
51
|
+
else
|
|
52
|
+
ZohoBooks.config.access_token
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
require 'httparty'
|
|
3
|
+
|
|
4
|
+
module ZohoBooks
|
|
5
|
+
BASE_URL='https://www.zohoapis.eu/books/v3'
|
|
6
|
+
|
|
7
|
+
class Item
|
|
8
|
+
def self.list(opts = {})
|
|
9
|
+
query = opts.map { |k, v| "#{k}=#{v}" }.join('&')
|
|
10
|
+
ZohoBooks::Connection.get("#{BASE_URL}/items?organization_id=#{ZohoBooks.config.organization_id}&#{query}")
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def self.create(body, opts = {})
|
|
14
|
+
ZohoBooks::Connection.post("#{BASE_URL}/items?organization_id=#{ZohoBooks.config.organization_id}", body.to_json)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def self.update(id, body, opts = {})
|
|
18
|
+
ZohoBooks::Connection.put("#{BASE_URL}/items/#{id}?organization_id=#{ZohoBooks.config.organization_id}", body.to_json)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def self.delete(id, opts = {})
|
|
22
|
+
ZohoBooks::Connection.delete("#{BASE_URL}/items/#{id}?organization_id=#{ZohoBooks.config.organization_id}")
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: zoho_books
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.44
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- PapaLoup
|
|
@@ -34,7 +34,9 @@ files:
|
|
|
34
34
|
- lib/zoho_books.rb
|
|
35
35
|
- lib/zoho_books/auth.rb
|
|
36
36
|
- lib/zoho_books/config.rb
|
|
37
|
+
- lib/zoho_books/connection.rb
|
|
37
38
|
- lib/zoho_books/error.rb
|
|
39
|
+
- lib/zoho_books/item.rb
|
|
38
40
|
homepage: https://rubygems.org/gems/zoho_books
|
|
39
41
|
licenses:
|
|
40
42
|
- MIT
|