Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

APIv4 - Add activity contacts to APIv4 field spec #17766

Merged
merged 1 commit into from
Jul 14, 2020

Conversation

colemanw
Copy link
Member

@colemanw colemanw commented Jul 6, 2020

Overview

The BAO supports these pseudo-fields during save operations, this exposes them to the api explorer.

Before

Activity-contact params not discoverable.

After

Activity-contact params discoverable.

Comments

This was based on discussion in https://chat.civicrm.org/civicrm/pl/wnuxuef3ppgt8q5jtdsa5kjsqh

@civibot
Copy link

civibot bot commented Jul 6, 2020

(Standard links)

@civibot civibot bot added the master label Jul 6, 2020
@colemanw colemanw force-pushed the activityContacts branch from 618f722 to 5391789 Compare July 6, 2020 22:21
@aydun
Copy link
Contributor

aydun commented Jul 7, 2020

I've tested creating activities specifying targets and assignees and all works as expected.

Although targets and assignees are specified as arrays, both also work with integer values when adding a single target or assignee which is handy in some situations. So addValue('target_contact_id', [ 3 ]) and addValue('target_contact_id', 3) both work. Can we get that documented as supported behaviour? Or if we don't want to support it, enforce from the beginning that it must be an array.

@colemanw
Copy link
Member Author

colemanw commented Jul 7, 2020

I'm thinking about the relative merits of enforcing data type on input fields in general.
For some data types like numbers, it makes sense for the api to accept 123, but I would argue strings like "123" are also acceptable.
For boolean fields, I think there's too much historical acceptance (and encouragement in basically all the APIv3 docs) of strings "1" and "0" as interchangeable for true and false so I'd be very reluctant to enforce data types there.
And for arrays that could also take a single value... dunno. We should probably add a unit test though.

@aydun
Copy link
Contributor

aydun commented Jul 8, 2020

I prefer the liberal approach so accepting a single value in place of an array is fine for me. I had a look at the existing unit tests and tried changing api_v3_ActivityTest::testActivityReturnTargetAssignee() to use @dataProvider versionThreeAndFour. The creation works but the test fails since target and assignee are not returned by Activity.get in Api4. Can we add those?

@eileenmcnaughton
Copy link
Contributor

@colemanw I don't have any concerns here- please merge once you and @aydun are in agreement...

@colemanw
Copy link
Member Author

colemanw commented Jul 9, 2020

I like the symmetry of having those pseudofields available for get but don't like much else about it. The api3 implementation is problematic and in general I'm trying to avoid klunky stuff in apiv4. Working on a different approach that will be more search-builder friendly.

@eileenmcnaughton
Copy link
Contributor

@colemanw is there test cover? (I'm going through tagging ones with tests & ok without tests - not sure where this fits)

@colemanw
Copy link
Member Author

This passes half the api3 test. I guess we could just include the part that works... I'll add that.

The BAO supports these pseudo-fields during save operations, this exposes them to the api explorer.
@colemanw
Copy link
Member Author

Ok I've added test coverage for what we've got. This should be mergable now.

@colemanw colemanw added the merge ready PR will be merged after a few days if there are no objections label Jul 14, 2020
@colemanw
Copy link
Member Author

Retest this please

@colemanw
Copy link
Member Author

Unrelated test fail

@colemanw colemanw merged commit cff3d6a into civicrm:master Jul 14, 2020
@colemanw colemanw deleted the activityContacts branch July 14, 2020 13:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
has-test master merge ready PR will be merged after a few days if there are no objections
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants