From de177ceda9fe34790fcc9051babf35b8983c9a57 Mon Sep 17 00:00:00 2001 From: Kristers Andersons Date: Mon, 13 May 2024 09:43:58 +0300 Subject: [PATCH 01/10] Added Location component --- src/Component.php | 5 +++++ src/Component/Location.php | 40 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 src/Component/Location.php diff --git a/src/Component.php b/src/Component.php index b63459e..bfa0e97 100644 --- a/src/Component.php +++ b/src/Component.php @@ -51,4 +51,9 @@ public static function flowButton(string $token, array $data): Component\FlowBut { return new Component\FlowButton($token, $data); } + + public static function location(string $name, string $address, float $latitude, float $longitude): Component\Location + { + return new Component\Location($name, $address, $latitude, $longitude); + } } diff --git a/src/Component/Location.php b/src/Component/Location.php new file mode 100644 index 0000000..f8de2f2 --- /dev/null +++ b/src/Component/Location.php @@ -0,0 +1,40 @@ +name = $name; + $this->address = $address; + $this->latitude = $latitude; + $this->longitude = $longitude; + } + + // TODO: PHP 8 + // public function __construct( + // protected string $name, + // protected string $address, + // protected float $latitude, + // protected float $longitude + // ) {} + + public function toArray(): array + { + return [ + "type" => "location", + "location"=> [ + "latitude" => (string)$this->latitude, + "longitude" => (string)$this->longitude, + "name" => $this->name, + "address" => $this->address, + ], + ]; + } +} From a8584a105c3978353501f0b7731c0bf902b1938f Mon Sep 17 00:00:00 2001 From: Kristers Andersons Date: Mon, 13 May 2024 09:47:03 +0300 Subject: [PATCH 02/10] Added Location component tests --- tests/Component/LocationTest.php | 30 ++++++++++++++++++++++++++++++ tests/ComponentTest.php | 8 ++++++++ 2 files changed, 38 insertions(+) create mode 100644 tests/Component/LocationTest.php diff --git a/tests/Component/LocationTest.php b/tests/Component/LocationTest.php new file mode 100644 index 0000000..f0cfc6d --- /dev/null +++ b/tests/Component/LocationTest.php @@ -0,0 +1,30 @@ + 'location', + 'location' => [ + 'latitude' => (string)$latitude, + 'longitude' => (string)$longitude, + 'name' => $name, + 'address' => $address, + ], + ]; + $this->assertEquals($expectedValue, $currency->toArray()); + } +} diff --git a/tests/ComponentTest.php b/tests/ComponentTest.php index 383f8fc..1f57501 100644 --- a/tests/ComponentTest.php +++ b/tests/ComponentTest.php @@ -55,6 +55,14 @@ public function it_can_return_a_video_component() $this->assertInstanceOf(Component\Video::class, $component); } + /** @test */ + public function it_can_return_a_location_component() + { + $component = Component::location('My Place', 'Liepaja, Latvia', 56.51078, 21.00212); + + $this->assertInstanceOf(Component\Location::class, $component); + } + /** @test */ public function it_can_return_a_url_button_component() { From d4df8a525b0939d7f273ad3dd0202ec96df4086f Mon Sep 17 00:00:00 2001 From: Kristers Andersons Date: Mon, 13 May 2024 09:49:07 +0300 Subject: [PATCH 03/10] Added Location component docs --- CHANGELOG.md | 12 ++++++++++++ README.md | 5 +++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4dfc218..0d9f70f 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,18 @@ All notable changes will be documented in this file +## 1.3.0 - 2024-05-XX + +### What's Changed + +* Add 'Location' component by @Indianos + +### New Contributors + +* @Indianos made their first contribution + +### Full Changelog + ## 1.3.0 - 2024-04-29 ### What's Changed diff --git a/README.md b/README.md index 2d3e33a..1389114 100644 --- a/README.md +++ b/README.md @@ -91,12 +91,13 @@ Component::text($text); Component::urlButton($array_of_urls); Component::quickReplyButton($array_of_payloads); Component::flowButton($flow_token, $array_of_data); +Component::location($name, $address, $latitude, $longitude); ``` Components supported by Whatsapp template sections: - - Header: image, video, document and text (the text accepts currency, datetime and text variables) + - Header: image, video, document, location and text (the text accepts currency, datetime and text variables) - Body: currency, datetime and text - - Buttons: url and quick reply, + - Buttons: url and quick reply ### Send a notification from a template From 9f53a36b3355aa1d87d6834b1a7de383a35e8f3c Mon Sep 17 00:00:00 2001 From: Kristers Andersons Date: Mon, 13 May 2024 10:00:02 +0300 Subject: [PATCH 04/10] Bump version --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0d9f70f..78dfc37 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ All notable changes will be documented in this file -## 1.3.0 - 2024-05-XX +## 1.4.0 - 2024-05-XX ### What's Changed From ea16752f6728c7ada148b836b7c6a412bc6bb4b6 Mon Sep 17 00:00:00 2001 From: Kristers Andersons Date: Mon, 13 May 2024 10:04:03 +0300 Subject: [PATCH 05/10] convert @ mention to GH link --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 78dfc37..85f771c 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,11 +6,11 @@ All notable changes will be documented in this file ### What's Changed -* Add 'Location' component by @Indianos +* Add 'Location' component by [Indianos](https://github.com/Indianos) ### New Contributors -* @Indianos made their first contribution +* [Indianos](https://github.com/Indianos) made their first contribution ### Full Changelog From f63d279a6a733e3b4c4704130181970b7ebdc3c6 Mon Sep 17 00:00:00 2001 From: Kristers Andersons Date: Mon, 13 May 2024 10:09:46 +0300 Subject: [PATCH 06/10] fix code styling --- src/Component/Location.php | 12 ++++++------ tests/Component/LocationTest.php | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Component/Location.php b/src/Component/Location.php index f8de2f2..99ae10f 100644 --- a/src/Component/Location.php +++ b/src/Component/Location.php @@ -28,12 +28,12 @@ public function __construct(string $name, string $address, float $latitude, floa public function toArray(): array { return [ - "type" => "location", - "location"=> [ - "latitude" => (string)$this->latitude, - "longitude" => (string)$this->longitude, - "name" => $this->name, - "address" => $this->address, + 'type' => 'location', + 'location' => [ + 'latitude' => (string) $this->latitude, + 'longitude' => (string) $this->longitude, + 'name' => $this->name, + 'address' => $this->address, ], ]; } diff --git a/tests/Component/LocationTest.php b/tests/Component/LocationTest.php index f0cfc6d..846f647 100644 --- a/tests/Component/LocationTest.php +++ b/tests/Component/LocationTest.php @@ -19,8 +19,8 @@ public function location_is_valid() $expectedValue = [ 'type' => 'location', 'location' => [ - 'latitude' => (string)$latitude, - 'longitude' => (string)$longitude, + 'latitude' => (string) $latitude, + 'longitude' => (string) $longitude, 'name' => $name, 'address' => $address, ], From 2375e9cf63d3e036cd6a33585176ad3240a1a51d Mon Sep 17 00:00:00 2001 From: Kristers Andersons Date: Sat, 20 Jul 2024 14:42:41 +0300 Subject: [PATCH 07/10] Revert "convert @ mention to GH link" This reverts commit ea16752f6728c7ada148b836b7c6a412bc6bb4b6. --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 85f771c..78dfc37 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,11 +6,11 @@ All notable changes will be documented in this file ### What's Changed -* Add 'Location' component by [Indianos](https://github.com/Indianos) +* Add 'Location' component by @Indianos ### New Contributors -* [Indianos](https://github.com/Indianos) made their first contribution +* @Indianos made their first contribution ### Full Changelog From 2990dba4ba5b320fe5bd42bf3ed58ef2df8ab713 Mon Sep 17 00:00:00 2001 From: Kristers Andersons Date: Sat, 20 Jul 2024 14:42:41 +0300 Subject: [PATCH 08/10] Revert "Bump version" This reverts commit 9f53a36b3355aa1d87d6834b1a7de383a35e8f3c. --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 78dfc37..0d9f70f 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ All notable changes will be documented in this file -## 1.4.0 - 2024-05-XX +## 1.3.0 - 2024-05-XX ### What's Changed From ba23c882622498045d3ed33ca9f546ca1e823db0 Mon Sep 17 00:00:00 2001 From: Kristers Andersons Date: Sat, 20 Jul 2024 14:42:42 +0300 Subject: [PATCH 09/10] Revert "Added Location component docs" This reverts commit d4df8a525b0939d7f273ad3dd0202ec96df4086f. --- CHANGELOG.md | 12 ------------ README.md | 5 ++--- 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0d9f70f..4dfc218 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,18 +2,6 @@ All notable changes will be documented in this file -## 1.3.0 - 2024-05-XX - -### What's Changed - -* Add 'Location' component by @Indianos - -### New Contributors - -* @Indianos made their first contribution - -### Full Changelog - ## 1.3.0 - 2024-04-29 ### What's Changed diff --git a/README.md b/README.md index 1389114..2d3e33a 100644 --- a/README.md +++ b/README.md @@ -91,13 +91,12 @@ Component::text($text); Component::urlButton($array_of_urls); Component::quickReplyButton($array_of_payloads); Component::flowButton($flow_token, $array_of_data); -Component::location($name, $address, $latitude, $longitude); ``` Components supported by Whatsapp template sections: - - Header: image, video, document, location and text (the text accepts currency, datetime and text variables) + - Header: image, video, document and text (the text accepts currency, datetime and text variables) - Body: currency, datetime and text - - Buttons: url and quick reply + - Buttons: url and quick reply, ### Send a notification from a template From 35b1351ea94036deafa2b963c74df2da57bc8c13 Mon Sep 17 00:00:00 2001 From: Kristers Andersons Date: Sat, 20 Jul 2024 14:44:59 +0300 Subject: [PATCH 10/10] Removing commented code --- src/Component/Location.php | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/Component/Location.php b/src/Component/Location.php index 99ae10f..08fb493 100644 --- a/src/Component/Location.php +++ b/src/Component/Location.php @@ -17,14 +17,6 @@ public function __construct(string $name, string $address, float $latitude, floa $this->longitude = $longitude; } - // TODO: PHP 8 - // public function __construct( - // protected string $name, - // protected string $address, - // protected float $latitude, - // protected float $longitude - // ) {} - public function toArray(): array { return [