add cid to TwingleCampaign.get and .getsingle specs

This commit is contained in:
Marc Michalsky forumZFD 2021-02-19 16:11:28 +01:00
parent fa093e4b68
commit 47e7d2a668
Signed by untrusted user who does not match committer: marc.koch
GPG key ID: 12406554CFB028B9
2 changed files with 23 additions and 0 deletions

View file

@ -19,6 +19,13 @@ function _civicrm_api3_twingle_campaign_Get_spec(array &$spec) {
'api.required' => 0,
'description' => E::ts('The Twingle Campaign ID'),
];
$spec['cid'] = [
'name' => 'cid',
'title' => E::ts('Twingle Campaign CID'),
'type' => CRM_Utils_Type::T_STRING,
'api.required' => 0,
'description' => E::ts('A unique identifier for a TwingleCampaign generated by a hashing its id + name'),
];
$spec['project_id'] = [
'name' => 'project_id',
'title' => E::ts('Parent Twingle Project ID'),
@ -132,6 +139,14 @@ function civicrm_api3_twingle_campaign_Get(array $params): array {
// Include campaign type ot TwingleCampaigns in $params
$params['campaign_type_id'] = $twingle_campaign_campaign_type_id;
// Translate cid custom field
if (array_key_exists('cid', $params) && !empty($params['cid'])) {
$cf_cid = Cache::getInstance()
->getCustomFieldMapping('twingle_campaign_cid');
$params[$cf_cid] = $params['cid'];
unset($params['cid']);
}
$campaigns = civicrm_api3('Campaign',
'get',
$params

View file

@ -17,6 +17,14 @@ function _civicrm_api3_twingle_campaign_Getsingle_spec(&$spec) {
'api.required' => 0,
'description' => E::ts('The Twingle Campaign ID'),
];
$spec['cid'] = [
'name' => 'cid',
'title' => E::ts('Twingle Campaign CID'),
'type' => CRM_Utils_Type::T_STRING,
'api.required' => 0,
'description' => E::ts('A unique identifier for a TwingleCampaign generated by a hashing its id + name'),
];
$spec['name'] = [
'name' => 'name',
'title' => E::ts('Campaign Name'),