hithorizons 0.6 → 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: dd4123e7f39897f826b6a63299c3d109098b61d9de82e882a7f8b890671d03c4
4
- data.tar.gz: bf965383e5a05c52efe9c245fd05a0f4bc52d70acda91cac4cee6cf477c12d35
3
+ metadata.gz: ed2a9f3745aafa5bf4bd325f5cf3b7101a45781d7519f00cfdac2a4c3584ef83
4
+ data.tar.gz: 135d638b875c73dc054196e47a3d9bd64afcab33f33ae6525c9c7a9766996eca
5
5
  SHA512:
6
- metadata.gz: 10b4a5c2dbb55827d3ab241c99a53e449e582bb25ac18db9f9bc0def008d2356a00808f6cde722cd3a09ad9727d7d7670708612657feaca0bc0c3463a28435b5
7
- data.tar.gz: c8486701a31bbb462ec8ccb294f8fedf4c16591aeb2bcbb0d9d24f04c133ec52b5993df8f2f0288a0f2b3c5939ba2a3a786dbede82a9013b5344e3a1f4f53a69
6
+ metadata.gz: b5b8f21278c674284a369de1104c4ff3bec52ec2549ea687ed938be665a124d2bada684642ecd169c38483d994eae68ba9af79de0c783a41c4cd5241cc2b06dc
7
+ data.tar.gz: 7f212841d98723fd5ad4eaed56554665e2a8827254c424662092b85e26e4a7ab00472ac5bd8f9717eaa2e19cf9ec58efb2fa8739b85c79c7fa03e73e8061e3dd
data/.rubocop.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  AllCops:
2
- TargetRubyVersion: 2.4
2
+ TargetRubyVersion: 3.1
3
3
  NewCops: enable
4
4
 
5
5
  CacheRootDirectory: /tmp
data/Gemfile.lock CHANGED
@@ -1,41 +1,57 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- hithorizons (0.6)
4
+ hithorizons (0.7)
5
5
  faraday (~> 1)
6
6
  faraday_middleware (~> 1)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- addressable (2.7.0)
11
+ addressable (2.8.0)
12
12
  public_suffix (>= 2.0.2, < 5.0)
13
- ast (2.4.1)
14
- codecov (0.2.12)
15
- json
16
- simplecov
13
+ ast (2.4.2)
14
+ codecov (0.6.0)
15
+ simplecov (>= 0.15, < 0.22)
17
16
  crack (0.4.5)
18
17
  rexml
19
- diff-lcs (1.4.4)
20
- docile (1.3.4)
21
- faraday (1.3.0)
18
+ diff-lcs (1.5.0)
19
+ docile (1.4.0)
20
+ faraday (1.9.3)
21
+ faraday-em_http (~> 1.0)
22
+ faraday-em_synchrony (~> 1.0)
23
+ faraday-excon (~> 1.1)
24
+ faraday-httpclient (~> 1.0)
25
+ faraday-multipart (~> 1.0)
22
26
  faraday-net_http (~> 1.0)
27
+ faraday-net_http_persistent (~> 1.0)
28
+ faraday-patron (~> 1.0)
29
+ faraday-rack (~> 1.0)
30
+ faraday-retry (~> 1.0)
31
+ ruby2_keywords (>= 0.0.4)
32
+ faraday-em_http (1.0.0)
33
+ faraday-em_synchrony (1.0.0)
34
+ faraday-excon (1.1.0)
35
+ faraday-httpclient (1.0.1)
36
+ faraday-multipart (1.0.3)
23
37
  multipart-post (>= 1.2, < 3)
24
- ruby2_keywords
25
- faraday-net_http (1.0.0)
26
- faraday_middleware (1.0.0)
38
+ faraday-net_http (1.0.1)
39
+ faraday-net_http_persistent (1.2.0)
40
+ faraday-patron (1.0.0)
41
+ faraday-rack (1.0.0)
42
+ faraday-retry (1.0.3)
43
+ faraday_middleware (1.2.0)
27
44
  faraday (~> 1.0)
28
45
  hashdiff (1.0.1)
29
- json (2.5.1)
30
46
  multipart-post (2.1.1)
31
- parallel (1.20.1)
32
- parser (3.0.0.0)
47
+ parallel (1.21.0)
48
+ parser (3.1.0.0)
33
49
  ast (~> 2.4.1)
34
50
  public_suffix (4.0.6)
35
- rainbow (3.0.0)
36
- rake (13.0.3)
37
- regexp_parser (2.0.3)
38
- rexml (3.2.4)
51
+ rainbow (3.1.1)
52
+ rake (13.0.6)
53
+ regexp_parser (2.2.0)
54
+ rexml (3.2.5)
39
55
  rspec (3.10.0)
40
56
  rspec-core (~> 3.10.0)
41
57
  rspec-expectations (~> 3.10.0)
@@ -45,35 +61,34 @@ GEM
45
61
  rspec-expectations (3.10.1)
46
62
  diff-lcs (>= 1.2.0, < 2.0)
47
63
  rspec-support (~> 3.10.0)
48
- rspec-mocks (3.10.1)
64
+ rspec-mocks (3.10.2)
49
65
  diff-lcs (>= 1.2.0, < 2.0)
50
66
  rspec-support (~> 3.10.0)
51
- rspec-support (3.10.1)
52
- rubocop (1.7.0)
67
+ rspec-support (3.10.3)
68
+ rubocop (1.24.1)
53
69
  parallel (~> 1.10)
54
- parser (>= 2.7.1.5)
70
+ parser (>= 3.0.0.0)
55
71
  rainbow (>= 2.2.2, < 4.0)
56
72
  regexp_parser (>= 1.8, < 3.0)
57
73
  rexml
58
- rubocop-ast (>= 1.2.0, < 2.0)
74
+ rubocop-ast (>= 1.15.1, < 2.0)
59
75
  ruby-progressbar (~> 1.7)
60
- unicode-display_width (>= 1.4.0, < 2.0)
61
- rubocop-ast (1.4.0)
62
- parser (>= 2.7.1.5)
63
- rubocop-rspec (2.1.0)
64
- rubocop (~> 1.0)
65
- rubocop-ast (>= 1.1.0)
76
+ unicode-display_width (>= 1.4.0, < 3.0)
77
+ rubocop-ast (1.15.1)
78
+ parser (>= 3.0.1.1)
79
+ rubocop-rspec (2.7.0)
80
+ rubocop (~> 1.19)
66
81
  ruby-progressbar (1.11.0)
67
- ruby2_keywords (0.0.2)
68
- simplecov (0.21.1)
82
+ ruby2_keywords (0.0.5)
83
+ simplecov (0.21.2)
69
84
  docile (~> 1.1)
70
85
  simplecov-html (~> 0.11)
71
86
  simplecov_json_formatter (~> 0.1)
72
87
  simplecov-html (0.12.3)
73
- simplecov_json_formatter (0.1.2)
74
- unicode-display_width (1.7.0)
75
- webmock (3.11.0)
76
- addressable (>= 2.3.6)
88
+ simplecov_json_formatter (0.1.3)
89
+ unicode-display_width (2.1.0)
90
+ webmock (3.14.0)
91
+ addressable (>= 2.8.0)
77
92
  crack (>= 0.3.2)
78
93
  hashdiff (>= 0.4.0, < 2.0.0)
79
94
 
@@ -88,7 +103,7 @@ DEPENDENCIES
88
103
  rubocop (~> 1.7)
89
104
  rubocop-rspec (~> 2)
90
105
  simplecov (~> 0.21)
91
- webmock (~> 3.11.0)
106
+ webmock (~> 3)
92
107
 
93
108
  BUNDLED WITH
94
109
  2.1.4
data/README.md CHANGED
@@ -29,6 +29,7 @@ Or install it yourself as:
29
29
  ```ruby
30
30
  Hithorizons.configure do |config|
31
31
  config.api_key = API_KEY
32
+ config.invoicing_api_key = INVOICING_API_KEY
32
33
  end
33
34
  ```
34
35
 
data/changelog.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.0
4
+
5
+ - Upgrade ruby to 3.1
6
+ - Add invoicing API
7
+
3
8
  ## 0.1
4
9
  Init
5
10
 
data/hithorizons.gemspec CHANGED
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
12
12
  spec.description = 'Horizonts api integration for get, search and search unstructured'
13
13
  spec.homepage = 'https://github.com/lubosch/hithorizons'
14
14
  spec.license = 'MIT'
15
- spec.required_ruby_version = Gem::Requirement.new('>= 2.4.0')
15
+ spec.required_ruby_version = Gem::Requirement.new('>= 3.1')
16
16
 
17
17
  spec.metadata['homepage_uri'] = spec.homepage
18
18
  spec.metadata['source_code_uri'] = spec.homepage
@@ -36,5 +36,6 @@ Gem::Specification.new do |spec|
36
36
  spec.add_development_dependency 'rubocop', '~> 1.7'
37
37
  spec.add_development_dependency 'rubocop-rspec', '~> 2'
38
38
  spec.add_development_dependency 'simplecov', '~> 0.21'
39
- spec.add_development_dependency 'webmock', '~> 3.11.0'
39
+ spec.add_development_dependency 'webmock', '~> 3'
40
+ spec.metadata['rubygems_mfa_required'] = 'true'
40
41
  end
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hithorizons
4
+ class BaseApi
5
+ API_URL = ''
6
+
7
+ def self.process_request(uri, method = 'GET', payload = nil)
8
+ response = request(uri, method, payload)
9
+
10
+ raise(Hithorizons::Error, response.body) if response.status != 200
11
+
12
+ Response.new(response.body)
13
+ end
14
+
15
+ def self.request(uri, method = 'GET', payload = nil)
16
+ client = initialize_client
17
+
18
+ client.send(method.downcase.to_sym) do |request|
19
+ request.headers['Ocp-Apim-Subscription-Key'] = api_key
20
+ request.url("#{self::API_URL}#{uri}")
21
+ if method == 'GET'
22
+ request.params = payload
23
+ else
24
+ request.body = payload
25
+ end
26
+ end
27
+ end
28
+
29
+ def self.api_key
30
+ Hithorizons.config.api_key
31
+ end
32
+
33
+ def self.initialize_client
34
+ ::Faraday.new(url: Hithorizons.config.api_url) do |faraday|
35
+ faraday.request :json
36
+ faraday.response :json
37
+
38
+ faraday.adapter Faraday.default_adapter
39
+ end
40
+ end
41
+
42
+ def self.get(path)
43
+ request(path, 'GET')
44
+ end
45
+ end
46
+ end
@@ -2,42 +2,11 @@
2
2
 
3
3
  module Hithorizons
4
4
  module Company
5
- class BaseApi
5
+ class BaseApi < Hithorizons::BaseApi
6
6
  API_URL = '/Company'
7
7
 
8
- def self.process_request(uri, method = 'GET', payload = nil)
9
- response = request(uri, method, payload)
10
-
11
- raise(Hithorizons::Error, response.body) if response.status != 200
12
-
13
- Hithorizons::Company::Response.new(response.body)
14
- end
15
-
16
- def self.request(uri, method = 'GET', payload = nil)
17
- client = initialize_client
18
-
19
- client.send(method.downcase.to_sym) do |request|
20
- request.headers['Ocp-Apim-Subscription-Key'] = Hithorizons.config.api_key
21
- request.url("#{API_URL}#{uri}")
22
- if method == 'GET'
23
- request.params = payload
24
- else
25
- request.body = payload
26
- end
27
- end
28
- end
29
-
30
- def self.initialize_client
31
- ::Faraday.new(url: Hithorizons.config.api_url) do |faraday|
32
- faraday.request :json
33
- faraday.response :json
34
-
35
- faraday.adapter Faraday.default_adapter
36
- end
37
- end
38
-
39
- def self.get(path)
40
- request(path, 'GET')
8
+ def self.api_key
9
+ Hithorizons.config.api_key
41
10
  end
42
11
  end
43
12
  end
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'hithorizons/company/base_api'
4
- require 'hithorizons/company/response'
5
4
  require 'hithorizons/company/detail'
6
5
  require 'hithorizons/company/search'
7
6
  require 'hithorizons/company/search_unstructured'
@@ -2,10 +2,11 @@
2
2
 
3
3
  module Hithorizons
4
4
  class Configuration
5
- attr_accessor :api_key, :api_url
5
+ attr_accessor :invoicing_api_key, :api_key, :api_url
6
6
 
7
7
  def initialize
8
8
  @api_key = ENV['HITHORIZONS_API_KEY']
9
+ @invoicing_api_key = ENV['HITHORIZONS_INVOICING_API_KEY']
9
10
  @api_url = 'https://api.hithorizons.com'
10
11
  end
11
12
  end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hithorizons
4
+ module Invoicing
5
+ class BaseApi < Hithorizons::BaseApi
6
+ API_URL = '/invoicing'
7
+
8
+ def self.api_key
9
+ Hithorizons.config.invoicing_api_key
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hithorizons
4
+ module Invoicing
5
+ class Detail < BaseApi
6
+ def self.get(country_code:, id:)
7
+ process_request("/#{country_code}/Company/Detail", 'GET', { Id: id })
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hithorizons
4
+ module Invoicing
5
+ class Search < BaseApi
6
+ def self.get(country_code:,
7
+ company_name: nil, national_id: nil, tax_id: nil, vat_id: nil, address_unstructured: nil, address_street: nil,
8
+ street_number: nil, locality: nil, district: nil, region: nil, postal_code: nil, city: nil, country: nil,
9
+ max_results: nil)
10
+ payload = {
11
+ CompanyName: company_name, NationalId: national_id, TaxId: tax_id, VatId: vat_id, AddressUnstructured: address_unstructured,
12
+ AddressStreet: address_street, StreetNumber: street_number, Locality: locality, District: district, Region: region,
13
+ PostalCode: postal_code, City: city, Country: country, MaxResults: max_results
14
+ }
15
+ process_request("/#{country_code}/Company/Search", 'GET', payload.compact)
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hithorizons
4
+ module Invoicing
5
+ class SearchUnstructured < BaseApi
6
+ def self.get(country_code:, ids: nil, name: nil, address: nil, max_results: nil)
7
+ payload = { Ids: ids, Name: name, Address: address, MaxResults: max_results }
8
+ process_request("/#{country_code}/Company/SearchUnstructured", 'GET', payload.compact)
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'hithorizons/invoicing/base_api'
4
+ require 'hithorizons/invoicing/detail'
5
+ require 'hithorizons/invoicing/search'
6
+ require 'hithorizons/invoicing/search_unstructured'
7
+
8
+ module Hithorizons
9
+ module Company
10
+ end
11
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Hithorizons
4
+ class Response
5
+ attr_reader :response
6
+
7
+ def initialize(response)
8
+ @response = response
9
+ end
10
+
11
+ def success
12
+ response['Success']
13
+ end
14
+
15
+ def error
16
+ response['Error']
17
+ end
18
+
19
+ def result
20
+ response['Result']
21
+ end
22
+
23
+ def results
24
+ response.dig('Result', 'Results')
25
+ end
26
+
27
+ def total_count
28
+ response.dig('Result', 'TotalCount')
29
+ end
30
+
31
+ def results_count
32
+ response.dig('Result', 'ResultsCount')
33
+ end
34
+ end
35
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Hithorizons
4
- VERSION = '0.6'
4
+ VERSION = '0.7'
5
5
  end
data/lib/hithorizons.rb CHANGED
@@ -5,7 +5,10 @@ require 'faraday_middleware'
5
5
 
6
6
  require 'hithorizons/version'
7
7
  require 'hithorizons/configuration'
8
+ require 'hithorizons/base_api'
9
+ require 'hithorizons/response'
8
10
  require 'hithorizons/company'
11
+ require 'hithorizons/invoicing'
9
12
  require 'hithorizons/country'
10
13
  require 'hithorizons/countries'
11
14
  require 'hithorizons/company_types'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hithorizons
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.6'
4
+ version: '0.7'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lubomir Vnenk
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-01-18 00:00:00.000000000 Z
11
+ date: 2022-01-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -128,14 +128,14 @@ dependencies:
128
128
  requirements:
129
129
  - - "~>"
130
130
  - !ruby/object:Gem::Version
131
- version: 3.11.0
131
+ version: '3'
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
- version: 3.11.0
138
+ version: '3'
139
139
  description: Horizonts api integration for get, search and search unstructured
140
140
  email:
141
141
  - lubomir.vnenk@zoho.com
@@ -157,10 +157,10 @@ files:
157
157
  - changelog.md
158
158
  - hithorizons.gemspec
159
159
  - lib/hithorizons.rb
160
+ - lib/hithorizons/base_api.rb
160
161
  - lib/hithorizons/company.rb
161
162
  - lib/hithorizons/company/base_api.rb
162
163
  - lib/hithorizons/company/detail.rb
163
- - lib/hithorizons/company/response.rb
164
164
  - lib/hithorizons/company/search.rb
165
165
  - lib/hithorizons/company/search_unstructured.rb
166
166
  - lib/hithorizons/company_types.rb
@@ -168,6 +168,12 @@ files:
168
168
  - lib/hithorizons/countries.rb
169
169
  - lib/hithorizons/country.rb
170
170
  - lib/hithorizons/industry_types.rb
171
+ - lib/hithorizons/invoicing.rb
172
+ - lib/hithorizons/invoicing/base_api.rb
173
+ - lib/hithorizons/invoicing/detail.rb
174
+ - lib/hithorizons/invoicing/search.rb
175
+ - lib/hithorizons/invoicing/search_unstructured.rb
176
+ - lib/hithorizons/response.rb
171
177
  - lib/hithorizons/version.rb
172
178
  homepage: https://github.com/lubosch/hithorizons
173
179
  licenses:
@@ -176,6 +182,7 @@ metadata:
176
182
  homepage_uri: https://github.com/lubosch/hithorizons
177
183
  source_code_uri: https://github.com/lubosch/hithorizons
178
184
  changelog_uri: https://github.com/lubosch/hithorizons/blob/master/changelog.md
185
+ rubygems_mfa_required: 'true'
179
186
  post_install_message:
180
187
  rdoc_options: []
181
188
  require_paths:
@@ -184,14 +191,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
184
191
  requirements:
185
192
  - - ">="
186
193
  - !ruby/object:Gem::Version
187
- version: 2.4.0
194
+ version: '3.1'
188
195
  required_rubygems_version: !ruby/object:Gem::Requirement
189
196
  requirements:
190
197
  - - ">="
191
198
  - !ruby/object:Gem::Version
192
199
  version: '0'
193
200
  requirements: []
194
- rubygems_version: 3.1.4
201
+ rubygems_version: 3.3.3
195
202
  signing_key:
196
203
  specification_version: 4
197
204
  summary: Horizonts api integration
@@ -1,37 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Hithorizons
4
- module Company
5
- class Response
6
- attr_reader :response
7
-
8
- def initialize(response)
9
- @response = response
10
- end
11
-
12
- def success
13
- response['Success']
14
- end
15
-
16
- def error
17
- response['Error']
18
- end
19
-
20
- def result
21
- response['Result']
22
- end
23
-
24
- def results
25
- response.dig('Result', 'Results')
26
- end
27
-
28
- def total_count
29
- response.dig('Result', 'TotalCount')
30
- end
31
-
32
- def results_count
33
- response.dig('Result', 'ResultsCount')
34
- end
35
- end
36
- end
37
- end