contact-person-profile-csv-imp-local 0.0.21__py3-none-any.whl → 0.0.23__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -279,9 +279,10 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
279
279
  contact_dict["data_source_instance_id"] = data_source_instance_id
280
280
  contact_dict["source"] = "Import"
281
281
  contact_id = self.contacts_local.upsert_contact_dict(contact_dict=contact_dict)
282
+ contact_dict["contact_id"] = contact_id
282
283
  if contact_id:
283
284
  self.__insert_contact_details_to_db(
284
- contact_id=contact_id, contact_dict=contact_dict, user_external_id=user_external_id,
285
+ contact_dict=contact_dict, user_external_id=user_external_id,
285
286
  data_source_instance_id=data_source_instance_id,
286
287
  data_source_type_id=data_source_type_id)
287
288
  contact_data_by_contact_id_dict[contact_id] = contact_dict
@@ -340,33 +341,32 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
340
341
  select_clause_value="location_type_id", column_name="title", column_value=location_type_name)
341
342
  return location_type_id
342
343
 
343
- def __insert_contact_details_to_db(self, *, contact_id: int, contact_dict: dict, user_external_id: int,
344
+ def __insert_contact_details_to_db(self, *, contact_dict: dict, user_external_id: int,
344
345
  data_source_instance_id: int, data_source_type_id: int) -> int:
345
346
 
346
- location_id = DEFAULT_LOCATION_ID
347
347
  # insert organization
348
348
  organization_id = self.__insert_organization(contact_dict=contact_dict)
349
349
 
350
350
  # insert link contact_location
351
351
  # The location is in contact_dict
352
352
  location_results = self.__insert_link_contact_location(
353
- contact_dict=contact_dict, contact_id=contact_id) or [{}]
354
- location_id = location_results[0].get(
355
- "location_id") or DEFAULT_LOCATION_ID
356
- country_id = location_results[0].get("country_id")
353
+ contact_dict=contact_dict) or [{}]
354
+ contact_dict["location_id"] = location_results[0].get(
355
+ "location_id")
356
+ contact_dict["country_id"] = location_results[0].get("country_id")
357
357
 
358
358
  # insert link contact_group
359
359
  self.__insert_link_contact_groups(
360
- contact_dict=contact_dict, contact_id=contact_id)
360
+ contact_dict=contact_dict)
361
361
 
362
362
  # insert link contact_persons
363
363
  contact_person_result_dict = self.__insert_link_contact_persons(
364
- contact_dict=contact_dict, contact_id=contact_id) or {}
365
- person_id = contact_person_result_dict.get("person_id")
364
+ contact_dict=contact_dict) or {}
365
+ contact_dict["person_id"] = contact_person_result_dict.get("person_id")
366
366
 
367
367
  # insert link contact_profiles
368
368
  contact_profile_info = self.__insert_contact_profiles(
369
- contact_dict=contact_dict, contact_id=contact_id, person_id=person_id) or {}
369
+ contact_dict=contact_dict) or {}
370
370
 
371
371
  profile_id = contact_profile_info.get("profile_id")
372
372
 
@@ -376,29 +376,27 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
376
376
 
377
377
  # insert link contact_email_addresses
378
378
  self.__insert_link_contact_email_addresses(
379
- contact_dict=contact_dict, contact_id=contact_id, person_id=person_id, profile_id=profile_id)
379
+ contact_dict=contact_dict, profile_id=profile_id)
380
380
 
381
381
  # insert link contact_notes
382
- self.__insert_link_contact_notes_and_text_blocks(
383
- contact_dict=contact_dict, contact_id=contact_id, profile_id=profile_id)
382
+ CSVToContactPersonProfile.__insert_link_contact_notes_and_text_blocks(
383
+ contact_dict=contact_dict, profile_id=profile_id)
384
384
 
385
385
  # insert link contact_phones
386
386
  self.__insert_link_contact_phones(
387
- contact_dict=contact_dict, contact_id=contact_id, profile_id=profile_id,
388
- person_id=person_id, location_id=location_id, country_id=country_id)
387
+ contact_dict=contact_dict, profile_id=profile_id)
389
388
 
390
389
  # inset link contact_user_externals
391
390
  self.__insert_link_contact_user_external(
392
- contact_dict=contact_dict, contact_id=contact_id)
391
+ contact_dict=contact_dict)
393
392
 
394
393
  # insert link contact_internet_domains
395
394
  self.__insert_link_contact_domains(
396
- contact_dict=contact_dict, contact_id=contact_id)
395
+ contact_dict=contact_dict)
397
396
 
398
397
  importer_id = self.__insert_importer(
399
- contact_id=contact_id, location_id=location_id,
398
+ contact_id=contact_dict.get("contact_id"), location_id=contact_dict.get("location_id") or DEFAULT_LOCATION_ID,
400
399
  user_external_id=user_external_id,
401
- google_people_api_resource_name=contact_dict.get("resource_name"),
402
400
  data_source_instance_id=data_source_instance_id,
403
401
  data_source_type_id=data_source_type_id
404
402
  )
@@ -458,8 +456,8 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
458
456
 
459
457
  return organization_profile_id
460
458
 
461
- def __insert_link_contact_groups(self, contact_dict: dict, contact_id: int) -> list:
462
-
459
+ def __insert_link_contact_groups(self, contact_dict: dict) -> list:
460
+ contact_id = contact_dict.get("contact_id")
463
461
  groups = []
464
462
  groups_linked = None
465
463
  if contact_dict.get("organization"):
@@ -472,11 +470,14 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
472
470
 
473
471
  return groups_linked
474
472
 
475
- def __insert_link_contact_persons(self, contact_dict: dict, contact_id: int) -> dict:
473
+ def __insert_link_contact_persons(self, contact_dict: dict) -> dict:
474
+ if not contact_dict.get("first_name") and not contact_dict.get("last_name"):
475
+ return {}
476
476
  phones_local = PhonesLocal(is_test_data=self.is_test_data)
477
477
  contact_phone_number = contact_dict.get("phone1")
478
478
  if contact_phone_number:
479
- result_dict = phones_local.normalize_phone_number(original_number=contact_phone_number, region=None)
479
+ result_dict = phones_local.normalize_phone_number(
480
+ original_number=contact_phone_number, region=None)
480
481
  if result_dict:
481
482
  contact_normalized_phone_number = result_dict.get("full_number_normalized")
482
483
  else:
@@ -484,14 +485,12 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
484
485
  contact_person_results_dict = self.contact_persons.insert_contact_and_link_to_existing_or_new_person(
485
486
  contact_dict=contact_dict,
486
487
  contact_email_address=contact_dict["email1"],
487
- contact_normalized_phone_number=contact_normalized_phone_number,
488
- contact_id=contact_id
488
+ contact_normalized_phone_number=contact_normalized_phone_number
489
489
  )
490
490
 
491
491
  return contact_person_results_dict
492
492
 
493
- def __insert_link_contact_email_addresses(self, contact_dict: dict, contact_id: int, person_id: int = None,
494
- profile_id: int = None) -> list[int]:
493
+ def __insert_link_contact_email_addresses(self, contact_dict: dict, profile_id: int = None) -> list[int]:
495
494
  email_addresses = self.contacts_local.get_contact_email_addresses_from_contact_dict(
496
495
  contact_dict=contact_dict)
497
496
  contact_email_addresses = self.contact_email_addresses
@@ -500,8 +499,6 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
500
499
  contact_email_address_id = contact_email_addresses.insert_contact_and_link_to_email_address(
501
500
  contact_dict=contact_dict,
502
501
  contact_email_address_str=email_address,
503
- contact_id=contact_id,
504
- person_id=person_id,
505
502
  profile_id=profile_id
506
503
  )
507
504
  contact_email_address_ids.append(contact_email_address_id)
@@ -510,7 +507,7 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
510
507
 
511
508
  @staticmethod
512
509
  def __insert_link_contact_notes_and_text_blocks(
513
- *, contact_dict: dict, contact_id: int, profile_id: int) -> int or None:
510
+ *, contact_dict: dict, profile_id: int) -> int or None:
514
511
  if not contact_dict.get("notes"):
515
512
  return
516
513
  # TODO: I think we should change ContactNotesLocal - send the args to the method and not the class
@@ -518,34 +515,27 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
518
515
  # TODO: check if this method works with profile_id = None
519
516
  profile_id = DEFAULT_PROFILE_ID
520
517
  contact_notes = ContactNotesLocal(
521
- contact_dict=contact_dict, contact_id=contact_id, profile_id=profile_id)
522
- insert_information = contact_notes.insert_contact_notes_text_block()
518
+ contact_dict=contact_dict, profile_id=profile_id)
519
+ insert_information = contact_notes.insert_contact_notes_text_block() or {}
523
520
  contact_note_id = insert_information.get("contact_note_id")
524
521
  return contact_note_id
525
522
 
526
- def __insert_link_contact_phones(self, contact_dict: dict, contact_id: int, profile_id: int, person_id: int,
527
- location_id: int, country_id: int) -> list[int]:
528
- if location_id == DEFAULT_LOCATION_ID:
529
- location_id = None
523
+ def __insert_link_contact_phones(self, contact_dict: dict, profile_id: int) -> list[int]:
530
524
  phone_numbers = self.contacts_local.get_contact_phone_numbers_from_contact_dict(
531
525
  contact_dict=contact_dict)
532
526
  contact_phone_ids = []
533
527
  for phone_number in phone_numbers:
534
- contact_phone_id = self.contact_phone.insert_contact_and_link_to_existing_or_new_phone(
528
+ process_phone_result_dict = self.contact_phone.insert_contact_and_link_to_existing_or_new_phone(
535
529
  contact_dict=contact_dict,
536
530
  phone_number=phone_number,
537
- contact_id=contact_id,
538
- profile_id=profile_id,
539
- person_id=person_id,
540
- location_id=location_id,
541
- country_id=country_id
531
+ profile_id=profile_id
542
532
  )
543
- contact_phone_ids.append(contact_phone_id.get("contact_phone_id"))
533
+ contact_phone_ids.append(process_phone_result_dict.get("contact_phone_id"))
544
534
 
545
535
  return contact_phone_ids
546
536
 
547
- def __insert_link_contact_user_external(self, contact_dict: dict, contact_id: int) -> int:
548
-
537
+ def __insert_link_contact_user_external(self, contact_dict: dict) -> int:
538
+ contact_id = contact_dict.get("contact_id")
549
539
  contact_user_external_id = self.contact_user_external.insert_contact_and_link_to_existing_or_new_user_external(
550
540
  contact_dict=contact_dict,
551
541
  contact_email_address=contact_dict["email1"],
@@ -555,18 +545,15 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
555
545
 
556
546
  return contact_user_external_id
557
547
 
558
- def __insert_contact_profiles(self, contact_dict: dict, contact_id: int, person_id: int = None) -> dict:
559
-
548
+ def __insert_contact_profiles(self, contact_dict: dict) -> dict:
560
549
  insert_information = self.contact_profiles.insert_and_link_contact_profile(
561
- contact_dict=contact_dict,
562
- contact_id=contact_id,
563
- person_id=person_id
550
+ contact_dict=contact_dict
564
551
  )
565
552
 
566
553
  return insert_information
567
554
 
568
- def __insert_link_contact_domains(self, contact_dict: dict, contact_id: int) -> list[dict]:
569
-
555
+ def __insert_link_contact_domains(self, contact_dict: dict) -> list[dict]:
556
+ contact_id = contact_dict.get("contact_id")
570
557
  website_count = 1
571
558
  website_url = contact_dict.get("website" + str(website_count))
572
559
  domain_insert_information_list = []
@@ -579,8 +566,8 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
579
566
 
580
567
  return domain_insert_information_list
581
568
 
582
- def __insert_link_contact_location(self, contact_dict: dict, contact_id: int) -> list[dict] or None:
583
-
569
+ def __insert_link_contact_location(self, contact_dict: dict) -> list[dict] or None:
570
+ contact_id = contact_dict.get("contact_id")
584
571
  location_dicts = self.__procces_location_of_contact(contact_dict)
585
572
  if not location_dicts:
586
573
  return
@@ -591,8 +578,7 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
591
578
  return location_results
592
579
 
593
580
  def __insert_importer(self, contact_id: int, location_id: int, user_external_id: int,
594
- google_people_api_resource_name: str, data_source_type_id: int,
595
- data_source_instance_id: int) -> int:
581
+ data_source_type_id: int, data_source_instance_id: int) -> int:
596
582
  # TODO: Shall we consider the url of csv's as the following? Use Sql2Code. Use const enum
597
583
  if data_source_type_id == 16:
598
584
  url = "www.google.com"
@@ -609,7 +595,6 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
609
595
  entity_type_id=self.contact_entity_type_id,
610
596
  entity_id=contact_id, url=url,
611
597
  user_external_id=user_external_id,
612
- google_people_api_resource_name=google_people_api_resource_name
613
598
  )
614
599
 
615
600
  return importer_id
@@ -756,7 +741,7 @@ class CSVToContactPersonProfile(GenericCRUD, metaclass=MetaLogger,
756
741
  file_name: str,
757
742
  user_external_username: str, start_index: int, end_index: int) -> int:
758
743
  name = datetime.now(ZoneInfo("UTC")).strftime("%y%m%d %H%M%S") + " " + \
759
- user_external_username + " 'Google Contact- Google Contact CSV'"
744
+ user_external_username + " 'Google Contact- Google Contact CSV'"
760
745
  # TODO: move to data_source
761
746
  data_source_instance_id = super().insert(
762
747
  schema_name="data_source_instance",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: contact-person-profile-csv-imp-local
3
- Version: 0.0.21
3
+ Version: 0.0.23
4
4
  Summary: PyPI Package for Circles CSVToContactPersonProfile-local Local/Remote Python
5
5
  Home-page: https://github.com/circles-zone/contact-person-profile-csv-imp-local-python-package
6
6
  Author: Circles
@@ -1,7 +1,7 @@
1
- contact_person_profile_csv_imp_local/CSVToContactPersonProfile.py,sha256=ClFAP6ntBayUJuH-k4dgJkrml8-Wy55E4mJc3a0YHeg,41424
1
+ contact_person_profile_csv_imp_local/CSVToContactPersonProfile.py,sha256=Wn_w0H-_aP-E3-bmK8PmewDcxV56DQZYeV-5nfiEUkI,40537
2
2
  contact_person_profile_csv_imp_local/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
3
  contact_person_profile_csv_imp_local/contact_person_profile_csv_imp_local_constants.py,sha256=eE0Bg2dCPrmG72K20k0_KOckc61C9cGSgH0Zgae_lbk,957
4
- contact_person_profile_csv_imp_local-0.0.21.dist-info/METADATA,sha256=2yl92Bd2snQzELayCR4qIbBIMPypqqU4PvZy5EBXAUM,1450
5
- contact_person_profile_csv_imp_local-0.0.21.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
6
- contact_person_profile_csv_imp_local-0.0.21.dist-info/top_level.txt,sha256=at6BnVzULDB109KZx9Cl9ClCHU4c0ykfV38WX-QR71U,37
7
- contact_person_profile_csv_imp_local-0.0.21.dist-info/RECORD,,
4
+ contact_person_profile_csv_imp_local-0.0.23.dist-info/METADATA,sha256=LWn0cu8t-BfNwevU9SmcRtMZ5T5sbtiqolz4lNQqNA0,1450
5
+ contact_person_profile_csv_imp_local-0.0.23.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
6
+ contact_person_profile_csv_imp_local-0.0.23.dist-info/top_level.txt,sha256=at6BnVzULDB109KZx9Cl9ClCHU4c0ykfV38WX-QR71U,37
7
+ contact_person_profile_csv_imp_local-0.0.23.dist-info/RECORD,,