Class: Atol::Transaction::GetDocumentState
- Inherits:
-
Object
- Object
- Atol::Transaction::GetDocumentState
- Defined in:
- lib/atol/transaction/get_document_state.rb
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(uuid:, token:, config: nil) ⇒ GetDocumentState
constructor
A new instance of GetDocumentState.
Constructor Details
#initialize(uuid:, token:, config: nil) ⇒ GetDocumentState
Returns a new instance of GetDocumentState.
7 8 9 10 11 |
# File 'lib/atol/transaction/get_document_state.rb', line 7 def initialize(uuid:, token:, config: nil) @config = config || Atol.config raise(Atol::ConfigExpectedError) unless @config.is_a?(Atol::Config) @params = Hash[uuid: uuid, token: token, config: @config] end |
Instance Method Details
#call ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/atol/transaction/get_document_state.rb', line 13 def call request = Atol::Request::GetDocumentState.new(params) response = request.call encoded_body = response.body.force_encoding(Atol::ENCODING) json = JSON.parse(encoded_body) if response.code == '200' && json['error'].nil? json elsif Atol::ERRORS[json['error']['code']] raise(Atol::ERRORS[json['error']['code']], encoded_body) else raise(encoded_body) end end |