addOrUpdateDeliveryGroup
The addOrUpdateDeliveryGroup
function allows you to add a delivery group if it is new, or update the delivery group if it already exists.
Syntax
writeResult = bApi.addOrUpdateDeliveryGroup(deliveryGroupObject[] deliveryGroup);
Required and Optional Message Object Attributes
Name | Type | Required | Description |
---|---|---|---|
id |
string | Required if no name is given. | The unique id for the delivery group. |
name |
string | Required if no id is given. | The name associated with the delivery group. |
deliveryIds[] |
string | No | An array of the delivery ids you want to associate with the delivery group. |
messageRuleIds[] |
string | No | An array of the automated message rule ids you want to associate with the delivery group. |
messageIds[] |
string | No | An array of the message ids you want to associate with the delivery group. |
PHP Code Example
<?php /** * This example will add the delivery group if it is new, and update * the delivery group if it already exists. */ $client = new SoapClient('https://api.bronto.com/v4?wsdl', array('trace' => 1, 'features' => SOAP_SINGLE_ELEMENT_ARRAYS)); setlocale(LC_ALL, 'en_US'); try { // Add in a valid API token $token = "ADD API TOKEN HERE"; print "logging in\n"; $sessionId = $client->login(array('apiToken' => $token))->return; $session_header = new SoapHeader("http://api.bronto.com/v4", 'sessionHeader', array('sessionId' => $sessionId) ); $client->__setSoapHeaders(array($session_header)); // Be sure to replace the generic values below $deliveryIds = array('SOME DELIVERY ID'); $deliveryGroupObject = array('name' => 'SOME DELIVERY GROUP', 'deliveryIds' => $deliveryIds); $write_result = $client->addOrUpdateDeliveryGroup(array($deliveryGroupObject))->return; if ($write_result->errors) { print "There was a problem adding or updating the delivery group:\n"; print_r($write_result->results); } elseif ($write_result->results[0]->isNew == true) { print "The delivery group has been created. Id: " . $write_result->results[0]->id . "\n"; } else { print "The delivery group has been updated. Id: " . $write_result->results[0]->id . "\n"; } } catch (Exception $e) { print "uncaught exception\n"; print_r($e); } ?>