einvoice 1.5.0 → 2.0.0.alpha2

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.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/.coderabbit.yaml +6 -8
  3. data/.github/workflows/build.yml +6 -3
  4. data/CHANGELOG.md +43 -44
  5. data/Gemfile +3 -10
  6. data/README.md +221 -328
  7. data/README.zh-TW.md +322 -0
  8. data/Rakefile +2 -51
  9. data/bin/console +3 -6
  10. data/einvoice.gemspec +16 -18
  11. data/lib/einvoice/amego/client.rb +116 -0
  12. data/lib/einvoice/amego/errors.rb +84 -0
  13. data/lib/einvoice/amego/payload.rb +276 -0
  14. data/lib/einvoice/amego/provider.rb +267 -0
  15. data/lib/einvoice/amego.rb +27 -0
  16. data/lib/einvoice/capability.rb +79 -0
  17. data/lib/einvoice/ecpay/client.rb +183 -0
  18. data/lib/einvoice/ecpay/crypto.rb +85 -0
  19. data/lib/einvoice/ecpay/errors.rb +115 -0
  20. data/lib/einvoice/ecpay/payload.rb +241 -0
  21. data/lib/einvoice/ecpay/provider.rb +362 -0
  22. data/lib/einvoice/ecpay.rb +31 -0
  23. data/lib/einvoice/error.rb +220 -0
  24. data/lib/einvoice/ezpay/client.rb +130 -0
  25. data/lib/einvoice/ezpay/crypto.rb +85 -0
  26. data/lib/einvoice/ezpay/errors.rb +72 -0
  27. data/lib/einvoice/ezpay/payload.rb +269 -0
  28. data/lib/einvoice/ezpay/provider.rb +235 -0
  29. data/lib/einvoice/ezpay.rb +19 -0
  30. data/lib/einvoice/input.rb +494 -0
  31. data/lib/einvoice/mock_provider.rb +191 -0
  32. data/lib/einvoice/mof/donation_codes.rb +157 -0
  33. data/lib/einvoice/mof.rb +16 -0
  34. data/lib/einvoice/number.rb +51 -0
  35. data/lib/einvoice/provider.rb +57 -13
  36. data/lib/einvoice/redaction.rb +54 -0
  37. data/lib/einvoice/taipei.rb +89 -0
  38. data/lib/einvoice/tax_split.rb +124 -0
  39. data/lib/einvoice/tradevan/default_api/client.rb +175 -0
  40. data/lib/einvoice/tradevan/default_api/crypto.rb +90 -0
  41. data/lib/einvoice/tradevan/default_api/errors.rb +54 -0
  42. data/lib/einvoice/tradevan/default_api/payload.rb +259 -0
  43. data/lib/einvoice/tradevan/default_api/provider.rb +366 -0
  44. data/lib/einvoice/tradevan/default_api/rules.rb +314 -0
  45. data/lib/einvoice/tradevan.rb +25 -0
  46. data/lib/einvoice/types.rb +323 -0
  47. data/lib/einvoice/version.rb +3 -1
  48. data/lib/einvoice.rb +21 -9
  49. metadata +52 -145
  50. data/.github/workflows/cron.yml +0 -31
  51. data/docs/Tradevan E-Invoice APIs.md +0 -201
  52. data/docs/neweb.md +0 -347
  53. data/lib/einvoice/client.rb +0 -21
  54. data/lib/einvoice/configuration.rb +0 -49
  55. data/lib/einvoice/connection.rb +0 -31
  56. data/lib/einvoice/donation_unit_list.json +0 -2025
  57. data/lib/einvoice/result.rb +0 -21
  58. data/lib/einvoice/tradevan/model/base.rb +0 -34
  59. data/lib/einvoice/tradevan/model/issue_data.rb +0 -129
  60. data/lib/einvoice/tradevan/model/issue_item.rb +0 -41
  61. data/lib/einvoice/tradevan/model/void_data.rb +0 -35
  62. data/lib/einvoice/tradevan/provider.rb +0 -139
  63. data/lib/einvoice/tradevan/result.rb +0 -25
  64. data/lib/einvoice/tradevan/validator/issue_data_validator.rb +0 -80
  65. data/lib/faraday/response/decode_tradevan.rb +0 -37
  66. data/lib/faraday/response/parse_xml.rb +0 -14
@@ -1,49 +0,0 @@
1
- require "faraday"
2
-
3
- module Einvoice
4
- module Configuration
5
- VALID_OPTIONS_KEYS = [
6
- :endpoint,
7
- :endpoint_url,
8
- :client_id,
9
- :client_secret,
10
- :encryption_keys,
11
- :format,
12
- :ssl_verify
13
- ].freeze
14
-
15
- DEFAULT_CLIENT_ID = nil
16
- DEFAULT_CLIENT_SECRET = nil
17
- DEFAULT_ENDPOINT = "".freeze
18
- DEFAULT_ENDPOINT_URL = nil
19
- DEFAULT_FORMAT = ""
20
- DEFAULT_ENCRYPTION_KEYS = {}
21
- DEFAULT_SSL_VERIFY = true
22
-
23
- attr_accessor(*VALID_OPTIONS_KEYS)
24
-
25
- def self.extended(base)
26
- base.reset
27
- end
28
-
29
- def configure
30
- yield self
31
- end
32
-
33
- def options
34
- VALID_OPTIONS_KEYS.inject({}) do |option, key|
35
- option.merge!(key => send(key))
36
- end
37
- end
38
-
39
- def reset
40
- self.client_id = DEFAULT_CLIENT_ID
41
- self.client_secret = DEFAULT_CLIENT_SECRET
42
- self.endpoint = DEFAULT_ENDPOINT
43
- self.endpoint_url = DEFAULT_ENDPOINT_URL
44
- self.encryption_keys = DEFAULT_ENCRYPTION_KEYS
45
- self.format = DEFAULT_FORMAT
46
- self.ssl_verify = DEFAULT_SSL_VERIFY
47
- end
48
- end
49
- end
@@ -1,31 +0,0 @@
1
- require "faraday/response/decode_tradevan"
2
- require "faraday/response/parse_xml"
3
-
4
- module Einvoice
5
- module Connection
6
- private
7
-
8
- def connection(options = {})
9
- connection_options = {
10
- headers: { "Accept" => "application/#{format}; charset=utf-8" },
11
- url: endpoint,
12
- ssl: { verify: ssl_verify != false }
13
- }.merge(options)
14
-
15
- ::Faraday::Connection.new(connection_options) do |connection|
16
- case self.class.to_s
17
- when "Einvoice::Tradevan::Provider"
18
- connection.response :decode_tradevan, encryption_keys[:key1]
19
- end
20
- connection.request :url_encoded
21
-
22
- case format.to_s.downcase
23
- when "xml" then connection.response :xml
24
- when "json" then connection.response :json
25
- end
26
-
27
- connection.adapter Faraday.default_adapter
28
- end
29
- end
30
- end
31
- end