Class: SatMx::DownloadRequestReceived Private

Inherits:
Object
  • Object
show all
Defined in:
lib/sat_mx/download_request_received.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

Constructor Details

#initialize(download_request_received_body:, client:) ⇒ DownloadRequestReceived

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 DownloadRequestReceived.



33
34
35
36
# File 'lib/sat_mx/download_request_received.rb', line 33

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

Class Method Details

.call(start_date:, end_date:, request_type:, recipient_rfc:, access_token:, certificate:, private_key:, requester_rfc: nil, issuing_rfc: nil, complement: nil, document_status: nil) ⇒ 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.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/sat_mx/download_request_received.rb', line 6

def self.call(start_date:,
  end_date:,
  request_type:,
  recipient_rfc:,
  access_token:,
  certificate:,
  private_key:,
  requester_rfc: nil,
  issuing_rfc: nil,
  complement: nil,
  document_status: nil)
  new(
    download_request_received_body: DownloadRequestReceivedBody.new(
      start_date:,
      end_date:,
      request_type:,
      recipient_rfc:,
      requester_rfc:,
      certificate:,
      issuing_rfc:,
      complement:,
      document_status:
    ),
    client: Client.new(private_key:, access_token:)
  ).call
end

Instance Method Details

#callObject

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.



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/sat_mx/download_request_received.rb', line 38

def call
  if (validation_error = validate_complement!)
    return validation_error
  end

  if (validation_error = validate_document_status!)
    return validation_error
  end

  response = client.download_request_received(download_request_received_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
    Error
  end
end