-
Notifications
You must be signed in to change notification settings - Fork 65
Add groups #21
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
Merged
Merged
Add groups #21
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
2c5dd2d
Refactor Client for easier mocking
epels ed694ba
Add simple Balance test for demonstration
epels 7872e19
Add Travis integration
epels 4ae7d79
Add test script to .travis.yml
epels cab7489
Install requests before running tests
epels 2a5a631
Use Python 3.6 instead of 3.7: latter doesn't seem to be supported by…
epels b844c64
Allow pypy2.7 to fail: Travis can not find virtualenv script
epels b6cf05b
Add Travis badge to README
epels e93a241
Add tests for other endpoints
epels a343fe9
Export ErrorException from messagebird
epels 24fbcbe
Add Contact objects
epels dbf1d25
Add Contact endpoints
epels 67e19ac
Add Group objects
epels 73693e7
Add Group endpoints
epels e0e8278
Fix contact_update to not expect a JSON response
epels ecfc63d
Merge branch 'add-contacts' into add-groups
epels File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| language: python | ||
| python: | ||
| - 'pypy2.7' | ||
| - 'pypy3.5' | ||
| - '2.7' | ||
| - '3.3' | ||
| - '3.6' | ||
| - 'nightly' | ||
| install: | ||
| - pip install mock==2.0 | ||
| - pip install requests | ||
| script: | ||
| - python -m unittest discover -s tests/ -p test_*.py -v | ||
| matrix: | ||
| allow_failures: | ||
| - python: 'nightly' | ||
| - python: 'pypy2.7' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| from messagebird.client import Client | ||
| from messagebird.client import Client, ErrorException |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| from messagebird.base import Base | ||
|
|
||
|
|
||
| class Links(Base): | ||
|
|
||
| def __init__(self): | ||
| self.first = None | ||
| self.previous = None | ||
| self.next = None | ||
| self.last = None | ||
|
|
||
|
|
||
| class BaseList(Base): | ||
|
|
||
| def __init__(self, item_type): | ||
| """When setting items, they are instantiated as objects of type item_type.""" | ||
| self.limit = None | ||
| self.offset = None | ||
| self.count = None | ||
| self.totalCount = None | ||
| self._links = None | ||
| self._items = None | ||
|
|
||
| self.itemType = item_type | ||
|
|
||
| @property | ||
| def links(self): | ||
| return self._links | ||
|
|
||
| @links.setter | ||
| def links(self, value): | ||
| self._links = Links().load(value) | ||
|
|
||
| @property | ||
| def items(self): | ||
| return self._items | ||
|
|
||
| @items.setter | ||
| def items(self, value): | ||
| """Create typed objects from the dicts.""" | ||
| items = [] | ||
| for item in value: | ||
| items.append(self.itemType().load(item)) | ||
|
|
||
| self._items = items |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| from messagebird.base import Base | ||
| from messagebird.base_list import BaseList | ||
|
|
||
|
|
||
| class CustomDetails(Base): | ||
|
|
||
| def __init__(self): | ||
| self.custom1 = None | ||
| self.custom2 = None | ||
| self.custom3 = None | ||
| self.custom4 = None | ||
|
|
||
|
|
||
| class GroupReference(Base): | ||
|
|
||
| def __init__(self): | ||
| self.href = None | ||
| self.totalCount = None | ||
|
|
||
|
|
||
| class MessageReference(Base): | ||
|
|
||
| def __init__(self): | ||
| self.href = None | ||
| self.totalCount = None | ||
|
|
||
|
|
||
| class ContactList(BaseList): | ||
|
|
||
| def __init__(self): | ||
| # Signal the BaseList that we're expecting items of type Contact... | ||
| super(ContactList, self).__init__(Contact) | ||
|
|
||
|
|
||
| class Contact(Base): | ||
|
|
||
| def __init__(self): | ||
| self.id = None | ||
| self.href = None | ||
| self.msisdn = None | ||
| self.firstName = None | ||
| self.lastName = None | ||
| self._customDetails = None | ||
| self._groups = None | ||
| self._messages = None | ||
| self._createdDatetime = None | ||
| self._updatedDatetime = None | ||
|
|
||
| @property | ||
| def customDetails(self): | ||
| return self._customDetails | ||
|
|
||
| @customDetails.setter | ||
| def customDetails(self, value): | ||
| self._customDetails = CustomDetails().load(value) | ||
|
|
||
| @property | ||
| def groups(self): | ||
| return self._groups | ||
|
|
||
| @groups.setter | ||
| def groups(self, value): | ||
| self._groups = GroupReference().load(value) | ||
|
|
||
| @property | ||
| def messages(self): | ||
| return self._messages | ||
|
|
||
| @messages.setter | ||
| def messages(self, value): | ||
| self._messages = MessageReference().load(value) | ||
|
|
||
| @property | ||
| def createdDatetime(self): | ||
| return self._createdDatetime | ||
|
|
||
| @createdDatetime.setter | ||
| def createdDatetime(self, value): | ||
| self._createdDatetime = self.value_to_time(value) | ||
|
|
||
| @property | ||
| def updatedDatetime(self): | ||
| return self._updatedDatetime | ||
|
|
||
| @updatedDatetime.setter | ||
| def updatedDatetime(self, value): | ||
| self._updatedDatetime = self.value_to_time(value) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| from messagebird.base import Base | ||
| from messagebird.base_list import BaseList | ||
|
|
||
|
|
||
| class ContactReference(Base): | ||
|
|
||
| def __init__(self): | ||
| self.href = None | ||
| self.totalCount = None | ||
|
|
||
|
|
||
| class GroupList(BaseList): | ||
|
|
||
| def __init__(self): | ||
| # Signal the BaseList that we're expecting items of type Group... | ||
| super(GroupList, self).__init__(Group) | ||
|
|
||
|
|
||
| class Group(Base): | ||
|
|
||
| def __init__(self): | ||
| self.id = None | ||
| self.href = None | ||
| self.name = None | ||
| self._contacts = None | ||
| self.createdDatetime = None | ||
| self.updatedDatetime = None | ||
|
|
||
| @property | ||
| def contacts(self): | ||
| return self._contacts | ||
|
|
||
| @contacts.setter | ||
| def contacts(self, value): | ||
| self._contacts = ContactReference().load(value) | ||
|
|
||
| @property | ||
| def createdDatetime(self): | ||
| return self._createdDatetime | ||
|
|
||
| @createdDatetime.setter | ||
| def createdDatetime(self, value): | ||
| self._createdDatetime = self.value_to_time(value) | ||
|
|
||
| @property | ||
| def updatedDatetime(self): | ||
| return self._updatedDatetime | ||
|
|
||
| @updatedDatetime.setter | ||
| def updatedDatetime(self, value): | ||
| self._updatedDatetime = self.value_to_time(value) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Nice 👍