Class: SatMx::DownloadPetition Private
- Inherits:
-
Object
- Object
- SatMx::DownloadPetition
- Defined in:
- lib/sat_mx/download_petition.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object private
-
#initialize(body:, client:) ⇒ DownloadPetition
constructor
private
A new instance of DownloadPetition.
Constructor Details
#initialize(body:, client:) ⇒ DownloadPetition
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of DownloadPetition.
15 16 17 18 |
# File 'lib/sat_mx/download_petition.rb', line 15 def initialize(body:, client:) @body = body @client = client end |
Class Method Details
.call(package_id:, requester_rfc:, access_token:, certificate:, private_key:) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
4 5 6 7 8 9 10 11 12 13 |
# File 'lib/sat_mx/download_petition.rb', line 4 def self.call(package_id:, requester_rfc:, access_token:, certificate:, private_key:) new( body: DownloadPetitionBody.new( package_id:, requester_rfc:, certificate: ), client: Client.new(private_key:, access_token:) ).call end |
Instance Method Details
#call ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/sat_mx/download_petition.rb', line 20 def call response = client.download_petition(body.generate) case response.status when 200..299 xml = response.xml response_tag = xml.xpath( "//xmlns:respuesta", xmlns: "http://DescargaMasivaTerceros.sat.gob.mx" )[0] if response_tag["CodEstatus"] == "5000" Result.new( success?: true, xml: response.xml, value: Base64.decode64( response.xml.xpath( "//xmlns:Paquete", xmlns: "http://DescargaMasivaTerceros.sat.gob.mx" ).inner_text ) ) else Result.new( success?: false, xml: response.xml, value: { cod_estatus: response_tag["CodEstatus"], mensaje: response_tag["Mensaje"] } ) end when 400..599 Result.new( success?: false, xml: nil, value: nil ) else SatMx::Error end end |