/** * @param null|CustomersFilter $data * @return null|void */ public function customers($data = null) { $action = 'customers'; $postMainParameters = null; if ($data instanceof CustomersFilter) { $this->addMainParameter($data->getId()); $this->addSecondaryParameter('search_string', $data->getSearchString()); $this->addSecondaryParameter('search_field', $data->getSearchField()); $this->addSecondaryParameter('page_size', $data->getPageSize()); $this->addSecondaryParameter('page', $data->getPage()); $this->addSecondaryParameter('sort_fields', $data->getSortFields()); $this->addSecondaryParameter('columns', $data->getColumns()); $this->addSecondaryParameter('extend', $data->getExtend()); } elseif (is_int($data)) { $this->addMainParameter($data); } $response = $this->call($action, $postMainParameters); $result = $this->handleResponse($response); return $result; }
/** * */ public function testCustomers() { $ot = $this->getOnTimeObjectOk(); $result = $ot->customers(); $this->assertTrue(is_array($result['data'])); // $ot = $this->getOnTimeObjectOk(); $filterT1 = new Customers(); $resultT1 = $ot->customers($filterT1); $this->assertTrue(is_array($resultT1['data'])); // $ot = $this->getOnTimeObjectOk(); $filterT2 = new Customers(); $filterT2->setId(1); $resultT2 = $ot->customers($filterT2); $this->assertTrue(is_array($resultT2['data'])); // $ot = $this->getOnTimeObjectOk(); $filterT3 = new Customers(); $filterT3->setId(9999); $resultT3 = $ot->customers($filterT3); $this->assertNull($resultT3['data']); // $ot = $this->getOnTimeObjectOk(); $filterT4 = new Customers(); $filterT4->setSearchString('h'); $resultT4 = $ot->customers($filterT4); $this->assertEquals(2, count($resultT4['data'])); // $ot = $this->getOnTimeObjectOk(); $filterT5 = new Customers(); $filterT5->setSearchString('fail'); $resultT5 = $ot->customers($filterT5); $this->assertEquals(0, count($resultT5['data'])); }