Skip to content

Commit

Permalink
Merge pull request #124 from clicksports/feature/contact-update
Browse files Browse the repository at this point in the history
  • Loading branch information
rene-mueller authored Nov 21, 2023
2 parents 422146c + 26faced commit b435205
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ $response = $client->getAll();
// other methods
$response = $client->get($entityId);
$response = $client->create($data);
$response = $client->update($entityId, $data);

```

### Country Endpoint
Expand Down
16 changes: 16 additions & 0 deletions src/Contact/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,20 @@ public function generateUrl(int $page): string
'&direction=' . $this->sortDirection .
'&property=' .$this->sortProperty;
}

/**
* @param string $id
* @param array $data
* @return ResponseInterface
* @throws CacheException
* @throws LexOfficeApiException
*/
public function update(string $id, array $data)
{
$api = $this->api->newRequest('PUT', $this->resource . '/' . $id);

$api->request = $api->request->withBody($this->createStream($data));

return $api->getResponse();
}
}
40 changes: 40 additions & 0 deletions tests/Contact/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,44 @@ public function testGenerateUrl()
);
}

public function testCreate()
{
$stub = $this->createClientMockObject(
Client::class,
new Response(200, [], 'body'),
['create']
);

$response = $stub->create([
'version' => 0
]);

$this->assertEquals('body', $response->getBody()->__toString());
}

public function testGet()
{
$stub = $this->createClientMockObject(
Client::class,
new Response(200, [], 'body'),
['get']
);

$response = $stub->get('resource-id');

$this->assertEquals('body', $response->getBody()->__toString());
}

public function testUpdate()
{
$stub = $this->createClientMockObject(
Client::class,
new Response(200, [], 'body'),
['update']
);

$response = $stub->update('resource-id', []);

$this->assertEquals('body', $response->getBody()->__toString());
}
}

0 comments on commit b435205

Please sign in to comment.