klaviyo / php-klaviyo

PHP wrapper for the Klaviyo API
59 stars 47 forks source link

202010 fix camelcasing issue inside Profile Model #33

Closed kamil-klasicki closed 3 years ago

kamil-klasicki commented 3 years ago

The profileModel class has its properties listed using camelCase notation. As we are now doing a a property check between '$this' and $properties, the values that use snake_casing such as first_name or last_name will be missed out.

As the code uses camelCasing across the board, we should keep this consistent and so before checking if property exists, we should do a conversion to camelCase.

This already happens inside of setAttributes() method, so the PR simply pulls out that logic and puts it in its own function. We can then call it before '!property_exists' to make sure all values align.

Screenshot 2020-10-07 at 10 44 15 Screenshot 2020-10-07 at 10 44 46
klaviyojad commented 3 years ago

Ok so this 🐫 logic was already there and all your doing is making a special method and calling it somewhere we missed?

kamil-klasicki commented 3 years ago

Yeah exactly, you can see that setAttributes method has the: $this->{lcfirst(strreplace('', '', ucwords(ltrim($key, '$'), '_')))} = $value; has the logic that converts the snake case into camelCase so the properties are set correctly.

We currently don't do it inside of json_Serialize, so when we do property_exists check, it will skip the ones that don't match (first_name/firstName, last_name/lastName, phone_number/phoneNumber)