pagopa-soap 0.1.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 (48) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +8 -0
  3. data/.rubocop.yml +137 -0
  4. data/.travis.yml +14 -0
  5. data/CODE_OF_CONDUCT.md +75 -0
  6. data/Gemfile +9 -0
  7. data/LICENSE.txt +29 -0
  8. data/README.md +229 -0
  9. data/Rakefile +13 -0
  10. data/bin/console +15 -0
  11. data/bin/setup +8 -0
  12. data/diagrams/diagrammi-psp.jpg +0 -0
  13. data/diagrams/diagrammi-revoca.jpg +0 -0
  14. data/diagrams/diagrammi-wisp.jpg +0 -0
  15. data/lib/pago_pa.rb +14 -0
  16. data/lib/pago_pa/soap.rb +17 -0
  17. data/lib/pago_pa/soap/configurable.rb +38 -0
  18. data/lib/pago_pa/soap/message/domain.rb +31 -0
  19. data/lib/pago_pa/soap/message/institution.rb +42 -0
  20. data/lib/pago_pa/soap/message/payer.rb +42 -0
  21. data/lib/pago_pa/soap/message/payment.rb +61 -0
  22. data/lib/pago_pa/soap/message/rpt.rb +86 -0
  23. data/lib/pago_pa/soap/message/rt.rb +43 -0
  24. data/lib/pago_pa/soap/message/single_payment.rb +18 -0
  25. data/lib/pago_pa/soap/version.rb +8 -0
  26. data/lib/pago_pa/soap/wsdl_loader.rb +66 -0
  27. data/lib/soap.rb +126 -0
  28. data/lib/soap/parser.rb +74 -0
  29. data/lib/soap/parser/binding.rb +53 -0
  30. data/lib/soap/parser/message.rb +27 -0
  31. data/lib/soap/parser/port_type.rb +42 -0
  32. data/lib/soap/parser/service.rb +25 -0
  33. data/lib/soap/parser/types.rb +97 -0
  34. data/lib/soap/string.rb +33 -0
  35. data/lib/soap/webservice.rb +4 -0
  36. data/lib/soap/webservice/client.rb +37 -0
  37. data/lib/soap/webservice/error.rb +17 -0
  38. data/lib/soap/webservice/fault_error.rb +12 -0
  39. data/lib/soap/webservice/request.rb +118 -0
  40. data/lib/soap/webservice/response.rb +88 -0
  41. data/pagopa-soap.gemspec +45 -0
  42. data/resources/PaPerNodo.wsdl +214 -0
  43. data/resources/PaPerNodoChiediElencoAvvisiDigitali.wsdl +93 -0
  44. data/resources/PaPerNodoPagamentoPsp.wsdl +241 -0
  45. data/resources/PaPerNodoRichiestaAvvisi.wsdl +202 -0
  46. data/resources/pagopa_avvisi.wsdl +98 -0
  47. data/resources/pagopa_base.wsdl +869 -0
  48. metadata +245 -0
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task test: :spec
9
+
10
+ require "rubocop/rake_task"
11
+ RuboCop::RakeTask.new
12
+
13
+ task default: %i[rubocop spec]
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "soap"
5
+ require "pago_pa"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ require "pry"
12
+ Pry.start
13
+
14
+ # require "irb"
15
+ # IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "nori"
4
+ require "gyoku"
5
+ require "soap"
6
+
7
+ require "pago_pa/soap"
8
+ require "pago_pa/soap/version"
9
+ require "pago_pa/soap/configurable"
10
+ require "pago_pa/soap/wsdl_loader"
11
+ require "pago_pa/soap/message/rpt"
12
+ require "pago_pa/soap/message/rt"
13
+
14
+ module PagoPA; end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PagoPA; end
4
+
5
+ module PagoPA::SOAP
6
+ class << self
7
+ def options
8
+ Hash[PagoPA::SOAP.keys.map { |key| [key, config.send(key)] }]
9
+ end
10
+
11
+ # API client based on configured options {Configurable}
12
+ def build
13
+ return @build if defined?(@build)
14
+ @build = PagoPA::SOAP::WSDLLoader.new(options)
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PagoPA::SOAP
4
+ class << self
5
+ # List of configurable keys for {Pagoparb::Client}
6
+ # @return [Array] of option keys
7
+ def keys
8
+ @keys ||= %i[
9
+ namespace wsdl_base wsdl_notify endpoint_base endpoint_notify
10
+ ]
11
+ end
12
+
13
+ def config
14
+ @config ||= Configurable.new
15
+ end
16
+
17
+ # Set configuration options using a block
18
+ def configure
19
+ yield(config)
20
+ end
21
+ end
22
+
23
+ class Configurable
24
+ attr_accessor :namespace
25
+ attr_accessor :wsdl_base
26
+ attr_accessor :wsdl_notify
27
+ attr_accessor :endpoint_base
28
+ attr_accessor :endpoint_notify
29
+
30
+ def initialize
31
+ @namespace ||= "PagoPA"
32
+ @wsdl_base ||=
33
+ File.expand_path("../../../resources/pagopa_base.wsdl", __dir__)
34
+ @wsdl_notify ||=
35
+ File.expand_path("../../../resources/pagopa_avvisi.wsdl", __dir__)
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PagoPA; end
4
+ module PagoPA::SOAP; end
5
+ module PagoPA::SOAP::Message; end
6
+
7
+ class PagoPA::SOAP::Message::Domain
8
+ REQUIRED_ATTRIBUTES = %i[
9
+ identificativo_dominio identificativo_stazione_richiedente
10
+ ].freeze
11
+
12
+ attr_reader :attributes
13
+
14
+ def initialize(attributes)
15
+ @attributes = attributes
16
+ validate_attrs!
17
+ end
18
+
19
+ def to_params
20
+ end
21
+
22
+ private
23
+
24
+ def validate_attrs!
25
+ attributes.each_key do |at|
26
+ if !REQUIRED_ATTRIBUTES.include?(at)
27
+ raise "Attribute #{at} must be present"
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PagoPA; end
4
+ module PagoPA::SOAP; end
5
+ module PagoPA::SOAP::Message; end
6
+
7
+ class PagoPA::SOAP::Message::Institution
8
+ REQUIRED_ATTRIBUTES = %i[
9
+ denominazione_beneficiario identificativo_univoco_beneficiario
10
+ ].freeze
11
+ REQUIRED_IUB = %i[
12
+ tipo_identificativo_univoco codice_identificativo_univoco
13
+ ].freeze
14
+
15
+ attr_reader :attributes
16
+ attr_reader :iub
17
+
18
+ def initialize(attributes)
19
+ @attributes = attributes
20
+ @iub = attributes[:identificativo_univoco_beneficiario]
21
+ validate_attrs!
22
+ end
23
+
24
+ def to_params
25
+ end
26
+
27
+ private
28
+
29
+ def validate_attrs!
30
+ attributes.each_key do |at|
31
+ if !REQUIRED_ATTRIBUTES.include?(at)
32
+ raise "Attribute #{at} must be present"
33
+ end
34
+ end
35
+
36
+ iub.each_key do |at|
37
+ if !REQUIRED_IUB.include?(at)
38
+ raise "Attribute Identifier #{at} must be present"
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PagoPA; end
4
+ module PagoPA::SOAP; end
5
+ module PagoPA::SOAP::Message; end
6
+
7
+ class PagoPA::SOAP::Message::Payer
8
+ REQUIRED_ATTRIBUTES = %i[
9
+ anagrafica_pagatore identificativo_univoco_pagatore
10
+ ].freeze
11
+ REQUIRED_IUP = %i[
12
+ tipo_identificativo_univoco codice_identificativo_univoco
13
+ ].freeze
14
+
15
+ attr_reader :attributes
16
+ attr_reader :iup
17
+
18
+ def initialize(attributes = {})
19
+ @attributes = attributes
20
+ @iup = attributes[:identificativo_univoco_pagatore]
21
+ validate_attrs!
22
+ end
23
+
24
+ def to_params
25
+ end
26
+
27
+ private
28
+
29
+ def validate_attrs!
30
+ attributes.each_key do |at|
31
+ if !REQUIRED_ATTRIBUTES.include?(at)
32
+ raise "Attribute #{at} must be present"
33
+ end
34
+ end
35
+
36
+ iup.each_key do |at|
37
+ if !REQUIRED_IUP.include?(at)
38
+ raise "Attribute Identifier #{at} must be present"
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,61 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "pago_pa/soap/message/single_payment"
4
+
5
+ module PagoPA; end
6
+ module PagoPA::SOAP; end
7
+ module PagoPA::SOAP::Message; end
8
+
9
+ class PagoPA::SOAP::Message::Payment
10
+ REQUIRED_ATTRIBUTES = %i[
11
+ data_esecuzione_pagamento importo_totale_da_versare tipo_versamento
12
+ identificativo_univoco_versamento codice_contesto_pagamento
13
+ firma_ricevuta dati_singolo_versamento
14
+ ].freeze
15
+
16
+ attr_reader :attributes
17
+ attr_reader :date
18
+ attr_reader :amount
19
+ attr_reader :type
20
+ attr_reader :iuv
21
+ attr_reader :contest
22
+ attr_reader :signature
23
+
24
+ def initialize(**args)
25
+ @attributes = args
26
+ validate_attrs!
27
+
28
+ @date = attributes.delete(:data_esecuzione_pagamento)
29
+ @amount = attributes.delete(:importo_totale_da_versare)
30
+ @type = attributes.delete(:tipo_versamento)
31
+ @iuv = attributes.delete(:identificativo_univoco_versamento)
32
+ @contest = attributes.delete(:codice_contesto_pagamento)
33
+ @signature = attributes.delete(:firma_ricevuta)
34
+ end
35
+
36
+ def to_params
37
+ end
38
+
39
+ private
40
+
41
+ def validate_attrs!
42
+ attributes.each_key do |at|
43
+ if !REQUIRED_ATTRIBUTES.include?(at)
44
+ raise "Attribute #{at} must be present"
45
+ end
46
+ end
47
+
48
+ if attributes[:dati_singolo_versamento].count >= 1
49
+ raise "Single payment must be exist"
50
+ end
51
+ if attributes[:dati_singolo_versamento].count > 5
52
+ raise "Single payment can contain up to 5 occurrences"
53
+ end
54
+ end
55
+
56
+ def single_payments
57
+ @single_payments ||= attributes[:dati_singolo_versamento].map do |single|
58
+ PagoPA::SOAP::Message::SinglePayment.new(single).perform!
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,86 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "pago_pa/soap/message/domain"
4
+ require "pago_pa/soap/message/payer"
5
+ require "pago_pa/soap/message/institution"
6
+ require "pago_pa/soap/message/payment"
7
+
8
+ module PagoPA::SOAP; end
9
+ module PagoPA::SOAP::Message; end
10
+
11
+ class PagoPA::SOAP::Message::Rpt
12
+ class << self
13
+ def decode(string)
14
+ nori = Nori.new(
15
+ advanced_typecasting: false,
16
+ convert_tags_to: lambda do |tag|
17
+ Soap.to_snakecase(tag.split(":").last).to_sym
18
+ end
19
+ )
20
+ xml = Base64.decode64(string)
21
+ nori.parse(xml)
22
+ end
23
+ end
24
+
25
+ REQUIRED_ATTRIBUTES = %i[
26
+ versione_oggetto dominio identificativo_messaggio_richiesta
27
+ data_ora_messaggio_richiesta autenticazione_soggetto
28
+ soggetto_pagatore ente_beneficiario dati_versamento
29
+ ].freeze
30
+
31
+ attr_reader :attributes
32
+ attr_reader :version
33
+ attr_reader :request_id
34
+ attr_reader :date_request
35
+ attr_reader :auth
36
+ attr_reader :base_64
37
+
38
+ def initialize(decode = false, **args)
39
+ if decode && args.key?(:base_64)
40
+ args = self.decode(args[:base_64] || "")
41
+ end
42
+
43
+ @attributes = args
44
+ @version = attributes.delete(:versione_oggetto)
45
+ @request_id = attributes.delete(:identificativo_messaggio_richiesta)
46
+ @date_request = attributes.delete(:data_ora_messaggio_richiesta)
47
+ @auth = attributes.delete(:autenticazione_soggetto)
48
+ end
49
+
50
+ def to_params
51
+ {
52
+ "RPT" => {}
53
+ }
54
+ end
55
+
56
+ def encode
57
+ Base64.encode64(to_xml)
58
+ end
59
+
60
+ def to_xml
61
+ Gyoku.xml(to_params)
62
+ end
63
+
64
+ private
65
+
66
+ def domain
67
+ @domain ||= PagoPA::SOAP::Message::Domain.new(attributes[:dominio]).perform!
68
+ end
69
+
70
+ def payer
71
+ @payer ||=
72
+ PagoPA::SOAP::Message::Payer.new(attributes[:soggetto_pagatore]).perform!
73
+ end
74
+
75
+ def institution
76
+ @institution ||=
77
+ PagoPA::SOAP::Message::Institution.new(
78
+ attributes[:ente_beneficiario]
79
+ ).perform!
80
+ end
81
+
82
+ def payment
83
+ @payment ||=
84
+ PagoPA::SOAP::Message::Payment.new(attributes[:dati_versamento]).perform!
85
+ end
86
+ end
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PagoPA; end
4
+ module PagoPA::SOAP; end
5
+ module PagoPA::SOAP::Message; end
6
+
7
+ class PagoPA::SOAP::Message::Rt
8
+ class << self
9
+ def decode(string)
10
+ Base64.decode64(string)
11
+ end
12
+ end
13
+
14
+ REQUIRED_ATTRIBUTES = %i[
15
+ versione_oggetto dominio identificativo_messaggio_ricevuta
16
+ data_ora_messaggio_richiesta riferimento_messaggio_richiesta
17
+ riferimento_data_richiesta istituto_attestante ente_beneficiario
18
+ soggetto_pagatore dati_pagamento
19
+ ].freeze
20
+
21
+ attr_reader :attributes
22
+
23
+ def initialize(attributes = {}, decode = false)
24
+ if decode && attributes.key?(:base_64)
25
+ parser = Nori.new(
26
+ advanced_typecasting: false,
27
+ convert_tags_to: lambda { |tag| Soap.to_nakecase(tag).to_sym }
28
+ )
29
+ attrs = parser.parse(self.decode(attributes[:base_64] || ""))
30
+ @attributes = attrs || {}
31
+ else
32
+ @attributes = attributes
33
+ end
34
+ end
35
+
36
+ def encode
37
+ Base64.encode64(to_xml)
38
+ end
39
+
40
+ def to_xml
41
+ Gyoku.xml(to_params)
42
+ end
43
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module PagoPA; end
4
+ module PagoPA::SOAP; end
5
+ module PagoPA::SOAP::Message; end
6
+
7
+ class PagoPA::SOAP::Message::SinglePayment
8
+ REQUIRED_ATTRIBUTES = %i[].freeze
9
+
10
+ attr_reader :attributes
11
+
12
+ def initialize(attributes = {})
13
+ @attributes = attributes
14
+ end
15
+
16
+ def to_params
17
+ end
18
+ end