vatsense 0.2.0 → 0.3.0

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.
@@ -0,0 +1,249 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Vatsense
4
+ module Resources
5
+ # Bulk validation: check many VAT numbers in one batch.
6
+ #
7
+ # Batch calls are free and work even when your requests are used up; each
8
+ # number a batch checks counts as one request. With a test key a batch is
9
+ # answered from the test numbers, is free and holds at most 1,000 numbers.
10
+ class Batches
11
+ BODY_KEYS = [:numbers, :rows, :reference, :start, :shortfall, :auto_continue, :consultation].freeze
12
+ private_constant :BODY_KEYS
13
+
14
+ # Create a batch of VAT numbers and, by default, start checking it. Pass
15
+ # exactly one of `numbers:` or `rows:`.
16
+ #
17
+ # @overload create(numbers: nil, rows: nil, reference: nil, start: nil, shortfall: nil, auto_continue: nil, consultation: nil, idempotency_key: nil, request_options: {})
18
+ #
19
+ # @param numbers [Array<String>] The VAT numbers to check, each with its 2-character country code.
20
+ #
21
+ # @param rows [Array<Hash{Symbol=>String}>] Rows with `vat_number:` and, for company matching, any of
22
+ # `country_code:`, `company_name:`, `address:`, `street:`, `address_line_2:`, `postcode:` and `city:`.
23
+ #
24
+ # @param reference [String] Your own label for the batch, at most 255 characters.
25
+ #
26
+ # @param start [Boolean] Defaults to true. False keeps a draft for 24 hours, to start with `start`.
27
+ #
28
+ # @param shortfall [Symbol, String] When your requests do not cover the batch: `:wait` (the default)
29
+ # starts nothing and returns the `quote`, `:pause` checks what is covered and pauses the rest,
30
+ # `:overage` runs into overage (it must already be on in the dashboard).
31
+ #
32
+ # @param auto_continue [Boolean] Defaults to true. With `:pause`, continue when your requests renew.
33
+ #
34
+ # @param consultation [Boolean] Defaults to false. Send the requester VAT number from your account
35
+ # settings with each check.
36
+ #
37
+ # @param idempotency_key [String] Sent as the `Idempotency-Key` header, at most 64 characters. The
38
+ # same key again returns the batch already made.
39
+ #
40
+ # @param request_options [Vatsense::RequestOptions, Hash{Symbol=>Object}, nil]
41
+ #
42
+ # @return [Vatsense::Models::BatchResponse]
43
+ def create(params = {})
44
+ params = params.dup
45
+ options = params.delete(:request_options)
46
+ key = params.delete(:idempotency_key)
47
+ @client.request(
48
+ method: :post,
49
+ path: "batches",
50
+ headers: key.nil? ? {} : {"idempotency-key" => key},
51
+ body: body_of(params),
52
+ model: Vatsense::Models::BatchResponse,
53
+ options: options
54
+ )
55
+ end
56
+
57
+ # The account's batches, newest first.
58
+ #
59
+ # @overload list(page: nil, limit: nil, status: nil, request_options: {})
60
+ #
61
+ # @param page [Integer] The page, from 1.
62
+ #
63
+ # @param limit [Integer] Batches a page, 1 to 100 (default 25).
64
+ #
65
+ # @param status [Symbol, String] `:draft` lists the drafts not yet started instead.
66
+ #
67
+ # @param request_options [Vatsense::RequestOptions, Hash{Symbol=>Object}, nil]
68
+ #
69
+ # @return [Vatsense::Models::BatchListResponse]
70
+ def list(params = {})
71
+ params = params.dup
72
+ options = params.delete(:request_options)
73
+ @client.request(
74
+ method: :get,
75
+ path: "batches",
76
+ query: query_of(params, [:page, :limit, :status]),
77
+ model: Vatsense::Models::BatchListResponse,
78
+ options: options
79
+ )
80
+ end
81
+
82
+ # A batch and its progress. Poll until `status` is `complete`, or take the
83
+ # `batch.completed` webhook.
84
+ #
85
+ # @overload retrieve(batch_id, request_options: {})
86
+ #
87
+ # @param batch_id [String]
88
+ # @param request_options [Vatsense::RequestOptions, Hash{Symbol=>Object}, nil]
89
+ #
90
+ # @return [Vatsense::Models::BatchResponse]
91
+ def retrieve(batch_id, params = {})
92
+ action(:get, batch_id, nil, nil, params)
93
+ end
94
+
95
+ # Delete a draft. A batch that has started cannot be deleted (409).
96
+ #
97
+ # @overload delete(batch_id, request_options: {})
98
+ #
99
+ # @param batch_id [String]
100
+ # @param request_options [Vatsense::RequestOptions, Hash{Symbol=>Object}, nil]
101
+ #
102
+ # @return [Vatsense::Models::BatchDeleteResponse]
103
+ def delete(batch_id, params = {})
104
+ @client.request(
105
+ method: :delete,
106
+ path: ["batches/%1$s", id_of(batch_id)],
107
+ model: Vatsense::Models::BatchDeleteResponse,
108
+ options: params[:request_options]
109
+ )
110
+ end
111
+
112
+ # Start a draft, with the same options as `create`.
113
+ #
114
+ # @overload start(batch_id, shortfall: nil, auto_continue: nil, consultation: nil, request_options: {})
115
+ #
116
+ # @param batch_id [String]
117
+ # @param shortfall [Symbol, String]
118
+ # @param auto_continue [Boolean]
119
+ # @param consultation [Boolean]
120
+ # @param request_options [Vatsense::RequestOptions, Hash{Symbol=>Object}, nil]
121
+ #
122
+ # @return [Vatsense::Models::BatchResponse]
123
+ def start(batch_id, params = {})
124
+ action(:post, batch_id, "start", [:shortfall, :auto_continue, :consultation], params)
125
+ end
126
+
127
+ # Pause a running batch.
128
+ #
129
+ # @overload pause(batch_id, request_options: {})
130
+ #
131
+ # @param batch_id [String]
132
+ # @param request_options [Vatsense::RequestOptions, Hash{Symbol=>Object}, nil]
133
+ #
134
+ # @return [Vatsense::Models::BatchResponse]
135
+ def pause(batch_id, params = {})
136
+ action(:post, batch_id, "pause", [], params)
137
+ end
138
+
139
+ # Continue a paused batch. Pass `shortfall: :overage` to run into overage.
140
+ #
141
+ # @overload continue(batch_id, shortfall: nil, request_options: {})
142
+ #
143
+ # @param batch_id [String]
144
+ # @param shortfall [Symbol, String]
145
+ # @param request_options [Vatsense::RequestOptions, Hash{Symbol=>Object}, nil]
146
+ #
147
+ # @return [Vatsense::Models::BatchResponse]
148
+ def continue(batch_id, params = {})
149
+ action(:post, batch_id, "continue", [:shortfall], params)
150
+ end
151
+
152
+ # Mark a paused batch complete, leaving the rest unchecked.
153
+ #
154
+ # @overload complete(batch_id, request_options: {})
155
+ #
156
+ # @param batch_id [String]
157
+ # @param request_options [Vatsense::RequestOptions, Hash{Symbol=>Object}, nil]
158
+ #
159
+ # @return [Vatsense::Models::BatchResponse]
160
+ def complete(batch_id, params = {})
161
+ action(:post, batch_id, "complete", [], params)
162
+ end
163
+
164
+ # The batch's checked rows as JSON, in row order. Follow `next_after` while
165
+ # `has_more` is true.
166
+ #
167
+ # @overload results(batch_id, after: nil, limit: nil, request_options: {})
168
+ #
169
+ # @param batch_id [String]
170
+ # @param after [Integer] Return rows after this row number (default 0).
171
+ # @param limit [Integer] Rows a page, 1 to 1,000 (default 100).
172
+ # @param request_options [Vatsense::RequestOptions, Hash{Symbol=>Object}, nil]
173
+ #
174
+ # @return [Vatsense::Models::BatchResultsResponse]
175
+ def results(batch_id, params = {})
176
+ params = params.dup
177
+ options = params.delete(:request_options)
178
+ @client.request(
179
+ method: :get,
180
+ path: ["batches/%1$s/results", id_of(batch_id)],
181
+ query: query_of(params, [:after, :limit]),
182
+ model: Vatsense::Models::BatchResultsResponse,
183
+ options: options
184
+ )
185
+ end
186
+
187
+ # The batch's CSV report, the same file the dashboard gives.
188
+ #
189
+ # @overload results_csv(batch_id, request_options: {})
190
+ #
191
+ # @param batch_id [String]
192
+ # @param request_options [Vatsense::RequestOptions, Hash{Symbol=>Object}, nil]
193
+ #
194
+ # @return [String]
195
+ def results_csv(batch_id, params = {})
196
+ body = @client.request(
197
+ method: :get,
198
+ path: ["batches/%1$s/results.csv", id_of(batch_id)],
199
+ headers: {"accept" => "text/csv"},
200
+ model: StringIO,
201
+ options: params[:request_options]
202
+ )
203
+ body.respond_to?(:read) ? body.read : body.to_s
204
+ end
205
+
206
+ # @api private
207
+ #
208
+ # @param client [Vatsense::Client]
209
+ def initialize(client:)
210
+ @client = client
211
+ end
212
+
213
+ private
214
+
215
+ def action(method, batch_id, suffix, keys, params)
216
+ params = params.dup
217
+ options = params.delete(:request_options)
218
+ path = suffix.nil? ? "batches/%1$s" : "batches/%1$s/#{suffix}"
219
+ @client.request(
220
+ method: method,
221
+ path: [path, id_of(batch_id)],
222
+ body: keys.nil? ? nil : body_of(params.slice(*keys)),
223
+ model: Vatsense::Models::BatchResponse,
224
+ options: options
225
+ )
226
+ end
227
+
228
+ def id_of(batch_id)
229
+ raise ArgumentError, "batch_id must not be empty" if batch_id.nil? || batch_id.to_s.empty?
230
+
231
+ batch_id
232
+ end
233
+
234
+ def body_of(params)
235
+ unknown = params.keys - BODY_KEYS
236
+ raise ArgumentError, "unknown batch parameters: #{unknown.join(', ')}" unless unknown.empty?
237
+
238
+ params.compact.transform_values { _1.is_a?(Symbol) ? _1.to_s : _1 }
239
+ end
240
+
241
+ def query_of(params, keys)
242
+ unknown = params.keys - keys
243
+ raise ArgumentError, "unknown batch parameters: #{unknown.join(', ')}" unless unknown.empty?
244
+
245
+ params.compact.transform_values(&:to_s)
246
+ end
247
+ end
248
+ end
249
+ end
@@ -25,7 +25,7 @@ module Vatsense
25
25
  #
26
26
  # Provide either `vat_number` or `eori_number`, but not both.
27
27
  #
28
- # @overload check(eori_number: nil, requester_vat_number: nil, vat_number: nil, match_address: nil, match_city: nil, match_company_name: nil, match_postcode: nil, match_street: nil, request_options: {})
28
+ # @overload check(eori_number: nil, requester_vat_number: nil, vat_number: nil, match_address: nil, match_city: nil, match_company_name: nil, match_postcode: nil, match_street: nil, consultation_optional: nil, request_options: {})
29
29
  #
30
30
  # @param eori_number [String] The EORI number to validate. Must include the leading 2-character
31
31
  #
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Vatsense
4
- VERSION = "0.2.0"
4
+ VERSION = "0.3.0"
5
5
  end
@@ -0,0 +1,104 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Vatsense
4
+ # Checks the `VatSense-Signature` header of webhook events.
5
+ #
6
+ # Every event is a signed JSON `POST` with a header such as
7
+ # `t=1793365200,v1=5257a8...`: `v1` is the hex HMAC-SHA256 of the timestamp, a
8
+ # full stop and the raw request body, keyed with the endpoint's signing secret
9
+ # (`whsec_...`). For 24 hours after a secret is rolled the header carries a
10
+ # second `v1`, so any match is accepted.
11
+ #
12
+ # @example
13
+ # event = Vatsense::Webhook.construct_event(
14
+ # request.raw_post,
15
+ # request.headers[Vatsense::Webhook::SIGNATURE_HEADER],
16
+ # ENV.fetch("VATSENSE_WEBHOOK_SECRET")
17
+ # )
18
+ module Webhook
19
+ # The name of the header that carries the signature.
20
+ SIGNATURE_HEADER = "VatSense-Signature"
21
+
22
+ # Events whose timestamp is more than this many seconds from now are refused.
23
+ DEFAULT_TOLERANCE = 300
24
+
25
+ # The event's signature is missing, malformed, too old or does not match.
26
+ class SignatureError < Vatsense::Errors::Error; end
27
+
28
+ class << self
29
+ # Check an event's signature header against its raw body, exactly as received.
30
+ #
31
+ # @param payload [String] the raw request body
32
+ # @param header [String, nil] the value of the `VatSense-Signature` header
33
+ # @param secret [String] the endpoint's signing secret, starting `whsec_`
34
+ # @param tolerance [Integer, nil] refuse events signed more than this many seconds ago; nil skips the check
35
+ # @param now [Integer, nil] the current Unix time, for tests
36
+ #
37
+ # @raise [Vatsense::Webhook::SignatureError]
38
+ # @return [true]
39
+ def verify_signature(payload, header, secret, tolerance: DEFAULT_TOLERANCE, now: nil)
40
+ raise SignatureError, "The VatSense-Signature header is missing." if header.nil? || header.empty?
41
+ raise SignatureError, "No signing secret was given." if secret.nil? || secret.empty?
42
+
43
+ timestamp = nil
44
+ signatures = []
45
+ header.split(",").each do |part|
46
+ key, value = part.strip.split("=", 2)
47
+ next if value.nil?
48
+
49
+ case key
50
+ in "t"
51
+ raise SignatureError, "The signature header's timestamp is not a number." unless value.match?(/\A\d+\z/)
52
+
53
+ timestamp = Integer(value, 10)
54
+ in "v1"
55
+ signatures << value unless value.empty?
56
+ else
57
+ nil
58
+ end
59
+ end
60
+ raise SignatureError, "The signature header has no timestamp." if timestamp.nil?
61
+ raise SignatureError, "The signature header has no v1 signature." if signatures.empty?
62
+
63
+ current = now || Time.now.to_i
64
+ if !tolerance.nil? && (current - timestamp).abs > tolerance
65
+ raise SignatureError, "The event's timestamp is outside the tolerance."
66
+ end
67
+
68
+ expected = OpenSSL::HMAC.hexdigest("SHA256", secret, "#{timestamp}.#{payload}")
69
+ return true if signatures.any? { secure_compare(expected, _1) }
70
+
71
+ raise SignatureError, "No signature matches the payload."
72
+ end
73
+
74
+ # Check the signature, then return the event (`id`, `type`, `created`,
75
+ # `livemode`, `data`) as a Hash with symbol keys.
76
+ #
77
+ # @param payload [String]
78
+ # @param header [String, nil]
79
+ # @param secret [String]
80
+ # @param tolerance [Integer, nil]
81
+ # @param now [Integer, nil]
82
+ #
83
+ # @raise [Vatsense::Webhook::SignatureError]
84
+ # @return [Hash{Symbol=>Object}]
85
+ def construct_event(payload, header, secret, tolerance: DEFAULT_TOLERANCE, now: nil)
86
+ verify_signature(payload, header, secret, tolerance: tolerance, now: now)
87
+ event = JSON.parse(payload, symbolize_names: true)
88
+ raise SignatureError, "The payload is not a JSON object." unless event.is_a?(Hash)
89
+
90
+ event
91
+ rescue JSON::ParserError
92
+ raise SignatureError, "The payload is not JSON."
93
+ end
94
+
95
+ private
96
+
97
+ def secure_compare(expected, given)
98
+ return false unless expected.bytesize == given.bytesize
99
+
100
+ OpenSSL.fixed_length_secure_compare(expected, given)
101
+ end
102
+ end
103
+ end
104
+ end
data/lib/vatsense.rb CHANGED
@@ -55,6 +55,12 @@ require_relative "vatsense/client"
55
55
  require_relative "vatsense/models/invoice/invoice_item_input"
56
56
  require_relative "vatsense/models/create_invoice"
57
57
  require_relative "vatsense/models/tax_rate"
58
+ require_relative "vatsense/models/batch"
59
+ require_relative "vatsense/models/batch_delete_response"
60
+ require_relative "vatsense/models/batch_list_response"
61
+ require_relative "vatsense/models/batch_response"
62
+ require_relative "vatsense/models/batch_result"
63
+ require_relative "vatsense/models/batch_results_response"
58
64
  require_relative "vatsense/models/country"
59
65
  require_relative "vatsense/models/country_list_params"
60
66
  require_relative "vatsense/models/country_list_provinces_params"
@@ -103,6 +109,7 @@ require_relative "vatsense/models/validate_check_params"
103
109
  require_relative "vatsense/models/validate_check_response"
104
110
  require_relative "vatsense/models/vat_price"
105
111
  require_relative "vatsense/models"
112
+ require_relative "vatsense/resources/batches"
106
113
  require_relative "vatsense/resources/countries"
107
114
  require_relative "vatsense/resources/currency"
108
115
  require_relative "vatsense/resources/invoice"
@@ -111,3 +118,4 @@ require_relative "vatsense/resources/rates"
111
118
  require_relative "vatsense/resources/sandbox"
112
119
  require_relative "vatsense/resources/usage"
113
120
  require_relative "vatsense/resources/validate"
121
+ require_relative "vatsense/webhook"
@@ -26,6 +26,8 @@ module Vatsense
26
26
 
27
27
  attr_reader sandbox: Vatsense::Resources::Sandbox
28
28
 
29
+ attr_reader batches: Vatsense::Resources::Batches
30
+
29
31
  private def auth_headers: (
30
32
  security: { basic_auth: bool }
31
33
  ) -> ::Hash[String, String]
@@ -0,0 +1,57 @@
1
+ module Vatsense
2
+ module Models
3
+ class Batch < Vatsense::Internal::Type::BaseModel
4
+ attr_accessor id: String
5
+ attr_accessor object: String?
6
+ attr_accessor auto_continue: bool?
7
+ attr_accessor consultation: bool?
8
+ attr_accessor created_at: String?
9
+ attr_accessor dashboard_url: String?
10
+ attr_accessor estimated_finish_at: String?
11
+ attr_accessor expires_at: String?
12
+ attr_accessor finished_at: String?
13
+ attr_accessor livemode: bool?
14
+ attr_accessor number: Integer?
15
+ attr_accessor pause_reason: String?
16
+ attr_accessor quote: Vatsense::Models::Batch::Quote?
17
+ attr_accessor reference: String?
18
+ attr_accessor requests_used: Integer?
19
+ attr_accessor results: Vatsense::Models::Batch::Results?
20
+ attr_accessor rows: Vatsense::Models::Batch::Rows?
21
+ attr_accessor source: String?
22
+ attr_accessor started_at: String?
23
+ attr_accessor status: String?
24
+ attr_accessor trial: bool?
25
+ attr_accessor uses_overage: bool?
26
+ class Rows < Vatsense::Internal::Type::BaseModel
27
+ attr_accessor done: Integer?
28
+ attr_accessor to_check: Integer?
29
+ attr_accessor total: Integer?
30
+ def initialize: (?done: Integer?, ?to_check: Integer?, ?total: Integer?) -> void
31
+ end
32
+
33
+ class Results < Vatsense::Internal::Type::BaseModel
34
+ attr_accessor duplicate: Integer?
35
+ attr_accessor invalid: Integer?
36
+ attr_accessor not_checked: Integer?
37
+ attr_accessor repaired: Integer?
38
+ attr_accessor retrying: Integer?
39
+ attr_accessor unsupported: Integer?
40
+ attr_accessor valid: Integer?
41
+ def initialize: (?duplicate: Integer?, ?invalid: Integer?, ?not_checked: Integer?, ?repaired: Integer?, ?retrying: Integer?, ?unsupported: Integer?, ?valid: Integer?) -> void
42
+ end
43
+
44
+ class Quote < Vatsense::Internal::Type::BaseModel
45
+ attr_accessor covered: bool?
46
+ attr_accessor overage_on: bool?
47
+ attr_accessor renews_at: String?
48
+ attr_accessor requests_left: Integer?
49
+ attr_accessor requests_needed: Integer?
50
+ attr_accessor shortfall: Integer?
51
+ def initialize: (?covered: bool?, ?overage_on: bool?, ?renews_at: String?, ?requests_left: Integer?, ?requests_needed: Integer?, ?shortfall: Integer?) -> void
52
+ end
53
+
54
+ def initialize: (id: String, ?object: String?, ?auto_continue: bool?, ?consultation: bool?, ?created_at: String?, ?dashboard_url: String?, ?estimated_finish_at: String?, ?expires_at: String?, ?finished_at: String?, ?livemode: bool?, ?number: Integer?, ?pause_reason: String?, ?quote: Vatsense::Models::Batch::Quote?, ?reference: String?, ?requests_used: Integer?, ?results: Vatsense::Models::Batch::Results?, ?rows: Vatsense::Models::Batch::Rows?, ?source: String?, ?started_at: String?, ?status: String?, ?trial: bool?, ?uses_overage: bool?) -> void
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,17 @@
1
+ module Vatsense
2
+ module Models
3
+ class BatchDeleteResponse < Vatsense::Internal::Type::BaseModel
4
+ attr_accessor code: Integer
5
+ attr_accessor data: Vatsense::Models::BatchDeleteResponse::Data
6
+ attr_accessor success: bool
7
+ class Data < Vatsense::Internal::Type::BaseModel
8
+ attr_accessor id: String
9
+ attr_accessor deleted: bool
10
+ attr_accessor object: String?
11
+ def initialize: (id: String, deleted: bool, ?object: String?) -> void
12
+ end
13
+
14
+ def initialize: (code: Integer, data: Vatsense::Models::BatchDeleteResponse::Data, success: bool) -> void
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,19 @@
1
+ module Vatsense
2
+ module Models
3
+ class BatchListResponse < Vatsense::Internal::Type::BaseModel
4
+ attr_accessor code: Integer
5
+ attr_accessor data: Vatsense::Models::BatchListResponse::Data
6
+ attr_accessor success: bool
7
+ class Data < Vatsense::Internal::Type::BaseModel
8
+ attr_accessor data: ::Array[Vatsense::Models::Batch]
9
+ attr_accessor has_more: bool
10
+ attr_accessor limit: Integer?
11
+ attr_accessor page: Integer?
12
+ attr_accessor total: Integer?
13
+ def initialize: (data: ::Array[Vatsense::Models::Batch], has_more: bool, ?limit: Integer?, ?page: Integer?, ?total: Integer?) -> void
14
+ end
15
+
16
+ def initialize: (code: Integer, data: Vatsense::Models::BatchListResponse::Data, success: bool) -> void
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,10 @@
1
+ module Vatsense
2
+ module Models
3
+ class BatchResponse < Vatsense::Internal::Type::BaseModel
4
+ attr_accessor code: Integer
5
+ attr_accessor data: Vatsense::Models::Batch
6
+ attr_accessor success: bool
7
+ def initialize: (code: Integer, data: Vatsense::Models::Batch, success: bool) -> void
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,38 @@
1
+ module Vatsense
2
+ module Models
3
+ class BatchResult < Vatsense::Internal::Type::BaseModel
4
+ attr_accessor row: Integer
5
+ attr_accessor authority: String?
6
+ attr_accessor checked_at: String?
7
+ attr_accessor company_address: String?
8
+ attr_accessor company_name: String?
9
+ attr_accessor confirmation_number: String?
10
+ attr_accessor consultation_number: String?
11
+ attr_accessor country_code: String?
12
+ attr_accessor country_uploaded: String?
13
+ attr_accessor duplicate_of_row: Integer?
14
+ attr_accessor match: Vatsense::Models::BatchResult::Match?
15
+ attr_accessor reason: String?
16
+ attr_accessor repaired: bool?
17
+ attr_accessor result: String?
18
+ attr_accessor vat_number: String?
19
+ attr_accessor vat_number_uploaded: String?
20
+ class Match < Vatsense::Internal::Type::BaseModel
21
+ attr_accessor fields: ::Hash[Symbol, Vatsense::Models::BatchResult::Match::Field]?
22
+ attr_accessor result: String?
23
+ attr_accessor score: Integer?
24
+ class Field < Vatsense::Internal::Type::BaseModel
25
+ attr_accessor result: String?
26
+ attr_accessor score: Integer?
27
+ attr_accessor sent: String?
28
+ attr_accessor vies: String?
29
+ def initialize: (?result: String?, ?score: Integer?, ?sent: String?, ?vies: String?) -> void
30
+ end
31
+
32
+ def initialize: (?fields: ::Hash[Symbol, Vatsense::Models::BatchResult::Match::Field]?, ?result: String?, ?score: Integer?) -> void
33
+ end
34
+
35
+ def initialize: (row: Integer, ?authority: String?, ?checked_at: String?, ?company_address: String?, ?company_name: String?, ?confirmation_number: String?, ?consultation_number: String?, ?country_code: String?, ?country_uploaded: String?, ?duplicate_of_row: Integer?, ?match: Vatsense::Models::BatchResult::Match?, ?reason: String?, ?repaired: bool?, ?result: String?, ?vat_number: String?, ?vat_number_uploaded: String?) -> void
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,17 @@
1
+ module Vatsense
2
+ module Models
3
+ class BatchResultsResponse < Vatsense::Internal::Type::BaseModel
4
+ attr_accessor code: Integer
5
+ attr_accessor data: Vatsense::Models::BatchResultsResponse::Data
6
+ attr_accessor success: bool
7
+ class Data < Vatsense::Internal::Type::BaseModel
8
+ attr_accessor data: ::Array[Vatsense::Models::BatchResult]
9
+ attr_accessor has_more: bool
10
+ attr_accessor next_after: Integer?
11
+ def initialize: (data: ::Array[Vatsense::Models::BatchResult], has_more: bool, ?next_after: Integer?) -> void
12
+ end
13
+
14
+ def initialize: (code: Integer, data: Vatsense::Models::BatchResultsResponse::Data, success: bool) -> void
15
+ end
16
+ end
17
+ end
@@ -1,13 +1,17 @@
1
1
  module Vatsense
2
2
  module Models
3
3
  type validate_check_params =
4
- { eori_number: String, requester_vat_number: String, vat_number: String, match_address: String, match_city: String, match_company_name: String, match_postcode: String, match_street: String }
4
+ { consultation_optional: bool, eori_number: String, requester_vat_number: String, vat_number: String, match_address: String, match_city: String, match_company_name: String, match_postcode: String, match_street: String }
5
5
  & Vatsense::Internal::Type::request_parameters
6
6
 
7
7
  class ValidateCheckParams < Vatsense::Internal::Type::BaseModel
8
8
  extend Vatsense::Internal::Type::RequestParameters::Converter
9
9
  include Vatsense::Internal::Type::RequestParameters
10
10
 
11
+ attr_reader consultation_optional: bool?
12
+
13
+ def consultation_optional=: (bool) -> bool
14
+
11
15
  attr_reader eori_number: String?
12
16
 
13
17
  def eori_number=: (String) -> String
@@ -41,6 +45,7 @@ module Vatsense
41
45
  def vat_number=: (String) -> String
42
46
 
43
47
  def initialize: (
48
+ ?consultation_optional: bool,
44
49
  ?eori_number: String,
45
50
  ?match_address: String,
46
51
  ?match_city: String,
@@ -53,6 +58,7 @@ module Vatsense
53
58
  ) -> void
54
59
 
55
60
  def to_hash: -> {
61
+ consultation_optional: bool,
56
62
  eori_number: String,
57
63
  match_address: String,
58
64
  match_city: String,
@@ -37,6 +37,7 @@ module Vatsense
37
37
  type data =
38
38
  {
39
39
  company: Vatsense::Models::ValidateCheckResponse::Data::company,
40
+ confirmation_number: String?,
40
41
  consultation_number: String?,
41
42
  match: Vatsense::Models::ValidateCheckResponse::Data::Match,
42
43
  valid: bool
@@ -49,6 +50,8 @@ module Vatsense
49
50
  Vatsense::Models::ValidateCheckResponse::Data::company
50
51
  ) -> Vatsense::Models::ValidateCheckResponse::Data::company
51
52
 
53
+ attr_accessor confirmation_number: String?
54
+
52
55
  attr_accessor consultation_number: String?
53
56
 
54
57
  attr_reader match: Vatsense::Models::ValidateCheckResponse::Data::Match?
@@ -63,6 +66,7 @@ module Vatsense
63
66
 
64
67
  def initialize: (
65
68
  ?company: Vatsense::Models::ValidateCheckResponse::Data::company,
69
+ ?confirmation_number: String?,
66
70
  ?consultation_number: String?,
67
71
  ?match: Vatsense::Models::ValidateCheckResponse::Data::Match,
68
72
  ?valid: bool
@@ -70,6 +74,7 @@ module Vatsense
70
74
 
71
75
  def to_hash: -> {
72
76
  company: Vatsense::Models::ValidateCheckResponse::Data::company,
77
+ confirmation_number: String?,
73
78
  consultation_number: String?,
74
79
  match: Vatsense::Models::ValidateCheckResponse::Data::Match,
75
80
  valid: bool