<commit_before><?php

namespace DoSomething\Gateway;

use DoSomething\Gateway\Common\RestApiClient;

class Gladiator extends RestApiClient
{
    use AuthorizesWithGladiator;

    /**
     * Configuration array.
     *
     * @var string
     */
    protected $config;

    /**
     * Default headers applied to every request.
     *
     * @var array
     */
    protected $defaultHeaders;

    /**
     * Create a new Gladiator API client.
     * @param array $config
     * @param array $overrides
     */
    public function __construct($config = [], $overrides = [])
    {
        // Save configuration.
        $this->config = $config;

        // Set response header.
        if (! empty($config['gladiator_api_key'])) {
            $this->apiKey = $config['gladiator_api_key'];
        }
        parent::__construct($config['url'], $overrides);
    }

    /**
     * Send a POST request Gladiator to add user to a contest.
     *
     * @param  string $userId
     * @param  string $campaignId
     * @param  string $campaignRunId
     *
     * @return bool
     */
    public function storeUserInContest($userId, $campaignId, $campaignRunId)
    {
        $response = $this->post('v1/users', [
            'id' => $userId,
            'term' => 'id',
            'campaign_id' => $legacyCampaignId,
            'campaign_run_id' => $legacyCampaignRunId,
        ]);

        // TODO: throw an exception if the post returns a validation error.
        return $this->responseSuccessful($response);
    }

    /**
     * Send a POST request Gladiator unsubscribe users from competition messages.
     *
     * @param  string $userId
     * @param  string $competitionId
     *
     * @return bool
     */
    public function unsubscribeUser($userId, $competition_id)
    {
        $response = $this->post('v1/unsubscribe', [
            'northstar_id' => $userId,
            'competition_id' => $competition_id,
        ]);

        // TODO: throw an exception if the post returns a validation error.
        return $this->responseSuccessful($response);
    }

    /**
     * Determine if the response was successful or not.
     *
     * @param mixed $json
     * @return bool
     */
    public function responseSuccessful($json)
    {
        return ! empty($json['data']) || ! empty($json['message']);
    }
}<commit_msg>remove TODOs that are taken care of already<commit_after><?php

namespace DoSomething\Gateway;

use DoSomething\Gateway\Common\RestApiClient;

class Gladiator extends RestApiClient
{
    use AuthorizesWithGladiator;

    /**
     * Configuration array.
     *
     * @var string
     */
    protected $config;

    /**
     * Default headers applied to every request.
     *
     * @var array
     */
    protected $defaultHeaders;

    /**
     * Create a new Gladiator API client.
     * @param array $config
     * @param array $overrides
     */
    public function __construct($config = [], $overrides = [])
    {
        // Save configuration.
        $this->config = $config;

        // Set response header.
        if (! empty($config['gladiator_api_key'])) {
            $this->apiKey = $config['gladiator_api_key'];
        }
        parent::__construct($config['url'], $overrides);
    }

    /**
     * Send a POST request Gladiator to add user to a contest.
     *
     * @param  string $userId
     * @param  string $campaignId
     * @param  string $campaignRunId
     *
     * @return bool
     */
    public function storeUserInContest($userId, $campaignId, $campaignRunId)
    {
        $response = $this->post('v1/users', [
            'id' => $userId,
            'term' => 'id',
            'campaign_id' => $legacyCampaignId,
            'campaign_run_id' => $legacyCampaignRunId,
        ]);

        return $this->responseSuccessful($response);
    }

    /**
     * Send a POST request Gladiator unsubscribe users from competition messages.
     *
     * @param  string $userId
     * @param  string $competitionId
     *
     * @return bool
     */
    public function unsubscribeUser($userId, $competition_id)
    {
        $response = $this->post('v1/unsubscribe', [
            'northstar_id' => $userId,
            'competition_id' => $competition_id,
        ]);

        return $this->responseSuccessful($response);
    }

    /**
     * Determine if the response was successful or not.
     *
     * @param mixed $json
     * @return bool
     */
    public function responseSuccessful($json)
    {
        return ! empty($json['data']) || ! empty($json['message']);
    }
}
{'fraction_non_alphanumeric': 0.12466960352422908, 'fraction_numerical': 0.000881057268722467, 'mean_word_length': 2.1145404663923184, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 27, 'https://': 0, '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': '4073302', 'n_tokens_mistral': 1333, 'n_tokens_neox': 1317, 'n_words': 317}