Skip to content

Commit

Permalink
add customer auth endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Netzer committed Mar 19, 2019
1 parent a4ac68c commit 7f01d6b
Showing 1 changed file with 25 additions and 11 deletions.
36 changes: 25 additions & 11 deletions paywhirl.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,20 @@ def get_profile(self, customer_id: int) -> Any:

return self._get(str.format('/customer/profile/{0}', customer_id))

def auth_customer(self, email: str, password: str) -> Any:
"""Authenticate a customer with supplied data.
Args:
email: customer's email address
password: plain-text or bcrypt hashed password
Returns:
Dictionary with status 'success' or 'failure'.
"""

data = {'email': email, 'password': password}
return self._post('/auth/customer', data)

def create_customer(self, data: dict) -> Any:
"""Create a new customer with supplied data.
Expand Down Expand Up @@ -671,19 +685,19 @@ def get_email_template(self, template_id: int) -> Any:
return self._get(str.format('/email/{0}', template_id))

def send_email(self, data: dict) -> Any:
"""Send a system generated email based on one of your pre-
defined templates on your paywhirl account page
"""Send a system generated email based on one of your pre-
defined templates on your paywhirl account page
Args:
see api.paywhirl.com, the list depends on what
email templates you have available
Args:
see api.paywhirl.com, the list depends on what
email templates you have available
Returns:
either a string with "status" => "success" or an error message indicating
the need for another parameter
"""
Returns:
either a string with "status" => "success" or an error message indicating
the need for another parameter
"""

return self._post('/send-email', data)
return self._post('/send-email', data)

def get_account(self) -> Any:
"""Get a dictionary containing your account information."""
Expand Down Expand Up @@ -772,4 +786,4 @@ def _get(self, endpoint: str, params: Any = None) -> Any:
resp.close()
return ret

return resp.status_code
return resp.status_code

0 comments on commit 7f01d6b

Please sign in to comment.