companies-house-rest 0.4.8 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f7536b868031c509fe65043133ad6cb31e17b66c4c034ef102b569898a9bb005
4
- data.tar.gz: 9f7ae0fdbe3bb6e1572e670963791d4d3fc3db2839fd051a45a22bbd171bd086
3
+ metadata.gz: acbe329349686658408d7b6d6cc2ba267b6a685f01238a56d00a465853f2862b
4
+ data.tar.gz: 55ad4bcb56c3895963785a1bb173c7095ad5443b9819bb562280d2df67bcb68d
5
5
  SHA512:
6
- metadata.gz: 13160029f1134d81eb3f2549e8d09cb580611fd650503946cfa8e952b2900f3f45ce273c4e13a955fa0acb6879ac50934e819ca4bd590dd351f2462fed614714
7
- data.tar.gz: '0927b242b41b068f2e487aaad888bb90876cc2bee86b3d821d5c81df65a214764a7249fd86b98bd8fa324def254321de7302267ede2cd03283229dd6c084796e'
6
+ metadata.gz: a5df96312aae7d77a847b33ad67b916fcfc3ef2ea67c8c333523322389adb79baed76033847c64a4aff29ab30c5b0bc1896ea8b40b6f72365c06fade8ff3ff57
7
+ data.tar.gz: 05ab11572766fdc6d61fa9d32ed9088297fc3dd399853343a9ad1767ede56ad94ef04f024a92269bbd3fa0641193de24bc05c5b712c02cb11ea2ad85ee292475
@@ -22,11 +22,11 @@ Gem::Specification.new do |spec|
22
22
  spec.require_paths = ["lib"]
23
23
  spec.required_ruby_version = ">= 2.5.5"
24
24
 
25
- spec.add_runtime_dependency "virtus", "~> 1.0", ">= 1.0.5"
25
+ spec.add_runtime_dependency "dry-struct", "~> 1"
26
26
 
27
27
  spec.add_development_dependency "activesupport", ">= 4.2", "< 7"
28
28
  spec.add_development_dependency "gc_ruboconfig", "~> 2.4"
29
- spec.add_development_dependency "rake", "~> 12.0"
29
+ spec.add_development_dependency "rake", "~> 13.0"
30
30
  spec.add_development_dependency "rspec", "~> 3.5"
31
31
  spec.add_development_dependency "rspec_junit_formatter", "~> 0.4.1"
32
32
  spec.add_development_dependency "timecop", "~> 0.8"
@@ -8,31 +8,30 @@ require "companies_house/timeout_error"
8
8
  require "companies_house/bad_gateway_error"
9
9
 
10
10
  require "net/http"
11
- require "virtus"
12
11
  require "uri"
13
12
  require "json"
13
+ require "dry-struct"
14
14
 
15
15
  module CompaniesHouse
16
16
  # This class manages individual requests.
17
17
  # Users of the CompaniesHouse gem should not instantiate this class
18
18
  # and should instead use CompaniesHouse::Client.
19
- class Request
20
- include Virtus.model
19
+ class Request < Dry::Struct
21
20
  # API-level attributes
22
- attribute :connection, Net::HTTP, required: true
23
- attribute :api_key, String, required: true
24
- attribute :endpoint, URI, required: true
21
+ attribute :connection, Dry.Types.Instance(Net::HTTP)
22
+ attribute :api_key, Dry.Types::String
23
+ attribute :endpoint, Dry.Types.Instance(URI)
25
24
 
26
25
  # Physical request attributes
27
- attribute :path, String, required: true
28
- attribute :query, Hash, required: true
26
+ attribute :path, Dry.Types::String
27
+ attribute :query, Dry.Types::Hash
29
28
 
30
29
  # Logical request attributes
31
- attribute :resource_type, Symbol, required: true
32
- attribute :resource_id, String
30
+ attribute :resource_type, Dry.Types::Symbol
31
+ attribute :resource_id, Dry.Types.Nominal(Integer)
33
32
 
34
- attribute :transaction_id, String, required: true
35
- attribute :instrumentation
33
+ attribute :transaction_id, Dry.Types::String
34
+ attribute :instrumentation, Dry.Types.Interface(:publish)
36
35
 
37
36
  def initialize(args)
38
37
  super(args)
@@ -49,11 +48,7 @@ module CompaniesHouse
49
48
 
50
49
  def execute
51
50
  @started = Time.now.utc
52
-
53
- req = Net::HTTP::Get.new(@uri)
54
- req.basic_auth @api_key, ""
55
-
56
- response = connection.request req
51
+ response = request_resource(@uri)
57
52
  @notification_payload[:status] = response.code
58
53
 
59
54
  begin
@@ -70,6 +65,13 @@ module CompaniesHouse
70
65
 
71
66
  private
72
67
 
68
+ def request_resource(uri)
69
+ req = Net::HTTP::Get.new(uri)
70
+ req.basic_auth api_key, ""
71
+
72
+ connection.request req
73
+ end
74
+
73
75
  def publish_notification
74
76
  instrumentation.publish(
75
77
  "companies_house.#{resource_type}",
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CompaniesHouse
4
- VERSION = "0.4.8"
4
+ VERSION = "0.5.0"
5
5
  end
metadata CHANGED
@@ -1,35 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: companies-house-rest
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.8
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GoCardless Engineering
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-09-23 00:00:00.000000000 Z
11
+ date: 2019-10-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: virtus
14
+ name: dry-struct
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.0'
20
- - - ">="
21
- - !ruby/object:Gem::Version
22
- version: 1.0.5
19
+ version: '1'
23
20
  type: :runtime
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
26
23
  requirements:
27
24
  - - "~>"
28
25
  - !ruby/object:Gem::Version
29
- version: '1.0'
30
- - - ">="
31
- - !ruby/object:Gem::Version
32
- version: 1.0.5
26
+ version: '1'
33
27
  - !ruby/object:Gem::Dependency
34
28
  name: activesupport
35
29
  requirement: !ruby/object:Gem::Requirement
@@ -70,14 +64,14 @@ dependencies:
70
64
  requirements:
71
65
  - - "~>"
72
66
  - !ruby/object:Gem::Version
73
- version: '12.0'
67
+ version: '13.0'
74
68
  type: :development
75
69
  prerelease: false
76
70
  version_requirements: !ruby/object:Gem::Requirement
77
71
  requirements:
78
72
  - - "~>"
79
73
  - !ruby/object:Gem::Version
80
- version: '12.0'
74
+ version: '13.0'
81
75
  - !ruby/object:Gem::Dependency
82
76
  name: rspec
83
77
  requirement: !ruby/object:Gem::Requirement
@@ -176,8 +170,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
176
170
  - !ruby/object:Gem::Version
177
171
  version: '0'
178
172
  requirements: []
179
- rubyforge_project:
180
- rubygems_version: 2.7.6
173
+ rubygems_version: 3.0.6
181
174
  signing_key:
182
175
  specification_version: 4
183
176
  summary: Look up UK company registration information