Page tree
Skip to end of metadata
Go to start of metadata
Table of Contents

Installing Component API

The Component API plugin can be installed under [Settings] > [Company] > [Plugins] > [Available].

Configuring Component API

Nothing to configure.

Using Component API

The Component API extends the API by offering a new model method capable of being invoked. This is a wrapper for every core and plugin component installed in the system. Consult the documentation for the component you are attempting to invoke through the API for details on the required parameters

Compatibility Warning

Components are internal objects to Blesta and its respective plugins. Blesta makes no effort to ensure backwards compatibility for components, so the functionality (parameters and return results) of any and all methods executed through this plugin may change at any time.

 

This plugin has a single model called ComponentApiCaller, which itself has a single callable method called call. Below are the parameters available to this method:

 

ParameterDescription
componentA string, the name of the component you wish to invoke (e.g. InvoiceDelivery)
methodA string, the name of the method to invoke for the given component (e.g. DownloadInvoices)
paramsAn array of parameters (each key is the name of the parameter) to pass to the component method
construct_params

An array of parameters to pass to the constructor, numerically indexed in the order required by the component constructor. Only required if the component requires parameters to its constructor.

Note

Note all components may be invoked via the API due to requirements for constructor and method parameters. Consult the documentation for the component you wish to invoke.

Example

This example demonstrates how to download an invoice through the API. In this example the invoice ID is 1. Note that invoice_ids is an index of the params array. This is because the InvoiceDelivery component requires an invoice_ids parameters to the downloadInvoices method.

% cd /path/to/blesta/
% php index.php api/ComponentApi.ComponentApiCaller/call.json -u USER -k KEY -m GET -p "component=InvoiceDelivery&method=downloadInvoices&params[invoice_ids][0]=1" > invoice_1.pdf

This example pulls invoice ID 1 and 2 in a single download.

% cd /path/to/blesta/
% php index.php api/ComponentApi.ComponentApiCaller/call.json -u USER -k KEY -m GET -p "component=InvoiceDelivery&method=downloadInvoices&params[invoice_ids][0]=1&params[invoice_ids][1]=2" > invoice_1-2.pdf
  • No labels