@@ -64,7 +64,12 @@ pub trait CompanyServiceApi: Send + Sync {
6464 name : Option < String > ,
6565 email : Option < String > ,
6666 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 > ,
6771 logo_file_upload_id : Option < String > ,
72+ proof_of_registration_file_upload_id : Option < String > ,
6873 timestamp : u64 ,
6974 ) -> Result < ( ) > ;
7075
@@ -313,7 +318,12 @@ impl CompanyServiceApi for CompanyService {
313318 name : Option < String > ,
314319 email : Option < String > ,
315320 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 > ,
316325 logo_file_upload_id : Option < String > ,
326+ proof_of_registration_file_upload_id : Option < String > ,
317327 timestamp : u64 ,
318328 ) -> Result < ( ) > {
319329 if !self . store . exists ( id) . await {
@@ -351,30 +361,45 @@ impl CompanyServiceApi for CompanyService {
351361 changed = true ;
352362 }
353363
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+ ) ;
371393
372394 if let Some ( ref postal_address_address_to_set) = postal_address. address {
373395 company. postal_address . address = postal_address_address_to_set. clone ( ) ;
374396 changed = true ;
375397 }
376398
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+ {
378403 return Ok ( ( ) ) ;
379404 }
380405
@@ -389,6 +414,17 @@ impl CompanyServiceApi for CompanyService {
389414 if logo_file. is_some ( ) {
390415 company. logo_file = logo_file. clone ( ) ;
391416 }
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+ }
392428
393429 self . store . update ( id, & company) . await ?;
394430
@@ -400,7 +436,12 @@ impl CompanyServiceApi for CompanyService {
400436 name,
401437 email,
402438 postal_address,
439+ country_of_registration,
440+ city_of_registration,
441+ registration_number,
442+ registration_date,
403443 logo_file,
444+ proof_of_registration_file,
404445 } ,
405446 & full_identity. key_pair ,
406447 & company_keys,
@@ -1101,7 +1142,12 @@ pub mod tests {
11011142 Some ( "name" . to_string ( ) ) ,
11021143 Some ( "[email protected] " . to_string ( ) ) , 11031144 OptionalPostalAddress :: new_empty ( ) ,
1145+ None ,
1146+ None ,
1147+ None ,
1148+ None ,
11041149 Some ( "some_file_id" . to_string ( ) ) ,
1150+ None ,
11051151 1731593928 ,
11061152 )
11071153 . await ;
@@ -1134,6 +1180,11 @@ pub mod tests {
11341180 Some ( "[email protected] " . to_string ( ) ) , 11351181 OptionalPostalAddress :: new_empty ( ) ,
11361182 None ,
1183+ None ,
1184+ None ,
1185+ None ,
1186+ None ,
1187+ None ,
11371188 1731593928 ,
11381189 )
11391190 . await ;
@@ -1178,6 +1229,11 @@ pub mod tests {
11781229 Some ( "[email protected] " . to_string ( ) ) , 11791230 OptionalPostalAddress :: new_empty ( ) ,
11801231 None ,
1232+ None ,
1233+ None ,
1234+ None ,
1235+ None ,
1236+ None ,
11811237 1731593928 ,
11821238 )
11831239 . await ;
@@ -1235,6 +1291,11 @@ pub mod tests {
12351291 Some ( "[email protected] " . to_string ( ) ) , 12361292 OptionalPostalAddress :: new_empty ( ) ,
12371293 None ,
1294+ None ,
1295+ None ,
1296+ None ,
1297+ None ,
1298+ None ,
12381299 1731593928 ,
12391300 )
12401301 . await ;
0 commit comments