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

🎉 Add ability to get user's phone number #85

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

opastushkov
Copy link
Collaborator

Summary:
Function for obtaining user's phone number was added. get_phone_number function returns phone number according to E.164 standard:

+{country_code}{phone_number}

If user doesn't provide phone number, function will return empty string.
Closes #69

@opastushkov opastushkov added the enhancement New feature or request label Jan 17, 2021
@opastushkov opastushkov added this to the 0.1.0 milestone Jan 17, 2021
@opastushkov opastushkov self-assigned this Jan 17, 2021
@codecov
Copy link

codecov bot commented Jan 17, 2021

Codecov Report

Merging #85 (37b53f1) into develop (337fed5) will decrease coverage by 0.55%.
The diff coverage is 40.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop      #85      +/-   ##
===========================================
- Coverage   100.00%   99.44%   -0.56%     
===========================================
  Files           15       15              
  Lines          538      543       +5     
===========================================
+ Hits           538      540       +2     
- Misses           0        3       +3     
Impacted Files Coverage Δ
instapi/models/user.py 97.32% <40.00%> (-2.68%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 337fed5...37b53f1. Read the comment docs.

Copy link
Owner

@uriyyo uriyyo left a comment

Choose a reason for hiding this comment

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

LGTM in general.

Could you please add unit tests to cover this feature?

@@ -88,6 +88,18 @@ def media_count(self) -> int:
"""
return cast(int, self.user_detail()["media_count"])

@property
def get_phone_number(self) -> str:
Copy link
Owner

Choose a reason for hiding this comment

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

I think a better name will be phone_number because it's a property and not a getter method.

detail = self.user_detail()
phone_number = detail["public_phone_country_code"] + detail["public_phone_number"]

return "+{}".format(phone_number) if phone_number else ""
Copy link
Owner

Choose a reason for hiding this comment

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

Please, use an f-string instead of a string formatting.

detail = self.user_detail()
phone_number = detail["public_phone_country_code"] + detail["public_phone_number"]

return "+{}".format(phone_number) if phone_number else ""
Copy link
Owner

Choose a reason for hiding this comment

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

Personally, I don't like the idea of returning an empty string when phone number is not present, I would rather return None to show that the phone number is missed.

@uriyyo uriyyo removed this from the 0.1.0 milestone Jan 17, 2021
@uriyyo uriyyo changed the title 🎉 Add ability to get user's phone number (#69) 🎉 Add ability to get user's phone number Jan 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🎉 Add function get_phone_number to User
2 participants