def import_data(): """Import sandbox data""" api = get_api() print('Posting data to {}'.format(URL_IMPORT)) response = api.post(URL_IMPORT, json=DATA) if response.status_code == 201: print('The data has been imported successfully.') else: print('Status code: {}'.format(response.status_code)) print(response.text)
def say_hello(): """Says hello to the API""" api = get_api() response = api.get(API_BASE_URL) status_code = response.status_code print('Status code: {}'.format(status_code)) if status_code == 200: print('Success JSON:') pprint(response.json()) else: print(response.text)
def say_hello(): """Says hello to the API""" api = get_api() """Get the current authenticated User """ response = api.get(API_USER_URL) status_code = response.status_code print('Status code: {}'.format(status_code)) if status_code == 200: print('Success JSON:') pprint(response.json()) else: print(response.text)
# -*- coding: utf-8 -*- import json import sys from pprint import pprint from oauth_dance import get_api from settings import API_HOST, OUR_BANK, COUNTERPART_BANK, COUNTERPART_ACCOUNT_ID api_base_url = "{}/obp/v1.2.1".format(API_HOST) api_accounts_url = "{}/banks/{}/accounts".format(api_base_url, OUR_BANK) openbank = get_api() # get accounts for a specific bank print("Available private accounts:") response = openbank.get("{}/private".format(api_accounts_url)) response_json = response.json() pprint(response_json) accounts = response_json["accounts"] if len(accounts) < 1: print("No private accounts found, exiting...") sys.exit(1) # just picking first account our_account = accounts[0]["id"] print("Our account: {} ({})".format(our_account, accounts[0]["label"])) api_owner_url = "{}/{}/owner".format(api_accounts_url, our_account) print("Get owner transactions: ") response = openbank.get("{}/transactions".format(api_owner_url), headers={"obp_limit": "25"})
# -*- coding: utf-8 -*- import json import sys from pprint import pprint from oauth_dance import get_api from settings import (API_HOST, OUR_BANK, COUNTERPART_BANK, COUNTERPART_ACCOUNT_ID) api_base_url = '{}/obp/v1.2.1'.format(API_HOST) api_accounts_url = '{}/banks/{}/accounts'.format(api_base_url, OUR_BANK) openbank = get_api() # get accounts for a specific bank print('Available private accounts:') response = openbank.get('{}/private'.format(api_accounts_url)) response_json = response.json() pprint(response_json) accounts = response_json['accounts'] if len(accounts) < 1: print('No private accounts found, exiting...') sys.exit(1) # just picking first account our_account = accounts[0]['id'] print('Our account: {} ({})'.format(our_account, accounts[0]['label'])) api_owner_url = '{}/{}/owner'.format(api_accounts_url, our_account) print('Get owner transactions: ') response = openbank.get(
def hello_payment(): """Say hello, Payment!""" api = get_api() my_account = get_account(api) print_transactions(api, my_account) pay(api, my_account)