Sha256: ab6d7c04fbbb4182dad0651c7cafad1c624eee6b3d63858dd4a3a33146a22e95

Contents?: true

Size: 1.16 KB

Versions: 10

Compression:

Stored size: 1.16 KB

Contents

# frozen_string_literal: true

module CzechPostB2bClient
  module Services
    class TimePeriodStatisticator < CzechPostB2bClient::Services::Communicator
      attr_reader :from_date, :to_date

      def initialize(from_date:, to_date:)
        @from_date = from_date
        @to_date = to_date
      end

      private

      def request_builder_args
        { from_date: from_date, to_date: to_date }
      end

      def request_builder_class
        CzechPostB2bClient::RequestBuilders::GetStatsBuilder
      end

      def api_caller_class
        CzechPostB2bClient::Services::ApiCaller
      end

      def response_parser_class
        CzechPostB2bClient::ResponseParsers::GetStatsParser
      end

      def endpoint_path
        '/getStats'
      end

      def build_result_from(response_hash)
        imports = response_hash[:imports]
        OpenStruct.new(requests: OpenStruct.new(total: imports[:requested],
                                                with_errors: imports[:with_errors],
                                                successful: imports[:successful]),
                       imported_parcels: imports[:imported_parcels])
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
czech_post_b2b_client-1.2.7 lib/czech_post_b2b_client/services/time_period_statisticator.rb
czech_post_b2b_client-1.2.6 lib/czech_post_b2b_client/services/time_period_statisticator.rb
czech_post_b2b_client-1.2.5 lib/czech_post_b2b_client/services/time_period_statisticator.rb
czech_post_b2b_client-1.2.4 lib/czech_post_b2b_client/services/time_period_statisticator.rb
czech_post_b2b_client-1.2.3 lib/czech_post_b2b_client/services/time_period_statisticator.rb
czech_post_b2b_client-1.2.2 lib/czech_post_b2b_client/services/time_period_statisticator.rb
czech_post_b2b_client-1.2.1 lib/czech_post_b2b_client/services/time_period_statisticator.rb
czech_post_b2b_client-1.1.0 lib/czech_post_b2b_client/services/time_period_statisticator.rb
czech_post_b2b_client-1.0.3 lib/czech_post_b2b_client/services/time_period_statisticator.rb
czech_post_b2b_client-1.0.2 lib/czech_post_b2b_client/services/time_period_statisticator.rb