nfp365_crm_api
Security covered
NfP365 CRM API is a module for developers to integrate Drupal with NfP 365 CRM — Microsoft Dynamics 365 designed for the Non-for-Profit sector.
It provides connectivity to the following APIs offered by Mhance (a Microsoft Solutions Partner):
- WebAPI
- OpenAPI
Each API includes resources such as Donations, Orders, Campaigns, etc.
Setup
After installing the module, you must provide credentials for both the OpenAPI and WebAPI.
Go to: /admin/config/services/nfp365-crm-api and enter the required credentials.
Debug Mode
On the same configuration page (/admin/config/services/nfp365-crm-api), you can enable Debug Mode.
When Debug Mode is enabled, Drupal logs all requests and responses made using the API connection.
Examples
// Request via OpenApi client.
/* @var \Drupal\nfp365_crm_api\Http\OpenApiClient $openApi */
$openApi = \Drupal::service('nfp365_crm_api.manager')->getOpenApiClient();
$response = $openApi->paymentProcessors()->all();
foreach ($response->PaymentProcessors as $paymentProcessor) {
// Process each payment processor.
}
// Request via WebApi client.
/* @var \Drupal\nfp365_crm_api\Http\WebApiClient $webApi */
$webApi = \Drupal::service('nfp365_crm_api.manager')->getWebApiClient();
$response = $webApi->campaigns()->all();
$campaigns = $response->getData();
foreach ($campaigns as $campaign) {
// Process each campaign.
}
// Additional methods for $response are also available.
$response->getStatusCode(); // Returns HTTP status code (e.g., 200)
$response->getReasonPhrase(); // Returns HTTP reason phrase (e.g., 'OK')
// etc...
How to Add a New Resource
An example for OpenAPI:
- Create a class and place it in the
/src/Resources/OpenAPI/folder. You can find existing examples there for reference. - Add a new method to the
/src/Http/OpenApiClient.phpfile.