class CzechPostB2bClient::Services::ParcelsSendProcessUpdater
Attributes
transaction_id[R]
Public Class Methods
new(transaction_id:)
click to toggle source
# File lib/czech_post_b2b_client/services/parcels_send_process_updater.rb, line 8 def initialize(transaction_id:) @transaction_id = transaction_id end
Public Instance Methods
steps()
click to toggle source
Calls superclass method
CzechPostB2bClient::Services::Communicator#steps
# File lib/czech_post_b2b_client/services/parcels_send_process_updater.rb, line 12 def steps super + %i[check_for_state_errors] end
Private Instance Methods
add_errors_for_failed_states(parcel_id, response_states)
click to toggle source
# File lib/czech_post_b2b_client/services/parcels_send_process_updater.rb, line 61 def add_errors_for_failed_states(parcel_id, response_states) response_states.each do |response_state| response_code = response_state[:code] next if response_code == CzechPostB2bClient::ResponseCodes::Ok.code errors.add(:parcels, "Parcel[#{parcel_id}] => #{CzechPostB2bClient::ResponseCodes.new_by_code(response_code)}") end end
api_caller_class()
click to toggle source
# File lib/czech_post_b2b_client/services/parcels_send_process_updater.rb, line 26 def api_caller_class CzechPostB2bClient::Services::ApiCaller end
build_result_from(response_hash)
click to toggle source
# File lib/czech_post_b2b_client/services/parcels_send_process_updater.rb, line 38 def build_result_from(response_hash) OpenStruct.new(parcels_hash: response_hash[:parcels], state_text: response_hash.dig(:response, :state, :text), state_code: response_hash.dig(:response, :state, :code)) end
check_for_state_errors()
click to toggle source
# File lib/czech_post_b2b_client/services/parcels_send_process_updater.rb, line 44 def check_for_state_errors return if result.state_code == CzechPostB2bClient::ResponseCodes::Ok.code r_code = CzechPostB2bClient::ResponseCodes.new_by_code(result.state_code) errors.add(:response_state, r_code.to_s) collect_parcel_errors fail! unless r_code.info? end
collect_parcel_errors()
click to toggle source
# File lib/czech_post_b2b_client/services/parcels_send_process_updater.rb, line 55 def collect_parcel_errors result.parcels_hash.each_pair do |parcel_id, parcel_hash| add_errors_for_failed_states(parcel_id, parcel_hash[:states]) end end
endpoint_path()
click to toggle source
# File lib/czech_post_b2b_client/services/parcels_send_process_updater.rb, line 34 def endpoint_path '/getResultParcels' end
request_builder_args()
click to toggle source
# File lib/czech_post_b2b_client/services/parcels_send_process_updater.rb, line 18 def request_builder_args { transaction_id: transaction_id } end
request_builder_class()
click to toggle source
# File lib/czech_post_b2b_client/services/parcels_send_process_updater.rb, line 22 def request_builder_class CzechPostB2bClient::RequestBuilders::GetResultParcelsBuilder end
response_parser_class()
click to toggle source
# File lib/czech_post_b2b_client/services/parcels_send_process_updater.rb, line 30 def response_parser_class CzechPostB2bClient::ResponseParsers::GetResultParcelsParser end