gutterboy Posted May 15, 2014 Report Posted May 15, 2014 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? Quote
Tyson Posted May 15, 2014 Report Posted May 15, 2014 The first parameter is the model to call. Your example calls Invoices::add() to add a new invoice. Quote
gutterboy Posted May 15, 2014 Author Report Posted May 15, 2014 Awesome - thanks. How would I go about passing in multiple parameters, such as if I wanted to make a call to Invoices::edit() ? Quote
Tyson Posted May 15, 2014 Report Posted May 15, 2014 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); Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.