<commit_before><?php
/**
 * Created by PhpStorm.
 * User: dave
 * Date: 02/11/16
 * Time: 14:23
 */

namespace DaveHamber\Bundles\MeetupEventsMapBundle\Model;

use Circle\RestClientBundle\Services\RestInterface;
use \HWI\Bundle\OAuthBundle\Security\Core\Authentication\Token\OAuthToken;
use \Symfony\Component\HttpFoundation\Response;

class MeetupApiClient
{
    private $restClient;

    private $accessToken;

    private $apiUri = "https://api.meetup.com/";

    private $findEventsEndpoint = "find/events";

    public function __construct(RestInterface $restClient, OAuthToken $token)
    {
        $this->restClient = $restClient;

        $this->accessToken = $token->getAccessToken();
    }

    public function findEvents()
    {
        $uri = $this->apiUri . $this->findEventsEndpoint . '?' . 'only=name';

        /**
         * @var \Symfony\Component\HttpFoundation\Response
         */
        $response = $this->restClient->get(
            $uri,
            array(
                CURLOPT_HTTPHEADER => array("Authorization: Bearer $this->accessToken")
            )
        );

        $httpCode = $response->getStatusCode();

        if (Response::HTTP_OK == $httpCode) {
            $eventData = json_decode($response->getContent());
        } else {
            $eventData = array();
        }

        return $eventData;
    }
}<commit_msg>findEvents() now removes duplicates and events without a venue or location.<commit_after><?php
/**
 * Created by PhpStorm.
 * User: dave
 * Date: 02/11/16
 * Time: 14:23
 */

namespace DaveHamber\Bundles\MeetupEventsMapBundle\Model;

use Circle\RestClientBundle\Services\RestInterface;
use \HWI\Bundle\OAuthBundle\Security\Core\Authentication\Token\OAuthToken;
use \Symfony\Component\HttpFoundation\Response;

class MeetupApiClient
{
    private $restClient;

    private $accessToken;

    private $apiUri = "https://api.meetup.com/";

    private $findEventsEndpoint = "find/events";

    public function __construct(RestInterface $restClient, OAuthToken $token)
    {
        $this->restClient = $restClient;

        $this->accessToken = $token->getAccessToken();
    }

    public function findEvents()
    {
        $uri = $this->apiUri . $this->findEventsEndpoint . '?' . 'only=name,venue,time,description';

        /**
         * @var \Symfony\Component\HttpFoundation\Response
         */
        $response = $this->restClient->get(
            $uri,
            array(
                CURLOPT_HTTPHEADER => array("Authorization: Bearer $this->accessToken")
            )
        );

        $httpCode = $response->getStatusCode();

        if (Response::HTTP_OK == $httpCode) {
            $decodedJsonEventData = json_decode($response->getContent());
            $decodedJsonEventData = array_unique($decodedJsonEventData, SORT_REGULAR);
            foreach ($decodedJsonEventData as $eventDataClass) {
                if (isset ($eventDataClass->name, $eventDataClass->venue) &&
                    isset($eventDataClass->time, $eventDataClass->time) &&
                    isset($eventDataClass->venue->lat, $eventDataClass->venue->lon) &&
                    !($eventDataClass->venue->lat == 0 && $eventDataClass->venue->lon == 0)
                ) {

                    $eventData[] = $eventDataClass;
                }
            }

        } else {
            $eventData = array();
        }
        $eventData = $eventData;
        return $eventData;
    }
}
{'fraction_non_alphanumeric': 0.13157130409526577, 'fraction_numerical': 0.006389776357827476, 'mean_word_length': 2.3831041257367387, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 37, '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': '4327318', 'n_tokens_mistral': 1026, 'n_tokens_neox': 976, 'n_words': 171}