mirror of
https://github.com/brunofontes/Memsource-API.git
synced 2025-12-13 04:40:42 -03:00
BilingualFile: added uploadBilingualFile
This commit is contained in:
@@ -42,9 +42,12 @@ class FetchApi
|
||||
$parameters = http_build_query($parameters);
|
||||
$url = $url . ($parameters ? '?'.$parameters : '');
|
||||
break;
|
||||
case 'put':
|
||||
$setopt = $this->getPutParam()+$this->getPostParam(implode("", $parameters));
|
||||
break;
|
||||
case 'post':
|
||||
$parameters = http_build_query($parameters);
|
||||
$setopt = $this->getPostParam($parameters);
|
||||
$setopt = $setopt + $this->getPostParam($parameters);
|
||||
break;
|
||||
case 'jsonPost':
|
||||
$setopt = $this->getJsonPostParam($parameters);
|
||||
@@ -67,7 +70,7 @@ class FetchApi
|
||||
];
|
||||
}
|
||||
|
||||
private function getJsonPostParam(array $postFields)
|
||||
private function getJsonPostParam(array $postFields = [])
|
||||
{
|
||||
return [
|
||||
CURLOPT_HTTPHEADER => ['Content-type: application/json'],
|
||||
@@ -76,7 +79,7 @@ class FetchApi
|
||||
];
|
||||
}
|
||||
|
||||
private function getPostParam(string $postFields)
|
||||
private function getPostParam(string $postFields = '')
|
||||
{
|
||||
return [
|
||||
CURLOPT_POST => true,
|
||||
@@ -84,6 +87,14 @@ class FetchApi
|
||||
];
|
||||
}
|
||||
|
||||
private function getPutParam()
|
||||
{
|
||||
return [
|
||||
CURLOPT_HTTPHEADER => ['Content-type: application/octet-stream'],
|
||||
CURLOPT_CUSTOMREQUEST => "PUT"
|
||||
];
|
||||
}
|
||||
|
||||
protected function curl(string $url, array $curl_extra_setopt = [])
|
||||
{
|
||||
if (empty($url)) {
|
||||
@@ -99,9 +110,9 @@ class FetchApi
|
||||
CURLOPT_TIMEOUT => 500,
|
||||
CURLOPT_FOLLOWLOCATION => true,
|
||||
CURLOPT_RETURNTRANSFER => true
|
||||
];
|
||||
] + $curl_extra_setopt;
|
||||
$curl = curl_init();
|
||||
curl_setopt_array($curl, ($curl_setopt + $curl_extra_setopt));
|
||||
curl_setopt_array($curl, $curl_setopt);
|
||||
$response = curl_exec($curl);
|
||||
curl_close($curl);
|
||||
return $response;
|
||||
|
||||
Reference in New Issue
Block a user