How to use the mintapi.api.MINT_ROOT_URL function in mintapi

To help you get started, we’ve selected a few mintapi examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jprouty / mint-amazon-tagger / tagger.py View on Github external
itemized_split['amount{}'.format(i)] = amount
                # Yup. Weird:
                itemized_split['percentAmount{}'.format(i)] = amount
                itemized_split['merchant{}'.format(i)] = trans.merchant
                # Yup weird. '0' means new?
                itemized_split['txnId{}'.format(i)] = 0
                if not ignore_category:
                    itemized_split['category{}'.format(i)] = trans.category
                    itemized_split['categoryId{}'.format(i)] = (
                        trans.category_id)

            logger.debug('Sending a "split" transaction request: {}'.format(
                itemized_split))
            response = mint_client.post(
                '{}{}'.format(
                    MINT_ROOT_URL,
                    UPDATE_TRANS_ENDPOINT),
                data=itemized_split).text
            updateProgress.next()
            logger.debug('Received response: {}'.format(response))
            num_requests += 1

    updateProgress.finish()

    dur = s_to_time(time.time() - start_time)
    logger.info('Sent {} updates to Mint in {}'.format(num_requests, dur))
github jprouty / mint-amazon-tagger / tagger.py View on Github external
'note': trans.note,
                'merchant': trans.merchant,
                'token': mint_client.token,
            }
            if not ignore_category:
                modify_trans = {
                    **modify_trans,
                    'category': trans.category,
                    'catId': trans.category_id,
                }

            logger.debug('Sending a "modify" transaction request: {}'.format(
                modify_trans))
            response = mint_client.post(
                '{}{}'.format(
                    MINT_ROOT_URL,
                    UPDATE_TRANS_ENDPOINT),
                data=modify_trans).text
            updateProgress.next()
            logger.debug('Received response: {}'.format(response))
            num_requests += 1
        else:
            # Split the existing transaction into many.
            # If the existing transaction is a:
            #   - credit: positive amount is credit, negative debit
            #   - debit: positive amount is debit, negative credit
            itemized_split = {
                'txnId': '{}:0'.format(orig_trans.id),
                'task': 'split',
                'data': '',  # Yup this is weird.
                'token': mint_client.token,
            }
github jprouty / mint-amazon-tagger / mintamazontagger / mintclient.py View on Github external
'merchant': trans.merchant,
                    'token': mint_client.token,
                }
                if not ignore_category:
                    modify_trans = {
                        **modify_trans,
                        'category': trans.category,
                        'catId': trans.category_id,
                    }

                logger.debug(
                    'Sending a "modify" transaction request: {}'.format(
                        modify_trans))
                response = mint_client.post(
                    '{}{}'.format(
                        MINT_ROOT_URL,
                        UPDATE_TRANS_ENDPOINT),
                    data=modify_trans).text
                updateProgress.next()
                logger.debug('Received response: {}'.format(response))
                num_requests += 1
            else:
                # Split the existing transaction into many.
                # If the existing transaction is a:
                #   - credit: positive amount is credit, negative debit
                #   - debit: positive amount is debit, negative credit
                itemized_split = {
                    'txnId': '{}:0'.format(orig_trans.id),
                    'task': 'split',
                    'data': '',  # Yup this is weird.
                    'token': mint_client.token,
                }
github jprouty / mint-amazon-tagger / mintamazontagger / mintclient.py View on Github external
'merchant': trans.merchant,
                    'token': mint_client.token,
                }
                if not ignore_category:
                    modify_trans = {
                        **modify_trans,
                        'category': trans.category,
                        'catId': trans.category_id,
                    }

                logger.debug(
                    'Sending a "modify" transaction request: {}'.format(
                        modify_trans))
                response = mint_client.post(
                    '{}{}'.format(
                        MINT_ROOT_URL,
                        UPDATE_TRANS_ENDPOINT),
                    data=modify_trans).text
                updateProgress.next()
                logger.debug('Received response: {}'.format(response))
                num_requests += 1
            else:
                # Split the existing transaction into many.
                # If the existing transaction is a:
                #   - credit: positive amount is credit, negative debit
                #   - debit: positive amount is debit, negative credit
                itemized_split = {
                    'txnId': '{}:0'.format(orig_trans.id),
                    'task': 'split',
                    'data': '',  # Yup this is weird.
                    'token': mint_client.token,
                }
github jprouty / mint-amazon-tagger / mintamazontagger / mintclient.py View on Github external
# Yup. Weird:
                    itemized_split['percentAmount{}'.format(i)] = amount
                    itemized_split['merchant{}'.format(i)] = trans.merchant
                    # Yup weird. '0' means new?
                    itemized_split['txnId{}'.format(i)] = 0
                    if not ignore_category:
                        itemized_split['category{}'.format(i)] = trans.category
                        itemized_split['categoryId{}'.format(i)] = (
                            trans.category_id)

                logger.debug(
                    'Sending a "split" transaction request: {}'.format(
                        itemized_split))
                response = mint_client.post(
                    '{}{}'.format(
                        MINT_ROOT_URL,
                        UPDATE_TRANS_ENDPOINT),
                    data=itemized_split)
                json_resp = response.json()
                # The first id is always the original transaction (now
                # parent transaction id).
                new_trans_ids = json_resp['txnId'][1:]
                assert len(new_trans_ids) == len(new_trans)
                for itemized_id, trans in zip(new_trans_ids, new_trans):
                    # Now send the note for each itemized transaction.
                    itemized_note = {
                        'task': 'txnedit',
                        'txnId': '{}:0'.format(itemized_id),
                        'note': trans.note,
                        'token': mint_client.token,
                    }
                    note_response = mint_client.post(
github jprouty / mint-amazon-tagger / mintamazontagger / mintclient.py View on Github external
json_resp = response.json()
                # The first id is always the original transaction (now
                # parent transaction id).
                new_trans_ids = json_resp['txnId'][1:]
                assert len(new_trans_ids) == len(new_trans)
                for itemized_id, trans in zip(new_trans_ids, new_trans):
                    # Now send the note for each itemized transaction.
                    itemized_note = {
                        'task': 'txnedit',
                        'txnId': '{}:0'.format(itemized_id),
                        'note': trans.note,
                        'token': mint_client.token,
                    }
                    note_response = mint_client.post(
                        '{}{}'.format(
                            MINT_ROOT_URL,
                            UPDATE_TRANS_ENDPOINT),
                        data=itemized_note)
                    logger.debug(
                        'Received note response: {}'.format(
                            note_response.text))

                updateProgress.next()
                logger.debug('Received response: {}'.format(response.text))
                num_requests += 1

        updateProgress.finish()

        logger.info('Sent {} updates to Mint'.format(num_requests))