Forms.php 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. <?php
  2. namespace OntraportAPI;
  3. /**
  4. * Class Forms
  5. *
  6. * @author ONTRAPORT
  7. *
  8. * @package OntraportAPI
  9. */
  10. class Forms extends BaseApi
  11. {
  12. /**
  13. * $var string endpoint for single form
  14. */
  15. protected $_endpoint = "Form";
  16. /**
  17. * $var string endpoint for plural forms
  18. */
  19. protected $_endpointPlural = "Forms";
  20. /**
  21. * @param Ontraport $client
  22. */
  23. public function __construct(Ontraport $client)
  24. {
  25. parent::__construct($client);
  26. }
  27. /*
  28. * @TODO: This is just a placeholder, the API needs to be fixed to only use the new endpoint standards
  29. */
  30. private $_mainFormEndpoint = "form";
  31. // Form specific function endpoint
  32. const FORM_BLOCKS = "getAllFormBlocks";
  33. const FORM_BLOCKS_BY_NAME = "getBlocksByFormName";
  34. /**
  35. * @brief Retrieve a single specified form
  36. *
  37. * @param mixed[] $requestParams The parameters to submit with GET request.
  38. * Possible array keys: "id" (required)
  39. *
  40. * @return string JSON formatted response
  41. */
  42. public function retrieveSingle($requestParams)
  43. {
  44. return parent::_retrieveSingle($requestParams);
  45. }
  46. /**
  47. * @brief Retrieve multiple forms according to specific criteria, handle pagination
  48. *
  49. * @param mixed[] $requestParams Array of parameters to submit with GET request. All parameters are optional but if "ids"
  50. * are not specified, all will be selected.
  51. * Possible array keys: "ids","start","range","sort","sortDir","condition","search",
  52. * "searchNotes","group_ids","performAll","externs","listFields"
  53. *
  54. * @return string JSON formatted array of response data: each page of data will be an element in that array
  55. */
  56. public function retrieveMultiplePaginated($requestParams)
  57. {
  58. return parent::_retrieveMultiplePaginated($requestParams);
  59. }
  60. /**
  61. * @brief Retrieve multiple forms according to specific criteria
  62. *
  63. * @param mixed[] $requestParams Array of parameters to submit with GET request. All parameters are optional but if "ids"
  64. * are not specified, all will be selected.
  65. * Possible array keys: "ids","start","range","sort","sortDir","condition","search",
  66. * "searchNotes","group_ids","performAll","externs","listFields"
  67. *
  68. * @return string JSON formatted response
  69. */
  70. public function retrieveMultiple($requestParams)
  71. {
  72. return parent::_retrieveMultiple($requestParams);
  73. }
  74. /**
  75. * @brief Retrieve information (such as number of forms) about form collection
  76. *
  77. * @param mixed[] $requestParams Array of parameters to submit with GET request. All parameters are optional.
  78. * Possible array keys: "condition","search","searchNotes","group_ids","performAll"
  79. *
  80. * @return string JSON formatted response
  81. */
  82. public function retrieveCollectionInfo($requestParams)
  83. {
  84. return parent::_retrieveCollectionInfo($requestParams);
  85. }
  86. /**
  87. * @brief Retrieve meta for a form object
  88. *
  89. * @return string JSON formatted response
  90. */
  91. public function retrieveMeta()
  92. {
  93. return parent::_retrieveMeta();
  94. }
  95. /**
  96. * @brief Retrieve HTML for a Smart Form
  97. *
  98. * @param mixed[] $requestParams Array of parameters to submit with GET request.
  99. * Possible array keys: "id" (required)
  100. *
  101. * @return string JSON formatted response
  102. */
  103. public function retrieveSmartFormHTML($requestParams)
  104. {
  105. $requiredParams = array("id");
  106. return $this->client->request($requestParams, $this->_mainFormEndpoint, "get", $requiredParams, $options = NULL);
  107. }
  108. /**
  109. * @brief Retrieve name and ID pairs for form blocks
  110. *
  111. * @param mixed[] $requestParams Array of parameters to submit with GET request.
  112. * Possible array keys: "page"
  113. *
  114. * @return string JSON formatted response
  115. */
  116. public function retrieveFormBlocks($requestParams = NULL)
  117. {
  118. return $this->client->request($requestParams, $this->_endpoint . "/" . self::FORM_BLOCKS, "get", NULL, $options = NULL);
  119. }
  120. /**
  121. * @brief Retrieve name and ID pairs for form blocks
  122. *
  123. * @param mixed[] $requestParams Array of parameters to submit with GET request.
  124. * Possible array keys: "page"
  125. *
  126. * @return string JSON formatted response
  127. */
  128. public function retrieveBlocksByForm($requestParams)
  129. {
  130. $requiredParams = array("name");
  131. return $this->client->request($requestParams, $this->_endpoint . "/" . self::FORM_BLOCKS_BY_NAME, "get", $requiredParams, $options = NULL);
  132. }
  133. }