tochka_cyclops_api 0.2.0 → 0.4.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.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +67 -10
  3. data/Rakefile +0 -4
  4. data/lib/tasks/methods.rake +11 -0
  5. data/lib/tochka_cyclops_api/data_processor.rb +46 -22
  6. data/lib/tochka_cyclops_api/generators/initializer_generator.rb +5 -5
  7. data/lib/tochka_cyclops_api/generators/{model_generator.rb → models_generator.rb} +8 -9
  8. data/lib/tochka_cyclops_api/generators/templates/tochka_cyclops_request_model_template.rb +1 -1
  9. data/lib/tochka_cyclops_api/generators/templates/tochka_cyclops_responses_migration_template.rb +1 -1
  10. data/lib/tochka_cyclops_api/methods.rb +198 -5
  11. data/lib/tochka_cyclops_api/request.rb +66 -31
  12. data/lib/tochka_cyclops_api/response.rb +27 -34
  13. data/lib/tochka_cyclops_api/result.rb +33 -0
  14. data/lib/tochka_cyclops_api/schemas/requests/activate_beneficiary.rb +22 -0
  15. data/lib/tochka_cyclops_api/schemas/requests/create_beneficiary_fl.rb +56 -0
  16. data/lib/tochka_cyclops_api/schemas/requests/create_beneficiary_ip.rb +22 -10
  17. data/lib/tochka_cyclops_api/schemas/requests/create_beneficiary_ul.rb +22 -10
  18. data/lib/tochka_cyclops_api/schemas/requests/deactivate_beneficiary.rb +22 -0
  19. data/lib/tochka_cyclops_api/schemas/requests/echo.rb +2 -0
  20. data/lib/tochka_cyclops_api/schemas/requests/get_beneficiary.rb +22 -0
  21. data/lib/tochka_cyclops_api/schemas/requests/list_beneficiary.rb +44 -0
  22. data/lib/tochka_cyclops_api/schemas/requests/update_beneficiary_fl.rb +51 -0
  23. data/lib/tochka_cyclops_api/schemas/requests/update_beneficiary_ip.rb +39 -0
  24. data/lib/tochka_cyclops_api/schemas/requests/update_beneficiary_ul.rb +38 -0
  25. data/lib/tochka_cyclops_api/schemas/responses/activate_beneficiary.rb +24 -0
  26. data/lib/tochka_cyclops_api/schemas/responses/create_beneficiary_fl.rb +24 -0
  27. data/lib/tochka_cyclops_api/schemas/responses/create_beneficiary_ip.rb +10 -1
  28. data/lib/tochka_cyclops_api/schemas/responses/create_beneficiary_ul.rb +9 -9
  29. data/lib/tochka_cyclops_api/schemas/responses/deactivate_beneficiary.rb +24 -0
  30. data/lib/tochka_cyclops_api/schemas/responses/echo.rb +1 -1
  31. data/lib/tochka_cyclops_api/schemas/responses/error.rb +5 -2
  32. data/lib/tochka_cyclops_api/schemas/responses/get_beneficiary.rb +48 -0
  33. data/lib/tochka_cyclops_api/schemas/responses/list_beneficiary.rb +38 -0
  34. data/lib/tochka_cyclops_api/schemas/responses/update_beneficiary_fl.rb +20 -0
  35. data/lib/tochka_cyclops_api/schemas/responses/update_beneficiary_ip.rb +20 -0
  36. data/lib/tochka_cyclops_api/schemas/responses/update_beneficiary_ul.rb +24 -0
  37. data/lib/tochka_cyclops_api/schemas/results/local_error.rb +0 -0
  38. data/lib/tochka_cyclops_api/test.rb +0 -0
  39. data/lib/tochka_cyclops_api/version.rb +1 -1
  40. data/lib/tochka_cyclops_api.rb +8 -2
  41. metadata +23 -17
@@ -1,63 +1,56 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative './schemas/responses/echo'
3
+ require_relative 'schemas/responses/error'
4
4
 
5
5
  module TochkaCyclopsApi
6
6
  # Class for processing the response received from the api bank
7
7
  class Response
8
- def self.create(request, response, method)
9
- @method = method
8
+ def self.create(request: ,response: ,method:)
10
9
  @request = request
11
- @response = response
12
- parse
10
+ @method = method
11
+ @body = JSON.parse(response.body)
12
+ @response_schema = "TochkaCyclopsApi::Schemas::Responses::#{camel_case_method}".constantize
13
+ @error_schema = 'TochkaCyclopsApi::Schemas::Responses::Error'.constantize
13
14
 
14
- {
15
- response_struct: @response_struct,
16
- result: @result
17
- }
15
+ call
18
16
  end
19
17
 
20
- def self.parse
21
- @body = JSON.parse(@response.body)
22
- if @body.key? 'result'
23
- parse_result
24
- elsif @body.key? 'error'
18
+ private
19
+
20
+ def self.call
21
+ @result = @body['result']
22
+ @error = @body['error']
23
+
24
+ if @error.present?
25
25
  parse_error
26
+ else
27
+ parse_result
26
28
  end
27
29
  end
28
30
 
29
31
  def self.parse_result
30
- @result = @body['result']
31
- response_schema = schema || -> { "Schema for #{@method} is not found" }[]
32
+ return nil if @result.nil?
32
33
 
33
- @response = TochkaCyclopsResponse.create(body: @body, result: @result)
34
- @request.update(result: @response)
34
+ response = TochkaCyclopsResponse.create(body: @body, result: @result)
35
+ @request.update(result: response, status: 'success')
35
36
  @result.deep_symbolize_keys if @result.is_a? Hash
36
- @response_struct = response_schema.new(@result)
37
+ response_struct = @response_schema.new(@result)
38
+
39
+ Result.success(response_struct)
37
40
  end
38
41
 
39
42
  def self.parse_error
40
- @error = @body['error']
41
- require_relative './schemas/responses/error'
42
- response_schema = 'TochkaCyclopsApi::Schemas::Responses::Error'.constantize
43
+ return nil if @error.nil?
43
44
 
44
- @response = TochkaCyclopsError.create(
45
+ response = TochkaCyclopsError.create(
45
46
  body: @body,
46
47
  code: @error['code'],
47
48
  message: @error['message']
48
49
  )
50
+ @request.update(result: response, status: 'failure')
51
+ response_struct = @error_schema.new(@error.deep_symbolize_keys)
49
52
 
50
- @request.update(result: @response)
51
-
52
- @response_struct = response_schema.new(@error.deep_symbolize_keys)
53
- end
54
-
55
- def self.schema
56
- require_relative "./schemas/responses/#{@method}"
57
- "TochkaCyclopsApi::Schemas::Responses::#{camel_case_method}".constantize
58
- rescue StandardError => e
59
- @errors = { error: e.message }
60
- false
53
+ Result.success(response_struct)
61
54
  end
62
55
 
63
56
  def self.camel_case_method
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TochkaCyclopsApi
4
+ # Displays the result of request
5
+ class Result
6
+ attr_reader :success, :data, :error_message
7
+
8
+ def self.create(success, data = nil, error_message = nil)
9
+ @success = success
10
+ @data = data
11
+ @error_message = error_message
12
+
13
+ display_result
14
+ end
15
+
16
+ def self.success(data)
17
+ Result.create(true, data)
18
+ end
19
+
20
+ def self.failure(error_message)
21
+ Result.create(false, nil, error_message)
22
+ end
23
+
24
+ private
25
+
26
+ def self.display_result
27
+ {
28
+ success: @success,
29
+ data: @data || @error_message
30
+ }
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'dry-validation'
4
+
5
+ module TochkaCyclopsApi
6
+ module Schemas
7
+ module Requests
8
+ # https://api.tochka.com/static/v1/tender-docs/cyclops/main/api_v2.html#api-v2-activate-beneficiary
9
+ class ActivateBeneficiary < Dry::Validation::Contract
10
+ schema do
11
+ required(:beneficiary_id).value(:string)
12
+ end
13
+
14
+ EXAMPLE = "
15
+ {
16
+ beneficiary_id: '981fee11-9969-4e80-9f5f-02af462cb51e'
17
+ }
18
+ "
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'dry-validation'
4
+
5
+ module TochkaCyclopsApi
6
+ module Schemas
7
+ module Requests
8
+ # https://api.tochka.com/static/v1/tender-docs/cyclops/main/api_v2.html#api-v2-create-beneficiary-fl
9
+ class CreateBeneficiaryFl < Dry::Validation::Contract
10
+ # Schema for beneficiary_data field of main schema
11
+ class BeneficiaryData < Dry::Validation::Contract
12
+ params do
13
+ required(:first_name).value(:string)
14
+ required(:last_name).value(:string)
15
+ required(:birth_date).value(:string)
16
+ required(:birth_place).value(:string)
17
+ required(:passport_number).value(:string)
18
+ required(:passport_date).value(:string)
19
+ required(:registration_address).value(:string)
20
+
21
+ optional(:passport_series).value(:string)
22
+ optional(:middle_name).value(:string)
23
+ optional(:resident).value(:bool)
24
+ end
25
+ end
26
+
27
+ schema do
28
+ required(:inn).value(:string)
29
+ required(:beneficiary_data).schema(
30
+ TochkaCyclopsApi::Schemas::Requests::CreateBeneficiaryFl::BeneficiaryData.schema
31
+ )
32
+
33
+ optional(:nominal_account_code).value(:string)
34
+ optional(:nominal_account_bic).value(:string)
35
+ end
36
+
37
+ EXAMPLE ="
38
+ {
39
+ inn: '7925930371',
40
+ nominal_account_code: '000000000000000000000',
41
+ nominal_account_bic: '0000000000',
42
+ beneficiary_data: {
43
+ first_name: 'Иван',
44
+ last_name: 'Иванов',
45
+ birth_date: '1990-01-24',
46
+ birth_place: 'г. Свердловск',
47
+ passport_series: '6509',
48
+ passport_number: '123456',
49
+ passport_date: '2020-01-01',
50
+ registration_address: '683031, г. Петропавловск-Камчатский, пр-кт. Карла Маркса, д. 21/1, офис 305'
51
+ }
52
+ }"
53
+ end
54
+ end
55
+ end
56
+ end
@@ -5,25 +5,37 @@ require 'dry-validation'
5
5
  module TochkaCyclopsApi
6
6
  module Schemas
7
7
  module Requests
8
- # Schema for beneficiary_data field of main schema
9
- class BeneficiaryData < Dry::Validation::Contract
10
- params do
11
- required(:first_name).value(:string)
12
- required(:last_name).value(:string)
13
- optional(:middle_name).value(:string)
14
- end
15
- end
16
-
17
8
  # https://api.tochka.com/static/v1/tender-docs/cyclops/main/api_v2.html#api-v2-create-beneficiary-ip
18
9
  class CreateBeneficiaryIp < Dry::Validation::Contract
10
+ # Schema for beneficiary_data field of main schema
11
+ class BeneficiaryData < Dry::Validation::Contract
12
+ params do
13
+ required(:first_name).value(:string)
14
+ required(:last_name).value(:string)
15
+ optional(:middle_name).value(:string)
16
+ end
17
+ end
18
+
19
19
  schema do
20
20
  required(:inn).value(:string)
21
21
  optional(:nominal_account_code).value(:string)
22
22
  optional(:nominal_account_bic).value(:string)
23
23
  required(:beneficiary_data).schema(
24
- TochkaCyclopsApi::Schemas::Reuqests::BeneficiaryData.schema
24
+ TochkaCyclopsApi::Schemas::Requests::CreateBeneficiaryIp::BeneficiaryData.schema
25
25
  )
26
26
  end
27
+
28
+ EXAMPLE =
29
+ "{
30
+ inn: '7743745038',
31
+ nominal_account_code: '40702810338170022645',
32
+ nominal_account_bic: '044525225',
33
+ beneficiary_data: {
34
+ first_name: 'Иван',
35
+ last_name: 'Иванов',
36
+ middle_name: 'Иванович'
37
+ }
38
+ }"
27
39
  end
28
40
  end
29
41
  end
@@ -5,25 +5,37 @@ require 'dry-validation'
5
5
  module TochkaCyclopsApi
6
6
  module Schemas
7
7
  module Requests
8
- # Schema for beneficiary_data field of main schema
9
- class BeneficiaryData < Dry::Validation::Contract
10
- params do
11
- required(:name).value(:string)
12
- required(:kpp).value(:string)
13
- optional(:ogrn).value(:string)
14
- end
15
- end
16
-
17
8
  # https://api.tochka.com/static/v1/tender-docs/cyclops/main/api_v2.html#api-v2-create-beneficiary-ul
18
9
  class CreateBeneficiaryUl < Dry::Validation::Contract
10
+ # Schema for beneficiary_data field of main schema
11
+ class BeneficiaryData < Dry::Validation::Contract
12
+ params do
13
+ required(:name).value(:string)
14
+ required(:kpp).value(:string)
15
+ optional(:ogrn).value(:string)
16
+ end
17
+ end
18
+
19
19
  schema do
20
20
  required(:inn).value(:string)
21
21
  optional(:nominal_account_code).value(:string)
22
22
  optional(:nominal_account_bic).value(:string)
23
23
  required(:beneficiary_data).schema(
24
- TochkaCyclopsApi::Schemas::Requests::BeneficiaryData.schema
24
+ TochkaCyclopsApi::Schemas::Requests::CreateBeneficiaryUl::BeneficiaryData.schema
25
25
  )
26
26
  end
27
+
28
+ EXAMPLE =
29
+ "{
30
+ inn: '7743745038',
31
+ nominal_account_code: '40702810338170022645',
32
+ nominal_account_bic: '044525225',
33
+ beneficiary_data: {
34
+ name: 'ООО «ТК ИнжСтройКомплект»',
35
+ kpp: '773401001',
36
+ ogrn: '1097746324169'
37
+ }
38
+ }"
27
39
  end
28
40
  end
29
41
  end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'dry-validation'
4
+
5
+ module TochkaCyclopsApi
6
+ module Schemas
7
+ module Requests
8
+ # https://api.tochka.com/static/v1/tender-docs/cyclops/main/api_v2.html#api-v2-deactivate-beneficiary
9
+ class DeactivateBeneficiary < Dry::Validation::Contract
10
+ schema do
11
+ required(:beneficiary_id).value(:string)
12
+ end
13
+
14
+ EXAMPLE = "
15
+ {
16
+ beneficiary_id: '981fee11-9969-4e80-9f5f-02af462cb51e'
17
+ }
18
+ "
19
+ end
20
+ end
21
+ end
22
+ end
@@ -10,6 +10,8 @@ module TochkaCyclopsApi
10
10
  schema do
11
11
  required(:text).value(:string)
12
12
  end
13
+
14
+ EXAMPLE = "{ text: 'Echo' }"
13
15
  end
14
16
  end
15
17
  end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'dry-validation'
4
+
5
+ module TochkaCyclopsApi
6
+ module Schemas
7
+ module Requests
8
+ # https://api.tochka.com/static/v1/tender-docs/cyclops/main/api_v2.html#api-v2-get-beneficiary
9
+ class GetBeneficiary < Dry::Validation::Contract
10
+ schema do
11
+ required(:beneficiary_id).value(:string)
12
+ end
13
+
14
+ EXAMPLE = "
15
+ {
16
+ beneficiary_id: '981fee11-9969-4e80-9f5f-02af462cb51e'
17
+ }
18
+ "
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'dry-validation'
4
+
5
+ module TochkaCyclopsApi
6
+ module Schemas
7
+ module Requests
8
+ # https://api.tochka.com/static/v1/tender-docs/cyclops/main/api_v2.html#api-v2-list-beneficiary
9
+ class ListBeneficiary < Dry::Validation::Contract
10
+ # Schema for beneficiary_data field of main schema
11
+ class Filters < Dry::Validation::Contract
12
+ params do
13
+ optional(:inn).value(:string)
14
+ optional(:is_active).value(:bool)
15
+ optional(:legal_type).value(:string)
16
+ optional(:nominal_account_code).value(:string)
17
+ optional(:nominal_account_bic).value(:string)
18
+ end
19
+ end
20
+
21
+ schema do
22
+ optional(:page).value(:integer)
23
+ optional(:per_page).value(:integer)
24
+ optional(:filters).schema(
25
+ TochkaCyclopsApi::Schemas::Requests::ListBeneficiary::Filters.schema
26
+ )
27
+ end
28
+
29
+ EXAMPLE = "
30
+ {
31
+ page: 2,
32
+ per_page: 20,
33
+ filters: {
34
+ is_active: true,
35
+ legal_type: 'F',
36
+ nominal_account_code: '000000000000000000000',
37
+ nominal_account_bic: '0000000000',
38
+ }
39
+ }
40
+ "
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'dry-validation'
4
+
5
+ module TochkaCyclopsApi
6
+ module Schemas
7
+ module Requests
8
+ # https://api.tochka.com/static/v1/tender-docs/cyclops/main/api_v2.html#api-v2-update-beneficiary-fl
9
+ class UpdateBeneficiaryFl < Dry::Validation::Contract
10
+ # Schema for beneficiary_data field of main schema
11
+ class BeneficiaryData < Dry::Validation::Contract
12
+ params do
13
+ required(:first_name).value(:string)
14
+ required(:last_name).value(:string)
15
+ required(:birth_date).value(:string)
16
+ required(:birth_place).value(:string)
17
+ required(:passport_number).value(:string)
18
+ required(:passport_date).value(:string)
19
+ required(:registration_address).value(:string)
20
+
21
+ optional(:passport_series).value(:string)
22
+ optional(:middle_name).value(:string)
23
+ optional(:resident).value(:bool)
24
+ end
25
+ end
26
+
27
+ schema do
28
+ required(:beneficiary_id).value(:string)
29
+ required(:beneficiary_data).schema(
30
+ TochkaCyclopsApi::Schemas::Requests::UpdateBeneficiaryFl::BeneficiaryData.schema
31
+ )
32
+ end
33
+
34
+ EXAMPLE = "
35
+ {
36
+ beneficiary_id: '981fee11-9969-4e80-9f5f-02af462cb51e',
37
+ beneficiary_data: {
38
+ first_name: 'Иван',
39
+ last_name: 'Иванов',
40
+ birth_date: '1990-01-24',
41
+ birth_place: 'г. Свердловск',
42
+ passport_series: '6509',
43
+ passport_number: '123456',
44
+ passport_date: '2020-01-01',
45
+ registration_address: '683031, г. Петропавловск-Камчатский, пр-кт. Карла Маркса, д. 21/1, офис 305'
46
+ }
47
+ }"
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'dry-validation'
4
+
5
+ module TochkaCyclopsApi
6
+ module Schemas
7
+ module Requests
8
+ # https://api.tochka.com/static/v1/tender-docs/cyclops/main/api_v2.html#api-v2-update-beneficiary-ip
9
+ class UpdateBeneficiaryIp < Dry::Validation::Contract
10
+ # Schema for beneficiary_data field of main schema
11
+ class BeneficiaryData < Dry::Validation::Contract
12
+ params do
13
+ required(:first_name).value(:string)
14
+ required(:last_name).value(:string)
15
+ optional(:middle_name).value(:string)
16
+ end
17
+ end
18
+
19
+ schema do
20
+ required(:beneficiary_id).value(:string)
21
+ required(:beneficiary_data).schema(
22
+ TochkaCyclopsApi::Schemas::Requests::UpdateBeneficiaryIp::BeneficiaryData.schema
23
+ )
24
+ end
25
+
26
+ EXAMPLE = "
27
+ {
28
+ beneficiary_id: 981fee11-9969-4e80-9f5f-02af462cb51e,
29
+ beneficiary_data: {
30
+ first_name: 'Иван',
31
+ middle_name: 'Иванович',
32
+ last_name: 'Иванов'
33
+ }
34
+ }
35
+ "
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'dry-validation'
4
+
5
+ module TochkaCyclopsApi
6
+ module Schemas
7
+ module Requests
8
+ # https://api.tochka.com/static/v1/tender-docs/cyclops/main/api_v2.html#api-v2-update-beneficiary-ul
9
+ class UpdateBeneficiaryUl < Dry::Validation::Contract
10
+ # Schema for beneficiary_data field of main schema
11
+ class BeneficiaryData < Dry::Validation::Contract
12
+ params do
13
+ required(:name).value(:string)
14
+ required(:kpp).value(:string)
15
+ optional(:ogrn).value(:string)
16
+ end
17
+ end
18
+
19
+ schema do
20
+ required(:beneficiary_id).value(:string)
21
+ required(:beneficiary_data).schema(
22
+ TochkaCyclopsApi::Schemas::Requests::UpdateBeneficiaryUl::BeneficiaryData.schema
23
+ )
24
+ end
25
+
26
+ EXAMPLE = "
27
+ {
28
+ beneficiary_id: '981fee11-9969-4e80-9f5f-02af462cb51e',
29
+ beneficiary_data: {
30
+ name: 'ООО \"Рога и Копыта\"',
31
+ kpp: '246301001'
32
+ }
33
+ }
34
+ "
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'dry-struct'
4
+
5
+ module Types
6
+ include Dry.Types()
7
+ end
8
+
9
+ module TochkaCyclopsApi
10
+ module Schemas
11
+ module Responses
12
+ # Response schema for activate_beneficiary request
13
+ class ActivateBeneficicary < Dry::Struct
14
+ # Schema for beneficiary field of main response
15
+ class BeneficiaryData < Dry::Struct
16
+ attribute :inn, Types::Strict::String
17
+ attribute :id, Types::Strict::String
18
+ end
19
+
20
+ attribute :beneficiary, BeneficiaryData
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,24 @@
1
+ require 'dry-struct'
2
+
3
+ module Types
4
+ include Dry.Types()
5
+ end
6
+
7
+ module TochkaCyclopsApi
8
+ module Schemas
9
+ module Responses
10
+ # Response schema for create_beneficiary_fl request
11
+ class CreateBeneficiaryFl < Dry::Struct
12
+ # Schema for beneficiary field of main response
13
+ class BeneficiaryData < Dry::Struct
14
+ attribute :inn, Types::Strict::String
15
+ attribute :id, Types::Strict::String
16
+ attribute :nominal_account_code, Types::Strict::String.optional
17
+ attribute :nominal_account_bic, Types::Strict::String.optional
18
+ end
19
+
20
+ attribute :beneficiary, BeneficiaryData
21
+ end
22
+ end
23
+ end
24
+ end
@@ -5,8 +5,17 @@ require 'dry-struct'
5
5
  module TochkaCyclopsApi
6
6
  module Schemas
7
7
  module Responses
8
- # Response chema for create_beneficiary_ip request
8
+ # Response schema for create_beneficiary_ip request
9
9
  class CreateBeneficiaryIp < Dry::Struct
10
+ # Schema for beneficiary field of main response
11
+ class BeneficiaryData < Dry::Struct
12
+ attribute :inn, Types::Strict::String
13
+ attribute :id, Types::Strict::String
14
+ attribute :nominal_account_code, Types::Strict::String.optional
15
+ attribute :nominal_account_bic, Types::Strict::String.optional
16
+ end
17
+
18
+ attribute :beneficiary, BeneficiaryData
10
19
  end
11
20
  end
12
21
  end
@@ -9,16 +9,16 @@ end
9
9
  module TochkaCyclopsApi
10
10
  module Schemas
11
11
  module Responses
12
- # Schema for beneficiary field of main response
13
- class BeneficiaryData < Dry::Struct
14
- attribute :inn, Types::Strict::String
15
- attribute :id, Types::Strict::String
16
- attribute :nominal_account_code, Types::Strict::String.optional
17
- attribute :nominal_account_bic, Types::Strict::String.optional
18
- end
19
-
20
- # Response chema for create_beneficiary_ul request
12
+ # Response schema for create_beneficiary_ul request
21
13
  class CreateBeneficiaryUl < Dry::Struct
14
+ # Schema for beneficiary field of main response
15
+ class BeneficiaryData < Dry::Struct
16
+ attribute :inn, Types::Strict::String
17
+ attribute :id, Types::Strict::String
18
+ attribute :nominal_account_code, Types::Strict::String.optional
19
+ attribute :nominal_account_bic, Types::Strict::String.optional
20
+ end
21
+
22
22
  attribute :beneficiary, BeneficiaryData
23
23
  end
24
24
  end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'dry-struct'
4
+
5
+ module Types
6
+ include Dry.Types()
7
+ end
8
+
9
+ module TochkaCyclopsApi
10
+ module Schemas
11
+ module Responses
12
+ # Response schema for deactivate_beneficiary request
13
+ class DeactivateBeneficicary < Dry::Struct
14
+ # Schema for beneficiary field of main response
15
+ class BeneficiaryData < Dry::Struct
16
+ attribute :inn, Types::Strict::String
17
+ attribute :id, Types::Strict::String
18
+ end
19
+
20
+ attribute :beneficiary, BeneficiaryData
21
+ end
22
+ end
23
+ end
24
+ end
@@ -5,7 +5,7 @@ require 'dry-struct'
5
5
  module TochkaCyclopsApi
6
6
  module Schemas
7
7
  module Responses
8
- # Response chema for echo request
8
+ # Response schema for echo request
9
9
  class Echo
10
10
  attr_accessor :text
11
11
 
@@ -5,11 +5,14 @@ require 'dry-struct'
5
5
  module TochkaCyclopsApi
6
6
  module Schemas
7
7
  module Responses
8
- # Response chema for bank's api errors
8
+ module Types
9
+ include Dry.Types()
10
+ end
11
+ # Response schema for bank's api errors
9
12
  class Error < Dry::Struct
10
13
  attribute :code, Types::Strict::Integer
11
14
  attribute :message, Types::Strict::String
12
- attribute :meta, Types::Strict::Array
15
+ attribute :meta, Types::Strict::Array.optional
13
16
  end
14
17
  end
15
18
  end