zoho_books 0.0.5 → 0.0.7

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: bb4b8600d21b217c2da5192625ef25fb2148a45bbe74107b19c34dba8c0dd8d2
4
- data.tar.gz: 0265b974da780a632dbd3c5a8bc441413a3c81ff04201c7bf7d4aa1ef83a2325
3
+ metadata.gz: aa494c986b5d2a51bd61c12e12d1daf454c548447d9cf0622874ffaa66ff4142
4
+ data.tar.gz: 7fd8d731a793fca4aa5206c9f9e51196cb86ebf2819ac99af23194b4f5aa01b6
5
5
  SHA512:
6
- metadata.gz: '08a246a314ef77fc8dac92e7d3ee6973aa6766c9783a793f641a342d91c94ac366fdad3ec09622c201a518ff0d03536dfe7d4279125b40423db7d5e06983879d'
7
- data.tar.gz: 4337a73f4112cd54a7c0cfd106f4f10c0f41bdea7cfb192615580814b105a03469324de06a9ad7e20d1407fa7696b1cefb9ce18016dbc4cf6c7c8e61eb3ac432
6
+ metadata.gz: dfc9f595f0b0c07cd0b361e38ee295aba573081147f782466b3634ecdf1b5f40497ec16e1debc7103d3f17436a6fe3e4defd1b002e7a3213efa5d24cc2de989c
7
+ data.tar.gz: a360ee96fbc8fc44849e76ec27dee02e10127110471fdf5fb5244e57e7fa1ba5cad9c4c4f59b856e6e980576f8497d83e45e5100b504f511df70385d721c0dce
@@ -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["error"]) if response.code != 200
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
@@ -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 = "https://accounts.zoho.eu".freeze
8
+ DEFAULT_BASE_URL = 'https://accounts.zoho.eu'
7
9
 
8
10
  def initialize(config = {})
9
- @base_url = config["base_url"] || DEFAULT_BASE_URL
10
- @portal_id = config["portal_id"]
11
- @access_token = config["access_token"]
12
- @client_id = config["client_id"]
13
- @client_secret = config["client_secret"]
14
- @redirect_uri = config["redirect_uri"]
15
- @organization_id = config["organization_id"]
16
- @refresh_token = config["refresh_token"]
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,19 +1,21 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'httparty'
3
4
 
4
5
  module ZohoBooks
5
- class Connection
6
+ BASE_URL = 'https://www.zohoapis.eu/books/v3'
6
7
 
8
+ class Connection
7
9
  def self.get(url)
8
- response = HTTParty.get(url, headers: headers)
10
+ response = HTTParty.get(url, headers:)
9
11
 
10
- 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
11
13
 
12
14
  response
13
15
  end
14
16
 
15
17
  def self.post(url, body)
16
- response = HTTParty.post(url, body: body, headers: headers)
18
+ response = HTTParty.post(url, body:, headers:)
17
19
 
18
20
  return render_error(response) if response.code != 201
19
21
 
@@ -21,7 +23,7 @@ module ZohoBooks
21
23
  end
22
24
 
23
25
  def self.put(url, body)
24
- response = HTTParty.put(url, body: body, headers: headers)
26
+ response = HTTParty.put(url, body:, headers:)
25
27
 
26
28
  return render_error(response) if response.code != 200
27
29
 
@@ -29,15 +31,13 @@ module ZohoBooks
29
31
  end
30
32
 
31
33
  def self.delete(url)
32
- response = HTTParty.delete(url, headers: headers)
34
+ response = HTTParty.delete(url, headers:)
33
35
 
34
36
  return render_error(response) if response.code != 200
35
37
 
36
38
  response
37
39
  end
38
40
 
39
- private
40
-
41
41
  def self.headers
42
42
  {
43
43
  'Authorization' => "Zoho-oauthtoken #{access_token}",
@@ -54,7 +54,7 @@ module ZohoBooks
54
54
  end
55
55
 
56
56
  def self.render_error(response)
57
- ZohoBooks::Error.new(response.code, response["message"] || '')
57
+ ZohoBooks::Error.new(response.code, response['message'] || '')
58
58
  end
59
59
  end
60
60
  end
@@ -1,28 +1,29 @@
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
-
7
6
  class Contact
8
7
  def self.list(opts = {})
9
8
  query = opts.map { |k, v| "#{k}=#{v}" }.join('&')
10
9
  ZohoBooks::Connection.get("#{BASE_URL}/contacts?organization_id=#{ZohoBooks.config.organization_id}&#{query}")
11
10
  end
12
-
13
- def self.get(id, opts = {})
11
+
12
+ def self.get(id, _opts = {})
14
13
  ZohoBooks::Connection.get("#{BASE_URL}/contacts/#{id}?organization_id=#{ZohoBooks.config.organization_id}")
15
14
  end
16
15
 
17
- def self.create(body, opts = {})
18
- ZohoBooks::Connection.post("#{BASE_URL}/contacts?organization_id=#{ZohoBooks.config.organization_id}", body.to_json)
16
+ def self.create(body, _opts = {})
17
+ ZohoBooks::Connection.post("#{BASE_URL}/contacts?organization_id=#{ZohoBooks.config.organization_id}",
18
+ body.to_json)
19
19
  end
20
20
 
21
- def self.update(id, body, opts = {})
22
- ZohoBooks::Connection.put("#{BASE_URL}/contacts/#{id}?organization_id=#{ZohoBooks.config.organization_id}", body.to_json)
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)
23
24
  end
24
25
 
25
- def self.delete(id, opts = {})
26
+ def self.delete(id, _opts = {})
26
27
  ZohoBooks::Connection.delete("#{BASE_URL}/contacts/#{id}?organization_id=#{ZohoBooks.config.organization_id}")
27
28
  end
28
29
  end
@@ -0,0 +1,30 @@
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
+ ZohoBooks::Connection.get("#{BASE_URL}/estimates/#{id}?organization_id=#{ZohoBooks.config.organization_id}")
14
+ end
15
+
16
+ def self.create(body, _opts = {})
17
+ ZohoBooks::Connection.post("#{BASE_URL}/estimates?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}/estimates/#{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}/estimates/#{id}?organization_id=#{ZohoBooks.config.organization_id}")
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,13 @@
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
@@ -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
@@ -1,24 +1,28 @@
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
-
7
6
  class Item
8
7
  def self.list(opts = {})
9
8
  query = opts.map { |k, v| "#{k}=#{v}" }.join('&')
10
9
  ZohoBooks::Connection.get("#{BASE_URL}/items?organization_id=#{ZohoBooks.config.organization_id}&#{query}")
11
10
  end
12
11
 
13
- def self.create(body, opts = {})
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 = {})
14
17
  ZohoBooks::Connection.post("#{BASE_URL}/items?organization_id=#{ZohoBooks.config.organization_id}", body.to_json)
15
18
  end
16
19
 
17
- def self.update(id, body, opts = {})
18
- ZohoBooks::Connection.put("#{BASE_URL}/items/#{id}?organization_id=#{ZohoBooks.config.organization_id}", body.to_json)
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)
19
23
  end
20
24
 
21
- def self.delete(id, opts = {})
25
+ def self.delete(id, _opts = {})
22
26
  ZohoBooks::Connection.delete("#{BASE_URL}/items/#{id}?organization_id=#{ZohoBooks.config.organization_id}")
23
27
  end
24
28
  end
@@ -0,0 +1,30 @@
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
data/lib/zoho_books.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ZohoBooks
2
4
  end
3
5
 
@@ -7,4 +9,7 @@ require 'zoho_books/connection'
7
9
  require 'zoho_books/item'
8
10
  require 'zoho_books/config'
9
11
  require 'zoho_books/contact'
10
-
12
+ require 'zoho_books/estimate'
13
+ require 'zoho_books/estimates/template'
14
+ require 'zoho_books/tax'
15
+ require 'zoho_books/invoice'
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zoho_books
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - PapaLoup
8
8
  - Raphtml
9
9
  - theobcl
10
- autorequire:
10
+ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2023-10-02 00:00:00.000000000 Z
13
+ date: 2023-10-19 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: httparty
@@ -38,12 +38,16 @@ files:
38
38
  - lib/zoho_books/connection.rb
39
39
  - lib/zoho_books/contact.rb
40
40
  - lib/zoho_books/error.rb
41
+ - lib/zoho_books/estimate.rb
42
+ - lib/zoho_books/estimates/template.rb
43
+ - lib/zoho_books/invoice.rb
41
44
  - lib/zoho_books/item.rb
45
+ - lib/zoho_books/tax.rb
42
46
  homepage: https://rubygems.org/gems/zoho_books
43
47
  licenses:
44
48
  - MIT
45
49
  metadata: {}
46
- post_install_message:
50
+ post_install_message:
47
51
  rdoc_options: []
48
52
  require_paths:
49
53
  - lib
@@ -58,8 +62,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
58
62
  - !ruby/object:Gem::Version
59
63
  version: '0'
60
64
  requirements: []
61
- rubygems_version: 3.1.6
62
- signing_key:
65
+ rubygems_version: 3.3.26
66
+ signing_key:
63
67
  specification_version: 4
64
68
  summary: Zoho Books API wrapper
65
69
  test_files: []