/**
  * Subscribers
  *
  * @param $handles
  * @return mixed
  */
 public function subscribers($handles)
 {
     $subscriber = $this->client->Subscriber_GetDataArray(['entityHandles' => $handles])->Subscriber_GetDataArrayResult;
     $debtor = new Debtor($this->client_raw);
     $subscriber->debtor = $debtor->get($subscriber->SubscriberData->DebtorHandle);
     return $subscriber;
 }
 /**
  * Get all Debtors of a debtor group
  *
  * @param integer $no
  * @return object
  */
 public function debtors($no)
 {
     $handle = $this->getHandle($no);
     $debtorHandles = $this->client->DebtorGroup_GetDebtors(['debtorGroupHandle' => $handle])->DebtorGroup_GetDebtorsResult->DebtorHandle;
     $debtor = new Debtor($this->client_raw);
     return $debtor->getArrayFromHandles($debtorHandles);
 }
 public function create(array $data)
 {
     $data['subscriptionHandle'] = $this->subscriptionHandle;
     if (!isset($data['debtor'])) {
         throw new InvalidArgumentException("It's required to provide a debtor number.");
     }
     $debtor = new Debtor($this->client_raw);
     $data['debtorHandle'] = $debtor->getHandle($data['debtor']);
     unset($data['debtor']);
     $data = array_merge(array('startDate' => date('Y-m-d H:i:s'), 'registeredDate' => date('Y-m-d H:i:s'), 'endDate' => date('Y-m-d H:i:s', strtotime('+99 YEAR'))), $data);
     return $this->client->Subscriber_Create($data)->Subscriber_CreateResponse->Subscriber_CreateResult;
 }
 /**
  * Create a new Contact from data array
  * @param  array   $data
  * @param  integer $debtor
  * @return array
  */
 public function create(array $data, $debtor)
 {
     $debtors = new Debtor($this->client_raw);
     $debtorHandle = $debtors->getHandle($debtor);
     $id = $this->client->DebtorContact_Create(array('debtorHandle' => $debtorHandle, 'name' => $data['name']))->DebtorContact_CreateResult;
     return $this->update($data, $id->Id);
 }
Exemple #5
0
    /**
     * Create new Order
     * @param  integer  $debtorNumber
     * @param  Closure  $callback
     * @return object
     */
    public function create($debtorNumber, Closure $callback, array $options=NULL)
    {
        $debtor = new Debtor($this->client_raw);
        $debtorHandle = $debtor->getHandle($debtorNumber);

        $orderHandle = $this->client
            ->Order_Create(array('debtorHandle'=>$debtorHandle))
            ->Order_CreateResult;


        if( !$orderHandle->Id )
        {
            throw new Exception("Error: creating Invoice.");
        }

        if( $options )
            $this->setOptions($orderHandle, $options);

        $this->lines = new Line($this->client_raw, $orderHandle);

        call_user_func($callback, $this->lines);

        return $this->client->Order_GetDataArray(
            array('entityHandles' => array('OrderHandle' => $orderHandle))
        )->Order_GetDataArrayResult;
    }
 /**
  * Create a new Quotaion to a specific Debtor
  * @param  integer  $debtorNumber
  * @param  Closure $callback
  * @return object
  */
 public function create($debtorNumber, Closure $callback)
 {
     $debtor = new Debtor($this->client_raw);
     $debtorHandle = $debtor->getHandle($debtorNumber);
     $quotationHandle = $this->client->Quotation_Create(array('debtorHandle' => $debtorHandle))->Quotation_CreateResult;
     if (!$quotationHandle->Id) {
         throw new Exception("Error: creating Quotation.");
     }
     $this->lines = new QuotationLines($this->client_raw, $quotationHandle);
     call_user_func($callback, $this->lines);
     return $this->get($quotationHandle);
 }
 /**
  * Create a new Quotaion to a specific Debtor
  *
  * @param integer $debtorNumber
  * @param Closure $callback
  * @return object
  * @throws Exception
  */
 public function create($debtorNumber, Closure $callback)
 {
     $debtor = new Debtor($this->client_raw);
     $debtorHandle = $debtor->getHandle($debtorNumber);
     $invoiceHandle = $this->client->CurrentInvoice_Create(['debtorHandle' => $debtorHandle])->CurrentInvoice_CreateResult;
     if (!$invoiceHandle->Id) {
         throw new Exception("Error: creating Invoice.");
     }
     $this->lines = new Line($this->client_raw, $invoiceHandle);
     call_user_func($callback, $this->lines);
     return $this->client->CurrentInvoice_GetDataArray(['entityHandles' => ['CurrentInvoiceHandle' => $invoiceHandle]])->CurrentInvoice_GetDataArrayResult;
 }