CWIS Developer Documentation

- Home
- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | List of all members
RestAPIHelper Class Reference

This class provides a general-purpose library for encrypted REST calls and responses. More...

## Public Member Functions
| __construct ($APIUrl, $APIPassword, $CheckForDuplicateFn, $RegisterMessageFn)
| Constructor. More...
| DoRestCommand ($Params)
| Run a REST API command against a remote site. More...
| EncodeEncryptedMessage ($Data)
| Construct an encrypted message packet from provided data. More...
| DecodeEncryptedMessage ($PostData)
| Decrypt an encrypted message packet. More...

## Detailed Description

This class provides a general-purpose library for encrypted REST calls and responses.

It is intended both for use in CWIS and for use in CWIS-companion plugins for other systems (e.g., the cwis_user Drupal plugin that takes to the CWIS DrupalSync plugin). As such, functions in this class should not use CWIS objects (StdLib, Database, CWUser, etc) that won't be available in other environments.

Definition at line 19 of file RestAPIHelper.php.

## Constructor & Destructor Documentation

RestAPIHelper::__construct | ( |  | $APIUrl,
|  |  | $APIPassword,
|  |  | $CheckForDuplicateFn,
|  |  | $RegisterMessageFn
| ) |  |

Constructor.

Parameters

  string | $APIUrl | Url to which REST calls will be directed.
  string | $APIPassword | Password for encrypting and authenticating rest calls.
  callable | $CheckForDuplicateFn | Function to check for duplicated messages.
  callable | $RegisterMessageFn | Function to register a message as received.

Definition at line 31 of file RestAPIHelper.php.

## Member Function Documentation

RestAPIHelper::DecodeEncryptedMessage | ( |  | $PostData | ) |

Decrypt an encrypted message packet.

Parameters

  array | $PostData | Encrypted data.

Returns
  array Result, always has a "Status" member that will either be "OK" on success or "Error". In the case of an error, there will also be a "Message" giving a description of the issue. On success, there will be a "Data" member giving the decrypted payload.

Definition at line 155 of file RestAPIHelper.php.

Referenced by DoRestCommand().

Here is the caller graph for this function:

RestAPIHelper::DoRestCommand | ( |  | $Params | ) |

Run a REST API command against a remote site.

Parameters

  array | $Params | REST API call parameters (often from $_POST).

Returns
  response from the remote site (format depends on the command issued) or NULL on command failure.

Definition at line 46 of file RestAPIHelper.php.

References DecodeEncryptedMessage(), and EncodeEncryptedMessage().

RestAPIHelper::EncodeEncryptedMessage | ( |  | $Data | ) |

Construct an encrypted message packet from provided data.

Parameters

  array | $Data | Data to encapsulate

Returns
  array Encrypted packet

Definition at line 100 of file RestAPIHelper.php.

Referenced by DoRestCommand().

Here is the caller graph for this function:

The documentation for this class was generated from the following file:

- objects/RestAPIHelper.php