@@ -24,30 +24,30 @@ type ClientMap = { [id: string]: soap.Client };
24
24
25
25
interface Origin
26
26
{
27
- country : string ;
28
- countryISOCode : string ;
27
+ 'cis: country' : string ;
28
+ 'cis: countryISOCode' : string ;
29
29
}
30
30
31
31
interface Communication
32
32
{
33
- phone ?: string ;
34
- email ?: string ;
35
- contactPerson ?: string ;
33
+ 'cis: phone' ?: string ;
34
+ 'cis: email' ?: string ;
35
+ 'cis: contactPerson' ?: string ;
36
36
}
37
37
38
38
interface Shipper
39
39
{
40
40
Name : {
41
- name1 : string ;
42
- name2 ?: string ;
43
- name3 ?: string ;
41
+ 'cis: name1' : string ;
42
+ 'cis: name2' ?: string ;
43
+ 'cis: name3' ?: string ;
44
44
} ;
45
45
Address : {
46
- streetName : string ;
47
- streetNumber : string ;
48
- zip : string ;
49
- city : string ;
50
- Origin : Origin ;
46
+ 'cis: streetName' : string ;
47
+ 'cis: streetNumber' : string ;
48
+ 'cis: zip' : string ;
49
+ 'cis: city' : string ;
50
+ 'cis: Origin' : Origin ;
51
51
} ;
52
52
Communication : Communication ;
53
53
}
@@ -58,11 +58,11 @@ interface Receiver
58
58
Address : {
59
59
name2 ?: string ;
60
60
name3 ?: string ;
61
- streetName : string ;
62
- streetNumber : string ;
63
- zip : string ;
64
- city : string ;
65
- Origin : Origin ;
61
+ 'cis: streetName' : string ;
62
+ 'cis: streetNumber' : string ;
63
+ 'cis: zip' : string ;
64
+ 'cis: city' : string ;
65
+ 'cis: Origin' : Origin ;
66
66
} ;
67
67
Communication : Communication ;
68
68
}
@@ -421,8 +421,8 @@ class DHLSoap extends Stub {
421
421
}
422
422
423
423
return fulfillments . map ( ( fulfillment , i ) => {
424
- const dhl_state = response ?. CreationFulfillmentState ?. find ( ( state : any ) => state . sequenceNumber === ( i + 1 ) . toString ( ) ) ;
425
- const code = dhl_state ?. LabelData . Status . statusCode ;
424
+ const dhl_state = response ?. CreationState ?. find ( ( state : any ) => state . sequenceNumber === ( i + 1 ) . toString ( ) ) ;
425
+ const code = dhl_state ?. LabelData ? .Status ? .statusCode ;
426
426
const state = code === 0 ? FulfillmentState . SUBMITTED : FulfillmentState . INVALID ;
427
427
const status = this . DHLCode2StatusCode (
428
428
code ,
@@ -466,44 +466,44 @@ class DHLSoap extends Stub {
466
466
Shipment : {
467
467
Shipper : {
468
468
Name : {
469
- name1 : packaging . sender . address . residential_address ?. family_name ?? packaging . sender . address . business_address ?. name ,
470
- name2 : packaging . sender . address . residential_address ?. given_name ,
471
- name3 : packaging . sender . address . residential_address ?. mid_name ,
469
+ 'cis: name1' : packaging . sender . address . residential_address ?. family_name ?? packaging . sender . address . business_address ?. name ,
470
+ 'cis: name2' : packaging . sender . address . residential_address ?. given_name ,
471
+ 'cis: name3' : packaging . sender . address . residential_address ?. mid_name ,
472
472
} ,
473
473
Address : {
474
- streetName : packaging . sender . address ?. street ,
475
- streetNumber : packaging . sender . address ?. building_number ,
476
- zip : packaging . sender . address ?. postcode ,
477
- city : packaging . sender . address ?. region ,
478
- Origin : {
479
- country : request . sender_country ?. name ,
480
- countryISOCode : request . sender_country ?. country_code
474
+ 'cis: streetName' : packaging . sender . address ?. street ,
475
+ 'cis: streetNumber' : packaging . sender . address ?. building_number ,
476
+ 'cis: zip' : packaging . sender . address ?. postcode ,
477
+ 'cis: city' : packaging . sender . address ?. region ,
478
+ 'cis: Origin' : {
479
+ 'cis: country' : request . sender_country ?. name ,
480
+ 'cis: countryISOCode' : request . sender_country ?. country_code
481
481
}
482
482
} ,
483
483
Communication : {
484
- contactPerson : packaging . sender ?. contact ?. name ,
485
- email : packaging . sender ?. contact . email ,
486
- phone : packaging . sender ?. contact . phone ,
484
+ 'cis: contactPerson' : packaging . sender ?. contact ?. name ,
485
+ 'cis: email' : packaging . sender ?. contact . email ,
486
+ 'cis: phone' : packaging . sender ?. contact . phone ,
487
487
}
488
488
} ,
489
489
Receiver : {
490
490
name1 : packaging . recipient . address . residential_address ?. family_name ?? packaging . recipient . address . business_address ?. name ,
491
491
Address : {
492
492
name2 : packaging . recipient . address . residential_address ?. given_name ,
493
493
name3 : packaging . recipient . address . residential_address ?. mid_name ,
494
- streetName : packaging . recipient . address ?. street ,
495
- streetNumber : packaging . recipient . address ?. building_number ,
496
- zip : packaging . recipient . address ?. postcode ,
497
- city : packaging . recipient . address ?. region ,
498
- Origin : {
499
- country : request . recipient_country ?. name ,
500
- countryISOCode : request . recipient_country ?. country_code
494
+ 'cis: streetName' : packaging . recipient . address ?. street ,
495
+ 'cis: streetNumber' : packaging . recipient . address ?. building_number ,
496
+ 'cis: zip' : packaging . recipient . address ?. postcode ,
497
+ 'cis: city' : packaging . recipient . address ?. region ,
498
+ 'cis: Origin' : {
499
+ 'cis: country' : request . recipient_country ?. name ,
500
+ 'cis: countryISOCode' : request . recipient_country ?. country_code
501
501
} ,
502
502
} ,
503
503
Communication : {
504
- contactPerson : packaging . recipient . contact ?. name ,
505
- email : packaging . recipient . contact ?. email ,
506
- phone : packaging . recipient . contact ?. phone ,
504
+ 'cis: contactPerson' : packaging . recipient . contact ?. name ,
505
+ 'cis: email' : packaging . recipient . contact ?. email ,
506
+ 'cis: phone' : packaging . recipient . contact ?. phone ,
507
507
}
508
508
} ,
509
509
ShipmentDetails : {
@@ -589,13 +589,18 @@ class DHLSoap extends Stub {
589
589
if ( fulfillments . length === 0 ) return [ ] ;
590
590
const dhl_order_request = this . AggregatedFulfillmentRequests2DHLShipmentOrderRequest ( fulfillments ) ;
591
591
const client = await this . registerSoapClient ( ) ;
592
- return new Promise < FlatAggregatedFulfillment [ ] > ( ( resolve , reject ) : void => {
592
+ return await new Promise < FlatAggregatedFulfillment [ ] > ( ( resolve , reject ) : void => {
593
593
const timer = setTimeout ( reject , 30000 , this . operation_status_codes . TIMEOUT ) ;
594
594
client . GVAPI_2_0_de . GKVAPISOAP11port0 . createShipmentOrder (
595
595
dhl_order_request ,
596
596
( error : any , result : any ) : any => {
597
597
clearTimeout ( timer ) ;
598
- resolve ( this . DHLShipmentLabels2FulfillmentResponses ( fulfillments , result , error ) ) ;
598
+ try {
599
+ resolve ( this . DHLShipmentLabels2FulfillmentResponses ( fulfillments , result , error ) ) ;
600
+ }
601
+ catch ( e : any ) {
602
+ reject ( e ) ;
603
+ }
599
604
}
600
605
) ;
601
606
} ) ;
@@ -627,16 +632,16 @@ class DHLSoap extends Stub {
627
632
const params = new URLSearchParams ( ) ;
628
633
params . append ( 'xml' , xml ) ;
629
634
const payload = {
630
- method : 'post ' ,
635
+ method : 'get ' ,
631
636
headers : {
632
637
Host : 'cig.dhl.de' ,
633
638
Authorization : auth ,
634
639
Connection : 'Keep-Alive' ,
635
640
} ,
636
- body : params ,
641
+ // body: params,
637
642
} ;
638
643
639
- return await fetch ( client . endpoint , payload ) . then (
644
+ return await fetch ( ` ${ client . endpoint } ? ${ params } ` , payload ) . then (
640
645
response => DHLTracking2FulfillmentTracking ( item , response ) ,
641
646
err => {
642
647
this . logger ?. error ( `${ this . constructor . name } : ${ err } ` ) ;
@@ -666,20 +671,27 @@ class DHLSoap extends Stub {
666
671
const dhl_cancel_request = this . AggregatedFulfillment2DHLShipmentCancelRequest ( fulfillments ) ;
667
672
const client = await this . registerSoapClient ( ) ;
668
673
return await new Promise < FlatAggregatedFulfillment [ ] > ( ( resolve , reject : ( v : FlatAggregatedFulfillment [ ] ) => void ) : void => {
674
+ const timer = setTimeout ( reject , 30000 , this . operation_status_codes . TIMEOUT ) ;
669
675
client . GVAPI_2_0_de . GKVAPISOAP11port0 . deleteShipmentOrder ( dhl_cancel_request ,
670
676
( err : any , result : any ) : any => {
671
- if ( err ) {
672
- if ( result ?. html ) {
673
- this . logger ?. error ( `${ this . constructor . name } : ${ result . html . head . title } ` ) ;
674
- reject ( DHLShipmentCancelResponse2AggregatedFulfillment ( fulfillment_map , null , result . html . head . title ) ) ;
677
+ clearTimeout ( timer ) ;
678
+ try {
679
+ if ( err ) {
680
+ if ( result ?. html ) {
681
+ this . logger ?. error ( `${ this . constructor . name } : ${ result . html . head . title } ` ) ;
682
+ reject ( DHLShipmentCancelResponse2AggregatedFulfillment ( fulfillment_map , null , result . html . head . title ) ) ;
683
+ }
684
+ else {
685
+ this . logger ?. error ( `${ this . constructor . name } : ${ err } ` ) ;
686
+ reject ( DHLShipmentCancelResponse2AggregatedFulfillment ( fulfillment_map , null , err ) ) ;
687
+ }
675
688
}
676
689
else {
677
- this . logger ?. error ( `${ this . constructor . name } : ${ err } ` ) ;
678
- reject ( DHLShipmentCancelResponse2AggregatedFulfillment ( fulfillment_map , null , err ) ) ;
690
+ resolve ( DHLShipmentCancelResponse2AggregatedFulfillment ( fulfillment_map , result ) ) ;
679
691
}
680
692
}
681
- else {
682
- resolve ( DHLShipmentCancelResponse2AggregatedFulfillment ( fulfillment_map , result ) ) ;
693
+ catch ( e : any ) {
694
+ reject ( e ) ;
683
695
}
684
696
} ) ;
685
697
} ) ;
0 commit comments