<commit_before><?php
/*
 * Bundle: Crisp / WebsitePeople
 * Project: Crisp - PHP API
 * Author: <NAME> http://jamin.me/
 * Copyright: 2018, Crisp IM
 */

class CrispWebsitePeople
{

  public function __construct($parent) {
    $this->crisp = $parent;
  }

  public function findByEmail($websiteId, $email) {
    $searchFilter = [["model" => "people","criterion" => "email","operator" => "eq","query" => [$email]]];

    $result = $this->crisp->_rest->get(
      "website/$websiteId/people/profiles?search_filter=".json_encode($searchFilter)
    );
    return $result->decode_response()["data"];
  }

  public function findBySegments($websiteId, $segments) {
    $searchFilter = [];

    foreach ($segments as $segment){
      $searchFilter[] = ["model" => "people","criterion" => "segments","operator" => "eq","query" => [$segment]];
    }

    $result = $this->crisp->_rest->get(
      "website/$websiteId/people/profiles?search_filter=".json_encode($searchFilter)
    );
    return $result->decode_response()["data"];
  }

  public function createNewPeopleProfile($websiteId, $params) {
    $result = $this->crisp->_rest->post(
      "website/$websiteId/people/profile",
      json_encode($params)
    );
    return $result->decode_response()["data"];
  }

  public function checkPeopleProfileExists($websiteId, $peopleId) {
    $result = $this->crisp->_rest->execute(
      "HEAD",
      "website/$websiteId/people/profile/$peopleId"
    );
    return $result->decode_response()["data"];
  }

  public function getPeopleProfile($websiteId, $peopleId) {
    $result = $this->crisp->_rest->get(
      "website/$websiteId/people/profile/$peopleId"
    );
    return $result->decode_response()["data"];
  }

  public function listPeopleProfiles($websiteId, $page) {
    $result = $this->crisp->_rest->get(
      "website/$websiteId/people/profiles/$page"
    );
    return $result->decode_response()["data"];
  }

  public function removePeopleProfile($websiteId, $peopleId) {
    $result = $this->crisp->_rest->delete(
      "website/$websiteId/people/profile/$peopleId"
    );
    return $result->decode_response()["data"];
  }

   public function savePeopleProfile($websiteId, $peopleId, $data) {
    $result = $this->crisp->_rest->put(
      "website/$websiteId/people/profile/$peopleId",
      json_encode($data)
    );
    return $result->decode_response()["data"];
  }

  public function updatePeopleProfile($websiteId, $peopleId, $data) {
    $result = $this->crisp->_rest->patch(
      "website/$websiteId/people/profile/$peopleId",
      json_encode($data)
    );
    return $result->decode_response()["data"];
  }

  public function listPeopleSegments($websiteId, $page) {
    $result = $this->crisp->_rest->get(
      "website/$websiteId/people/segments/$page"
    );
    return $result->decode_response()["data"];
  }

  public function listPeopleConversations($websiteId, $peopleId, $page) {
    $result = $this->crisp->_rest->get(
      "website/$websiteId/people/conversations/$peopleId/list/$page"
    );
    return $result->decode_response()["data"];
  }

  public function addPeopleEvent($websiteId, $peopleId, $data) {
    $result = $this->crisp->_rest->post(
      "website/$websiteId/people/events/$peopleId",
      json_encode($data)
    );
    return $result->decode_response()["data"];
  }

  public function listPeopleEvent($websiteId, $peopleId, $page) {
    $result = $this->crisp->_rest->execute(
      "GET",
      "website/$websiteId/people/events/$peopleId/list/$page",
      json_encode($data)
    );
    return $result->decode_response()["data"];
  }

  public function getPeopleData($websiteId, $peopleId) {
    $result = $this->crisp->_rest->get(
      "website/$websiteId/people/data/$peopleId"
    );
    return $result->decode_response()["data"];
  }

  public function updatePeopleData($websiteId, $peopleId, $data) {
    $result = $this->crisp->_rest->put(<commit_msg>Update WebsitePeople.php<commit_after><?php
/*
 * Bundle: Crisp / WebsitePeople
 * Project: Crisp - PHP API
 * Author: <NAME> http://jamin.me/
 * Copyright: 2018, Crisp IM
 */

class CrispWebsitePeople
{

  public function __construct($parent) {
    $this->crisp = $parent;
  }

  public function findByEmail($websiteId, $email) {
    $searchFilter = [["model" => "people","criterion" => "email","operator" => "eq","query" => [$email]]];

    $result = $this->crisp->_rest->get(
      "website/$websiteId/people/profiles?search_filter=".json_encode($searchFilter)
    );
    return $result->decode_response()["data"];
  }

  public function findBySegments($websiteId, $segments) {
    $searchFilter = [];

    foreach ($segments as $segment){
      $searchFilter[] = ["model" => "people","criterion" => "segments","operator" => "eq","query" => [$segment]];
    }

    $result = $this->crisp->_rest->get(
      "website/$websiteId/people/profiles?search_filter=".json_encode($searchFilter)
    );
    return $result->decode_response()["data"];
  }

  public function createNewPeopleProfile($websiteId, $params) {
    $result = $this->crisp->_rest->post(
      "website/$websiteId/people/profile",
      json_encode($params)
    );
    return $result->decode_response()["data"];
  }

  public function checkPeopleProfileExists($websiteId, $peopleId) {
    $result = $this->crisp->_rest->execute(
      "HEAD",
      "website/$websiteId/people/profile/$peopleId"
    );
    return $result->decode_response()["data"];
  }

  public function getPeopleProfile($websiteId, $peopleId) {
    $result = $this->crisp->_rest->get(
      "website/$websiteId/people/profile/$peopleId"
    );
    return $result->decode_response()["data"];
  }

  public function listPeopleProfiles($websiteId, $page) {
    $result = $this->crisp->_rest->get(
      "website/$websiteId/people/profiles/$page"
    );
    return $result->decode_response()["data"];
  }

  public function removePeopleProfile($websiteId, $peopleId) {
    $result = $this->crisp->_rest->delete(
      "website/$websiteId/people/profile/$peopleId"
    );
    return $result->decode_response()["data"];
  }

   public function savePeopleProfile($websiteId, $peopleId, $data) {
    $result = $this->crisp->_rest->put(
      "website/$websiteId/people/profile/$peopleId",
      json_encode($data)
    );
    return $result->decode_response()["data"];
  }

  public function updatePeopleProfile($websiteId, $peopleId, $data) {
    $result = $this->crisp->_rest->patch(
      "website/$websiteId/people/profile/$peopleId",
      json_encode($data)
    );
    return $result->decode_response()["data"];
  }

  public function listPeopleSegments($websiteId, $page) {
    $result = $this->crisp->_rest->get(
      "website/$websiteId/people/segments/$page"
    );
    return $result->decode_response()["data"];
  }

  public function listPeopleConversations($websiteId, $peopleId, $page) {
    $result = $this->crisp->_rest->get(
      "website/$websiteId/people/conversations/$peopleId/list/$page"
    );
    return $result->decode_response()["data"];
  }

  public function addPeopleEvent($websiteId, $peopleId, $data) {
    $result = $this->crisp->_rest->post(
      "website/$websiteId/people/events/$peopleId",
      json_encode($data)
    );
    return $result->decode_response()["data"];
  }

  public function listPeopleEvent($websiteId, $peopleId, $page) {
    $result = $this->crisp->_rest->execute(
      "GET",
      "website/$websiteId/people/events/$peopleId/list/$page"
    );
    return $result->decode_response()["data"];
  }

  public function getPeopleData($websiteId, $peopleId) {
    $result = $this->crisp->_rest->get(
      "website/$websiteId/people/data/$peopleId"
    );
    return $result->decode_response()["data"];
  }

  public function updatePeopleData($websiteId, $peopleId, $data) {
    $result = $this->crisp->_rest->put(
{'fraction_non_alphanumeric': 0.1801051147288809, 'fraction_numerical': 0.001025509550057685, 'mean_word_length': 3.8580323785803237, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 141, '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': '4711749', 'n_tokens_mistral': 2599, 'n_tokens_neox': 2451, 'n_words': 367}