Skip to content

Add External ID Field to Contact Model#155

Merged
keith-chartmogul merged 3 commits intomainfrom
keith/del-1610-php-client-library-add-external-id-field-to-contact-model
Mar 13, 2026
Merged

Add External ID Field to Contact Model#155
keith-chartmogul merged 3 commits intomainfrom
keith/del-1610-php-client-library-add-external-id-field-to-contact-model

Conversation

@keith-chartmogul
Copy link
Copy Markdown
Contributor

@keith-chartmogul keith-chartmogul commented Mar 13, 2026

This PR updates the Contact model to include the external_id field. The external_id field can be either a string or null. The Contact model tests have been updated to demonstrate how the external_id field can be set in both CREATE and UPDATE requests.

@keith-chartmogul keith-chartmogul changed the title PHP Client Library - Add External ID Field to Contact Model [del-1610] Add External ID Field to Contact Model Mar 13, 2026

$this->assertTrue($result instanceof Contact);
$this->assertNull($result->external_id);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[minor] I guess for the similar changes in the chartmogul-ruby repo, this kind of test makes sense: you have an input, the VCR cassette logs and asserts the actual HTTP payload (e.g. external_id is omitted in the input, it's also omitted in the request payload, logged in the cassette), mocks the response body and in the end the class property is asserted.

But in this case, we're not testing the request payload; the HTTP response is mocked, so in the end we're testing if the mocked response ContactTest::CONTACT_NULL_EXTERNAL_ID_JSON has external_id=null regardless of what is the input for Contact::create. You can test it out yoursef; pass in 'external_id' => '123' and $this->assertNull($result->external_id) would still pass.

There was actually an integration tests setup and I fixed it a few years back (PR). I would suggest to test it in a more integrated way using VCR cassettes similar to how we do things in charmogul-ruby. This type of unit test isn't exactly suitable for the logic you're introducing.

But it's minor; I see that a lot of tests have the exact same issue, so I don't want to block your PR and you can fix it in another PR. I just wanted to point this out

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for the context, I've added some Contact model integration tests per your suggestion 👍

@keith-chartmogul keith-chartmogul requested a review from briwa March 13, 2026 09:09
@keith-chartmogul keith-chartmogul marked this pull request as draft March 13, 2026 10:29
@keith-chartmogul
Copy link
Copy Markdown
Contributor Author

I received validation from Dijana that maintaining the external_id field naming as currently implemented is the correct path forward.

@keith-chartmogul keith-chartmogul marked this pull request as ready for review March 13, 2026 11:57
@keith-chartmogul keith-chartmogul requested a review from pkopac March 13, 2026 12:03
@keith-chartmogul keith-chartmogul merged commit 036c553 into main Mar 13, 2026
6 checks passed
@keith-chartmogul keith-chartmogul deleted the keith/del-1610-php-client-library-add-external-id-field-to-contact-model branch March 13, 2026 12:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants