Beispiel #1
0
 /**
  * Create a new user in your echosign account.
  * @param $firstName
  * @param $lastName
  * @param $email
  * @param $password
  * @return bool|mixed
  */
 public function create($firstName, $lastName, $email, $password)
 {
     $this->user = new Users($this->getToken(), $this->getTransport());
     $userInfo = new UserCreationInfo($firstName, $lastName, $email, $password);
     try {
         $this->response = $this->user->create($userInfo);
     } 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->getUserId();
 }
Beispiel #2
0
 public function testCreate()
 {
     $transport = new \Echosign\Transports\GuzzleTransport();
     $client = $transport->getClient();
     $json = '{"userId":"123446"}';
     $stream = Stream::factory($json);
     $mock = new Mock([new Response(200, ['content-type' => 'application/json'], $stream)]);
     $client->getEmitter()->attach($mock);
     $users = new Users('465789', $transport);
     $creationInfo = new UserCreationInfo('Fred', 'Flintstone', '*****@*****.**', '123rock');
     $response = $users->create($creationInfo);
     $this->assertInstanceOf('Echosign\\Responses\\UserCreationResponse', $response);
     $this->assertEquals('123446', $response->getUserId());
 }