Class: CzechPostB2bClient::ResponseParsers::GetStatsParser

Inherits:
BaseParser show all
Defined in:
lib/czech_post_b2b_client/response_parsers/get_stats_parser.rb

Instance Attribute Summary

Attributes inherited from SteppedService::Base

#result

Instance Method Summary collapse

Methods inherited from BaseParser

#initialize, #steps

Methods inherited from SteppedService::Base

call, #call, #errors, #failure?, #finished?, #steps, #success?

Constructor Details

This class inherits a constructor from CzechPostB2bClient::ResponseParsers::BaseParser

Instance Method Details

#build_resultObject



6
7
8
9
10
11
12
# File 'lib/czech_post_b2b_client/response_parsers/get_stats_parser.rb', line 6

def build_result
  super
  @result[:imports] = { requested: imports.all,
                        with_errors: imports.err,
                        successful: imports.ok,
                        imported_parcels: imports.parcels }
end

#importsObject



14
15
16
17
18
19
20
# File 'lib/czech_post_b2b_client/response_parsers/get_stats_parser.rb', line 14

def imports
  imports_hash = response_root_node
  OpenStruct.new(all: imports_hash.dig('importAll').to_i,
                 err: imports_hash.dig('importErr').to_i,
                 ok: imports_hash.dig('importOk').to_i,
                 parcels: imports_hash.dig('parcels').to_i)
end

#response_root_node_nameObject



22
23
24
# File 'lib/czech_post_b2b_client/response_parsers/get_stats_parser.rb', line 22

def response_root_node_name
  'getStatsResponse'
end