Class: SatMx::VerifyRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/sat_mx/verify_request.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(body:, client:) ⇒ VerifyRequest

Returns a new instance of VerifyRequest.



20
21
22
23
# File 'lib/sat_mx/verify_request.rb', line 20

def initialize(body:, client:)
  @body = body
  @client = client
end

Class Method Details

.call(request_id:, requester_rfc:, access_token:, private_key:, certificate:) ⇒ Object



13
14
15
16
17
18
# File 'lib/sat_mx/verify_request.rb', line 13

def self.call(request_id:, requester_rfc:, access_token:, private_key:, certificate:)
  new(
    body: VerifyRequestBody.new(request_id:, requester_rfc:, certificate:),
    client: Client.new(private_key:, access_token:)
  ).call
end

Instance Method Details

#callObject



25
26
27
28
29
30
31
32
33
34
35
# File 'lib/sat_mx/verify_request.rb', line 25

def call
  response = client.verify_request(body.generate)
  case response.status
  when 200..299
    check_body_status(response.xml)
  when 400..599
    Result.new(success?: false, value: nil, xml: response.xml)
  else
    SatMx::Error
  end
end