-
-
Notifications
You must be signed in to change notification settings - Fork 97
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 option to query account details including personal data #159
base: master
Are you sure you want to change the base?
Changes from 1 commit
e339fa4
f4d0313
d74d643
92f0fe7
beb62ff
1ce3145
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import json | ||
|
||
class Accountdetails: | ||
def __init__(self, tr): | ||
self.tr = tr | ||
self.data = None | ||
|
||
def get(self): | ||
self.data = self.tr.get_account_details() | ||
print(f"{self.data}") | ||
return self.data | ||
|
||
def data_to_file(self, output_path): | ||
with open(output_path, "w", encoding="utf-8") as f: | ||
json.dump(self.data, f) | ||
|
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -17,6 +17,7 @@ | |||||||||||||||||||||||
from pytr.portfolio import Portfolio | ||||||||||||||||||||||||
from pytr.alarms import Alarms | ||||||||||||||||||||||||
from pytr.details import Details | ||||||||||||||||||||||||
from pytr.accountdetails import Accountdetails | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
|
||||||||||||||||||||||||
def get_main_parser(): | ||||||||||||||||||||||||
|
@@ -200,6 +201,18 @@ def formatter(prog): | |||||||||||||||||||||||
help='Two letter language code or "auto" for system language', | ||||||||||||||||||||||||
default="auto", | ||||||||||||||||||||||||
) | ||||||||||||||||||||||||
# account details | ||||||||||||||||||||||||
info = "Show account details" | ||||||||||||||||||||||||
parser_accountdetails = parser_cmd.add_parser( | ||||||||||||||||||||||||
"accountdetails", | ||||||||||||||||||||||||
formatter_class=argparse.ArgumentDefaultsHelpFormatter, | ||||||||||||||||||||||||
parents=[parser_login_args], | ||||||||||||||||||||||||
help=info, | ||||||||||||||||||||||||
description=info, | ||||||||||||||||||||||||
) | ||||||||||||||||||||||||
parser_accountdetails.add_argument( | ||||||||||||||||||||||||
"-j", "--jsonoutput", help="Output path of JSON file", metavar="OUTPUT", type=Path | ||||||||||||||||||||||||
) | ||||||||||||||||||||||||
marcusfey marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||
|
||||||||||||||||||||||||
info = "Print shell tab completion" | ||||||||||||||||||||||||
parser_completion = parser_cmd.add_parser( | ||||||||||||||||||||||||
|
@@ -287,6 +300,13 @@ def main(): | |||||||||||||||||||||||
installed_version = version("pytr") | ||||||||||||||||||||||||
print(installed_version) | ||||||||||||||||||||||||
check_version(installed_version) | ||||||||||||||||||||||||
elif args.command == "accountdetails": | ||||||||||||||||||||||||
ad = Accountdetails( | ||||||||||||||||||||||||
login(phone_no=args.phone_no, pin=args.pin, web=not args.applogin), | ||||||||||||||||||||||||
) | ||||||||||||||||||||||||
ad.get() | ||||||||||||||||||||||||
if args.jsonoutput is not None: | ||||||||||||||||||||||||
ad.data_to_file(args.jsonoutput) | ||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A question here: this would write the json elif args.command == "accountdetails":
tr = login(phone_no=args.phone_no, pin=args.pin, web=not args.applogin)
account_details = tr.get_account_details()
if args.jsonoutput is not None:
args.jsonoutput.write(json.dumps(account_details)) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The other change above I suggested makes it so There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, right! I wasn't aware initially that those |
||||||||||||||||||||||||
else: | ||||||||||||||||||||||||
parser.print_help() | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this class has any right to be here, it's such a thin wrapper. :)
What would be neat is this was a
TypedDict
instead that describes the fields returned byTradeRepublicApi.get_account_details()
.