class FioAPI::ImportResponseDeserializer

ImportResponseDeserializer

Deserializer responsible for response json deserializing. Should construct object with status attributes.

Attributes

status[RW]

Public Instance Methods

deserialize(json) click to toggle source

Deserialize json

Parameters:

hash

Hash returned from payments request.

Returns:

New object with status attributes
# File lib/base/deserializers/import_response_deserializer.rb, line 28
def deserialize(json)
  self.status = deserialize_import(json.try_path('responseImport', 'result'))
  self
end
parse() click to toggle source

Parse json

Returns:

Should return new deserialized object
Calls superclass method
# File lib/base/deserializers/import_response_deserializer.rb, line 15
def parse
  deserialize super
end

Private Instance Methods

deserialize_import(response_json) click to toggle source

Deserialize import of payments

Parameters:

response_json

Hash with informations about payments

Returns:

Status
# File lib/base/deserializers/import_response_deserializer.rb, line 41
def deserialize_import(response_json)
  return FioAPI::Payments::Status.new(error_code: 500) unless response_json
  FioAPI::Payments::Status.new(
    error_code: response_json.try_path('errorCode').to_i,
    error_message: response_json.try_path('message').to_s,
    id_instruction: response_json.try_path('idInstruction').to_i,
    sum_credit: response_json.try_path('sums', 'sum', 'sumCredit').to_f,
    sum_debet: response_json.try_path('sums', 'sum', 'sumDebet').to_f
  )
end