<commit_before><?php
    // Uses Composer.
    require 'vendor/autoload.php';
    use GuzzleHttp\Client;
    use Symfony\Component\Yaml\Yaml;

    // App to
    // * search for donations in a date range, or
    // * search for donations for a list of activity IDs.

    // Config is a YAML file. The Engage API call expects either a
    // date range (modifiedFrom and/or modifiedTo) or a list of
    // activityIds.  This sameple is equipped with both.  See the
    // payload comment to learn now to use both types of requests.
    /*
    token:          "<PASSWORD>"
    identifierType: FUNDRAISE
    modifiedFrom:   "2018-07-01T00:00:00.000Z"
    modifiedTo:     "2018-07-31T23:59:59.999Z"
    activityIds:
        - "3a05282d-c648-4c9f-a880-574211b019d6"
        - "04afe721-ac62-4b2e-aa66-bc6cba7fac71"
        - "17fd2a78-4ff6-4f3a-b2b1-278355716eff"
        - "3a05282d-c648-4c9f-a880-574211b019d6"
        - "48b25138-a021-4eff-89d2-7161d1caed29"
        - "54ecf33b-b7f7-4d83-85d8-eb9ffac97a66"

    This is a sample of the output:

    Activity ID                          Transaction ID                       Transaction Date         Type          Amount
    04afe721-ac62-4b2e-aa66-bc6cba7fac71 6f150ba4-f5ad-45cf-a7c6-a6c599a68be0 2018-07-20T02:36:10.002Z CHARGE        50.00
    17fd2a78-4ff6-4f3a-b2b1-278355716eff 2a48a1cd-3906-46da-bf4f-255e7d338b65 2018-07-15T16:50:54.143Z CHARGE        50.00
    3a05282d-c648-4c9f-a880-574211b019d6 614e1ea2-9de3-4e9e-b089-b5db0e149463 2018-07-20T02:28:37.025Z CHARGE       100.00
    48b25138-a021-4eff-89d2-7161d1caed29 6f4e7bed-d504-4507-88a7-73d8ed0bdcf0 2018-07-20T02:23:58.640Z CHARGE        50.00
    54ecf33b-b7f7-4d83-85d8-eb9ffac97a66 ed3a8e28-7f99-484c-9642-9af68e31a856 2018-07-27T14:38:20.666Z CHARGE        25.00
                                                                                                        Total        275.00

    */

    // Retrieve the runtime parameters and validate them.
    function initialize()
    {
        $shortopts = "";
        $longopts = array(
            "login:"
        );
        $options = getopt($shortopts, $longopts);
        if (false == array_key_exists('login', $options)) {
            exit("\nYou must provide a parameter file with --login!\n");
        }
        $filename = $options['login'];
        $cred =  Yaml::parseFile($filename);
        validateCredentials($cred, $filename);
        return $cred;
    }

    // Validate the contents of the provided credential file.
    // All fields are required.  Exits on errors.
    function validateCredentials($cred, $filename) {
        $errors = false;<commit_msg>Added usage doc.<commit_after><?php
    // Uses Composer.
    require 'vendor/autoload.php';
    use GuzzleHttp\Client;
    use Symfony\Component\Yaml\Yaml;

    // App to search for donation records with dedications that were made in
    // a timeframe that you choose.
    //
    // Usage:
    //
    //  php src/search_for_dedications.php -login config.yaml
    //

    // "config.yaml" is a YAML file.It contains these fields.
    /*
    token:          "<PASSWORD>"
    identifierType: FUNDRAISE
    modifiedFrom:   "2018-07-01T00:00:00.000Z"
    modifiedTo:     "2018-07-31T23:59:59.999Z"

    This is a sample of the output:

    [  100: 3] d9f2d14f-d37e-4091-a4a6-d68c3c613cac   IN_HONOR_OF Milly the Swimming Mule

    where:
        100 is the current offset.
        3 is the record number at the offset.
        d9f2d14f-d37e-4091-a4a6-d68c3c613cac is the donation ID
        IN_HONOR_OF is the dedication type
        Milly the Swimming Mule is the dedication.
    */

    // Retrieve the runtime parameters and validate them.
    function initialize()
    {
        $shortopts = "";
        $longopts = array(
            "login:"
        );
        $options = getopt($shortopts, $longopts);
        if (false == array_key_exists('login', $options)) {
            exit("\nYou must provide a parameter file with --login!\n");
        }
        $filename = $options['login'];
        $cred =  Yaml::parseFile($filename);
        validateCredentials($cred, $filename);
        return $cred;
    }

    // Validate the contents of the provided credential file.
    // All fields are required.  Exits on errors.
    function validateCredentials($cred, $filename) {
        $errors = false;
{'fraction_non_alphanumeric': 0.10458419718958765, 'fraction_numerical': 0.12393457728633955, 'mean_word_length': 2.0577464788732396, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2951388', 'n_tokens_mistral': 1802, 'n_tokens_neox': 1509, 'n_words': 332}