/** * @param string $ean * @param ProductDataTransfer $data * * @return string * @throws \Hitmeister\Component\Api\Exceptions\ServerException */ public function upsert($ean, ProductDataTransfer $data) { $endpoint = new Upsert($this->getTransport()); $endpoint->setId($ean); $endpoint->setTransfer($data); $resultRequest = $endpoint->performRequest(); return $resultRequest['status'] == 201; }
public function testInstance() { /** @var \Mockery\Mock|\Hitmeister\Component\Api\Transfers\ProductDataTransfer $transfer */ $transfer = \Mockery::mock('\\Hitmeister\\Component\\Api\\Transfers\\ProductDataTransfer'); $transfer->shouldReceive('toArray')->once()->andReturn(['condition' => 'new']); $update = new Upsert($this->transport); $update->setId('1231231231232'); $update->setTransfer($transfer); $this->assertInstanceOf('\\Hitmeister\\Component\\Api\\Transfers\\ProductDataTransfer', $update->getTransfer()); $this->assertEquals('1231231231232', $update->getId()); $this->assertEquals([], $update->getParamWhiteList()); $this->assertEquals('PUT', $update->getMethod()); $this->assertEquals('product-data/1231231231232/', $update->getURI()); $body = $update->getBody(); $this->assertArrayHasKey('condition', $body); }