@@ -1309,6 +1309,53 @@ public function test_send_multi_product()
13091309 $ this ->assertEquals (false , $ response ->isError ());
13101310 }
13111311
1312+ public function test_send_single_product ()
1313+ {
1314+ $ to = $ this ->faker ->phoneNumber ;
1315+ $ url = $ this ->buildMessageRequestUri ();
1316+ $ message = $ this ->faker ->text (1024 );
1317+ $ footer = $ this ->faker ->text (60 );
1318+ $ catalog_id = $ this ->faker ->randomNumber ();
1319+ $ product_retailer_id = $ this ->faker ->uuid ();
1320+
1321+ $ body = [
1322+ 'messaging_product ' => 'whatsapp ' ,
1323+ 'recipient_type ' => 'individual ' ,
1324+ 'to ' => $ to ,
1325+ 'type ' => 'interactive ' ,
1326+ 'interactive ' => [
1327+ 'type ' => 'product ' ,
1328+ 'body ' => ['text ' => $ message ],
1329+ 'footer ' => ['text ' => $ footer ],
1330+ 'action ' => [
1331+ 'catalog_id ' => $ catalog_id ,
1332+ 'product_retailer_id ' => $ product_retailer_id ,
1333+ ],
1334+ ],
1335+ ];
1336+ $ headers = [
1337+ 'Authorization ' => 'Bearer ' . $ this ->access_token ,
1338+ ];
1339+
1340+ $ this ->client_handler
1341+ ->postJsonData ($ url , $ body , $ headers , Argument::type ('int ' ))
1342+ ->shouldBeCalled ()
1343+ ->willReturn (new RawResponse ($ headers , $ this ->successfulMessageNodeResponse (), 200 ));
1344+
1345+ $ response = $ this ->whatsapp_app_cloud_api ->sendSingleProduct (
1346+ $ to ,
1347+ $ catalog_id ,
1348+ $ product_retailer_id ,
1349+ $ message ,
1350+ $ footer
1351+ );
1352+
1353+ $ this ->assertEquals (200 , $ response ->httpStatusCode ());
1354+ $ this ->assertEquals (json_decode ($ this ->successfulMessageNodeResponse (), true ), $ response ->decodedBody ());
1355+ $ this ->assertEquals ($ this ->successfulMessageNodeResponse (), $ response ->body ());
1356+ $ this ->assertEquals (false , $ response ->isError ());
1357+ }
1358+
13121359 public function test_mark_a_message_as_read ()
13131360 {
13141361 $ url = $ this ->buildMessageRequestUri ();
0 commit comments