/** * @test */ public function testSerializationDeserialization() { $user = new PPOpenIdUserinfo(); $user->setAccountType("PERSONAL")->setAgeRange("20-30")->setBirthday("1970-01-01")->setEmail("*****@*****.**")->setEmailVerified(true)->setFamilyName("Doe")->setMiddleName("A")->setGivenName("John")->setLocale("en-US")->setGender("male")->setName("John A Doe")->setPayerId("A-XZASASA")->setPhoneNumber("1-408-111-1111")->setPicture("http://gravatar.com/me.jpg")->setSub("*****@*****.**")->setUserId("userId")->setVerifiedAccount(true)->setZoneinfo("America/PST"); $userCopy = new PPOpenIdUserinfo(); $userCopy->fromJson($user->toJSON()); $this->assertEquals($user, $userCopy); }
/** * @test */ public function testInvalidParamUserInfoCall() { $this->setExpectedException('PayPal\\Exception\\PPConnectionException'); PPOpenIdUserinfo::getUserinfo(array('access_token' => 'accessToken')); }
/** * returns user details * * @path /v1/identity/openidconnect/userinfo * @method GET * @param array $params (allowed values are access_token) * access_token - access token from the createFromAuthorizationCode / createFromRefreshToken calls * @param PPApiContext $apiContext Optional API Context * @return PPOpenIdUserinfo */ public static function getUserinfo($params, $apiContext = null) { static $allowedParams = array('schema' => 1); if (is_null($apiContext)) { $apiContext = new PPApiContext(); } if (!array_key_exists('schema', $params)) { $params['schema'] = 'openid'; } $requestUrl = "/v1/identity/openidconnect/userinfo?" . http_build_query(array_intersect_key($params, $allowedParams)); $call = new PPRestCall($apiContext); $ret = new PPOpenIdUserinfo(); $ret->fromJson($call->execute(array(new PPOpenIdHandler($apiContext)), $requestUrl, "GET", "", array('Authorization' => "Bearer " . $params['access_token'], 'Content-Type' => 'x-www-form-urlencoded'))); return $ret; }