Sha256: 24ede51669caa9579513b4325f4af9cd9473affbbf2f7995b651424967d455ea

Contents?: true

Size: 814 Bytes

Versions: 11

Compression:

Stored size: 814 Bytes

Contents

# frozen_string_literal: true

module CzechPostB2bClient
  module ResponseParsers
    class GetStatsParser < BaseParser
      def build_result
        super
        @result[:imports] = { requested: imports.all,
                              with_errors: imports.err,
                              successful: imports.ok,
                              imported_parcels: imports.parcels }
      end

      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

      def response_root_node_name
        'getStatsResponse'
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
czech_post_b2b_client-1.2.7 lib/czech_post_b2b_client/response_parsers/get_stats_parser.rb
czech_post_b2b_client-1.2.6 lib/czech_post_b2b_client/response_parsers/get_stats_parser.rb
czech_post_b2b_client-1.2.5 lib/czech_post_b2b_client/response_parsers/get_stats_parser.rb
czech_post_b2b_client-1.2.4 lib/czech_post_b2b_client/response_parsers/get_stats_parser.rb
czech_post_b2b_client-1.2.3 lib/czech_post_b2b_client/response_parsers/get_stats_parser.rb
czech_post_b2b_client-1.2.2 lib/czech_post_b2b_client/response_parsers/get_stats_parser.rb
czech_post_b2b_client-1.2.1 lib/czech_post_b2b_client/response_parsers/get_stats_parser.rb
czech_post_b2b_client-1.1.0 lib/czech_post_b2b_client/response_parsers/get_stats_parser.rb
czech_post_b2b_client-1.0.3 lib/czech_post_b2b_client/response_parsers/get_stats_parser.rb
czech_post_b2b_client-1.0.2 lib/czech_post_b2b_client/response_parsers/get_stats_parser.rb
czech_post_b2b_client-1.0.0 lib/czech_post_b2b_client/response_parsers/get_stats_parser.rb