Class: SatMx::DownloadRequestBody

Inherits:
Object
  • Object
show all
Includes:
Body
Defined in:
lib/sat_mx/download_request_body.rb

Constant Summary collapse

REQUEST_TYPES =
{
  cfdi: "CFDI",
  metadata: "Metadata"
}.freeze

Constants included from Body

Body::DES, Body::DS, Body::ENVELOPE_ATTRS, Body::NAMESPACE, Body::S11, Body::XMLNS

Instance Method Summary collapse

Constructor Details

#initialize(start_date:, end_date:, request_type:, issuing_rfc:, recipient_rfcs:, requester_rfc:, certificate:) ⇒ DownloadRequestBody

Returns a new instance of DownloadRequestBody.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/sat_mx/download_request_body.rb', line 12

def initialize(start_date:,
  end_date:,
  request_type:,
  issuing_rfc:,
  recipient_rfcs:,
  requester_rfc:,
  certificate:)
  @start_date = start_date
  @end_date = end_date
  @request_type = request_type
  @issuing_rfc = issuing_rfc
  @recipient_rfcs = recipient_rfcs
  @requester_rfc = requester_rfc
  @certificate = certificate
end

Instance Method Details

#generateObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/sat_mx/download_request_body.rb', line 28

def generate
  envelope do |xml|
    xml[Body::DES].SolicitaDescarga do
      xml[Body::DES].solicitud(
        "FechaInicial" => start_date,
        "FechaFinal" => end_date,
        "RfcEmisor" => issuing_rfc,
        "RfcSolicitante" => requester_rfc,
        "TipoSolicitud" => request_type
      ) do
        xml[Body::DES].RfcReceptores do
          @recipient_rfcs.each do |rfc|
            xml[Body::DES].RfcReceptor(rfc)
          end
        end
        signature(xml)
      end
    end
  end
end