Skip to content
This repository has been archived by the owner on Jul 19, 2022. It is now read-only.

Service Implementation. #1

Open
khairulashraff opened this issue Jun 11, 2016 · 7 comments
Open

Service Implementation. #1

khairulashraff opened this issue Jun 11, 2016 · 7 comments

Comments

@khairulashraff
Copy link
Contributor

khairulashraff commented Jun 11, 2016

Here is a list of services that are still being implemented.

  • Account
    • - Create
    • - Read
    • - Update
  • Attachable
    • - Create
    • - Read
    • - Update
    • - Delete
  • Batch
    • - BatchRequest
  • Bill
    • - Create
    • - Read
    • - Update
    • - Delete
  • BillPayment
    • - Create
    • - Read
    • - Update
    • - Delete
  • Budget
    • - Create
    • - Read
    • - Update
  • ChangeDataCapture
    • - ChangeDataCapture
  • Class
    • - Create
    • - Read
    • - Update
  • CompanyInfo
    • - Read
  • CreditMemo
    • - Create
    • - Read
    • - Update
    • - Delete
  • Customer
    • - Create
    • - Read
    • - Update
  • Department
    • - Create
    • - Read
    • - Update
  • Deposit
    • - Create
    • - Read
    • - Update
    • - Delete
  • Employee
    • - Create
    • - Read
    • - Update
  • Estimate
    • - Create
    • - Read
    • - Update
    • - Delete
  • Invoice
    • - Create
    • - Read
    • - Update
    • - Delete
  • Item
    • - Create
    • - Read
    • - Update
  • JournalEntry
    • - Create
    • - Read
    • - Update
    • - Delete
  • Payment
    • - Create
    • - Read
    • - Update
    • - Delete
  • PaymentMethod
    • - Create
    • - Read
    • - Update
  • Preferences
    • - Read
    • - Update
  • Purchase
    • - Create
    • - Read
    • - Update
    • - Delete
  • PurchaseOrder
    • - Create
    • - Read
    • - Update
    • - Delete
  • RefundReceipt
    • - Create
    • - Read
    • - Update
    • - Delete
  • Reports
    • - Read
  • SalesReceipt
    • - Create
    • - Read
    • - Update
    • - Delete
  • TaxAgency
    • - Create
    • - Read
  • TaxCode
    • - Read
  • TaxRate
    • - Read
  • TaxService
    • - Create
  • Term
    • - Create
    • - Read
    • - Update
  • TimeActivity
    • - Create
    • - Read
    • - Update
    • - Delete
  • Transfer
    • - Create
    • - Read
    • - Update
    • - Delete
  • Vendor
    • - Create
    • - Read
    • - Update
  • VendorCredit
    • - Create
    • - Read
    • - Update
    • - Delete
@richardhdc
Copy link

richardhdc commented Mar 14, 2017

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();
        }
    }

@khairulashraff
Copy link
Contributor Author

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.

@jthomaschewski
Copy link
Contributor

@khairulashraff the service TaxService is listed here but I can't find it in the source. How can I use it?
Thanks!

@khairulashraff
Copy link
Contributor Author

@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.

@basherr
Copy link

basherr commented Apr 20, 2017

@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"
				]
			]
		];
	}
}

@khairulashraff
Copy link
Contributor Author

@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).

@basherr
Copy link

basherr commented Apr 21, 2017

Ah agreed 👍

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants