forked from coolshop-com/AltaPay
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from AltaPay/support-get-terminals
Add support for API/getTerminals
- Loading branch information
Showing
6 changed files
with
74 additions
and
16 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
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from __future__ import absolute_import, unicode_literals | ||
|
||
from altapay import exceptions | ||
from altapay.resource import Resource | ||
|
||
|
||
class Terminals(Resource): | ||
def __init__(self, api): | ||
""" | ||
Initialize the Terminal object by fetching terminals data from AltaPay. | ||
:arg api: An API object used for AltaPay communication. | ||
""" | ||
response = api.get('API/getTerminals')['APIResponse'] | ||
|
||
try: | ||
terminals = response['Body']['Terminals']['Terminal'] | ||
except KeyError: | ||
raise exceptions.ResourceNotFoundError('Terminals not found') | ||
if isinstance(terminals, list): | ||
self.terminals = terminals | ||
else: | ||
self.terminals = [terminals] |
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/usr/bin/python | ||
# -*- coding: utf-8 -*- | ||
|
||
""" | ||
Terminals test script. | ||
""" | ||
|
||
import sys, random | ||
|
||
# Update this with real path and uncomment before use, please | ||
# sys.path.append('/absolute_path_to/sdk-python') | ||
|
||
|
||
#sdk path check | ||
sdkPathExists = False | ||
for path in sys.path: | ||
if path.endswith("/sdk-python"): | ||
sdkPathExists=True | ||
if sdkPathExists is False: | ||
print("Path to sdk-python does not exist, update your environment variable, or put sys.path.append('/absolute_path_to/sdk-python') before including altapay sdk modules") | ||
sys.exit() | ||
|
||
from altapay import API, Terminals | ||
|
||
api = API(mode='test',account='API username', password='API Password', url='https://testgateway.altapaysecure.com/merchant/') | ||
|
||
response = Terminals(api = api) | ||
|
||
print(response.terminals) |
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