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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions samples/generate_pat.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
from __future__ import print_function, unicode_literals

import urllib3
import getpass
import sys

sys.path.append('.')
import urllib3

from uphold import *

sys.path.append('.')

#input('You are about to generate a persistent Personal Access Token on Uphold. Press ENTER to continue. ')

un = input("Uphold username: ").rstrip()
pw = getpass.getpass("Uphold password: ").rstrip()
un = input("Uphold username: ").rstrip()
pw = getpass.getpass("Uphold password: ").rstrip()
desc = input("Label/description for PAT (optional): ").rstrip()

api = Uphold(True)
api.auth_basic( un, pw )
api = Uphold(True)
api.auth_basic(un, pw)

pat = None

Expand All @@ -30,12 +32,11 @@
print("Error again: " + repr(e2))
except Exception as e:
print("An unexpected error occurred: " + repr(e))
exit(0);
exit(0)

if pat is not None:
print("Your PAT is: " + pat)
else:
print("Failed to generate PAT")

exit(0)

54 changes: 40 additions & 14 deletions samples/test.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
from __future__ import print_function, unicode_literals

import urllib3
import locale
import sys

import urllib3

from uphold import *

try:
from configparser import ConfigParser
except:
except ImportError:
from ConfigParser import ConfigParser
import sys

sys.path.append('.')
from uphold import *

sys.path.append('.')
locale.setlocale(locale.LC_ALL, 'en_US')
Config = ConfigParser()
Config.read('samples/config.ini')

api = Uphold()
api.auth_pat( Config.get('Settings','pat') )
api.auth_pat(Config.get('Settings', 'pat'))

print("Getting user data...")
me = api.get_me()
Expand All @@ -31,13 +34,14 @@
card_id = cards[0]['id']

print("\nGetting card labeled '" + cards[0]['label'] + "'")
card = api.get_card( cards[0]['id'] )
card = api.get_card(cards[0]['id'])
print("Available balance: " + card['available'])

print("\nGetting contacts...")
contacts = api.get_contacts()
for contact in contacts:
if contact and contact['firstName'] is not None and contact['lastName'] is not None:
if contact and contact['firstName'] is not None and contact[
'lastName'] is not None:
print(contact['firstName'] + " " + contact['lastName'])

print("\nGetting phones...")
Expand All @@ -56,10 +60,24 @@
i += 1
if i > 20:
break
if entry["in"]:
print(str(i) + ". " + entry['type'] + ": +" + entry["in"]["amount"] + " " + entry["in"]["currency"])
if entry["out"]:
print(str(i) + ". " + entry['type'] + ": -" + entry["in"]["amount"] + " " + entry["in"]["currency"])
if entry["in"]:
print(
str(i) +
". " +
entry['type'] +
": +" +
entry["in"]["amount"] +
" " +
entry["in"]["currency"])
if entry["out"]:
print(
str(i) +
". " +
entry['type'] +
": -" +
entry["in"]["amount"] +
" " +
entry["in"]["currency"])

print("\nGetting transactions (first 20 entries)...")
entries = api.get_reserve_chain()
Expand All @@ -68,11 +86,19 @@
i += 1
if i > 20:
break
print(str(i) + ". " + entry['origin']['amount'] + " " + entry["origin"]["currency"] + " => " + entry['destination']['amount'] + " " + entry["destination"]["currency"])
print(
str(i) +
". " +
entry['origin']['amount'] +
" " +
entry["origin"]["currency"] +
" => " +
entry['destination']['amount'] +
" " +
entry["destination"]["currency"])

print("\nGetting all tickers...")
tic = api.get_ticker()
print("ok.")

exit(0)

21 changes: 11 additions & 10 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
# -*- coding: utf-8 -*-
from distutils.core import setup

setup(
name = 'uphold',
packages = ['uphold'],
version = '0.1',
description = "Library for uphold.com's API",
author = 'Byrne Reese, João Miguel Neves',
author_email = '[email protected]',
url = 'https://github.com/byrnereese/uphold-python-sdk',
download_url = 'https://github.com/byrnereese/uphold-python-sdk/tarball/0.1',
keywords = ['uphold', 'bitreserve', 'currency', 'trading', 'api'],
classifiers = [],
name='uphold',
packages=['uphold'],
version='0.1',
description="Library for uphold.com's API",
author='Byrne Reese, João Miguel Neves',
author_email='[email protected]',
url='https://github.com/byrnereese/uphold-python-sdk',
download_url='https://github.com/byrnereese/uphold-python-sdk/tarball/0.1',
keywords=['uphold', 'bitreserve', 'currency', 'trading', 'api'],
classifiers=[],
)
22 changes: 17 additions & 5 deletions tests.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# -*- coding: utf-8 -*-
from __future__ import print_function, unicode_literals

from decimal import Decimal
from unittest import TestCase, main, skip

from mock import Mock, patch
from decimal import Decimal

from uphold import Uphold

Expand All @@ -13,6 +15,7 @@ class FakeResponse(object):


class TestAuthentication(TestCase):

def setUp(self):
pass

Expand All @@ -21,6 +24,7 @@ def test_(self):


class TestCurrencies(TestCase):

def setUp(self):
pass

Expand All @@ -29,6 +33,7 @@ def test_(self):


class TestTicker(TestCase):

def setUp(self):
pass

Expand All @@ -37,6 +42,7 @@ def test_(self):


class TestCard(TestCase):

def setUp(self):
pass

Expand All @@ -45,6 +51,7 @@ def test_(self):


class TestContact(TestCase):

def setUp(self):
pass

Expand All @@ -53,6 +60,7 @@ def test_(self):


class TestCurrencyPair(TestCase):

def setUp(self):
pass

Expand Down Expand Up @@ -106,13 +114,15 @@ def test_(self):
}
}'''


class TestTransaction(TestCase):

def setUp(self):
self.api = Bitreserve()
#self.api.auth('user', 'password')

@patch('requests.Session.post', Mock(return_value=fake_transaction_response))
@patch('requests.Session.post', Mock(
return_value=fake_transaction_response))
def test_prepare_txn(self):
res = self.api.prepare_txn(
'66cf2c86-8247-4094-bbec-ca29cea8220f',
Expand All @@ -122,16 +132,18 @@ def test_prepare_txn(self):
)
self.assertEqual(res, '7c377eba-cb1e-45a2-8c13-9807b4139bec')

@patch('requests.Session.post', Mock(return_value=fake_transaction_response))
@patch('requests.Session.post', Mock(
return_value=fake_transaction_response))
def test_execute_txn(self):
res = self.api.execute_txn(
'66cf2c86-8247-4094-bbec-ca29cea8220f',
'7c377eba-cb1e-45a2-8c13-9807b4139bec',
)
self.assertEqual(res['id'], '7c377eba-cb1e-45a2-8c13-9807b4139bec')


class TestUser(TestCase):

def setUp(self):
pass

Expand Down
Loading