Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Full documentation to use this package. #44

Open
abhimanusharma opened this issue May 4, 2021 · 2 comments
Open

Full documentation to use this package. #44

abhimanusharma opened this issue May 4, 2021 · 2 comments

Comments

@abhimanusharma
Copy link

I get the basic idea of using this package, but it would be great if there is a detailed documentation of this package as there are so many scopes and using each of them is very different. I Explored the calcinai/xero-php and Xero api explorer but understanding of CREATE scope is much complicated than that of GET scope.

I am trying to convert the idea given on calcinai/xero-php 's README page:

$xero_auth = XeroAuth::where('admin_id', $request->admin_id)->first();
        $this->createXeroApp($xero_auth->access_token, $xero_auth->tenant_id);

        $line_item = new LineItem();
        
        $contact = $this->xero->loadByGUID(Contact::class, $xero_auth->contact_id);
        $invoice = new Invoice($this->xero);
        $invoice->setContact($contact)
                ->setType('ACCREC')
                ->addLineItem($line_item);
        $invoice->save();

Suppose I have multiple LineItems that I wanted to add in a single invoice. I know the values required to set a LineItem is { "Description": "Acme Tires", "Quantity": 2, "UnitAmount": 20, "AccountCode": "200", "TaxType": "NONE", "LineAmount": 40 } but there is no proper documentation to show how to set these values and there is no example exists.

Can you please at least help me in creating an invoice and save it in xero crm?

@seanmccabe
Copy link

You should post that question in the calcinai/xero-php Issues section.
This package just allows you to use the calcinai package in an eloquent like syntax.

The above code you posted showx exactly how to create an invoice, and to add multiple line items, just do ->addLineItem for however many lines you need to add.

If you open the Invoice class in the calcinai package you will see all the properties and methods that can be used.

@abhimanusharma
Copy link
Author

@seanmccabe
Ok. I have added addLineItem many times instead of passing this as a single array, but now when I am trying to fetch the contact from xero I am getting an unexpected error. You have implemented the calcinai/xero-php in your package you must know why this issue is persisting. Please help me resolve this error.

This is my code: $contact = $this->xero->load(Contact::class)->where('ContactID', $xero_auth->contact_id)->first();
I have also tried: $contact = $this->xero->contacts()->where('ContactID', $xero_auth->contact_id)->first();

This is the error.

XeroPHP\Remote\Exception\ForbiddenException: You are not permitted to access this resource in /var/www/html/project_dev/vendor/calcinai/xero-php/src/XeroPHP/Remote/Response.php:127
Stack trace:
#0 /var/www/html/project_dev/vendor/calcinai/xero-php/src/XeroPHP/Remote/Request.php(119): XeroPHP\Remote\Response->parse()
#1 /var/www/html/project_dev/vendor/calcinai/xero-php/src/XeroPHP/Remote/Query.php(330): XeroPHP\Remote\Request->send()
#2 /var/www/html/project_dev/vendor/calcinai/xero-php/src/XeroPHP/Remote/Query.php(347): XeroPHP\Remote\Query->execute()
#3 /var/www/html/project_dev/app/Service/XeroApiService.php(144): XeroPHP\Remote\Query->first()

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

No branches or pull requests

2 participants