예제 #1
0
 /**
  * @param  null|ContactsFilter $data
  * @return null|void
  */
 public function contacts($data = null)
 {
     $action = 'contacts';
     $postMainParameters = null;
     if ($data instanceof ContactsFilter) {
         $this->addMainParameter($data->getId());
         $this->addSecondaryParameter('search_string', $data->getSearchString());
         $this->addSecondaryParameter('search_field', $data->getSearchField());
         $this->addSecondaryParameter('customer_id', $data->getCustomerId());
         $this->addSecondaryParameter('page_size', $data->getPageSize());
         $this->addSecondaryParameter('page', $data->getPage());
         $this->addSecondaryParameter('sort_fields', $data->getSortFields());
         $this->addSecondaryParameter('columns', $data->getColumns());
         $this->addSecondaryParameter('group_field', $data->getGroupField());
         $this->addSecondaryParameter('extend', $data->getExtend());
     } elseif (is_int($data)) {
         $this->addMainParameter($data);
     }
     $response = $this->call($action, $postMainParameters);
     $result = $this->handleResponse($response);
     return $result;
 }
예제 #2
0
 /**
  *
  */
 public function testContacts()
 {
     $ot = $this->getOnTimeObjectOk();
     $result = $ot->contacts();
     $this->assertTrue(is_array($result['data']));
     //
     $ot = $this->getOnTimeObjectOk();
     $filterT1 = new Contacts();
     $resultT1 = $ot->contacts($filterT1);
     $this->assertTrue(is_array($resultT1['data']));
     //
     $ot = $this->getOnTimeObjectOk();
     $filterT2 = new Contacts();
     $filterT2->setId(1);
     $resultT2 = $ot->contacts($filterT2);
     $this->assertTrue(is_array($resultT2['data']));
     //
     $ot = $this->getOnTimeObjectOk();
     $filterT3 = new Contacts();
     $filterT3->setId(9999);
     $resultT3 = $ot->contacts($filterT3);
     $this->assertNull($resultT3['data']);
     //
     $ot = $this->getOnTimeObjectOk();
     $filterT4 = new Contacts();
     $filterT4->setSearchString('h');
     $resultT4 = $ot->contacts($filterT4);
     $this->assertEquals(3, count($resultT4['data']));
     //
     $ot = $this->getOnTimeObjectOk();
     $filterT5 = new Contacts();
     $filterT5->setSearchString('fail');
     $resultT5 = $ot->contacts($filterT5);
     $this->assertEquals(0, count($resultT5['data']));
     //
     $ot = $this->getOnTimeObjectOk();
     $filterT6 = new Contacts();
     $filterT6->setCustomerId(1);
     $resultT6 = $ot->contacts($filterT6);
     $this->assertTrue(is_array($resultT6['data']));
     //
     $ot = $this->getOnTimeObjectOk();
     $filterT7 = new Contacts();
     $filterT7->setCustomerId(9999);
     $resultT7 = $ot->contacts($filterT7);
     $this->assertTrue(is_array($resultT7['data']));
 }