Metadata.php 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. class Mandrill_Metadata {
  3. public function __construct(Mandrill $master) {
  4. $this->master = $master;
  5. }
  6. /**
  7. * Get the list of custom metadata fields indexed for the account.
  8. * @return array the custom metadata fields for the account
  9. * - return[] struct the individual custom metadata field info
  10. * - name string the unique identifier of the metadata field to update
  11. * - state string the current state of the metadata field, one of "active", "delete", or "index"
  12. * - view_template string Mustache template to control how the metadata is rendered in your activity log
  13. */
  14. public function getList() {
  15. $_params = array();
  16. return $this->master->call('metadata/list', $_params);
  17. }
  18. /**
  19. * Add a new custom metadata field to be indexed for the account.
  20. * @param string $name a unique identifier for the metadata field
  21. * @param string $view_template optional Mustache template to control how the metadata is rendered in your activity log
  22. * @return struct the information saved about the new metadata field
  23. * - name string the unique identifier of the metadata field to update
  24. * - state string the current state of the metadata field, one of "active", "delete", or "index"
  25. * - view_template string Mustache template to control how the metadata is rendered in your activity log
  26. */
  27. public function add($name, $view_template=null) {
  28. $_params = array("name" => $name, "view_template" => $view_template);
  29. return $this->master->call('metadata/add', $_params);
  30. }
  31. /**
  32. * Update an existing custom metadata field.
  33. * @param string $name the unique identifier of the metadata field to update
  34. * @param string $view_template optional Mustache template to control how the metadata is rendered in your activity log
  35. * @return struct the information for the updated metadata field
  36. * - name string the unique identifier of the metadata field to update
  37. * - state string the current state of the metadata field, one of "active", "delete", or "index"
  38. * - view_template string Mustache template to control how the metadata is rendered in your activity log
  39. */
  40. public function update($name, $view_template) {
  41. $_params = array("name" => $name, "view_template" => $view_template);
  42. return $this->master->call('metadata/update', $_params);
  43. }
  44. /**
  45. * Delete an existing custom metadata field. Deletion isn't instataneous, and /metadata/list will continue to return the field until the asynchronous deletion process is complete.
  46. * @param string $name the unique identifier of the metadata field to update
  47. * @return struct the information for the deleted metadata field
  48. * - name string the unique identifier of the metadata field to update
  49. * - state string the current state of the metadata field, one of "active", "delete", or "index"
  50. * - view_template string Mustache template to control how the metadata is rendered in your activity log
  51. */
  52. public function delete($name) {
  53. $_params = array("name" => $name);
  54. return $this->master->call('metadata/delete', $_params);
  55. }
  56. }