Jump to content

Recommended Posts

Posted

I have been looking over the API docs and found an example such as:

$api = new BlestaApi($url, $user, $key);
 
$data = array(
    'vars' => array(
        'client_id' => 1,
        'date_billed' => date("c"),
        'date_due' => date("c"),
        'currency' => "USD",
        'lines' => array(
            array(
                'description' => "Line item #1",
                'amount' => "5.99"
            ),
            array(
                'description' => "Line item #2",
                'amount' => "3.75",
                'qty' => 2
            )
        ),
        'delivery' => array("email")
    )
);

$response = $api->post("invoices", "add", $data);

From what I can tell the "add" parameter we are passing in is the method we want to run from the invoices class and the $data is obviously the parameters we want to pass in the call to 'add()', but what is the first parameter? The class name I assume?

Posted

Set it in the array you pass as parameters. Invoices::edit() is mostly the same as adding, but specifies the invoice ID to edit. Note that the name and order of the data is important.

$api = new BlestaApi($url, $user, $key);
 
$data = array(
    'invoice_id' => 17,
    'vars' => array(
        'client_id' => 1,
        'date_billed' => date("c"),
        'date_due' => date("c"),
        'currency' => "USD",
        'lines' => array(
            array(
                'description' => "Line item #1",
                'amount' => "5.99"
            ),
            array(
                'description' => "Line item #2",
                'amount' => "3.75",
                'qty' => 2
            )
        ),
        'delivery' => array("email")
    )
);

$response = $api->post("invoices", "add", $data);

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...