Skip to content

Commit

Permalink
Added are all fieds none method. (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
OGKevin committed Nov 21, 2017
1 parent d288c92 commit d68c28a
Show file tree
Hide file tree
Showing 3 changed files with 5,129 additions and 1,318 deletions.
64 changes: 64 additions & 0 deletions bunq/sdk/model/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
from bunq.sdk.json import converter


class AnchoredObjectInterface:
pass


class BunqModel(object):
# Field constants
_FIELD_RESPONSE = 'Response'
Expand All @@ -12,6 +16,9 @@ class BunqModel(object):
# The very first index of an array
_INDEX_FIRST = 0

def are_all_fields_none(self):
raise NotImplementedError

def to_json(self):
"""
:rtype: str
Expand Down Expand Up @@ -141,6 +148,13 @@ def id_(self):

return self._id_

def are_all_fields_none(self):
if self.id_ is not None:
return False

return True



class Uuid(BunqModel):
"""
Expand All @@ -158,6 +172,11 @@ def uuid(self):

return self._uuid

def are_all_fields_none(self):
if self.uuid is not None:
return False

return True

class SessionToken(BunqModel):
"""
Expand Down Expand Up @@ -205,6 +224,21 @@ def token(self):

return self._token

def are_all_fields_none(self):
if self.id_ is not None:
return False

if self.created is not None:
return False

if self.updated is not None:
return False

if self.token is not None:
return False

return True


class PublicKeyServer(BunqModel):
"""
Expand All @@ -222,6 +256,12 @@ def server_public_key(self):

return self._server_public_key

def are_all_fields_none(self):
if self.server_public_key is not None:
return False

return True


class Installation(BunqModel):
"""
Expand Down Expand Up @@ -296,6 +336,17 @@ def generate_request_body_bytes(cls, public_key_string):
}
).encode()

def are_all_fields_none(self):
if self.id_ is not None:
return False

if self.token is not None:
return False

if self.server_public_key is not None:
return False

return True

class SessionServer(BunqModel):
"""
Expand Down Expand Up @@ -373,4 +424,17 @@ def generate_request_body_bytes(cls, secret):

return converter.class_to_json({cls.FIELD_SECRET: secret}).encode()

def are_all_fields_none(self):
if self.id_ is not None:
return False

if self.token is not None:
return False

if self.user_person is not None:
return False

if self.user_company is not None:
return False

return True
Loading

0 comments on commit d68c28a

Please sign in to comment.