/** * @param string $licenseId * @return LicenseInformation */ public function getLicenseInformation($licenseId) { $apiLicenseInformation = $this->connection->sendRequest('getLicense', ['licenseId' => $licenseId]); $licenseInformation = new LicenseInformation(); $licenseInformation->host = $apiLicenseInformation->host; $licenseInformation->customerName = $apiLicenseInformation->customer_name; $licenseInformation->email = $apiLicenseInformation->email; $licenseInformation->dateStart = $apiLicenseInformation->date_start; $licenseInformation->dateEnd = $apiLicenseInformation->date_end; $licenseInformation->type = $apiLicenseInformation->type; $licenseInformation->version = $apiLicenseInformation->version; $licenseInformation->packageName = $apiLicenseInformation->package_name; $licenseInformation->periodInMonths = $apiLicenseInformation->period_months; $licenseInformation->periodName = $apiLicenseInformation->period_name; $licenseInformation->limits = $apiLicenseInformation->limits; return $licenseInformation; }
/** * @test */ public function shouldDecodeResponse() { $httpClient = new Client(); $errorResponseMock = new Mock([new Response(200, [], Stream::factory('{}')), new Response(200, [], Stream::factory('{"foo":"bar"}'))]); $httpClient->getEmitter()->attach($errorResponseMock); $connection = new ApiConnection($httpClient, 'apiUrl', 'login', 'password'); $expectedResult = new stdClass(); $expectedResult->foo = 'bar'; $this->assertEquals($expectedResult, $connection->sendRequest('fooMethod', [])); }