Example #1
1
 public function retrieveVoidedStatement($id)
 {
     $response = $this->sendRequest('GET', 'statements', array('params' => array('voidedStatementId' => $id)));
     if ($response->success) {
         $response->content = Statement::FromJSON($response->content);
     }
     return $response;
 }
Example #2
0
 public function retrieveStatement($id, $options = array())
 {
     if (!isset($options['voided'])) {
         $options['voided'] = false;
     }
     if (!isset($options['attachments'])) {
         $options['attachments'] = false;
     }
     $params = array();
     if ($options['voided']) {
         $params['voidedStatementId'] = $id;
     } else {
         $params['statementId'] = $id;
     }
     if ($options['attachments']) {
         $params['attachments'] = 'true';
     }
     $response = $this->sendRequest('GET', 'statements', array('params' => $params));
     if ($response->success) {
         if (is_array($response->content)) {
             $orig = $response->httpResponse['_multipartContent'] = $response->content;
             $response->content = Statement::FromJSON($orig[0]['body']);
             $attachmentsByHash = array();
             for ($i = 1; $i < count($orig); $i++) {
                 $attachmentsByHash[$orig[$i]['headers']['x-experience-api-hash']] = $orig[$i];
             }
             foreach ($response->content->getAttachments() as $attachment) {
                 $attachment->setContent($attachmentsByHash[$attachment->getSha2()]['body']);
             }
         } else {
             $response->content = Statement::FromJSON($response->content);
         }
     }
     return $response;
 }