infusionsoft / infusionsoft-php

PHP client library for the Infusionsoft API.
https://developer.infusionsoft.com/
Other
130 stars 128 forks source link

Fixed REST applying tags for contacts #276

Closed Proxxx23 closed 3 years ago

Proxxx23 commented 3 years ago

This fixes method that is responsible for this REST path: https://developer.infusionsoft.com/docs/rest/#!/Tags/applyTagToContactIdsUsingPOST

The problem was, method TagService::addContacts() pointed to URI: /tags/contacts but should point to /tags/{tagId}/contacts. TagId param was missing.

Also, i've changed if/elseif behaviour for better readability and adde missing doc, as you do not want to use typed params AFAIK.

bbooth commented 3 years ago

I don't think this should have been merged. Tag ID should be passed into the function. It was correct the way it was as far as I know. There are other functions in the same file that use the current paradigm.

Proxxx23 commented 3 years ago

@bbooth But... how? There's no tagId param, and the REST path is invalid in addContacts method. See: Infusionsoft\Api\Rest\TagSerbice.php. There's no way to add contact(s) to tag here, in a REST way. In any way...

I've added tagId param, as you've mentioned: "Tag ID should be passed into the function.". Should be, but is not passed...

bbooth commented 3 years ago
    $tagService = $infusionsoft->tags();
    $tag = $tagService->find(91);
    $result = $tag->addContacts([2059]);

or if you don't want to fetch the tag first

    $tagService = $infusionsoft->tags();
    $tagService->setAttribute('id', 91);
    $result = $tagService->addContacts([2059]);