@@ -35,7 +35,7 @@ def as_aeon_create_ead_request_data(patron_request, volume_params) # rubocop:dis
3535 AeonClient ::RequestData . with_defaults . with (
3636 call_number : "#{ patron_request . ead_doc . identifier } #{ volume_params [ 'series' ] } " ,
3737 ead_number : patron_request . ead_doc . identifier ,
38- appointment_id : volume_params [ 'appointment_id' ] . to_i ,
38+ appointment_id : volume_params [ 'appointment_id' ] . presence &. to_i ,
3939 for_publication : volume_params [ 'for_publication' ] == 'yes' ,
4040 item_author : patron_request . ead_doc . author ,
4141 item_info1 : patron_request . ead_doc . item_url ,
@@ -56,7 +56,7 @@ def as_aeon_create_ead_request_data(patron_request, volume_params) # rubocop:dis
5656 # and reading room id.
5757 def as_aeon_create_request_data ( patron_request , folio_item , volume_params ) # rubocop:disable Metrics/AbcSize
5858 AeonClient ::RequestData . with_defaults . with (
59- appointment_id : volume_params [ 'appointment_id' ] . to_i ,
59+ appointment_id : volume_params [ 'appointment_id' ] . presence &. to_i ,
6060 call_number : folio_item . callnumber ,
6161 document_type : 'Monograph' ,
6262 format : nil ,
@@ -78,6 +78,23 @@ def as_aeon_create_request_data(patron_request, folio_item, volume_params) # rub
7878 # rubocop:enable Metrics/MethodLength
7979
8080 def submit_aeon_request ( aeon_payload )
81- AeonClient . new . create_request ( aeon_payload )
81+ response = aeon_client . create_request ( aeon_payload )
82+
83+ return response if complete? ( aeon_payload )
84+
85+ aeon_client . update_request_route ( transaction_number : response . transaction_number ,
86+ status : Settings . aeon . queue_names . draft . transaction . first )
87+ end
88+
89+ def aeon_client
90+ @aeon_client ||= AeonClient . new
91+ end
92+
93+ def complete? ( payload )
94+ if payload . shipping_option == 'Electronic Delivery'
95+ payload . item_info5 . present?
96+ else
97+ payload . appointment_id . present?
98+ end
8299 end
83100end
0 commit comments