<commit_before>from datetime import datetime, timedelta
import json
import redis

#from flask import jsonify

import requests

from salesforce import SalesforceConnection

from config import PLAID_CLIENT_ID
from config import PLAID_SECRET
from config import PLAID_PUBLIC_KEY
from config import PLAID_ENVIRONMENT

from check_response import check_response


def get_bank_token(public_token=None, account_id=None):
    """
    Call the Plaid API to get a bank account
    """
    url = 'https://{}.plaid.com/{}'.format(PLAID_ENVIRONMENT, 'exchange_token')

    print('url is {}. now make request with public token {}'.format(url, public_token))

    request = {'client_id' : PLAID_CLIENT_ID, 'secret' : PLAID_SECRET, 'public_token' : public_token, 'account_id' : account_id}
    print('created the request')
    resp = requests.post(url, request)
    print('response below')
    print(resp)
    response = json.loads(resp.text)
    print('load it with json')
    print(response)
    print('now return it')
    check_response(response=resp, expected_status=200)
    return response<commit_msg>fix subdomain mess<commit_after>from datetime import datetime, timedelta
import json
import redis

#from flask import jsonify

import requests

from salesforce import SalesforceConnection

from config import PLAID_CLIENT_ID
from config import PLAID_SECRET
from config import PLAID_PUBLIC_KEY
from config import PLAID_ENVIRONMENT

from check_response import check_response


def get_bank_token(public_token=None, account_id=None):
    """
    Call the Plaid API to get a bank account
    """

    # production url is api not production
    if PLAID_ENVIRONMENT == 'production':
        subdomain = 'api'
    else:
        subdomain = PLAID_ENVIRONMENT

    url = 'https://{}.plaid.com/{}'.format(subdomain, 'exchange_token')

    print('url is {}. now make request with public token {}'.format(url, public_token))

    request = {'client_id' : PLAID_CLIENT_ID, 'secret' : PLAID_SECRET, 'public_token' : public_token, 'account_id' : account_id}
    print('created the request')
    resp = requests.post(url, request)
    print('response below')
    print(resp)
    response = json.loads(resp.text)
    print('load it with json')
    print(response)
    print('now return it')
    check_response(response=resp, expected_status=200)
    return response
{'fraction_non_alphanumeric': 0.09195893926432848, 'fraction_numerical': 0.0025662959794696323, 'mean_word_length': 4.426914153132251, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6549225', 'n_tokens_mistral': 733, 'n_tokens_neox': 703, 'n_words': 207}