Open khairulashraff opened 8 years ago
Please add send for Invoice. I resolved it by copying request and just removing the content-type and json property on Guzzle.
From Clients.php
public function request2($method, $url, $body = [], $headers = []) {
$url = trim($url, '/');
$base_uri = $this->getBaseURL() . '/' . self::$company_id . '/';
$full_url = $base_uri . $url;
$signed = $this->sign($method, $full_url, [
'oauth_token' => self::$oauth_token
]);
$headers = array_merge([
'Accept' => 'application/json',
], $headers);
$response = (new Guzzle([
'base_uri' => $base_uri,
'headers' => [
'Accept' => $headers['Accept'],
'Authorization' => $signed['header']
],
]))->request($method, $url);
if ($headers['Accept'] == 'application/json') {
return json_decode((string) $response->getBody());
}
else {
return $response->getBody();
}
}
Please add send for Invoice. I resolved it by copying request and just removing the content-type and json property on Guzzle.
Thank you for the request @richardhdc. I have added the method. Call it via its service;
$service = new \Rangka\Quickbooks\Services\Invoice;
$serivce->send($invoiceID, $email); // email is optional
As a note, to add feature to a specific Service, edit its Service file. In this case Services/Invoice.php
.
@khairulashraff the service TaxService
is listed here but I can't find it in the source. How can I use it?
Thanks!
@khairulashraff the service
TaxService
is listed here but I can't find it in the source. How can I use it? Thanks!
I may have missed this due to Quickbooks' foolishness in handling their API. TaxService is not an actual object but just an API endpoint to create TaxCode and TaxRate. Their docs however only document how to create TaxCode and that what I have foolishly implemented for now, creating a TaxService will create a TaxCode instead. If you find any docs on creating TaxRate, do let me know.
My API will probably change once I got my hands on the TaxRate create docs.
@jbbr Here's how I create a TaxCode
namespace App\Repository\Quickbooks;
use \Rangka\Quickbooks\Services\Service as RangkaService;
class TaxService extends RangkaService {
/**
* Create a single item
* @param array $data Item information
* @return
*/
public function create($data) {
dd(parent::post($this->getResourceName(), $data)->{$this->getEntityName()});
}
/**
* Get Entity Name
*
* @return string
*/
public function getEntityName() {
return 'TaxCode';
}
/*
* Set Entity Name
*
* @param string $name
* @return null
*/
public function getResourceName()
{
return 'taxservice/taxcode';
}
}
//Invoice Model
class Invoice extends Model
public function createTaxCode() {
$service = new Repository\Quickbooks\TaxService();
$response = $service->create($this->getDefaultTaxServiceArray());
}
/*
* Add TaxService Array
*
* @param null
* @return null
*/
public function getDefaultTaxServiceArray()
{
return [
"TaxCode" => $this->getTaxCodeName(),
"TaxRateDetails" => [
[
"TaxRateName" => $this->getTaxRateName(),
"RateValue" => "0",
"TaxAgencyId" => $this->getTaxAgencyRef(),
"TaxApplicableOn" => "Sales"
]
]
];
}
}
@jbbr Here's how I create a TaxCode
I have no problem in creating TaxCode, just TaxRate as TaxService can create both TaxCode and TaxRate although only TaxCode was documented.
FYI, on an unrelated topic, don't override the getXXX
methods`. Override their statics instead. That's what they're for after all (the statics).
Ah agreed :+1:
Here is a list of services that are still being implemented.