-
Notifications
You must be signed in to change notification settings - Fork 13
Open
Labels
Description
I noticed that all functions that call BaseApiAbstract->sendRequest() return bool. An example,
/**
* Returns a job.
*
* @param string $jobId
* @return bool
*/
public function getJob($jobId)
{
$requestData = $this->getDefaultRequestData('query', []);
$request = $this->prepareHttpRequest('jobs/' . $jobId, $requestData, self::HTTP_METHOD_GET);
return $this->sendRequest($request);
}But if you look at sendRequest() more close that it can return only:
- Some data (JSON or file body)
true- Exception
In example above we don't expect data, thus it means our function can return only true.
Such "contract" may confuse end-developer. If i see return bool then i add if () then statement in code. But actually i should add try catch.
So we should review SDK methods and remove return statement if it returns only a single value. Let's refactor only Jobs API because we don't use it yet.
DoD:
- Update following methods:
- createJob
- updateJob
- cancelJob
- listJobs
- getJob
- authorizeJob
- addFileToJob
- Update method documentation. Make it clear that it doesn't return value, but may throw exception
@throws \Smartling\Exceptions\SmartlingApiException