Open kewan opened 6 years ago
I would do
if(isset($cid->tag_ids)) unset($cid->tag_ids);
That way your code won't break again when InfusionSoft decides to take the tag_ids out again. This has been going on since April and messed up our code. Did anyone tell InfusionSoft that the point of versioning APIs is to not make changes to existing versions.
Looking for input from @kewan and the InfusionSoft team - would calling unset
inside ContactService
be an acceptable solution to this? I'd be happy to submit a PR.
@acobster that feels like a bandaid fix. Ideally we'd have a transformer in the sdk that handles all of that for us. The problem with a transformer is that we'd have to update it every time a field changes on the model, however there might be ways to automate updating that.
Taking a step back, would a more appropriate fix be to ignore tag_ids
on the server side? Or perhaps even honor updates to tag_ids
? The Principle of Least Astonishment leads me to the conclusion that any data I get back about a Contact (or any RESTful entity) should bear meaning when sending them back in an update, or at least shouldn't cause any errors when you do (with the possible exception of truly immutable values, like id
). And I can't imagine that other client implementations wouldn't run across this same issue.
I agree with @acobster on this. As far as I know a resource obtained through a GET method should be the same resource provided to the POST/PATCH/PUT methods without any alterations. I am not sure the best way for IFS to handle this because I don't know the code base but I think customizing the endpoint to allow the tags array to be accepted and parsed, removing and adding tags as necessary, would not be a breaking change since everyone currently has to remove the tags before sending back. This would simply allow any future calls to allow tags to be passed.
This is still happening.
You can't have $contact = $infusionsoft->contacts()->find(1);
and then immediately follow up with $contact->save()
without running into this error. It's a little frustrating.
I can't believe how long this has been problem, judging by the comments on this issue. At the very least put a note in the README that explains the workaround of unsetting the tag_ids.
Another problem I ran into is that if there are data validation errors which were set on the front end, as mentioned by @jwong-quaver, pulling one of these records and immediately calling $contact->save()
will cause an exception.
I am running into this problem with billing/shipping addresses that use abbreviations rather than full state names.
Still happening in April 2020.
will result in a contact object with a tag_ids attribute, eg:
Then when you try to save the contact using:
You will get the following error:
As a workaround you can do this: