Exemple #1
0
 /**
  * Create a new search request based on date range. If successful, it returns all events for given date range.
  * @param \DateTime $startDate
  * @param \DateTime $endDate
  * @param null $userId
  * @param null $userEmail
  * @return array|bool
  */
 public function create(\DateTime $startDate, \DateTime $endDate, $userId = null, $userEmail = null)
 {
     $this->search = new SearchRequest($this->getToken(), $this->getTransport());
     $eventRequest = new AgreementAssetEventRequest($startDate, $endDate);
     try {
         $this->response = $this->search->create($eventRequest, $userId, $userEmail);
     } catch (JsonApiResponseException $e) {
         $this->errorMessages[$e->getCode()] = sprintf('%s - %s', $e->getApiCode(), $e->getMessage());
         return false;
     } catch (\Exception $e) {
         $this->errorMessages[$e->getCode()] = $e->getMessage();
         return false;
     }
     return $this->response->getEvents();
 }
Exemple #2
0
 public function testCreate()
 {
     $transport = new \Echosign\Transports\GuzzleTransport();
     $client = $transport->getClient();
     // mock the request
     $json = '{
       "events": [
         {
           "agreementAssetId": "2BAABLblqZhARJcIh9hAZIrdTii8G2wvQzCNPWf9x7Mb83vrC6TzIlBunHE2m9f-qenIfQ9Vl2aE*",
           "agreementAssetName": "grid math.pdf",
           "agreementAssetType": "agreement",
           "documentHistoryEvent": {
             "actingUserEmail": "*****@*****.**",
             "date": "2014-10-21T09:40:00-07:00",
             "description": "Sent out for signature to test@gmail.com",
             "participantEmail": "*****@*****.**",
             "type": "SIGNATURE_REQUESTED"
           }
         }
       ],
       "nextPageCursor": "",
       "currentPageCursor": "BwELAQYAAgEAAAICABC3ZbmoWj1h0-Yh4J_rTKgWDqg3GHWhshZTliKBxcTxfLM6jDjlKoH4Kg**",
       "searchId": "2ABAsBLblqZhD5AFD8c2jjh4rkc4Ljb6V0_2j_i2DFRfpnfI0C6nzsgStRyv7jBh1oDbbTD3QbhIgEJ8NtBcmcd0absBPfr5-AA5wf_WPVQcN-nNOK61RDU1qS96nqpLYupWJxdViVilM*"
     }';
     $jsonArray = json_decode($json, true);
     $stream = Stream::factory($json);
     $mock = new Mock([new Response(200, ['content-type' => 'application/json'], $stream)]);
     $client->getEmitter()->attach($mock);
     $search = new Search('123465', $transport);
     $assetRequest = new AgreementAssetEventRequest(new DateTime(), new DateTime(), 2, true);
     $response = $search->create($assetRequest);
     $this->assertInstanceOf('Echosign\\Responses\\AgreementAssetEventPostResponse', $response);
     $events = $response->getEvents();
     $this->assertEquals(1, count($events));
     $this->assertEquals($jsonArray['currentPageCursor'], $response->getCurrentPageCursor());
     $this->assertEquals($jsonArray['searchId'], $response->getSearchId());
 }