Class: SigepWeb::RequestLabels

Inherits:
WebServiceInterfaceApi show all
Defined in:
lib/sigep_web/request_labels.rb

Instance Method Summary collapse

Methods inherited from WebServiceInterfaceApi

#process

Constructor Details

#initialize(receiver_type:, identifier:, id_service:, qt_labels:) ⇒ RequestLabels

Returns a new instance of RequestLabels.



5
6
7
8
9
10
11
12
# File 'lib/sigep_web/request_labels.rb', line 5

def initialize(receiver_type:, identifier:, id_service:, qt_labels:)
  @receiver_type = receiver_type
  @identifier = identifier
  @id_service = id_service
  @qt_labels = qt_labels

  super()
end

Instance Method Details

#requestObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/sigep_web/request_labels.rb', line 14

def request
  authenticate = SigepWeb.configuration.authenticate

  response = process(
    :solicita_etiquetas,
    tipoDestinatario: receiver_type,
    identificador: identifier,
    idServico: id_service,
    qtdEtiquetas: qt_labels,
    usuario: authenticate.user,
    senha: authenticate.password
  ).to_hash[:solicita_etiquetas_response][:return]

  {success: true, response: build_label_array(response)}
rescue Savon::SOAPFault => e
  {success: false, error: e.message}
end