Skip to content
Snippets Groups Projects
Commit b1c5b074 authored by jitendra's avatar jitendra
Browse files

Participant changes

parent d228a50d
Branches
Tags
No related merge requests found
......@@ -2,6 +2,9 @@
class CRM_Zapier_Page_Auth {
/**
* Authenticate CiviCRM on zapier account.
*/
public function run() {
$apiKey = CRM_Utils_Request::retrieveValue('apiKey', 'String', NULL, TRUE);
CRM_Utils_Request::retrieveValue('key', 'String', NULL, TRUE);
......
......@@ -20,38 +20,9 @@ class CRM_Zapier_Page_Contact {
}
public function run() {
// $inputJSON = file_get_contents('php://input');
// $input = json_decode($inputJSON, TRUE); //convert JSON into array
// $id = CRM_Utils_Request::retrieveValue('id', 'Integer', NULL, FALSE);
// if (empty($id)) {
// $contact = $this->sampleContact();
// }
// else {
// $contact = \Civi\Api4\Contact::get(FALSE)
// ->addWhere('id', '=', $id)
// ->execute()
// ->first();
// if (empty($contact['id'])) {
// $contact = $this->sampleContact();
// }
// }
$contact = $this->sampleContact();
// $contact = [
// 0 => [
// 'id' => '134',
// 'first_name' => 'Dummy4',
// 'last_name' => 'Dummy4',
// 'email' => 'dummy4@email.com',
// ]
// ];
CRM_Utils_JSON::output($contact);
CRM_Utils_System::civiExit();
}
// public static function createContact($id) {
// }
}
......@@ -2,23 +2,50 @@
class CRM_Zapier_Page_Participant {
public function run() {
$contact = [
0 => [
private function sampleParticipant() {
$participant = civicrm_api3('Participant', 'get', [
'sequential' => 1,
'options' => ['limit' => 1, 'sort' => "id DESC"],
])['values'][0] ?? NULL;
$contact = civicrm_api3('Contact', 'getsingle', [
'id' => $participant['contact_id'],
]);
if (!empty($contact)) {
$participant['contact_first_name'] = $contact['first_name'] ?? '';
$participant['contact_last_name'] = $contact['last_name'] ?? '';
$participant['contact_email'] = $contact['email'] ?? '';
}
if (empty($participant)) {
$participant = [
'id' => '134',
'contact_id' => 'John Doe',
'contact_first_name' => 'John',
'contact_last_name' => 'Doe',
'contact_email' => 'john.doe@example.com',
'event_id' => 'Fall Fundraiser Dinner',
'status_id' => 'Registered',
'role_id' => 'Volunteer',
'source' => 'created from zapier',
'fee_amount' => '100',
]
];
'event_title' => 'Fall Fundraiser Dinner',
'participant_status' => 'Registered',
'participant_role' => 'Volunteer',
'participant_source' => 'created from zapier',
'participant_fee_amount' => '100',
];
// $participant = [
// 'id' => '134',
// 'contact_id' => 'John Doe',
// 'contact_first_name' => 'John',
// 'contact_last_name' => 'Doe',
// 'contact_email' => 'john.doe@example.com',
// 'event_id' => 'Fall Fundraiser Dinner',
// 'status_id' => 'Registered',
// 'role_id' => 'Volunteer',
// 'source' => 'created from zapier',
// 'fee_amount' => '100',
// ];
}
return [$participant];
}
public function run() {
$contact = $this->sampleParticipant();
CRM_Utils_JSON::output($contact);
CRM_Utils_System::civiExit();
}
......
......@@ -2,6 +2,7 @@
class CRM_Zapier_Triggers_UpdateParticipant {
public function sendData($participantID, $params = []) {
$participant = civicrm_api3('Participant', 'get', [
'sequential' => 1,
......@@ -11,21 +12,26 @@ class CRM_Zapier_Triggers_UpdateParticipant {
'sequential' => 1,
'id' => $participant['contact_id'],
])['values'][0] ?? [];
if (!empty($contact)) {
$participant['contact_first_name'] = $contact['first_name'] ?? '';
$participant['contact_last_name'] = $contact['last_name'] ?? '';
$participant['contact_email'] = $contact['email'] ?? '';
}
$data = [
'id' => $participantID,
'contact_id' => $participant['display_name'] ?? '',
'contact_first_name' => $contact['first_name'] ?? '',
'contact_last_name' => $contact['last_name'] ?? '',
'contact_email' => $contact['email'] ?? '',
'event_id' => $participant['event_title'] ?? '',
'status_id' => $participant['participant_status'] ?? '',
'role_id' => $participant['participant_role'] ?? '',
'source' => $participant['participant_source'] ?? '',
'fee_amount' => $participant['participant_fee_amount'] ?? '',
];
// $data = [
// 'id' => $participantID,
// 'contact_id' => $participant['display_name'] ?? '',
// 'contact_first_name' => $contact['first_name'] ?? '',
// 'contact_last_name' => $contact['last_name'] ?? '',
// 'contact_email' => $contact['email'] ?? '',
// 'event_id' => $participant['event_title'] ?? '',
// 'status_id' => $participant['participant_status'] ?? '',
// 'role_id' => $participant['participant_role'] ?? '',
// 'source' => $participant['participant_source'] ?? '',
// 'fee_amount' => $participant['participant_fee_amount'] ?? '',
// ];
$hookURL = CRM_Zapier_Utils::getZapHook('update_participant');
CRM_Zapier_Utils::triggerZap('POST', $hookURL, $data);
CRM_Zapier_Utils::triggerZap('POST', $hookURL, $participant);
}
}
\ No newline at end of file
......@@ -52,11 +52,11 @@ class CRM_Zapier_Utils {
$contact = [
'id' => '134',
'contact_id' => 'John Doe',
'event_id' => 'Fall Fundraiser Dinner',
'status_id' => 'Registered',
'role_id' => 'Volunteer',
'source' => 'created from zapier',
'fee_amount' => '100',
'event_title' => 'Fall Fundraiser Dinner',
'participant_status' => 'Registered',
'participant_role' => 'Volunteer',
'participant_source' => 'created from zapier',
'participant_fee_amount' => '100',
];
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment