Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3
Excerpt
hiddentrue

The Component API plugin grants API access to core and plugin components through the API. This can be used to, among other things, download PDF invoices via the API.

Table of Contents
Table of Contents
maxLevel4
minLevel2
outlinetrue
classtoc

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

Warning
titleCompatibility 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
titleNote

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.

Code Block
languagebash
% 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.

Code Block
languagebash
% 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