Skip to content
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
300 changes: 151 additions & 149 deletions marqeta/__init__.py

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions marqeta/errors.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
class MarqetaError(Exception):
'''
"""
Handles Marqeta Errors!
'''
"""

def __init__(self, **kwargs):
if 'error_message' in kwargs:
self.message = kwargs['error_message']
if 'error_code' in kwargs:
self.code = kwargs['error_code']
if "error_message" in kwargs:
self.message = kwargs["error_message"]
if "error_code" in kwargs:
self.code = kwargs["error_code"]

def __str__(self):
try:
return self.message + '\nError Code:' + self.code
return self.message + "\nError Code:" + self.code
except:
return self.message

def __repr__(self):
return '<Marqeta.errors.MarqetaError>'
return "<Marqeta.errors.MarqetaError>"
73 changes: 46 additions & 27 deletions marqeta/resources/accepted_countries.py
Original file line number Diff line number Diff line change
@@ -1,72 +1,91 @@

'''ACCEPTEDCOUNTRIES RESOURCE WITH CRU PARAMETERS'''
"""ACCEPTEDCOUNTRIES RESOURCE WITH CRU PARAMETERS"""

from marqeta.resources.collection import Collection
from marqeta.response_models.accepted_countries_model import AcceptedCountriesModel


class AcceptedCountriesCollection(object):
'''
"""
Marqeta API 'acceptedcountries' endpoint list, create, find and update operations
'''
_endpoint = 'acceptedcountries'
"""

_endpoint = "acceptedcountries"

def __init__(self, client):
'''
"""
Creates a client collection object
:param client: client object
'''
"""
self.client = client
self.collections = Collection(self.client, AcceptedCountriesModel)

def page(self, count=5, start_index=0, params=None):
'''
"""
Provides the requested page for acceptedcountries
:param count: data to be displayed per page
:param start_index: start_index
:param params: query parameters
:return: requested page with AcceptedCountriesModel object for the requested
page 'data'field
'''
return self.collections.page(endpoint=self._endpoint, count=count, start_index=start_index, query_params=params)
"""
return self.collections.page(
endpoint=self._endpoint,
count=count,
start_index=start_index,
query_params=params,
)

def stream(self, params=None):
'''
"""
Stream through the list of requested endpoint data field
:param params: query parameters
:return: AcceptedCountriesModel object
'''
"""
return self.collections.stream(endpoint=self._endpoint, query_params=params)

def list(self, params=None, limit=None):
'''
"""
List all the acceptedcountries
:param params: query parameters
:param limit: parameter to limit the list count
:return: List of AcceptedCountriesModel object
'''
return self.collections.list(endpoint=self._endpoint, query_params=params, limit=limit)
"""
return self.collections.list(
endpoint=self._endpoint, query_params=params, limit=limit
)

def create(self, data, params=None):
'''
"""
Creates an acceptedcountries object
:param data: data required for creation
:param params: query parameters
:return: AcceptedCountriesModel object of the created acceptedcountries
'''
return self.collections.create(endpoint=self._endpoint, query_params=params, data=data)
"""
return self.collections.create(
endpoint=self._endpoint, query_params=params, data=data
)

def find(self, token, params=None):
'''
"""
Finds the existing acceptedcountries
:param token: acceptedcountries token to find
:param params: query parameters
:return: AcceptedCountriesModel object
'''
return self.collections.find(endpoint=self._endpoint + '/{}'.format(token),
query_params=params)
"""
return self.collections.find(
endpoint=self._endpoint + "/{}".format(token), query_params=params
)

def save(self, token, data):
'''
"""
Updates the existing acceptedcountries data
:param token: acceptedcountries token to update
:param data: data to be updated
:return: AcceptedCountriesModel object of the updated acceptedcountries
'''
return self.collections.save(data, endpoint=self._endpoint + '/{}'.format(token))
def __repr__(self):
return '<Marqeta.resources.accepted_countries.AcceptedCountriesCollection>'
"""
return self.collections.save(
data, endpoint=self._endpoint + "/{}".format(token)
)

def __repr__(self):
return "<Marqeta.resources.accepted_countries.AcceptedCountriesCollection>"
89 changes: 55 additions & 34 deletions marqeta/resources/account_holder_groups.py
Original file line number Diff line number Diff line change
@@ -1,83 +1,104 @@

'''ACCOUNTHOLDERGROUPS RESOURCE WITH CRU PARAMETERS'''
"""ACCOUNTHOLDERGROUPS RESOURCE WITH CRU PARAMETERS"""

from marqeta.resources.collection import Collection
from marqeta.response_models.account_holder_group_response import AccountHolderGroupResponse
from marqeta.response_models.account_holder_group_response import (
AccountHolderGroupResponse,
)


class AccountHolderGroupsCollection(object):
'''
"""
Marqeta API 'accountholdergroups' endpoint list, create, find and update operations
'''
_endpoint = 'accountholdergroups'
"""

_endpoint = "accountholdergroups"

def __init__(self, client):
'''
"""
Creates a client collection object
:param client: client object
'''
"""
self.client = client
self.collections = Collection(self.client, AccountHolderGroupResponse)

def page(self, count=5, start_index=0, params=None):
'''
"""
Provides the requested page for accountholdergroups
:param count: data to be displayed per page
:param start_index: start_index
:param params: query parameters
:return: requested page with AccountHolderGroupResponse object for the requested
page 'data'field
'''
query_params = {'count': 10}
"""
query_params = {"count": 10}
if params is not None:
query_params.update(params)
return self.collections.page(endpoint=self._endpoint, count=count,
start_index=start_index, query_params=query_params)
return self.collections.page(
endpoint=self._endpoint,
count=count,
start_index=start_index,
query_params=query_params,
)

def stream(self, params=None):
'''
"""
Stream through the list of requested endpoint data field
:param params: query parameters
:return: AccountHolderGroupResponse object
'''
query_params = {'count': 10}
"""
query_params = {"count": 10}
if params is not None:
query_params.update(params)
return self.collections.stream(endpoint=self._endpoint, query_params=query_params)
return self.collections.stream(
endpoint=self._endpoint, query_params=query_params
)

def list(self, params=None, limit=None):
'''
"""
List all the accountholdergroups
:param params: query parameters
:param limit: parameter to limit the list count
:return: List of AccountHolderGroupResponse object
'''
query_params = {'count': 10}
"""
query_params = {"count": 10}
if params is not None:
query_params.update(params)
return self.collections.list(endpoint=self._endpoint, query_params=query_params,
limit=limit)
return self.collections.list(
endpoint=self._endpoint, query_params=query_params, limit=limit
)

def create(self, data, params=None):
'''
"""
Creates an accountholdergroups object
:param data: data required for creation
:param params: query parameters
:return: AccountHolderGroupResponse object of the created accountholdergroups
'''
return self.collections.create(endpoint=self._endpoint, query_params=params, data=data)
"""
return self.collections.create(
endpoint=self._endpoint, query_params=params, data=data
)

def find(self, token, params=None):
'''
"""
Finds the existing accountholdergroups
:param token: accountholdergroups token to find
:param params: query parameters
:return: AccountHolderGroupResponse object
'''
return self.collections.find(endpoint=self._endpoint + '/{}'.format(token),
query_params=params)
"""
return self.collections.find(
endpoint=self._endpoint + "/{}".format(token), query_params=params
)

def save(self, token, data):
'''
"""
Updates the existing accountholdergroups data
:param token: accountholdergroups token to update
:param data: data to be updated
:return: AccountHolderGroupResponse object of the updated accountholdergroups
'''
return self.collections.save(data, endpoint=self._endpoint + '/{}'.format(token))
def __repr__(self):
return '<Marqeta.resources.account_holder_groups.AccountHolderGroupsCollection>'
"""
return self.collections.save(
data, endpoint=self._endpoint + "/{}".format(token)
)

def __repr__(self):
return "<Marqeta.resources.account_holder_groups.AccountHolderGroupsCollection>"
Loading