Skip to content

Commit

Permalink
create customer
Browse files Browse the repository at this point in the history
  • Loading branch information
lukecurtis93 committed Feb 9, 2019
1 parent 381ba1c commit 8fd44ce
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/Models/BaseModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ public function __construct()
if(MyobConfiguration::first()) {
$myobConfiguration = MyobConfiguration::first();
$this->myobRequest = new MyobRequest([
'Authorization' => 'Bearer '.$myobConfiguration->access_token,
'Authorization' => 'Bearer '.$myobConfiguration->access_token,
'x-myobapi-version' => 'v2',
'x-myobapi-key' => config('laramyob.client_id'),
'x-myobapi-key' => config('laramyob.client_id'),
'x-myobapi-cftoken' => $myobConfiguration->company_file_token,
'Accept' => 'application/json',
'Content-Type' =>'application/json',
'Accept' => 'application/json',
'Content-Type' =>'application/json',
]);
$this->baseurl = MyobConfiguration::first()->company_file_uri;
} else {
Expand Down
7 changes: 5 additions & 2 deletions src/Request/MyobRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,12 @@ public function setHttpClient(Client $client)
*/
public function sendPostRequest($endpoint, $data)
{
return $this->getHttpClient()->post($endpoint, [
//For refreshing token we can't encode the form
//And we also have to tell MYOB to return the created object
$params = $data['form_params'] ?? json_encode($data);
return $this->getHttpClient()->post($endpoint.'?returnBody=true', [
'headers' => empty($this->httpConfig) ? $data['headers'] : $this->httpConfig,
'form_params' => $data['form_params'] ?? $data,
'body' => $params,
]);
}

Expand Down

0 comments on commit 8fd44ce

Please sign in to comment.