Vonage / vonage-php-sdk-core

Vonage REST API client for PHP. API support for SMS, Voice, Text-to-Speech, Numbers, Verify (2FA) and more.
https://developer.vonage.com/
Apache License 2.0
916 stars 180 forks source link

TypeError: `Vonage\SMS\Webhook\InboundSMS::getKeyword()`: Return value must be of type string, null returned #426

Closed ankurk91 closed 11 months ago

ankurk91 commented 1 year ago

The keyword can be null in incoming SMS Webhook payload

Expected Behavior

The vonage SDK must allow null keyword

Current Behavior

Vonage SDK throws error when null keyword is received

TypeError: `Vonage\SMS\Webhook\InboundSMS::getKeyword()`: Return value must be of type string, null returned

Possible Solution

Assign empty string in src/SMS/Webhook/InboundSMS.php

 $this->keyword = $data['keyword'] ?? '';

or

public function getKeyword(): ?string
    {
        return $this->keyword;
    }

Steps to Reproduce (for bugs)

Context

Incoming webhook payload JSON

{
  "to": "123456789",
  "sig": "dbbb7c772af79ce264096990cfb92739",
  "text": "Valid text was here",
  "type": "text",
  "nonce": "f37c8ecf-ad90-453b-8c1d-198cd8dd3045",
  "concat": "true",
  "msisdn": "123456789",
  "api-key": "SECRET",
  "keyword": null,
  "messageId": "3E0000003AA1A11F",
  "timestamp": "1691444462",
  "concat-ref": "3",
  "concat-part": "2",
  "concat-total": "2",
  "message-timestamp": "2023-08-07 21:41:02"
}

The messageId is real here

Your Environment

SecondeJK commented 11 months ago

Fixed by #440