Example #1
0
 def test_test_customer_list(self):
     auth = OAuthHandler(oauth_client_id, oauth_client_secret,
                         get_private_key(), redirect_uri)
     api = API(auth)
     r = api.test_customer_list()
     self.assertTrue(r.success)
     self.assertEqual(len(r.value), 5)
Example #2
0
    def test_client_credentials_access_token(self):
        auth = OAuthHandler(oauth_client_id, oauth_client_secret,
                            get_private_key(), redirect_uri)

        # test getting access token
        auth.get_access_token_via_client_credentials_flow(['public'])
        self.assert_(auth.access_token is not None)

        # use the access token to verify that it is valid
        api = API(auth)
        r = api.test_customer_list()
        self.assert_(r.success)
Example #3
0
 def test_collection_list(self):
     auth = OAuthHandler(oauth_client_id, oauth_client_secret,
                         get_private_key(), redirect_uri)
     api = API(auth)
     data = {
         "accountNumber": 8002577,
         "accountSuffix": 1,
         "processId": 421553,
         "isPTTCollection": "false"
     }
     r = api.collection_list(data)
     self.assertTrue(r.success)
Example #4
0
    def test_bank_branch_list(self):
        auth = OAuthHandler(oauth_client_id, oauth_client_secret,
                            get_private_key(), redirect_uri)
        auth.get_access_token_via_client_credentials_flow(['public'])
        api = API(auth)
        r = api.bank_branch_list(bankId=205, cityId=34)
        self.assertTrue(r.success)

        try:
            r = api.bank_branch_list(bankId=205, cityId=34)
        except KTError as error:
            self.assertTrue('cityId' in error.reason)
Example #5
0
 def test_authorization_code_access_token(self):
     auth = OAuthHandler(oauth_client_id, oauth_client_secret,
                         get_private_key(), redirect_uri)
     scopes = ['accounts']
     authorization_url = auth.get_authorization_url(scopes)
     print('Please authorize: ' + authorization_url)
     code = input('Enter the authorization code from the callback URL')
     auth.get_access_token_via_authorization_code_flow(code)
     self.assert_(auth.access_token is not None)
     # use the access token to verify that it is valid
     api = API(auth)
     r = api.account_list()
     self.assert_(r.success)
Example #6
0
 def test_generic_request(self):
     auth = OAuthHandler(oauth_client_id, oauth_client_secret,
                         get_private_key(), redirect_uri)
     api = API(auth)
     endpoint_params = {
         'path': '/v1/data/testcustomers',
         'method': 'GET',
         'scope': 'public',
         'authorization_flow': 'client credentials'
     }
     r = api.generic_request(endpoint_params)
     self.assertTrue(r.success)
     self.assertEqual(len(r.value), 5)
Example #7
0
from kuveytturk.api import API
from kuveytturk.auth import OAuthHandler
from kuveytturk.error import KTError

CLIENT_ID = ''
CLIENT_SECRET = ''
REDIRECT_URI = ''
PRIVATE_KEY = ''

# Create an authentication handler with your credentials
auth = OAuthHandler(CLIENT_ID, CLIENT_SECRET, PRIVATE_KEY, REDIRECT_URI)

# Then create an API instance using this authentication handler
api = API(auth)

try:
    response = api.test_customer_list()
except KTError as err:
    pass

for customerId in response.value:
    print(customerId)
Example #8
0
from kuveytturk.api import API
from kuveytturk.auth import OAuthHandler
from kuveytturk.error import KTError

CLIENT_ID = ''
CLIENT_SECRET = ''
REDIRECT_URI = ''
PRIVATE_KEY = ''

# Create an authentication handler with your credentials
auth = OAuthHandler(CLIENT_ID, CLIENT_SECRET, PRIVATE_KEY, REDIRECT_URI)

# Then create an API instance using this authentication handler
api = API(auth)

try:
    # Since this endpoint is not defined as a method in this library,
    # we use the generic_request method to call any endpoint.
    response = api.generic_request({
        'path': '/v1/data/banks',
        'method': 'GET',
        'scope': 'public',
        'authorization_flow': 'client credentials'
    })
except KTError as err:
    pass
Example #9
0
CLIENT_ID = ''
CLIENT_SECRET = ''
REDIRECT_URI = ''
PRIVATE_KEY = ''

# Create an authentication handler with your credentials
auth = OAuthHandler(CLIENT_ID, CLIENT_SECRET, PRIVATE_KEY, REDIRECT_URI)

# Then create an authorization url to get consent of the user.
scopes = ['accounts']
authorization_url = auth.get_authorization_url(scopes)

print('Please authorize: ' + authorization_url)
code = input('Enter the authorization code from the callback URL')

# Using the authroziation code, request an access token
auth.get_access_token_via_authorization_code_flow(code)

# Then create an API instance using this authentication handler
api = API(auth)

# Finally make the api request to retrieve the list of account information
# of the authenticated customer.
try:
    response = api.account_list()
except KTError as err:
    pass

print(response.value)
Example #10
0
 def setUp(self):
     self.auth = create_auth()
     self.api = API(self.auth)
     self.api.retry_count = 2
     self.api.retry_delay = 0 if use_replay else 5
Example #11
0
from kuveytturk.api import API
from kuveytturk.auth import OAuthHandler
from kuveytturk.error import KTError

CLIENT_ID = ''
CLIENT_SECRET = ''
REDIRECT_URI = ''
PRIVATE_KEY = ''

# Create an authentication handler with your credentials
auth = OAuthHandler(CLIENT_ID, CLIENT_SECRET, PRIVATE_KEY, REDIRECT_URI)

# Then create an API instance using this authentication handler
api = API(auth)

try:
    response = api.collection_list({
        "accountNumber": 8002577,
        "accountSuffix": 1,
        "processId": 421553,
        "isPTTCollection": "false"
    })
except KTError as err:
    pass
Example #12
0
from kuveytturk.api import API
from kuveytturk.auth import OAuthHandler
from kuveytturk.error import KTError

CLIENT_ID = ''
CLIENT_SECRET = ''
REDIRECT_URI = ''
PRIVATE_KEY = ''

# Create an authentication handler with your credentials
auth = OAuthHandler(CLIENT_ID, CLIENT_SECRET, PRIVATE_KEY, REDIRECT_URI)

# Then create an API instance using this authentication handler
api = API(auth)

try:
    response = api.bank_branch_list(bankId=205, cityId=24)
except KTError as err:
    pass