public static function documentDetails($client, $documentGuid)
 {
     $xml = $client->get(sprintf('/api/documents/%s.xml', $documentGuid));
     $array = ArrayHelpers::normaliseKeys(XmlHelpers::toArray($xml));
     $array = ArrayHelpers::collapseGroup($array, 'audit_trail');
     $array = ArrayHelpers::collapseGroup($array, 'form_fields');
     $array = ArrayHelpers::collapseGroup($array, 'recipients');
     $array = ArrayHelpers::collapseGroup($array, 'pages');
     return new self($array);
 }
示例#2
0
 /**
  * Creates an intermediate document via the Prepackage Template call.
  *
  * @see https://rightsignature.com/apidocs/api_calls?api_method=prepackageTemplate
  *
  * @param object $client       HTTP client
  * @param string $templateGuid template GUID
  * @param string $callbackUrl  optional callback URL
  *
  * @return RightSignature\PrepackagedDocument
  */
 public static function prepackage($client, $templateGuid, $callbackUrl = null)
 {
     $payload = $callbackUrl ? "<callback_location>{$callbackUrl}</callback_location>" : null;
     $xml = $client->post("/api/templates/{$templateGuid}/prepackage.xml", $payload);
     $array = ArrayHelpers::normaliseKeys(XmlHelpers::toArray($xml));
     $array = ArrayHelpers::collapseGroup($array, 'merge_fields');
     $array = ArrayHelpers::collapseGroup($array, 'roles');
     $array = ArrayHelpers::collapseGroup($array, 'pages');
     return new PrepackagedDocument($client, $array);
 }
示例#3
0
 /**
  * This method is for sending a once-off document that has not been setup as a Template.
  *
  * @param string $path    Absolute path of the document
  * @param array  $payload Payload of the request
  *
  * @return array XML response parsed to array
  *
  * @throws Exception Missing required key
  */
 public static function send($client, $path, $payload)
 {
     // validation of required arguments
     foreach (['action', 'type', 'recipients'] as $argument) {
         ArrayHelpers::ensureIsSet($payload, $argument);
     }
     $info = pathinfo($path);
     $payload['document_data'] = ['type' => $payload['type'], 'value' => $path];
     // change the underlying document (url, base64)
     if ('base64' == $payload['type']) {
         $payload['document_data']['filename'] = $info['basename'];
         // get the resource content
         $resource = fopen($path, 'r');
         $content = fread($resource, filesize($path));
         fclose($resource);
         $payload['document_data']['value'] = base64_encode($content);
     }
     // make the request
     $payload = XmlHelpers::toXml(['document' => $payload]);
     $response = $client->post('/api/documents.xml', $payload);
     return XmlHelpers::toArray($response);
 }
示例#4
0
 public static function parse($xml)
 {
     return new self(ArrayHelpers::normaliseKeys(XmlHelpers::toArray($xml)));
 }
 /**
  * Structurally compares two XML strings.
  */
 public function assertEqualXml($a, $b)
 {
     $this->assertEquals(XmlHelpers::toArray($a), XmlHelpers::toArray($b));
 }
 /**
  * Parse the XML response of a Prefill Template call.
  */
 private static function _parsePrefillResponse($xml)
 {
     $array = ArrayHelpers::normaliseKeys(XmlHelpers::toArray($xml));
     $array = ArrayHelpers::collapseGroup($array, 'merge_fields');
     $array = ArrayHelpers::collapseGroup($array, 'roles');
     $array = ArrayHelpers::collapseGroup($array, 'pages');
     return $array;
 }
 /**
  * Return new instance with error message extracted from XML response.
  *
  * @param string $xml
  *
  * @return InvalidRequest
  */
 public static function fromXml($xml)
 {
     $data = \RightSignature\Util\XmlHelpers::toArray($xml);
     return new self($data['message']);
 }