-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bb6fc1c
commit 30c0be6
Showing
5 changed files
with
56 additions
and
5 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
|
@@ -19,4 +19,3 @@ def __init__(self, api_key): | |
"paypal": "paypal" | ||
} | ||
|
||
# API functions will be added later |
This file contains 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,9 +1,62 @@ | ||
import requests | ||
from .API import NjallaAPI | ||
|
||
|
||
class NjallaUser: | ||
def __init__(self, api_key): | ||
self.api_key = api_key | ||
self.base_url = "https://njal.la/api/1/" | ||
|
||
# will be added later on | ||
def login(self, email, password): | ||
""" | ||
Login into an existing account (cookie-based session). | ||
Consider using API tokens instead | ||
:param email: Email address | ||
:param password: Password | ||
""" | ||
data = { | ||
"method": "login", | ||
"params": { | ||
"email": email, | ||
"password": password | ||
} | ||
} | ||
r = requests.post(self.base_url, json=data, headers=self.headers) | ||
result = r.json()["result"] | ||
if "error" in r.json(): | ||
raise ValueError(r.json()["error"]["message"]) | ||
return result | ||
|
||
def logout(self): | ||
""" | ||
Logout and end your current session | ||
""" | ||
data = { | ||
"method": "logout", | ||
"params": { | ||
} | ||
} | ||
r = requests.post(self.base_url, json=data, headers=self.headers) | ||
result = r.json()["result"] | ||
if "error" in r.json(): | ||
raise ValueError(r.json()["error"]["message"]) | ||
return result | ||
|
||
def delete_account(self): | ||
""" | ||
Delete your account. | ||
You can only delete the account if all domains and servers | ||
have been removed and your wallet is empty. | ||
""" | ||
data = { | ||
"method": "delete-account", | ||
"params": { | ||
} | ||
} | ||
r = requests.post(self.base_url, json=data, headers=self.headers) | ||
result = r.json()["result"] | ||
if "error" in r.json(): | ||
raise ValueError(r.json()["error"]["message"]) | ||
return result |
This file contains 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 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,6 +1,6 @@ | ||
[metadata] | ||
name = Njalla | ||
version = 0.2.1 | ||
version = 0.3 | ||
author = Luca from DevCa | ||
author_email= [email protected] | ||
description = A python library built to integrate the njal.la API | ||
|
This file contains 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