12 global $wgDonationInterfaceCiviproxyURLBase;
14 $client =
new GuzzleHttp\Client();
18 "$wgDonationInterfaceCiviproxyURLBase/rest.php",
20 'entity' =>
'civiproxy',
21 'action' =>
'getpreferences',
22 'key' => self::SITE_KEY_KEY,
23 'api_key' => self::API_KEY_KEY,
26 'checksum' => $checksum,
27 'contact_id' => $contact_id
33 $rawResp = $resp->getBody()->getContents();
34 $resp = json_decode( $rawResp,
true );
37 throw new RuntimeException(
"Invalid JSON from CiviProxy for id $contact_id" );
41 'country' => $resp[
'country' ] ??
null,
42 'sendEmail' => $resp[
'is_opt_in' ] ??
null,
43 'email' => $resp[
'email' ],
44 'first_name' => $resp[
'first_name' ],
45 'preferred_language' => $resp[
'preferred_language' ] ??
null,
46 'is_error' => ( $resp[
'is_error' ] === 1 ),
47 'error_message' => $resp[
'error_message' ] ??
null
50 }
catch ( Exception $e ) {
52 'CiviproxyConnector',
true,
false,
'',
null );
54 $logger->error(
"contact id: $contact_id, " . $e->getMessage() );
57 'error_message' => $e->getMessage()