zoho_books 0.0.6 → 0.0.7.1
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/auth.rb +2 -1
- data/lib/zoho_books/config.rb +11 -9
- data/lib/zoho_books/connection.rb +8 -10
- data/lib/zoho_books/contact.rb +10 -7
- data/lib/zoho_books/estimate.rb +11 -7
- data/lib/zoho_books/estimates/template.rb +1 -0
- data/lib/zoho_books/invoice.rb +30 -0
- data/lib/zoho_books/item.rb +10 -4
- data/lib/zoho_books/tax.rb +9 -6
- data/lib/zoho_books.rb +3 -0
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 83991e8d0cb0386e456b3a11b18d91023993a9ddf91d6cdc7fb07477a1534d4c
|
|
4
|
+
data.tar.gz: def07a59b6a3e4e00b1843fdddc349bad1ddcc949f812ee55b3633ca2d905e4b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e2fd505779ab8858a83c9ebd7b38032e9f9c535074a9de68b07873d5a881bc2f210bb4d8920626fc215b6f18c5ffb40f68e56312b4a5e8326d02c19089484b97
|
|
7
|
+
data.tar.gz: '002508ab668c8431f053de17bba7126f527ad3046515fc6e539c6fabc88a50b72f83d652a8f2e7fed8771e918a79e46c08698598d2dc91edb19515bc7ce67687'
|
data/lib/zoho_books/auth.rb
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
|
|
2
3
|
require 'httparty'
|
|
3
4
|
|
|
4
5
|
module ZohoBooks
|
|
@@ -7,7 +8,7 @@ module ZohoBooks
|
|
|
7
8
|
endoint_url = "oauth/v2/token?refresh_token=#{ZohoBooks.config.refresh_token}&client_id=#{ZohoBooks.config.client_id}&client_secret=#{ZohoBooks.config.client_secret}&redirect_uri=#{ZohoBooks.config.redirect_uri}&grant_type=refresh_token"
|
|
8
9
|
response = HTTParty.post("#{ZohoBooks.config.base_url}/#{endoint_url}")
|
|
9
10
|
|
|
10
|
-
return ZohoBooks::Error.new(response.code, response[
|
|
11
|
+
return ZohoBooks::Error.new(response.code, response['error']) if response.code != 200
|
|
11
12
|
|
|
12
13
|
ZohoBooks.config.access_token = response.parsed_response['access_token']
|
|
13
14
|
ZohoBooks.config.access_token_expires_at = Time.now.to_i + response.parsed_response['expires_in'].to_i
|
data/lib/zoho_books/config.rb
CHANGED
|
@@ -1,19 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module ZohoBooks
|
|
2
4
|
class Config
|
|
3
5
|
attr_accessor :client_id, :client_secret, :redirect_uri, :refresh_token, :base_url,
|
|
4
6
|
:portal_id, :access_token, :organization_id, :refresh_token, :access_token_expires_at
|
|
5
7
|
|
|
6
|
-
DEFAULT_BASE_URL =
|
|
8
|
+
DEFAULT_BASE_URL = 'https://accounts.zoho.eu'
|
|
7
9
|
|
|
8
10
|
def initialize(config = {})
|
|
9
|
-
@base_url = config[
|
|
10
|
-
@portal_id = config[
|
|
11
|
-
@access_token = config[
|
|
12
|
-
@client_id = config[
|
|
13
|
-
@client_secret = config[
|
|
14
|
-
@redirect_uri = config[
|
|
15
|
-
@organization_id = config[
|
|
16
|
-
@refresh_token = config[
|
|
11
|
+
@base_url = config['base_url'] || DEFAULT_BASE_URL
|
|
12
|
+
@portal_id = config['portal_id']
|
|
13
|
+
@access_token = config['access_token']
|
|
14
|
+
@client_id = config['client_id']
|
|
15
|
+
@client_secret = config['client_secret']
|
|
16
|
+
@redirect_uri = config['redirect_uri']
|
|
17
|
+
@organization_id = config['organization_id']
|
|
18
|
+
@refresh_token = config['refresh_token']
|
|
17
19
|
|
|
18
20
|
@access_token_expires_at = nil
|
|
19
21
|
end
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
|
|
2
3
|
require 'httparty'
|
|
3
4
|
|
|
4
5
|
module ZohoBooks
|
|
5
|
-
BASE_URL='https://www.zohoapis.eu/books/v3'
|
|
6
|
+
BASE_URL = 'https://www.zohoapis.eu/books/v3'
|
|
6
7
|
|
|
7
8
|
class Connection
|
|
8
|
-
|
|
9
9
|
def self.get(url)
|
|
10
|
-
response = HTTParty.get(url, headers:
|
|
10
|
+
response = HTTParty.get(url, headers:)
|
|
11
11
|
|
|
12
|
-
return ZohoBooks::Error.new(response.code, response[
|
|
12
|
+
return ZohoBooks::Error.new(response.code, response['error']) if response.code != 200
|
|
13
13
|
|
|
14
14
|
response
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
def self.post(url, body)
|
|
18
|
-
response = HTTParty.post(url, body
|
|
18
|
+
response = HTTParty.post(url, body:, headers:)
|
|
19
19
|
|
|
20
20
|
return render_error(response) if response.code != 201
|
|
21
21
|
|
|
@@ -23,7 +23,7 @@ module ZohoBooks
|
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
def self.put(url, body)
|
|
26
|
-
response = HTTParty.put(url, body
|
|
26
|
+
response = HTTParty.put(url, body:, headers:)
|
|
27
27
|
|
|
28
28
|
return render_error(response) if response.code != 200
|
|
29
29
|
|
|
@@ -31,15 +31,13 @@ module ZohoBooks
|
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
def self.delete(url)
|
|
34
|
-
response = HTTParty.delete(url, headers:
|
|
34
|
+
response = HTTParty.delete(url, headers:)
|
|
35
35
|
|
|
36
36
|
return render_error(response) if response.code != 200
|
|
37
37
|
|
|
38
38
|
response
|
|
39
39
|
end
|
|
40
40
|
|
|
41
|
-
private
|
|
42
|
-
|
|
43
41
|
def self.headers
|
|
44
42
|
{
|
|
45
43
|
'Authorization' => "Zoho-oauthtoken #{access_token}",
|
|
@@ -56,7 +54,7 @@ module ZohoBooks
|
|
|
56
54
|
end
|
|
57
55
|
|
|
58
56
|
def self.render_error(response)
|
|
59
|
-
ZohoBooks::Error.new(response.code, response[
|
|
57
|
+
ZohoBooks::Error.new(response.code, response['message'] || '')
|
|
60
58
|
end
|
|
61
59
|
end
|
|
62
60
|
end
|
data/lib/zoho_books/contact.rb
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
|
|
2
3
|
require 'httparty'
|
|
3
4
|
|
|
4
5
|
module ZohoBooks
|
|
@@ -7,20 +8,22 @@ module ZohoBooks
|
|
|
7
8
|
query = opts.map { |k, v| "#{k}=#{v}" }.join('&')
|
|
8
9
|
ZohoBooks::Connection.get("#{BASE_URL}/contacts?organization_id=#{ZohoBooks.config.organization_id}&#{query}")
|
|
9
10
|
end
|
|
10
|
-
|
|
11
|
-
def self.get(id,
|
|
11
|
+
|
|
12
|
+
def self.get(id, _opts = {})
|
|
12
13
|
ZohoBooks::Connection.get("#{BASE_URL}/contacts/#{id}?organization_id=#{ZohoBooks.config.organization_id}")
|
|
13
14
|
end
|
|
14
15
|
|
|
15
|
-
def self.create(body,
|
|
16
|
-
ZohoBooks::Connection.post("#{BASE_URL}/contacts?organization_id=#{ZohoBooks.config.organization_id}",
|
|
16
|
+
def self.create(body, _opts = {})
|
|
17
|
+
ZohoBooks::Connection.post("#{BASE_URL}/contacts?organization_id=#{ZohoBooks.config.organization_id}",
|
|
18
|
+
body.to_json)
|
|
17
19
|
end
|
|
18
20
|
|
|
19
|
-
def self.update(id, body,
|
|
20
|
-
ZohoBooks::Connection.put("#{BASE_URL}/contacts/#{id}?organization_id=#{ZohoBooks.config.organization_id}",
|
|
21
|
+
def self.update(id, body, _opts = {})
|
|
22
|
+
ZohoBooks::Connection.put("#{BASE_URL}/contacts/#{id}?organization_id=#{ZohoBooks.config.organization_id}",
|
|
23
|
+
body.to_json)
|
|
21
24
|
end
|
|
22
25
|
|
|
23
|
-
def self.delete(id,
|
|
26
|
+
def self.delete(id, _opts = {})
|
|
24
27
|
ZohoBooks::Connection.delete("#{BASE_URL}/contacts/#{id}?organization_id=#{ZohoBooks.config.organization_id}")
|
|
25
28
|
end
|
|
26
29
|
end
|
data/lib/zoho_books/estimate.rb
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
|
|
2
3
|
require 'httparty'
|
|
3
4
|
|
|
4
5
|
module ZohoBooks
|
|
@@ -8,19 +9,22 @@ module ZohoBooks
|
|
|
8
9
|
ZohoBooks::Connection.get("#{BASE_URL}/estimates?organization_id=#{ZohoBooks.config.organization_id}&#{query}")
|
|
9
10
|
end
|
|
10
11
|
|
|
11
|
-
def self.get(id,
|
|
12
|
-
|
|
12
|
+
def self.get(id, _opts = {})
|
|
13
|
+
query = _opts.map { |k, v| "#{k}=#{v}" }.join('&')
|
|
14
|
+
ZohoBooks::Connection.get("#{BASE_URL}/estimates/#{id}?organization_id=#{ZohoBooks.config.organization_id}&#{query}")
|
|
13
15
|
end
|
|
14
16
|
|
|
15
|
-
def self.create(body,
|
|
16
|
-
ZohoBooks::Connection.post("#{BASE_URL}/estimates?organization_id=#{ZohoBooks.config.organization_id}",
|
|
17
|
+
def self.create(body, _opts = {})
|
|
18
|
+
ZohoBooks::Connection.post("#{BASE_URL}/estimates?organization_id=#{ZohoBooks.config.organization_id}",
|
|
19
|
+
body.to_json)
|
|
17
20
|
end
|
|
18
21
|
|
|
19
|
-
def self.update(id, body,
|
|
20
|
-
ZohoBooks::Connection.put("#{BASE_URL}/estimates/#{id}?organization_id=#{ZohoBooks.config.organization_id}",
|
|
22
|
+
def self.update(id, body, _opts = {})
|
|
23
|
+
ZohoBooks::Connection.put("#{BASE_URL}/estimates/#{id}?organization_id=#{ZohoBooks.config.organization_id}",
|
|
24
|
+
body.to_json)
|
|
21
25
|
end
|
|
22
26
|
|
|
23
|
-
def self.delete(id,
|
|
27
|
+
def self.delete(id, _opts = {})
|
|
24
28
|
ZohoBooks::Connection.delete("#{BASE_URL}/estimates/#{id}?organization_id=#{ZohoBooks.config.organization_id}")
|
|
25
29
|
end
|
|
26
30
|
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'httparty'
|
|
4
|
+
|
|
5
|
+
module ZohoBooks
|
|
6
|
+
class Invoice
|
|
7
|
+
def self.list(opts = {})
|
|
8
|
+
query = opts.map { |k, v| "#{k}=#{v}" }.join('&')
|
|
9
|
+
ZohoBooks::Connection.get("#{BASE_URL}/invoices?organization_id=#{ZohoBooks.config.organization_id}&#{query}")
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def self.get(id, _opts = {})
|
|
13
|
+
ZohoBooks::Connection.get("#{BASE_URL}/invoices/#{id}?organization_id=#{ZohoBooks.config.organization_id}")
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def self.create(body, _opts = {})
|
|
17
|
+
ZohoBooks::Connection.post("#{BASE_URL}/invoices?organization_id=#{ZohoBooks.config.organization_id}",
|
|
18
|
+
body.to_json)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def self.update(id, body, _opts = {})
|
|
22
|
+
ZohoBooks::Connection.put("#{BASE_URL}/invoices/#{id}?organization_id=#{ZohoBooks.config.organization_id}",
|
|
23
|
+
body.to_json)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def self.delete(id, _opts = {})
|
|
27
|
+
ZohoBooks::Connection.delete("#{BASE_URL}/invoices/#{id}?organization_id=#{ZohoBooks.config.organization_id}")
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
data/lib/zoho_books/item.rb
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
|
|
2
3
|
require 'httparty'
|
|
3
4
|
|
|
4
5
|
module ZohoBooks
|
|
@@ -8,15 +9,20 @@ module ZohoBooks
|
|
|
8
9
|
ZohoBooks::Connection.get("#{BASE_URL}/items?organization_id=#{ZohoBooks.config.organization_id}&#{query}")
|
|
9
10
|
end
|
|
10
11
|
|
|
11
|
-
def self.
|
|
12
|
+
def self.get(id, _opts = {})
|
|
13
|
+
ZohoBooks::Connection.get("#{BASE_URL}/items/#{id}?organization_id=#{ZohoBooks.config.organization_id}")
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def self.create(body, _opts = {})
|
|
12
17
|
ZohoBooks::Connection.post("#{BASE_URL}/items?organization_id=#{ZohoBooks.config.organization_id}", body.to_json)
|
|
13
18
|
end
|
|
14
19
|
|
|
15
|
-
def self.update(id, body,
|
|
16
|
-
ZohoBooks::Connection.put("#{BASE_URL}/items/#{id}?organization_id=#{ZohoBooks.config.organization_id}",
|
|
20
|
+
def self.update(id, body, _opts = {})
|
|
21
|
+
ZohoBooks::Connection.put("#{BASE_URL}/items/#{id}?organization_id=#{ZohoBooks.config.organization_id}",
|
|
22
|
+
body.to_json)
|
|
17
23
|
end
|
|
18
24
|
|
|
19
|
-
def self.delete(id,
|
|
25
|
+
def self.delete(id, _opts = {})
|
|
20
26
|
ZohoBooks::Connection.delete("#{BASE_URL}/items/#{id}?organization_id=#{ZohoBooks.config.organization_id}")
|
|
21
27
|
end
|
|
22
28
|
end
|
data/lib/zoho_books/tax.rb
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
|
|
2
3
|
require 'httparty'
|
|
3
4
|
|
|
4
5
|
module ZohoBooks
|
|
@@ -8,19 +9,21 @@ module ZohoBooks
|
|
|
8
9
|
ZohoBooks::Connection.get("#{BASE_URL}/settings/taxes?organization_id=#{ZohoBooks.config.organization_id}&#{query}")
|
|
9
10
|
end
|
|
10
11
|
|
|
11
|
-
def self.get(id,
|
|
12
|
+
def self.get(id, _opts = {})
|
|
12
13
|
ZohoBooks::Connection.get("#{BASE_URL}/settings/taxes/#{id}?organization_id=#{ZohoBooks.config.organization_id}")
|
|
13
14
|
end
|
|
14
15
|
|
|
15
|
-
def self.create(body,
|
|
16
|
-
ZohoBooks::Connection.post("#{BASE_URL}/settings/taxes?organization_id=#{ZohoBooks.config.organization_id}",
|
|
16
|
+
def self.create(body, _opts = {})
|
|
17
|
+
ZohoBooks::Connection.post("#{BASE_URL}/settings/taxes?organization_id=#{ZohoBooks.config.organization_id}",
|
|
18
|
+
body.to_json)
|
|
17
19
|
end
|
|
18
20
|
|
|
19
|
-
def self.update(id, body,
|
|
20
|
-
ZohoBooks::Connection.put("#{BASE_URL}/settings/taxes/#{id}?organization_id=#{ZohoBooks.config.organization_id}",
|
|
21
|
+
def self.update(id, body, _opts = {})
|
|
22
|
+
ZohoBooks::Connection.put("#{BASE_URL}/settings/taxes/#{id}?organization_id=#{ZohoBooks.config.organization_id}",
|
|
23
|
+
body.to_json)
|
|
21
24
|
end
|
|
22
25
|
|
|
23
|
-
def self.delete(id,
|
|
26
|
+
def self.delete(id, _opts = {})
|
|
24
27
|
ZohoBooks::Connection.delete("#{BASE_URL}/settings/taxes/#{id}?organization_id=#{ZohoBooks.config.organization_id}")
|
|
25
28
|
end
|
|
26
29
|
end
|
data/lib/zoho_books.rb
CHANGED
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.7.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- PapaLoup
|
|
@@ -10,7 +10,7 @@ authors:
|
|
|
10
10
|
autorequire:
|
|
11
11
|
bindir: bin
|
|
12
12
|
cert_chain: []
|
|
13
|
-
date: 2023-10-
|
|
13
|
+
date: 2023-10-20 00:00:00.000000000 Z
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
16
16
|
name: httparty
|
|
@@ -40,6 +40,7 @@ files:
|
|
|
40
40
|
- lib/zoho_books/error.rb
|
|
41
41
|
- lib/zoho_books/estimate.rb
|
|
42
42
|
- lib/zoho_books/estimates/template.rb
|
|
43
|
+
- lib/zoho_books/invoice.rb
|
|
43
44
|
- lib/zoho_books/item.rb
|
|
44
45
|
- lib/zoho_books/tax.rb
|
|
45
46
|
homepage: https://rubygems.org/gems/zoho_books
|