From 47e7d2a668b2c5de49d5caf69e1432911ec687b2 Mon Sep 17 00:00:00 2001 From: Marc Michalsky forumZFD Date: Fri, 19 Feb 2021 16:11:28 +0100 Subject: [PATCH] add cid to TwingleCampaign.get and .getsingle specs --- api/v3/TwingleCampaign/Get.php | 15 +++++++++++++++ api/v3/TwingleCampaign/Getsingle.php | 8 ++++++++ 2 files changed, 23 insertions(+) diff --git a/api/v3/TwingleCampaign/Get.php b/api/v3/TwingleCampaign/Get.php index c573d59..cf1c42d 100644 --- a/api/v3/TwingleCampaign/Get.php +++ b/api/v3/TwingleCampaign/Get.php @@ -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 diff --git a/api/v3/TwingleCampaign/Getsingle.php b/api/v3/TwingleCampaign/Getsingle.php index 2f9c97c..42aa9b2 100644 --- a/api/v3/TwingleCampaign/Getsingle.php +++ b/api/v3/TwingleCampaign/Getsingle.php @@ -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'),