zoho_books 0.0.7.6 → 0.0.41

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 79421c4d03ccd34a3f432588ca683e7fdf6293837367c5b38e62bdad8db4a3d7
4
- data.tar.gz: 062d84d3147e2f9f74cce73aec394b762c01081fed46ca6fc09dc00872d08255
3
+ metadata.gz: 585a879d5ea41b068f4463c17c4fc198f80b41bfcbe53f28885a968da83ec4c0
4
+ data.tar.gz: 67365eb6b896b6e9bf03c8c5eff56aa83883be7ba9bcb35b984ca20b706f7896
5
5
  SHA512:
6
- metadata.gz: f9d1a7acef2169bb7199d4f928ef4af0e334ab507ea580e52f0bc3239469622f0efdf415a675a0f69e50aba4826034a2a22f7baf1b0249ca09b478c9ac2591c1
7
- data.tar.gz: 32313219e7e4786476c666c162a6b3b27873da81aaf141863e8ff49c1d8478d2ba5530121dd065e8c6092d2a7c3fa7fd4c7a96dc5daf12653a7248229e9dab38
6
+ metadata.gz: d763d9eb0864e76276d0110ac1ee1bb4d7e174ecf15447d3233ca1599aa2c2514003cf25e34b9d79b3d758a27f80a18fb5f88021d59a58fd772278d37058e51b
7
+ data.tar.gz: 604ca3da71ff52eae434b09dde3187694f035c02506b3db9123b409f487979f92a1edab91b1e32332a0d2a123db193365af25f583e270ea8d6d0cf52e9edf4dc
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
-
3
2
  require 'httparty'
3
+ require 'zoho_books/error'
4
+ require_relative 'zoho_books/config'
4
5
 
5
6
  module ZohoBooks
6
7
  class Auth
@@ -8,7 +9,7 @@ module ZohoBooks
8
9
  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"
9
10
  response = HTTParty.post("#{ZohoBooks.config.base_url}/#{endoint_url}")
10
11
 
11
- return ZohoBooks::Error.new(response.code, response['error']) if response.code != 200
12
+ return ZohoBooks::Error.new(response.code, response["error"]) if response.code != 200
12
13
 
13
14
  ZohoBooks.config.access_token = response.parsed_response['access_token']
14
15
  ZohoBooks.config.access_token_expires_at = Time.now.to_i + response.parsed_response['expires_in'].to_i
data/lib/zoho_books.rb CHANGED
@@ -1,19 +1,9 @@
1
- # frozen_string_literal: true
2
-
3
1
  module ZohoBooks
4
2
  end
5
3
 
6
- require 'zoho_books/auth'
7
- require 'zoho_books/error'
8
- require 'zoho_books/connection'
9
- require 'zoho_books/item'
10
- require 'zoho_books/config'
11
- require 'zoho_books/contact'
12
- require 'zoho_books/estimate'
13
- require 'zoho_books/estimates/template'
14
- require 'zoho_books/tax'
15
- require 'zoho_books/invoice'
16
- require 'zoho_books/invoices/status'
17
- require 'zoho_books/invoices/pdf'
18
- require 'zoho_books/payment'
19
- require 'zoho_books/credit_note'
4
+ require_relative 'zoho_books/auth'
5
+ require_relative 'zoho_books/error'
6
+ require_relative 'zoho_books/connection'
7
+ require_relative 'zoho_books/item'
8
+ require_relative 'zoho_books/config'
9
+
metadata CHANGED
@@ -1,16 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zoho_books
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7.6
4
+ version: 0.0.41
5
5
  platform: ruby
6
6
  authors:
7
7
  - PapaLoup
8
8
  - Raphtml
9
- - theobcl
10
9
  autorequire:
11
10
  bindir: bin
12
11
  cert_chain: []
13
- date: 2024-07-29 00:00:00.000000000 Z
12
+ date: 2023-09-25 00:00:00.000000000 Z
14
13
  dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: httparty
@@ -34,19 +33,7 @@ extra_rdoc_files: []
34
33
  files:
35
34
  - lib/zoho_books.rb
36
35
  - lib/zoho_books/auth.rb
37
- - lib/zoho_books/config.rb
38
- - lib/zoho_books/connection.rb
39
- - lib/zoho_books/contact.rb
40
- - lib/zoho_books/credit_note.rb
41
36
  - lib/zoho_books/error.rb
42
- - lib/zoho_books/estimate.rb
43
- - lib/zoho_books/estimates/template.rb
44
- - lib/zoho_books/invoice.rb
45
- - lib/zoho_books/invoices/pdf.rb
46
- - lib/zoho_books/invoices/status.rb
47
- - lib/zoho_books/item.rb
48
- - lib/zoho_books/payment.rb
49
- - lib/zoho_books/tax.rb
50
37
  homepage: https://rubygems.org/gems/zoho_books
51
38
  licenses:
52
39
  - MIT
@@ -66,7 +53,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
66
53
  - !ruby/object:Gem::Version
67
54
  version: '0'
68
55
  requirements: []
69
- rubygems_version: 3.4.19
56
+ rubygems_version: 3.3.7
70
57
  signing_key:
71
58
  specification_version: 4
72
59
  summary: Zoho Books API wrapper
@@ -1,32 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module ZohoBooks
4
- class Config
5
- attr_accessor :client_id, :client_secret, :redirect_uri, :refresh_token, :base_url,
6
- :portal_id, :access_token, :organization_id, :refresh_token, :access_token_expires_at
7
-
8
- DEFAULT_BASE_URL = 'https://accounts.zoho.eu'
9
-
10
- def initialize(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']
19
-
20
- @access_token_expires_at = nil
21
- end
22
- end
23
-
24
- class << self
25
- attr_accessor :config
26
-
27
- def configure
28
- self.config ||= Config.new
29
- yield(config)
30
- end
31
- end
32
- end
@@ -1,60 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'httparty'
4
-
5
- module ZohoBooks
6
- BASE_URL = 'https://www.zohoapis.eu/books/v3'
7
-
8
- class Connection
9
- def self.get(url, stream_body = false)
10
- response = HTTParty.get(url, headers:, stream_body:)
11
-
12
- return ZohoBooks::Error.new(response.code, response['error']) if response.code != 200
13
-
14
- response
15
- end
16
-
17
- def self.post(url, body)
18
- response = HTTParty.post(url, body:, headers:)
19
-
20
- return render_error(response) unless [200, 201].include?(response.code)
21
-
22
- response
23
- end
24
-
25
- def self.put(url, body)
26
- response = HTTParty.put(url, body:, headers:)
27
-
28
- return render_error(response) if response.code != 200
29
-
30
- response
31
- end
32
-
33
- def self.delete(url)
34
- response = HTTParty.delete(url, headers:)
35
-
36
- return render_error(response) if response.code != 200
37
-
38
- response
39
- end
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
-
56
- def self.render_error(response)
57
- ZohoBooks::Error.new(response.code, response['message'] || '')
58
- end
59
- end
60
- end
@@ -1,30 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'httparty'
4
-
5
- module ZohoBooks
6
- class Contact
7
- def self.list(opts = {})
8
- query = opts.map { |k, v| "#{k}=#{v}" }.join('&')
9
- ZohoBooks::Connection.get("#{BASE_URL}/contacts?organization_id=#{ZohoBooks.config.organization_id}&#{query}")
10
- end
11
-
12
- def self.get(id, _opts = {})
13
- ZohoBooks::Connection.get("#{BASE_URL}/contacts/#{id}?organization_id=#{ZohoBooks.config.organization_id}")
14
- end
15
-
16
- def self.create(body, _opts = {})
17
- ZohoBooks::Connection.post("#{BASE_URL}/contacts?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}/contacts/#{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}/contacts/#{id}?organization_id=#{ZohoBooks.config.organization_id}")
28
- end
29
- end
30
- end
@@ -1,22 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'httparty'
4
-
5
- module ZohoBooks
6
- class CreditNote
7
- def self.list(opts = {})
8
- query = opts.map { |k, v| "#{k}=#{v}" }.join('&')
9
- ZohoBooks::Connection.get("#{BASE_URL}/creditnotes?organization_id=#{ZohoBooks.config.organization_id}&#{query}")
10
- end
11
-
12
- def self.get(id, _opts = {})
13
- query = _opts.map { |k, v| "#{k}=#{v}" }.join('&')
14
- ZohoBooks::Connection.get("#{BASE_URL}/creditnotes/#{id}?organization_id=#{ZohoBooks.config.organization_id}&#{query}")
15
- end
16
-
17
- def self.create(body, _opts = {})
18
- ZohoBooks::Connection.post("#{BASE_URL}/creditnotes?organization_id=#{ZohoBooks.config.organization_id}",
19
- body.to_json)
20
- end
21
- end
22
- end
@@ -1,31 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'httparty'
4
-
5
- module ZohoBooks
6
- class Estimate
7
- def self.list(opts = {})
8
- query = opts.map { |k, v| "#{k}=#{v}" }.join('&')
9
- ZohoBooks::Connection.get("#{BASE_URL}/estimates?organization_id=#{ZohoBooks.config.organization_id}&#{query}")
10
- end
11
-
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}")
15
- end
16
-
17
- def self.create(body, _opts = {})
18
- ZohoBooks::Connection.post("#{BASE_URL}/estimates?organization_id=#{ZohoBooks.config.organization_id}",
19
- body.to_json)
20
- end
21
-
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)
25
- end
26
-
27
- def self.delete(id, _opts = {})
28
- ZohoBooks::Connection.delete("#{BASE_URL}/estimates/#{id}?organization_id=#{ZohoBooks.config.organization_id}")
29
- end
30
- end
31
- end
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'httparty'
4
-
5
- module ZohoBooks
6
- module Estimates
7
- class Template
8
- def self.list
9
- ZohoBooks::Connection.get("#{BASE_URL}/estimates/templates?organization_id=#{ZohoBooks.config.organization_id}")
10
- end
11
- end
12
- end
13
- end
@@ -1,31 +0,0 @@
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
- query = _opts.map { |k, v| "#{k}=#{v}" }.join('&')
14
- ZohoBooks::Connection.get("#{BASE_URL}/invoices/#{id}?organization_id=#{ZohoBooks.config.organization_id}&#{query}")
15
- end
16
-
17
- def self.create(body, _opts = {})
18
- ZohoBooks::Connection.post("#{BASE_URL}/invoices?organization_id=#{ZohoBooks.config.organization_id}",
19
- body.to_json)
20
- end
21
-
22
- def self.update(id, body, _opts = {})
23
- ZohoBooks::Connection.put("#{BASE_URL}/invoices/#{id}?organization_id=#{ZohoBooks.config.organization_id}",
24
- body.to_json)
25
- end
26
-
27
- def self.delete(id, _opts = {})
28
- ZohoBooks::Connection.delete("#{BASE_URL}/invoices/#{id}?organization_id=#{ZohoBooks.config.organization_id}")
29
- end
30
- end
31
- end
@@ -1,11 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module ZohoBooks
4
- module Invoices
5
- class Pdf
6
- def self.get(invoice_ids)
7
- ZohoBooks::Connection.get("#{BASE_URL}/invoices/pdf?organization_id=#{ZohoBooks.config.organization_id}&invoice_ids=#{invoice_ids.join(',')}", true)
8
- end
9
- end
10
- end
11
- end
@@ -1,11 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module ZohoBooks
4
- module Invoices
5
- class Status
6
- def self.update(id)
7
- ZohoBooks::Connection.post("#{BASE_URL}/invoices/#{id}/status/sent?organization_id=#{ZohoBooks.config.organization_id}", {}.to_json)
8
- end
9
- end
10
- end
11
- end
@@ -1,29 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'httparty'
4
-
5
- module ZohoBooks
6
- class Item
7
- def self.list(opts = {})
8
- query = opts.map { |k, v| "#{k}=#{v}" }.join('&')
9
- ZohoBooks::Connection.get("#{BASE_URL}/items?organization_id=#{ZohoBooks.config.organization_id}&#{query}")
10
- end
11
-
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 = {})
17
- ZohoBooks::Connection.post("#{BASE_URL}/items?organization_id=#{ZohoBooks.config.organization_id}", body.to_json)
18
- end
19
-
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)
23
- end
24
-
25
- def self.delete(id, _opts = {})
26
- ZohoBooks::Connection.delete("#{BASE_URL}/items/#{id}?organization_id=#{ZohoBooks.config.organization_id}")
27
- end
28
- end
29
- end
@@ -1,11 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'httparty'
4
-
5
- module ZohoBooks
6
- class Payment
7
- def self.create(body, _opts = {})
8
- ZohoBooks::Connection.post("#{BASE_URL}/customerpayments?organization_id=#{ZohoBooks.config.organization_id}", body.to_json)
9
- end
10
- end
11
- end
@@ -1,30 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'httparty'
4
-
5
- module ZohoBooks
6
- class Tax
7
- def self.list(opts = {})
8
- query = opts.map { |k, v| "#{k}=#{v}" }.join('&')
9
- ZohoBooks::Connection.get("#{BASE_URL}/settings/taxes?organization_id=#{ZohoBooks.config.organization_id}&#{query}")
10
- end
11
-
12
- def self.get(id, _opts = {})
13
- ZohoBooks::Connection.get("#{BASE_URL}/settings/taxes/#{id}?organization_id=#{ZohoBooks.config.organization_id}")
14
- end
15
-
16
- def self.create(body, _opts = {})
17
- ZohoBooks::Connection.post("#{BASE_URL}/settings/taxes?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}/settings/taxes/#{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}/settings/taxes/#{id}?organization_id=#{ZohoBooks.config.organization_id}")
28
- end
29
- end
30
- end