Class: SatMx::Authentication Private
- Inherits:
-
Object
- Object
- SatMx::Authentication
- Defined in:
- lib/sat_mx/authentication.rb
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
- #authenticate ⇒ Object private
-
#initialize(xml_auth_body:, client:) ⇒ Authentication
constructor
private
A new instance of Authentication.
Constructor Details
#initialize(xml_auth_body:, client:) ⇒ Authentication
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 Authentication.
21 22 23 24 |
# File 'lib/sat_mx/authentication.rb', line 21 def initialize(xml_auth_body:, client:) @xml_auth_body = xml_auth_body @client = client end |
Class Method Details
.authenticate(certificate:, private_key:, uuid: SecureRandom.uuid) ⇒ 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.
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/sat_mx/authentication.rb', line 8 def self.authenticate(certificate:, private_key:, uuid: SecureRandom.uuid) new( xml_auth_body: XmlAuthBody.new( certificate:, uuid: ), client: Client.new( private_key:, access_token: "" ) ).authenticate end |
Instance Method Details
#authenticate ⇒ 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.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/sat_mx/authentication.rb', line 26 def authenticate response = client.authenticate(xml_auth_body.generate) case response.status when 200..299 Result.new(success?: true, value: response.xml.xpath("//xmlns:AutenticaResult", xmlns: "http://DescargaMasivaTerceros.gob.mx").inner_text, xml: response.xml) when 400..599 Result.new(success?: false, value: nil, xml: response.xml) else SatMx::Error end end |