<commit_before><?php

namespace smoice;

class Wrapper
{
  private $refreshToken;
  private $url;
  private $body;

  public function __construct ( $refreshToken, $server = 'https://easy.smoice.com/' )
  {
    $this->refreshToken = $refreshToken;
    $this->url = $server;
  }

  /*
   * ask for user information providing login credentials
   * result include api key for further requests
   */
  public function login ( $email, $passwordHash )
  {
    return $this->executeRequest('login','POST',array('email' => $email, 'passwordHash' => $passwordHash));
  }

  /*
   * ask for user information providing
   */
  public function findUser ( )
  {
    return $this->executeRequest('user','GET');
  }










  /*
   * customer related methods
   */
  public function createCustomer ( Customer $customer )
  {
    return $this->executeRequest('customers','POST',$customer);
  }

  public function findCustomer ( $id )
  {
    return $this->findOne('customers',$id);
  }

  public function findCustomerByNumber ( $number )
  {
    $result = $this->executeRequest('customers','GET',array('numbers' => array($number)));
    if ( isset($result->errorCode) )
      return $result;

    $row = reset($result);
    $customer = new Customer($row);

    return $customer;
  }

  public function findCustomers ( $ids = null )
  {
    return $this->findMany('customers',$ids);
  }

  /*
   * possible values for orderBy: number, name, phone, email
   * possible values for order: asc, desc
   */
  public function searchCustomers ( $searchValue, $start, $length, $orderBy = 'name', $order = 'asc' )
  {
    $result = $this->executeRequest('customers/search',
                                    'GET',
                                    array('search' => $searchValue,
                                          'start' => $start,
                                          'length' => $length,
                                          'orderBy' => $orderBy,
                                          'order' => $order)
                                    );
    if ( isset($result->errorCode) )
      return $result;

    $customers = array();
    foreach ( $result->customers as $row )
      $customers[] = new Customer($row);

    return array('numberTotal' => (int)$result->numberTotal,
                 'numberFiltered' => (int)$result->numberFiltered,
                 'customers' => $customers);
  }
  
  public function updateCustomer ( Customer $customer )
  {
    return $this->executeRequest('customers/'.$customer->id,'PUT',$customer);
  }





  
  /*
   * project related methods
   */
  public function createProject ( Project $project )
  {
    return $this->executeRequest('projects','POST',$project);
  }

  public function findProjects ( $ids = null )
  {
    return $this->findMany('projects',$ids);
  }

  public function findProject ( $id )
  {
    return $this->findOne('projects',$id);
  }

  public function updateProject ( Project $project )
  {
    return $this->executeRequest('projects/'.$project->id,'PUT',$project);
  }





  
  /*
   * contract related methods
   */
  public function createContract ( Contract $contract )
  {
    return $this->executeRequest('contracts','POST',$contract);
  }
  
  public function findContracts ( )
  {
    return $this->findMany('contracts');
  }

  public function findContract ( $id )
  {
    return $this->findOne('contracts',$id);
  }

  public function updateContract ( Contract $contract )
  {
    return $this->executeRequest('contracts/'.$contract->id,'PUT',$contract);
  }




  
  /*
   * invoice related methods
   */
  public function createInvoice ( $customerId, $details, $textBefore = null, $textAfter = null, $pricesIncludeVAT = false, $preview = false,
                                  $dueDate = null, $proforma = false, $orderNumber = null )
  {
    return $this->executeRequest('invoices',
                                 'POST',
                                 array('customerId' => $customerId,
                                       'textBefore' => $textBefore,
                                       'textAfter' => $textAfter,
                                       'pricesIncludeVAT' => $pricesIncludeVAT,
                                       'details' => $details,
                                       'preview' => $preview,
                                       'dueDate' => $dueDate,
                                       'proforma' => $proforma,
                                       'orderNumber' => $orderNumber,
                                       )
                                 );
  }

  public function getInvoicePDF ( $id, $includeBackground = true, $showProforma = false )
  {
    $result = $this->executeRequest('pdfinvoice/'.$id,'GET',array('includeBackground' => $includeBackground,
                                                                  'showProforma' => $showProforma));
    if ( isset($result->errorCode) )
      return $result;

    return $result;
  }

  public function findInvoice ( $id )
  {
    $result = $this->executeRequest('invoices/'.$id,'GET');
    if ( isset($result->errorCode) )
      return $result;

    return new Invoice($result);
  }

  public function sendInvoice ( $id )
  {
    return $this->executeRequest('invoices/send/'.$id,'GET');
  }<commit_msg>added support for no opem item<commit_after><?php

namespace smoice;

class Wrapper
{
  private $refreshToken;
  private $url;
  private $body;

  public function __construct ( $refreshToken, $server = 'https://easy.smoice.com/' )
  {
    $this->refreshToken = $refreshToken;
    $this->url = $server;
  }

  /*
   * ask for user information providing login credentials
   * result include api key for further requests
   */
  public function login ( $email, $passwordHash )
  {
    return $this->executeRequest('login','POST',array('email' => $email, 'passwordHash' => $passwordHash));
  }

  /*
   * ask for user information providing
   */
  public function findUser ( )
  {
    return $this->executeRequest('user','GET');
  }










  /*
   * customer related methods
   */
  public function createCustomer ( Customer $customer )
  {
    return $this->executeRequest('customers','POST',$customer);
  }

  public function findCustomer ( $id )
  {
    return $this->findOne('customers',$id);
  }

  public function findCustomerByNumber ( $number )
  {
    $result = $this->executeRequest('customers','GET',array('numbers' => array($number)));
    if ( isset($result->errorCode) )
      return $result;

    $row = reset($result);
    $customer = new Customer($row);

    return $customer;
  }

  public function findCustomers ( $ids = null )
  {
    return $this->findMany('customers',$ids);
  }

  /*
   * possible values for orderBy: number, name, phone, email
   * possible values for order: asc, desc
   */
  public function searchCustomers ( $searchValue, $start, $length, $orderBy = 'name', $order = 'asc' )
  {
    $result = $this->executeRequest('customers/search',
                                    'GET',
                                    array('search' => $searchValue,
                                          'start' => $start,
                                          'length' => $length,
                                          'orderBy' => $orderBy,
                                          'order' => $order)
                                    );
    if ( isset($result->errorCode) )
      return $result;

    $customers = array();
    foreach ( $result->customers as $row )
      $customers[] = new Customer($row);

    return array('numberTotal' => (int)$result->numberTotal,
                 'numberFiltered' => (int)$result->numberFiltered,
                 'customers' => $customers);
  }
  
  public function updateCustomer ( Customer $customer )
  {
    return $this->executeRequest('customers/'.$customer->id,'PUT',$customer);
  }





  
  /*
   * project related methods
   */
  public function createProject ( Project $project )
  {
    return $this->executeRequest('projects','POST',$project);
  }

  public function findProjects ( $ids = null )
  {
    return $this->findMany('projects',$ids);
  }

  public function findProject ( $id )
  {
    return $this->findOne('projects',$id);
  }

  public function updateProject ( Project $project )
  {
    return $this->executeRequest('projects/'.$project->id,'PUT',$project);
  }





  
  /*
   * contract related methods
   */
  public function createContract ( Contract $contract )
  {
    return $this->executeRequest('contracts','POST',$contract);
  }
  
  public function findContracts ( )
  {
    return $this->findMany('contracts');
  }

  public function findContract ( $id )
  {
    return $this->findOne('contracts',$id);
  }

  public function updateContract ( Contract $contract )
  {
    return $this->executeRequest('contracts/'.$contract->id,'PUT',$contract);
  }




  
  /*
   * invoice related methods
   */
  public function createInvoice ( $customerId, $details, $textBefore = null, $textAfter = null, $pricesIncludeVAT = false, $preview = false,
                                  $dueDate = null, $proforma = false, $orderNumber = null, $createOpenItem = true )
  {
    return $this->executeRequest('invoices',
                                 'POST',
                                 array('customerId' => $customerId,
                                       'textBefore' => $textBefore,
                                       'textAfter' => $textAfter,
                                       'pricesIncludeVAT' => $pricesIncludeVAT,
                                       'details' => $details,
                                       'preview' => $preview,
                                       'dueDate' => $dueDate,
                                       'proforma' => $proforma,
                                       'orderNumber' => $orderNumber,
                                       'createOpenItem' => $createOpenItem,
                                       )
                                 );
  }

  public function getInvoicePDF ( $id, $includeBackground = true, $showProforma = false )
  {
    $result = $this->executeRequest('pdfinvoice/'.$id,'GET',array('includeBackground' => $includeBackground,
                                                                  'showProforma' => $showProforma));
    if ( isset($result->errorCode) )
      return $result;

    return $result;
  }

  public function findInvoice ( $id )
  {
    $result = $this->executeRequest('invoices/'.$id,'GET');
    if ( isset($result->errorCode) )
      return $result;

    return new Invoice($result);
  }

  public function sendInvoice ( $id )
  {
    return $this->executeRequest('invoices/send/'.$id,'GET');
  }
{'fraction_non_alphanumeric': 0.13454545454545455, 'fraction_numerical': 0.0, 'mean_word_length': 1.918639455782313, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 112, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 51, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2312799', 'n_tokens_mistral': 2943, 'n_tokens_neox': 2866, 'n_words': 607}