Skip to content

Bug: incorrect parameter serialization in ContentCreateRequest #815

@jeslopcru

Description

@jeslopcru

Issue Summary

It is not possible to create a Template with friendly name using PHP library version 8.3.4

Steps to Reproduce

  1. Create a template using PHP library
                $sid = getenv("TWILIO_ACCOUNT_SID");
                $token = getenv("TWILIO_AUTH_TOKEN");
                $twilio = new Client($sid, $token);

                $twilio->content->v1->contents->create(
                    ContentModels::createContentCreateRequest(
                        [
                            'friendlyName' => 'my_template_friendly_name,
                            'language' => 'en',
                            'types' => [
                                'twilio/text' => [
                                    'body' => 'this is a example body,
                                ],
                            ],
                        ],
                    ),
  1. When checking the template in Content Template Builder then friendly_name not provided appears as a name

Technical details:

  • twilio-php version: 8.3.4
  • php version: 8.3

Hints

I think that the problem is in ContentCreateRequest file because the serialization is with camelCase instead snake_case

problem

public function jsonSerialize(): array
    {
        return [
            'friendlyName' => $this->friendlyName,
            'variables' => $this->variables,
            'language' => $this->language,
            'types' => $this->types
        ];
    }

solution

public function jsonSerialize(): array
    {
        return [
            'friendly_name' => $this->friendlyName,
            'variables' => $this->variables,
            'language' => $this->language,
            'types' => $this->types
        ];
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions