Skip to content

Commit

Permalink
Fix missing customer_uuid when creating a note from a customer (#119)
Browse files Browse the repository at this point in the history
* Fix missing customer_uuid when creating a note from a customer
  • Loading branch information
SoeunSona committed Dec 21, 2023
1 parent bbb45a5 commit e3b6690
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 7 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ and this project adheres to [Semantic Versioning].
[Keep a Changelog]: https://keepachangelog.com/en/1.0.0/
[Semantic Versioning]: https://semver.org/spec/v2.0.0.html

## [6.1.1] - 2023-12-21
- Fix missing customer_uuid when creating a note from a customer

## [6.1.0] - 2023-12-20
- Support customer notes

Expand Down
3 changes: 2 additions & 1 deletion src/Customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,8 @@ public function notes(array $options = [])
public function createNote(array $data = [])
{
$client = $this->getClient();
$result = $client->send("/v1/customer_notes", "POST", [$data, "customer_uuid" => $this->uuid]);
$data["customer_uuid"] = $this->uuid;
$result = $client->send("/v1/customer_notes", "POST", $data);

return new CustomerNote($result, $client);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Client implements ClientInterface
/**
* @var string
*/
private $apiVersion = '6.1.0';
private $apiVersion = '6.1.1';

/**
* @var string
Expand Down
8 changes: 4 additions & 4 deletions tests/Unit/CustomerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -421,19 +421,19 @@ public function testCreateNote()
$uuid = "cus_00000000-0000-0000-0000-000000000000";

$result = (new Customer(["uuid" => $uuid], $cmClient))->createNote(
[
"customer_uuid" => $uuid,
], [
[
"type" => "note",
"author_email" => "john@example.com",
"text" => "This is a note",
]
]
);
$request = $mockClient->getRequests()[0];

$this->assertEquals("POST", $request->getMethod());
$uri = $request->getUri();
$this->assertEquals("/v1/customer_notes", $uri->getPath());
$requestBody = (string) $request->getBody();
$this->assertEquals('{"type":"note","author_email":"john@example.com","text":"This is a note","customer_uuid":"cus_00000000-0000-0000-0000-000000000000"}', $requestBody);

$this->assertTrue($result instanceof CustomerNote);
$this->assertEquals("note_00000000-0000-0000-0000-000000000000", $result->uuid);
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Http/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function testGetUserAgent()
->onlyMethods([])
->getMock();

$this->assertEquals("chartmogul-php/6.1.0/PHP-".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION, $mock->getUserAgent());
$this->assertEquals("chartmogul-php/6.1.1/PHP-".PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION, $mock->getUserAgent());
}

public function testGetBasicAuthHeader()
Expand Down

0 comments on commit e3b6690

Please sign in to comment.