-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
renamed service ParcelsSender to ParcelsAsyncSender
- Loading branch information
Showing
3 changed files
with
59 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
lib/czech_post_b2b_client/services/parcels_async_sender.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters