public function testSales()
 {
     $from = time() - 100;
     $to = $from + 200;
     $this->transport->shouldReceive('performRequest')->once()->withArgs(['POST', 'reports/sales/', [], ['status' => ['received'], 'ts_from' => Request::formatDateTime($from), 'ts_to' => Request::formatDateTime($to)], \Mockery::any()])->andReturn(['headers' => ['Location' => ['/reports/123456/']]]);
     $namespace = new ReportsNamespace($this->transport);
     $result = $namespace->sales(['received'], $from, $to);
     $this->assertEquals(123456, $result);
 }
Example #2
0
 public function testDateTime()
 {
     $now = time();
     $dt = new \DateTime();
     $expected = date(Request::DATE_TIME_FORMAT);
     $this->assertNull(Request::formatDateTime(null));
     $this->assertEquals($dt->format(Request::DATE_TIME_FORMAT), Request::formatDateTime($dt));
     $this->assertEquals($expected, Request::formatDateTime($now));
     $this->assertEquals($expected, Request::formatDateTime($expected));
     $this->assertEquals(date(Request::DATE_FORMAT), Request::formatDate($now));
 }
 /**
  * @param array                $statuses
  * @param \DateTime|int|string $dateTimeFrom
  * @param \DateTime|int|string $dateTimeTo
  * @return int
  * @throws \Hitmeister\Component\Api\Exceptions\ServerException
  */
 public function sales(array $statuses, $dateTimeFrom, $dateTimeTo)
 {
     $data = new ReportRequestSalesTransfer();
     $data->status = $statuses;
     $data->ts_from = Request::formatDateTime($dateTimeFrom);
     $data->ts_to = Request::formatDateTime($dateTimeTo);
     $endpoint = new Sales($this->getTransport());
     $endpoint->setTransfer($data);
     $resultRequest = $endpoint->performRequest();
     return Response::extractId($resultRequest, '/reports/%d/');
 }
Example #4
0
 /**
  * @param string               $name
  * @param \DateTime|int|string $dateTime
  * @return $this
  */
 public function addDateTimeParam($name, $dateTime)
 {
     return $this->addParam($name, Request::formatDateTime($dateTime));
 }