'twingle_api_key', 'title' => E::ts('Twingle API key'), 'type' => CRM_Utils_Type::T_STRING, 'api.required' => 0, 'description' => E::ts('The key to access the Twingle API'), ]; $spec['limit'] = [ 'name' => 'limit', 'title' => E::ts('Limit'), 'type' => CRM_Utils_Type::T_INT, 'api.required' => 0, 'description' => E::ts('Limit for the number of events that should get requested per call to the Twingle API'), ]; $spec['is_test'] = [ 'name' => 'is_test', 'title' => E::ts('Test'), 'type' => CRM_Utils_Type::T_BOOLEAN, 'api.required' => 0, 'description' => E::ts('If this is set true, no database change will be made'), ]; } /** * # TwingleSync.Sync API * This API synchronizes all *TwingleProject* and *TwingleEvent* campaigns. * * @param array $params * * @return array * API result descriptor * * @throws CiviCRM_API3_Exception * @see civicrm_api3_create_success */ function civicrm_api3_twingle_sync_Sync(array $params): array { $result_values = []; unset($params['sequential']); // Synchronize all TwingleProject campaigns $projects = civicrm_api3( 'TwingleProject', 'sync', $params )['values']; // Synchronize all TwingleEvent campaigns foreach ($projects as $project) { if (is_array($project)) { $_params = $params; $_params['project_id'] = $project['project_id']; $result_values[] = [ 'project' => $project, 'events' => array_values( civicrm_api3( 'TwingleEvent', 'sync', $_params )['values'] ), ]; } } return civicrm_api3_create_success($result_values); }