Class: FE::Api::DocumentStatus

Inherits:
Object
  • Object
show all
Defined in:
lib/facturacr/api/document_status.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(json) ⇒ DocumentStatus

Returns a new instance of DocumentStatus.



12
13
14
15
16
17
18
19
20
# File 'lib/facturacr/api/document_status.rb', line 12

def initialize(json)
  @json = json
  @response = JSON.parse(json)
  @xml = Base64.decode64(@response["respuesta-xml"]) if @response["respuesta-xml"]
  @status = @response["ind-estado"]
  @date = @response["fecha"]
  @key = @response["clave"]
  @document = Nokogiri::XML(@xml) if @xml
end

Instance Attribute Details

#dateObject

Returns the value of attribute date.



10
11
12
# File 'lib/facturacr/api/document_status.rb', line 10

def date
  @date
end

#documentObject (readonly)

Returns the value of attribute document.



9
10
11
# File 'lib/facturacr/api/document_status.rb', line 9

def document
  @document
end

#jsonObject

Returns the value of attribute json.



10
11
12
# File 'lib/facturacr/api/document_status.rb', line 10

def json
  @json
end

#keyObject

Returns the value of attribute key.



10
11
12
# File 'lib/facturacr/api/document_status.rb', line 10

def key
  @key
end

#statusObject

Returns the value of attribute status.



10
11
12
# File 'lib/facturacr/api/document_status.rb', line 10

def status
  @status
end

#xmlObject

Returns the value of attribute xml.



10
11
12
# File 'lib/facturacr/api/document_status.rb', line 10

def xml
  @xml
end

Instance Method Details

#detailsObject



22
23
24
# File 'lib/facturacr/api/document_status.rb', line 22

def details
  @document.css("MensajeHacienda DetalleMensaje").first.text if @document
end

#to_hObject



26
27
28
29
30
31
32
33
# File 'lib/facturacr/api/document_status.rb', line 26

def to_h
  {
    key: @key,
    date:  @date,
    status: @status,
    details: details
  }
end