picqer / exact-php-client

PHP Client library for Exact Online
MIT License
165 stars 200 forks source link

The UPDATE / DELETE function seems to be a bit strange #2

Closed sebastianberm closed 9 years ago

sebastianberm commented 9 years ago

I don't know if it's dependant on my PHP version, but I noticed some issues with the update / delete function in the Storable trait. When I'm done, I'll file a PR for this. If you want to research this in the mean while. Please see if changing lines 25 and 30 of Storable.php to:

        return $this->connection()->put($this->url . "(guid'{$this->{$this->primaryKey}}')", $this->json());

And

        return $this->connection()->delete($this->url . "(guid'{$this->{$this->primaryKey}}')");

Thanks ;-).

stephangroen commented 9 years ago

Hi :) What PHP version are you using? What issues did you get?

sebastianberm commented 9 years ago

I've been using PHP 5.4.36. For some reason, the system mentioned, for example, the ID 'ID' to be invalid, until I modified it to this. I'll issue a pull request when I've got everything working :+1:

ghost commented 9 years ago

On 1 august 2015 Exact Online NL will start with Oauth2. I have to change my old way of form authentication NOW.... within 8 days !!!! Running on PHP 5.3 I will try to use this modules... Stephan. I will let you know if it works.... if not I have a little time to change things.... Maybe I have to upgrade to PHP 5.5 or 5.6 but even then I don't know if my app will work.... So problems allover....

stephangroen commented 9 years ago

@sebastianberm Thanks!

@MHermsen I don't officially support 5.3, because its already EOL. You could try using it though, but there might be issues. Ofcourse, upgrading PHP to 5.5 or 5.6 is recommended because of obvious reasons.

sebastianberm commented 9 years ago

@MHermsen This won't work with 5.3, as it uses traits which were introduced in 5.4. You should probably contact someone to accomplish this for you.

@stephangroen Have you tried adding invoices with invoicelines? - that part is a bit missing in the documentation (both of this package and of Exact). So far, I've added support for Contacts & SalesEntries, and have tried to expand the filter to support OData a bit better, but that's still a no go so far. I've asked Exact support for a working example on how to craft a request that will add an SalesEntry with SalesEntryLines (same for SalesInvoice with SalesInvoiceLines).

I do know this package is the most complete one, I've been able to find so far :). (this shouldn't be in a Github issue... :-1:)

stephangroen commented 9 years ago

@sebastianberm This is the way I create an invoice with invoicelines:

        $salesInvoice = new SalesInvoice($this->connection());
        $salesInvoice->InvoiceTo = $customer_code;
        $salesInvoice->OrderedBy = $customer_code;
        $salesInvoice->YourRef = $orderId;
        $salesInvoice->SalesInvoiceLines = $items;

where $items in an array consisting of the following:

            $items[] = [
                'Item'      => $itemId,
                'Quantity'  => $orderproduct['amount'],
                'UnitPrice' => $orderproduct['price']
            ];

Here $itemId is the ID as returned by Exact (Item entity in this client).

I have not implemented the full Exact API yet, because I didn't need it in my project. A pull request with added entities and enhancements is always welcome :)

I'm currently working on changing this library to Guzzle 6 (will of course be a new version) so it supports PSR-7, which is easier to integrate when used with other packages. This does have the added dependancy of PHP >5.5 though.

stephangroen commented 9 years ago

Would be nice to be able to have a collection of Item models, which you can create and add to a SalesInvoice as well and/or be able to just do something like $salesInvoice->addItem($item);. But haven't got to that.

sebastianberm commented 9 years ago

Ah... as an array... Well, that is something I didn't try last Saturday while coding an example. Ehh, I'll try and figure something out ;-).

stephangroen commented 9 years ago

I'll update the docs to reflect this :)

sebastianberm commented 9 years ago

I've filed a PR for most changes now. There are a few things not yet in the PR though. I don't know if I want to file the Document system without documentation. (I've got it working for myself though. Our invoicing system will now automatically also add a PDF version of the current invoice to Exact.) (I should go and sell these integrations ;-))

stephangroen commented 9 years ago

@sebastianberm Nice, thank you. I see you made some nice additions in SalesInvoiceLines as well. I haven't looked into the Document system tbh. Is it undocumented at Exact or do you mean it needs to be documented for this client?

At Picqer we use quite some open source software to build our product, so we try to give back and contribute as much as we can. Therefor we contribute to other open source projects and open source some stuff ourselves :) There are quite some companies selling integrations like this though.

sebastianberm commented 9 years ago

@stephangroen The documentation API is a "ramp" (in both Dutch & English). It's hard to understand at first, due to the fact only the API arguments themselves have been documented, and when you finally get it, you need to understand you need to do stuff in the right order...

At Sebsoft, we try to do the same. See for example all the Moodle plugins and addons we've released (and are supporting) :).

ghost commented 9 years ago

@sebastianberm mail send with attach... maybe you have a solution ?

stephangroen commented 9 years ago

@MHermsen Please continue your conversation by email with @sebastianberm direclty. This is not the right place for this.

@sebastianberm Yeah, I had to ask several questions to Exact to know exactly what some arguments where. The lack of documentation in general prevents an easy use of the API.

If you would like to send a PR for the document system, I would be happy to merge it if we can provide some documentation on how to use it with this client. Ofcourse you don't have to.