<commit_before><?php namespace Northstar\Services\Drupal;

class DrupalAPI {

  protected $client;

  public function __construct()
  {
    $base_url = \Config::get('services.drupal.url');
    if (\App::environment('local')) {
      $base_url .=  ":" . \Config::get('services.drupal.port');
    }
    $base_url .= '/api';
    $version = \Config::get('services.drupal.version');
    $client = new \GuzzleHttp\Client([
      'base_url' => [$base_url . '/{version}/', ['version' => $version]],
      'defaults' => array(
        'headers' => [
          'Content-Type' => 'application/json',
          'Accept' => 'application/json'
          ]
        ),
    ]);
    $this->client = $client;
  }

  public function campaigns($id = NULL)
  {
    // Get all campaigns if there's no id set.
    if (!$id) {
      $response = $this->client->get('campaigns.json');
    }
    else {
      $response = $this->client->get('content/' . $id . '.json');
    }
    return $response->json();
  }

  /**
   * Forward registration to drupal.
   */
  public function register($user)
  {
    $user->birthdate = date('Y-m-d', strtotime($user->birthdate));
    $user->user_registration_source = $user->source;
    $response = $this->client->post('users', [
      'body' => json_encode($user),
      ]);
    return $response->json();
<commit_msg>Don't modify the $user object was saving null `user_registration_source` to northstar.<commit_after><?php namespace Northstar\Services\Drupal;

class DrupalAPI {

  protected $client;

  public function __construct()
  {
    $base_url = \Config::get('services.drupal.url');
    if (\App::environment('local')) {
      $base_url .=  ":" . \Config::get('services.drupal.port');
    }
    $base_url .= '/api';
    $version = \Config::get('services.drupal.version');
    $client = new \GuzzleHttp\Client([
      'base_url' => [$base_url . '/{version}/', ['version' => $version]],
      'defaults' => array(
        'headers' => [
          'Content-Type' => 'application/json',
          'Accept' => 'application/json'
          ]
        ),
    ]);
    $this->client = $client;
  }

  public function campaigns($id = NULL)
  {
    // Get all campaigns if there's no id set.
    if (!$id) {
      $response = $this->client->get('campaigns.json');
    }
    else {
      $response = $this->client->get('content/' . $id . '.json');
    }
    return $response->json();
  }

  /**
   * Forward registration to drupal.
   */
  public function register($d_user)
  {
    try {
      $d_user->birthdate = date('Y-m-d', strtotime($user->birthdate));
      $d_user->user_registration_source = $user->source;
      $response = $this->client->post('users', [
        'body' => json_encode($user),
        ]);
      return $response->json();
    } catch (Exception $e) {
      // whatever.
      return;
    }
{'fraction_non_alphanumeric': 0.19176136363636365, 'fraction_numerical': 0.0, 'mean_word_length': 2.5523329129886507, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 43, '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': '1987032', 'n_tokens_mistral': 917, 'n_tokens_neox': 898, 'n_words': 172}