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

Added profile lookup #416

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions cbpro/authenticated_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1047,3 +1047,55 @@ def get_fees(self):
}
"""
return self._send_message('get', '/fees')

def get_profiles(self, active):
""" List Profiles.

List your profiles.

https://docs.pro.coinbase.com/#list-profiles

Args:
active (bool): active flag

Returns:
list: List your profiles, profiles are equivalent to portfolios.

[
{
"id": "86602c68-306a-4500-ac73-4ce56a91d83c",
"user_id": "5844eceecf7e803e259d0365",
"name": "default",
"active": true,
"is_default": true,
"created_at": "2019-11-18T15:08:40.236309Z"
}
]
"""
if active is not None:
params = {'active': active}
else:
params = None
return self._send_message('get', '/profiles', params=params)

def get_profile(self, profile_id):
""" Get a Profile

Get a single profile by profile id.

Args:
profile_id (str): profile id

Returns:
dict: Single Profile

{
"id": "86602c68-306a-4500-ac73-4ce56a91d83c",
"user_id": "5844eceecf7e803e259d0365",
"name": "default",
"active": true,
"is_default": true,
"created_at": "2019-11-18T15:08:40.236309Z"
}
"""
return self._send_message('get', '/profiles/' + profile_id)
9 changes: 9 additions & 0 deletions tests/test_authenticated_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,3 +206,12 @@ def test_get_trailing_volume(self, client):
def test_get_fees(self, client):
r = client.get_fees()
assert type(r) is dict

def test_get_profiles(self, client):
r = client.get_profiles()
assert type(r) is list

def test_get_profile_by_id(self, client):
# Took the id from the docs as the sample response.
r = client.get_profile('86602c68-306a-4500-ac73-4ce56a91d83c')
assert type(r) is dict