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);

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...