Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(lookup): Add Zucchetti Infinity API in lookup sample scripts #374

Merged
merged 2 commits into from
Feb 13, 2025

Conversation

Stell0
Copy link
Collaborator

@Stell0 Stell0 commented Feb 6, 2025

@Stell0 Stell0 requested a review from Amygos February 6, 2025 11:03
@Stell0 Stell0 merged commit 05fd5fc into main Feb 13, 2025
5 checks passed
@Stell0 Stell0 deleted the infinity branch February 13, 2025 09:34
Copy link
Member

@gsanchietti gsanchietti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few changes should be required.

token_response = requests.post(token_url, auth=auth, data=token_body)
if token_response.status_code != 200:
raise Exception('Failed to get token from ' + token_url + ' with status code ' + str(token_response.status_code))
token = token_response.json()['access_token']
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is duplicated: already done on next line

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines +82 to +88
if 'company' in contact and contact['company'] != '':
result["company"] = contact['company']
if 'name' in contact and contact["name"] != '':
names.add(contact["name"])
if len(names) == 1:
result["name"] = names.pop()

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is can be greatly simplified:

result["company"] = contact.get("company", "")
result["name"] = contact.get("name", "")

Since names.pop() returns a random element, it does not make sense at all.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

result["company"] = contact.get("company", "") is not the same because i don't wan't to overwrite a possible good result with an empty string

pop returns the only element (if len(names) == 1) if there are more than one is good that it remains empty because is the case that number have more contacts with different names, like if there is "Giacomo" and "Stefano" both with company "Nethesis" and same number, it returns {"company":"Nethesis" , "name":""}

@Stell0 Stell0 restored the infinity branch February 13, 2025 10:45
@Stell0 Stell0 deleted the infinity branch February 13, 2025 10:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants