@@ -64,7 +64,12 @@ pub trait CompanyServiceApi: Send + Sync {
64
64
name : Option < String > ,
65
65
email : Option < String > ,
66
66
postal_address : OptionalPostalAddress ,
67
+ country_of_registration : Option < String > ,
68
+ city_of_registration : Option < String > ,
69
+ registration_number : Option < String > ,
70
+ registration_date : Option < String > ,
67
71
logo_file_upload_id : Option < String > ,
72
+ proof_of_registration_file_upload_id : Option < String > ,
68
73
timestamp : u64 ,
69
74
) -> Result < ( ) > ;
70
75
@@ -313,7 +318,12 @@ impl CompanyServiceApi for CompanyService {
313
318
name : Option < String > ,
314
319
email : Option < String > ,
315
320
postal_address : OptionalPostalAddress ,
321
+ country_of_registration : Option < String > ,
322
+ city_of_registration : Option < String > ,
323
+ registration_number : Option < String > ,
324
+ registration_date : Option < String > ,
316
325
logo_file_upload_id : Option < String > ,
326
+ proof_of_registration_file_upload_id : Option < String > ,
317
327
timestamp : u64 ,
318
328
) -> Result < ( ) > {
319
329
if !self . store . exists ( id) . await {
@@ -351,30 +361,45 @@ impl CompanyServiceApi for CompanyService {
351
361
changed = true ;
352
362
}
353
363
354
- match company. postal_address . zip {
355
- Some ( _) => {
356
- if let Some ( ref postal_address_zip_to_set) = postal_address. zip {
357
- company. postal_address . zip = Some ( postal_address_zip_to_set. clone ( ) ) ;
358
- changed = true ;
359
- } else {
360
- company. postal_address . zip = None ;
361
- changed = true ;
362
- }
363
- }
364
- None => {
365
- if let Some ( ref postal_address_zip_to_set) = postal_address. zip {
366
- company. postal_address . zip = Some ( postal_address_zip_to_set. clone ( ) ) ;
367
- changed = true ;
368
- }
369
- }
370
- } ;
364
+ util:: update_optional_field (
365
+ & mut company. postal_address . zip ,
366
+ & postal_address. zip ,
367
+ & mut changed,
368
+ ) ;
369
+
370
+ util:: update_optional_field (
371
+ & mut company. country_of_registration ,
372
+ & country_of_registration,
373
+ & mut changed,
374
+ ) ;
375
+
376
+ util:: update_optional_field (
377
+ & mut company. city_of_registration ,
378
+ & city_of_registration,
379
+ & mut changed,
380
+ ) ;
381
+
382
+ util:: update_optional_field (
383
+ & mut company. registration_date ,
384
+ & registration_date,
385
+ & mut changed,
386
+ ) ;
387
+
388
+ util:: update_optional_field (
389
+ & mut company. registration_number ,
390
+ & registration_number,
391
+ & mut changed,
392
+ ) ;
371
393
372
394
if let Some ( ref postal_address_address_to_set) = postal_address. address {
373
395
company. postal_address . address = postal_address_address_to_set. clone ( ) ;
374
396
changed = true ;
375
397
}
376
398
377
- if !changed && logo_file_upload_id. is_none ( ) {
399
+ if !changed
400
+ && logo_file_upload_id. is_none ( )
401
+ && proof_of_registration_file_upload_id. is_none ( )
402
+ {
378
403
return Ok ( ( ) ) ;
379
404
}
380
405
@@ -389,6 +414,17 @@ impl CompanyServiceApi for CompanyService {
389
414
if logo_file. is_some ( ) {
390
415
company. logo_file = logo_file. clone ( ) ;
391
416
}
417
+ let proof_of_registration_file = self
418
+ . process_upload_file (
419
+ & proof_of_registration_file_upload_id,
420
+ id,
421
+ & full_identity. key_pair . get_public_key ( ) ,
422
+ )
423
+ . await ?;
424
+ // only override the document, if there is a new one
425
+ if proof_of_registration_file. is_some ( ) {
426
+ company. proof_of_registration_file = proof_of_registration_file. clone ( ) ;
427
+ }
392
428
393
429
self . store . update ( id, & company) . await ?;
394
430
@@ -400,7 +436,12 @@ impl CompanyServiceApi for CompanyService {
400
436
name,
401
437
email,
402
438
postal_address,
439
+ country_of_registration,
440
+ city_of_registration,
441
+ registration_number,
442
+ registration_date,
403
443
logo_file,
444
+ proof_of_registration_file,
404
445
} ,
405
446
& full_identity. key_pair ,
406
447
& company_keys,
@@ -1101,7 +1142,12 @@ pub mod tests {
1101
1142
Some ( "name" . to_string ( ) ) ,
1102
1143
Some ( "[email protected] " . to_string ( ) ) ,
1103
1144
OptionalPostalAddress :: new_empty ( ) ,
1145
+ None ,
1146
+ None ,
1147
+ None ,
1148
+ None ,
1104
1149
Some ( "some_file_id" . to_string ( ) ) ,
1150
+ None ,
1105
1151
1731593928 ,
1106
1152
)
1107
1153
. await ;
@@ -1134,6 +1180,11 @@ pub mod tests {
1134
1180
Some ( "[email protected] " . to_string ( ) ) ,
1135
1181
OptionalPostalAddress :: new_empty ( ) ,
1136
1182
None ,
1183
+ None ,
1184
+ None ,
1185
+ None ,
1186
+ None ,
1187
+ None ,
1137
1188
1731593928 ,
1138
1189
)
1139
1190
. await ;
@@ -1178,6 +1229,11 @@ pub mod tests {
1178
1229
Some ( "[email protected] " . to_string ( ) ) ,
1179
1230
OptionalPostalAddress :: new_empty ( ) ,
1180
1231
None ,
1232
+ None ,
1233
+ None ,
1234
+ None ,
1235
+ None ,
1236
+ None ,
1181
1237
1731593928 ,
1182
1238
)
1183
1239
. await ;
@@ -1235,6 +1291,11 @@ pub mod tests {
1235
1291
Some ( "[email protected] " . to_string ( ) ) ,
1236
1292
OptionalPostalAddress :: new_empty ( ) ,
1237
1293
None ,
1294
+ None ,
1295
+ None ,
1296
+ None ,
1297
+ None ,
1298
+ None ,
1238
1299
1731593928 ,
1239
1300
)
1240
1301
. await ;
0 commit comments