Skip to content

Commit

Permalink
renamed service ParcelsSender to ParcelsAsyncSender
Browse files Browse the repository at this point in the history
  • Loading branch information
foton committed May 27, 2020
1 parent 0c1796a commit 5057c59
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 46 deletions.
3 changes: 2 additions & 1 deletion lib/czech_post_b2b_client/services.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
require 'czech_post_b2b_client/services/orchestrator'
require 'czech_post_b2b_client/services/communicator'
require 'czech_post_b2b_client/services/api_caller'
require 'czech_post_b2b_client/services/parcels_sender'
require 'czech_post_b2b_client/services/parcels_async_sender'
require 'czech_post_b2b_client/services/parcels_immediate_sender'
require 'czech_post_b2b_client/services/parcels_sender' # deprecated
require 'czech_post_b2b_client/services/parcels_send_process_updater'
require 'czech_post_b2b_client/services/address_sheets_generator'
require 'czech_post_b2b_client/services/parcels_submission_closer'
Expand Down
53 changes: 53 additions & 0 deletions lib/czech_post_b2b_client/services/parcels_async_sender.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# 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
49 changes: 4 additions & 45 deletions lib/czech_post_b2b_client/services/parcels_sender.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,51 +2,10 @@

module CzechPostB2bClient
module Services
class ParcelsSender < 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))
class ParcelsSender < CzechPostB2bClient::Services::ParcelsAsyncSender
class << self
extend Gem::Deprecate
deprecate :call, 'CzechPostB2bClient::Services::ParcelsAsyncSender.call', 2020, 8
end
end
end
Expand Down

0 comments on commit 5057c59

Please sign in to comment.