Skip to content

Commit

Permalink
Merge pull request #53 from TicketGuardian/release/1.3.0
Browse files Browse the repository at this point in the history
Release/1.3.0
  • Loading branch information
Jrobles70 committed May 18, 2020
2 parents c7e5507 + feabb3c commit 5237fe7
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 7 deletions.
12 changes: 9 additions & 3 deletions docs/changlog/changelog.md
@@ -1,3 +1,7 @@
## [1.3.0] 5/7/2020
### Fixed
- Bug where get_parents would fail if affiliate can not retrieve parent affiliate.

## [1.2.0] 4/4/2019
### Added
- backwards compatibility testing with `tox`
Expand All @@ -18,18 +22,20 @@
- Auth class
- Scope property for Client and Affiliate
- Parent Scope property for Affiliate
- auth/me call to Auth Class. [BE-361]
- User class that supports retrieve, list, and update.
- Update and Partial Update examples on README

### Changed
- `.update()` and `.patch()` will use the Object's `id` by default. Changed from having to pass `id` as an argument.

## [1.0.1]
- Core URL
## [1.0.1] 3/1/2019
### Updated
- Development core url

## [1.0.0] 1/21/2019
### Added
- Lazy load list and iterator (Not 100% complete but okay for internal use)
- Lazy load list and iterator
- Lazy load iterator which only stores the current page of objects
- credentials file for a users set of keys
- Example showing how to use the sdk for quoting items, creating an order, and charging the order.
Expand Down
2 changes: 1 addition & 1 deletion setup.py
@@ -1,6 +1,6 @@
from setuptools import setup, find_packages

__version__ = '1.2.0'
__version__ = '1.3.0'

import os

Expand Down
44 changes: 41 additions & 3 deletions ticketguardian/auth/auth.py
Expand Up @@ -5,11 +5,49 @@ class Auth(RetrieveResourceMixin):

resource = 'auth'

def get_scope(self):
@property
def scope(self):
"""
Get own scope.
Get scope of self.
Returns:
list -- A list containing all objects within scope including self
"""
return self.retrieve('scope', raw_data=True, instance=self)

@classmethod
def get_parents(cls, affiliate_id):
"""
Get all parents of an affiliate.
Returns:
list -- A list containing all parent ids of the Affiliate.
"""
affiliate = Affiliate.retrieve(affiliate_id)

result = []

while hasattr(affiliate.parent, 'id'):
try:
result.append(affiliate.parent.id)
affiliate = affiliate.parent
except Exception:
# Relies on either reaching top affiliate which has a null
# parent or not having permissions to access top level parent.
break

return result

@classmethod
def me(cls, **params):
"""
GET /auth/me/
returns a dict containing info about the user, with the following keys:
id, first_name, last_name, email, is_admin, is_superuser,
external_id, affiliate, client, role
params:
1. token (str): JWT token.
When provided, it will override the instances default headers.
If you don't provide the token, then it will default to the
sdk's instantiated token.
"""
return cls.retrieve('me', raw_data=True, instance=cls(**params))
7 changes: 7 additions & 0 deletions ticketguardian/auth/tests/test_auth.py
Expand Up @@ -10,3 +10,10 @@ def test_auth_get_my_scope():
# assert format
assert isinstance(scope, list)
assert isinstance(scope[0], list)
assert isinstance(scope[0][0], str)


@affiliate_test_method
def test_auth_get_me():
me = Auth.me()
assert isinstance(me.get('id'), str)

0 comments on commit 5237fe7

Please sign in to comment.