Sha256: 8bda39c2333b22aa09074130f0a6d36cd3429f420ac41c480d2efbb28baf0108

Contents?: true

Size: 1.34 KB

Versions: 8

Compression:

Stored size: 1.34 KB

Contents

# frozen_string_literal: true

module CzechPostB2bClient
  module Services
    class ParcelsAsyncSender < CzechPostB2bClient::Services::Communicator
      attr_reader :sending_data, :parcels

      def initialize(sending_data:, parcels:)
        @sending_data = sending_data
        @parcels = parcels
      end

      private

      def request_builder_args
        { common_data: common_data, parcels: parcels }
      end

      def request_builder_class
        CzechPostB2bClient::RequestBuilders::SendParcelsBuilder
      end

      def api_caller_class
        CzechPostB2bClient::Services::ApiCaller
      end

      def response_parser_class
        CzechPostB2bClient::ResponseParsers::SendParcelsParser
      end

      def common_data
        data_from_config.merge(sending_data)
      end

      def data_from_config
        {
          contract_id: configuration.contract_id,
          customer_id: configuration.customer_id,
          sending_post_office_code: configuration.sending_post_office_code
        }
      end

      def endpoint_path
        '/sendParcels'
      end

      def build_result_from(response_hash)
        OpenStruct.new(transaction_id: response_hash.dig(:async_result, :transaction_id),
                       processing_end_expected_at: response_hash.dig(:async_result, :processing_end_expected_at))
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

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