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

[WIP] Rewrite/Extend all resources #142

Open
wants to merge 409 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
409 commits
Select commit Hold shift + click to select a range
5e21647
Update CustomerIntegrationTest.php
iranl May 11, 2019
aa75d5b
Add files via upload
iranl May 11, 2019
bcdf453
Update CustomerApiConnectorTest.php
iranl May 11, 2019
3c4d000
Add files via upload
iranl May 11, 2019
381872a
Update InvoiceIntegrationTest.php
iranl May 11, 2019
11d1ba7
Update InvoiceIntegrationTest.php
iranl May 11, 2019
e81d620
Update InvoiceIntegrationTest.php
iranl May 11, 2019
85a2c66
Update InvoiceIntegrationTest.php
iranl May 11, 2019
9c0e99c
Add files via upload
iranl May 11, 2019
50ef823
Update InvoiceIntegrationTest.php
iranl May 11, 2019
c5b02fd
Update InvoiceIntegrationTest.php
iranl May 11, 2019
ab32877
Update InvoiceIntegrationTest.php
iranl May 11, 2019
7df8bbc
Update InvoiceIntegrationTest.php
iranl May 11, 2019
6f318d8
Update InvoiceIntegrationTest.php
iranl May 11, 2019
00bcb12
Update InvoiceIntegrationTest.php
iranl May 11, 2019
dc760ab
Update InvoiceIntegrationTest.php
iranl May 11, 2019
45c5e8f
Update InvoiceIntegrationTest.php
iranl May 11, 2019
fc922fc
Update composer.json
iranl May 11, 2019
79d02ad
Update composer.json
iranl May 11, 2019
609bcb2
Update InvoiceIntegrationTest.php
iranl May 11, 2019
1be57e6
Update InvoiceIntegrationTest.php
iranl May 11, 2019
f09fe2d
Add files via upload
iranl May 11, 2019
201b771
Update InvoiceIntegrationTest.php
iranl May 11, 2019
6544d91
Update InvoiceIntegrationTest.php
iranl May 11, 2019
757073e
Update invoiceSendRequest.xml
iranl May 11, 2019
f12e5e8
Update invoiceFinalGetResponse.xml
iranl May 11, 2019
d0290b0
Update invoiceConceptGetResponse.xml
iranl May 11, 2019
19a25cb
Update InvoiceIntegrationTest.php
iranl May 11, 2019
f477953
Update invoiceSendRequest.xml
iranl May 11, 2019
6b5c447
Add files via upload
iranl May 11, 2019
3c15fba
Add files via upload
iranl May 11, 2019
97634c1
Update OfficeTest.php
iranl May 11, 2019
0637b3e
Update CustomerIntegrationTest.php
iranl May 11, 2019
00463ee
Create customerListResponse.json
iranl May 11, 2019
9619d3c
Delete customerListResponse.xml
iranl May 11, 2019
6585b01
Update CustomerIntegrationTest.php
iranl May 11, 2019
b26be1c
Update CustomerIntegrationTest.php
iranl May 11, 2019
703b4cd
Update .travis.yml
iranl May 11, 2019
1e94c04
Add files via upload
iranl May 11, 2019
cd1cb46
Update .travis.yml
iranl May 11, 2019
a2f2ad8
Merge branch 'extend-all' into extend-all-testing
iranl May 11, 2019
a7356fd
Merge pull request #2 from iranl/extend-all-testing
iranl May 11, 2019
2df7f55
Update .travis.yml
iranl May 11, 2019
128aed7
Upload
iranl May 11, 2019
5c2d6ad
Upload
iranl May 11, 2019
d606daf
Merge pull request #3 from iranl/extend-all-testing
iranl May 11, 2019
d3213bd
Upload
iranl May 12, 2019
13225d2
Upload
iranl May 12, 2019
d9869e1
Upload
iranl May 12, 2019
dab2d1f
Update InvoiceMapper.php
iranl May 12, 2019
d1e9dfb
Upload
iranl May 12, 2019
727156a
Upload
iranl May 12, 2019
c8bc29e
Merge pull request #4 from iranl/extend-all-testing
iranl May 12, 2019
ac63f2e
Update readme.md
iranl May 13, 2019
ba254d2
Upload
iranl May 14, 2019
8ff1016
Update readme.md
iranl May 14, 2019
f25dade
Update RenewAuthorization.php
iranl May 14, 2019
c910487
Upload
iranl May 15, 2019
ab8485a
Upload
iranl May 15, 2019
f636072
Update readme.md
iranl May 15, 2019
e1ae0ef
Upload
iranl May 15, 2019
8fb6a18
Upload
iranl May 20, 2019
23c3588
Upload
iranl May 20, 2019
a9a47c1
Update LinesField.php
iranl May 20, 2019
511901e
Upload
iranl May 20, 2019
1b895af
Upload
iranl May 20, 2019
d473a43
Upload
iranl May 20, 2019
715cfae
Upload
iranl May 20, 2019
84bd966
Update BaseTransactionLine.php
iranl May 20, 2019
ea1110c
Upload
iranl May 20, 2019
fd87d27
Upload
iranl May 20, 2019
8b93d38
Upload
iranl May 20, 2019
9d80a55
Upload
iranl May 20, 2019
4f1cf71
Update TransactionsDocument.php
iranl May 20, 2019
900e206
Upload
iranl May 20, 2019
352c0bb
Upload
iranl May 20, 2019
501813c
Upload
iranl May 20, 2019
cf55a0f
Upload
iranl May 20, 2019
39fe6da
Upload
iranl May 20, 2019
dd99194
Upload
iranl May 21, 2019
036b0e0
Update CloseAndStartValueFields.php
iranl May 21, 2019
7f2c6db
Update CloseAndStartValueFields.php
iranl May 21, 2019
4a58c61
Update CloseAndStartValueFields.php
iranl May 21, 2019
dc31e4b
Update CloseAndStartValueFields.php
iranl May 21, 2019
2dd2e3b
Upload
iranl May 21, 2019
f31caf2
Upload
iranl May 21, 2019
3ac3c74
Upload
iranl May 21, 2019
a4d8709
Upload
iranl May 21, 2019
0f19a0a
Upload
iranl May 21, 2019
75b6bde
Upload
iranl May 21, 2019
0a9dc3b
Upload
iranl May 21, 2019
31dcd9b
Upload
iranl May 21, 2019
5361b7c
Update TransactionMapper.php
iranl May 21, 2019
007cbd9
Upload
iranl May 21, 2019
7d08f62
Upload
iranl May 21, 2019
a1d8d65
Upload
iranl May 21, 2019
564e413
Upload
iranl May 21, 2019
220c4d2
Upload
iranl May 21, 2019
c9a42b9
Upload
iranl May 21, 2019
361a7a1
Upload
iranl May 21, 2019
9968021
Upload
iranl May 21, 2019
02dd604
Update TransactionLineInterface.php
iranl May 21, 2019
a683cbb
Upload
iranl May 21, 2019
e0f5377
Update TransactionsDocument.php
iranl May 21, 2019
4243673
Upload
iranl May 21, 2019
5294f07
Merge pull request #5 from iranl/extend-all-testing
iranl May 21, 2019
619822d
Upload
iranl May 22, 2019
2ec6227
Upload
iranl May 22, 2019
df47753
Upload
iranl May 22, 2019
2b49268
Upload
iranl May 23, 2019
7fa022f
Merge pull request #6 from iranl/extend-all-testing
iranl May 23, 2019
a0506bd
Merge branch 'master' into extend-all
iranl May 29, 2019
93710d3
Upload
iranl Jun 2, 2019
b8aa58d
Upload
iranl Jun 2, 2019
fdf088e
UploaD
iranl Jun 2, 2019
ab4aed5
Update project-response.xml
iranl Jun 2, 2019
9cf8e77
Delete ArticleApiConnectorTest.php
iranl Jun 2, 2019
ceb6dcd
Merge pull request #7 from iranl/extend-all-testing
iranl Jun 2, 2019
68517e0
Upload
iranl Jun 5, 2019
27c8494
Update SupplierDocumentUnitTest.php
iranl Jun 5, 2019
5126e6f
Update SupplierDocumentUnitTest.php
iranl Jun 5, 2019
ca34d3b
Update SupplierDocumentUnitTest.php
iranl Jun 5, 2019
738c574
Update SupplierDocumentUnitTest.php
iranl Jun 5, 2019
c2bb338
Upload
iranl Jun 7, 2019
68c4a3b
Upload
iranl Jun 7, 2019
faf07f3
Update CustomerDocumentUnitTest.php
iranl Jun 7, 2019
c0a7d5d
Upload
iranl Jun 9, 2019
9c32f2f
Upload
iranl Jun 9, 2019
35dcfdc
Update InvoiceIntegrationTest.php
iranl Jun 9, 2019
d342b2b
Merge pull request #8 from iranl/extend-all-testing
iranl Jun 9, 2019
b1ea92f
Upload
iranl Jun 10, 2019
ca3f809
Upload
iranl Jun 10, 2019
39a9221
Update BaseMapper.php
iranl Jun 10, 2019
e433224
Update BaseMapper.php
iranl Jun 10, 2019
fe189f9
Update BaseMapper.php
iranl Jun 10, 2019
e6fc8b5
Upload
iranl Jun 10, 2019
a6b6be9
Upload
iranl Jun 10, 2019
12c2fb4
Upload
iranl Jun 10, 2019
074f843
Upload
iranl Jun 10, 2019
9d92c98
Upload
iranl Jun 10, 2019
99c473a
Merge pull request #10 from iranl/extend-all-testing
iranl Jun 10, 2019
2437fa3
Update BaseMapper.php
iranl Jun 10, 2019
1955678
Update BaseMapper.php
iranl Jun 10, 2019
bb9ee1f
Base Modifications Change Requests 2
iranl Jun 11, 2019
800546c
Upload
iranl Jun 11, 2019
fbe5d88
Upload
iranl Jun 11, 2019
531bfa7
Update BaseObject.php
iranl Jun 11, 2019
121cf6c
Update BaseMapper.php
iranl Jun 11, 2019
f509f4f
Upload
iranl Jun 11, 2019
18e9f2c
Update Util.php
iranl Jun 11, 2019
5dbc686
Merge pull request #11 from iranl/extend-all-testing
iranl Jun 11, 2019
468c1a9
Update BaseMapper.php
iranl Jun 16, 2019
b8fc6dc
Upload
iranl Jun 16, 2019
66fa961
Upload
iranl Jun 16, 2019
2760753
Update BankTransactionIntegrationTest.php
iranl Jun 19, 2019
3270e40
Update BankTransactionIntegrationTest.php
iranl Jun 19, 2019
477919d
Upload
iranl Jun 19, 2019
1898b76
Update BankTransactionIntegrationTest.php
iranl Jun 19, 2019
3d5afda
Update BankTransactionIntegrationTest.php
iranl Jun 19, 2019
c4221e9
Update CustomerIntegrationTest.php
iranl Jun 19, 2019
8a5cf08
Upload
iranl Jun 19, 2019
63f9ac0
Upload
iranl Jun 19, 2019
b3c5341
Upload
iranl Jun 19, 2019
1c9d8d0
Upload
iranl Jun 19, 2019
62ec817
Update BankTransactionIntegrationTest.php
iranl Jun 19, 2019
8554593
Upload
iranl Jun 19, 2019
1d43105
Upload
iranl Jun 19, 2019
3f6603b
Upload
iranl Jun 19, 2019
ac1f183
Upload
iranl Jun 19, 2019
87d83a9
Upload
iranl Jun 19, 2019
edca44c
Upload
iranl Jun 19, 2019
ecd678e
Upload
iranl Jun 19, 2019
1db8b4e
Upload
iranl Jun 20, 2019
79636eb
Upload
iranl Jun 20, 2019
2b7da9c
Merge pull request #12 from iranl/extend-all-testing
iranl Jun 20, 2019
a1431de
Upload
iranl Jun 22, 2019
9370f47
Upload
iranl Jun 22, 2019
09f4cfd
Upload
iranl Jun 22, 2019
6e913bc
Upload
iranl Jun 22, 2019
ec96351
Upload
iranl Jun 22, 2019
03fc055
Upload
iranl Jun 22, 2019
0d33c24
Update CustomerDocumentUnitTest.php
iranl Jun 22, 2019
dcf54bb
Update CustomerDocumentUnitTest.php
iranl Jun 22, 2019
af7618d
Upload
iranl Jun 22, 2019
f4a7780
Update CustomerDocumentUnitTest.php
iranl Jun 22, 2019
f53a222
Update BaseMapper.php
iranl Jun 22, 2019
b9fa8dd
Upload
iranl Jun 23, 2019
052507f
Upload
iranl Jun 23, 2019
dae6343
Upload
iranl Jun 23, 2019
0f85eae
Upload
iranl Jun 23, 2019
f73bb7a
Update SalesTransactionIntegrationTest.php
iranl Jun 23, 2019
cadb1c6
Upload
iranl Jun 23, 2019
9343389
Update CustomersDocument.php
iranl Jun 23, 2019
c766b27
Upload
iranl Jun 23, 2019
f98cd9d
Upload
iranl Jun 23, 2019
139be89
Upload
iranl Jun 23, 2019
5498579
Update BaseIntegrationTest.php
iranl Jun 23, 2019
72048bc
Upload
iranl Jun 23, 2019
91521be
Upload
iranl Jun 23, 2019
0b69521
Update InvoiceIntegrationTest.php
iranl Jun 23, 2019
eb68013
Update OfficeIntegrationTest.php
iranl Jun 23, 2019
314a997
Update OfficeIntegrationTest.php
iranl Jun 23, 2019
5bd7893
Upload
iranl Jun 23, 2019
6c729e9
Upload
iranl Jun 23, 2019
cf5d63c
Upload
iranl Jun 23, 2019
4fdc64c
Upload
iranl Jun 23, 2019
1968e56
Upload
iranl Jun 23, 2019
77acb8a
Merge pull request #13 from iranl/extend-all-testing
iranl Jun 23, 2019
975f06c
Update readme.md
iranl Jun 23, 2019
f719b89
Upload
iranl Jun 24, 2019
6146ac9
Upload
iranl Jun 26, 2019
903effe
Upload
iranl Jun 26, 2019
4282634
Upload
iranl Jun 26, 2019
ca336d3
Upload
iranl Jun 26, 2019
b5d8f94
Upload
iranl Jun 26, 2019
db2af07
Upload
iranl Jun 26, 2019
508afeb
Upload
iranl Jun 26, 2019
6fd649e
Upload
iranl Jun 26, 2019
29b3167
Upload
iranl Jun 27, 2019
e0bea3d
Merge pull request #14 from iranl/extend-all-testing
iranl Jun 27, 2019
a64f25a
Upload
iranl Jun 27, 2019
aa0d208
Merge pull request #15 from iranl/extend-all-testing
iranl Jun 27, 2019
1f23450
Upload
iranl Jun 28, 2019
0ecd76f
Upload
iranl Jun 28, 2019
313ccd8
Upload
iranl Jun 28, 2019
04511be
Upload
iranl Jun 28, 2019
0de6e15
Update RateApiConnectorTest.php
iranl Jun 28, 2019
73461aa
Upload
iranl Jun 29, 2019
910fb2a
Upload
iranl Jun 29, 2019
4413e28
Upload
iranl Jun 29, 2019
7e66b9c
Upload
iranl Jun 29, 2019
32e221c
Update HasEqualInterface.php
iranl Jun 29, 2019
52f401c
Upload
iranl Jun 29, 2019
eefc402
Update VatCodeApiConnectorTest.php
iranl Jun 29, 2019
f49a93d
Upload
iranl Jun 30, 2019
aba5b58
Update AssetMethodApiConnectorTest.php
iranl Jun 30, 2019
9c61dae
Merge pull request #16 from iranl/extend-all-testing
iranl Jun 30, 2019
e622718
Update readme.md
iranl Jul 3, 2019
58b2192
Upload
iranl Jul 3, 2019
20f10ec
Upload
iranl Jul 4, 2019
9b62945
Upload
iranl Jul 6, 2019
a366c77
Upload
iranl Jul 9, 2019
03ac86d
Merge pull request #17 from iranl/extend-all-testing
iranl Jul 9, 2019
a04d0d3
Upload
iranl Jul 10, 2019
2c80142
Upload
iranl Jul 10, 2019
b6dcb7f
Merge pull request #18 from iranl/extend-all-testing
iranl Jul 10, 2019
6f1a37f
Merge branch 'master' into extend-all
iranl Jul 10, 2019
479067f
Upload
iranl Jul 21, 2019
40307e6
Merge pull request #19 from iranl/extend-all-testing
iranl Jul 21, 2019
984f66b
Update readme.md
iranl Jul 21, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
52 changes: 52 additions & 0 deletions breaking270.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Breaking changes since 2.7.0
Release ... added multiple new resources, but also broke several existing ones.

Breaking changes are present in:
- Bank Transactions (Separate API connector completely removed and functionality moved to general Transactions API Connector)
- Articles
- Customers
- Sales Invoices
- Suppliers
- Transactions
- Vat Codes

Except for Bank Transactions, the breaking changes are primarily due to the fact that most fields and methods are now properly type cast.

This means (among others) that all booleans are now type cast as bool, all monetary values are now Money\Money instances and several fields now use Enums instead of strings.

Another big change is that retrieved fields that are instances of another entity in Twinfield and this library are now retrieved and set in the same way as was already done with Office or Customer codes.
So for example a VAT code retrieved from or set to a PhpTwinfield\Article will now become an instance of PhpTwinfield\VatCode with its $code set to "VH" instead of begin just a string with the value "VH".

See the tables per class below for breaking changes and suggestions for fixes/replacement methods.

## Bank Transactions

-TODO

## Articles

-TODO

### Article Lines

-TODO

## Customers

-TODO

## Sales Invoices

-TODO

## Suppliers

-TODO

## Cash/Journal/Purchase/Sale Transactions

-TODO

## VAT

-TODO
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"eloquent/liberator": "^2.0",
"league/oauth2-client": "^2.2",
"mediact/dependency-guard": "^1.0",
"mockery/mockery": "dev-master",
"phpstan/phpstan": "^0.10.1",
"phpunit/phpunit": "^7.3"
}
Expand Down
358 changes: 358 additions & 0 deletions examples/Activity.php

Large diffs are not rendered by default.

305 changes: 305 additions & 0 deletions examples/Article.php

Large diffs are not rendered by default.

355 changes: 355 additions & 0 deletions examples/AssetMethod.php

Large diffs are not rendered by default.

113 changes: 113 additions & 0 deletions examples/Authorization.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
<?php

error_reporting(E_ALL);
ini_set("display_errors", 1);

/* To use OAuth 2 for logging in it is necessary that a user with access rights to Twinfield grants authorization.

* On loading a page containing the following code the user will be redirected to the Twinfield Login page.
* After successful login and optionally consent the user will be redirected back to the page at which point the Access Token and Refresh Token can be retrieved.

* For more information, please refer to: https://github.com/thephpleague/oauth2-client#usage
*/

function SaveRefreshTokenToStore(array $refreshTokenStorage) {
/* Save refresh token and expiry time to some kind of storage (e.g. SQL database).
* $refreshTokenStorage['refresh_token']
* $refreshTokenStorage['refresh_expiry']
*/
}

function SaveAccessTokenToStore(array $accessTokenStorage) {
/* Save access token, expiry time and cluster to some kind of storage (e.g. SQL database).
* $accessTokenStorage['access_token']
* $accessTokenStorage['access_expiry']
* $accessTokenStorage['access_cluster']
*/
}

require_once('vendor/autoload.php');

// The client ID assigned to you by Twinfield.
$twin_client_id = 'SomeClientId';

// The client secret assigned to you by Twinfield.
$twin_client_secret = 'SomeClientSecret';

/* The FQDN URI where this script can be called from when Twinfield redirects back to after the user logs in.
* Must be filled out on the form (Redirect URL) when requesting the client ID/Secret from Twinfield.
*/
$twin_redirect_uri = 'https://example.org/twinfield/Authorization.php';

$provider = new \PhpTwinfield\Secure\Provider\OAuthProvider([
'clientId' => $twin_client_id,
'clientSecret' => $twin_client_secret,
'redirectUri' => $twin_redirect_uri,
]);

// If we don't have an authorization code then get one.
if (!isset($_GET['code'])) {
//Optionally limit your scope if you don't require all.
$options = [
'scope' => ['twf.user','twf.organisation','twf.organisationUser','offline_access','openid']
];

$authorizationUrl = $provider->getAuthorizationUrl($options);

// Get the state generated for you and store it to the session.
$_SESSION['oauth2state'] = $provider->getState();

// Redirect the user to the authorization URL.
header('Location: ' . $authorizationUrl);
exit;

// Check given state against previously stored one to mitigate CSRF attack.
} elseif (empty($_GET['state']) || (isset($_SESSION['oauth2state']) && $_GET['state'] !== $_SESSION['oauth2state'])) {
if (isset($_SESSION['oauth2state'])) {
unset($_SESSION['oauth2state']);
}

exit('Invalid state');
} else {
try {
// Try to get an access token using the authorization code grant.
$accessToken = $provider->getAccessToken('authorization_code', [
'code' => $_GET['code']
]);

/* Twinfield's refresh token is valid for 550 days.
* Renewing the refresh token can be done by requesting the user to reload this page and logging into Twinfield before the refresh token is invalidated after 550 days.
* NOTE: Remember to put in place functionality to request the user to renew their authorization, see RenewAuthorization.php for an example.
*/

$refresh_expiry = strtotime(date('Ymd') . " +550 days");

// Save refresh token and refresh token expiry time to storage.
$refreshTokenStorage = array();
$refreshTokenStorage['refresh_token'] = $accessToken->getRefreshToken();
$refreshTokenStorage['refresh_expiry'] = $refresh_expiry;

SaveRefreshTokenToStore($refreshTokenStorage);

/* Optionally save access token, access token expiry time and access cluster to storage.
* If you choose to use an always valid access token to login to speed up your requests you need to put in place functionality to automatically renew the access token using the save refresh token.
* As the access token is valid for 60 minutes you need to create a task scheduler/cron that runs at least once every hour, see RenewAccessToken.php for an example.
*/

$validationUrl = "https://login.twinfield.com/auth/authentication/connect/accesstokenvalidation?token=";
$validationResult = @file_get_contents($validationUrl . urlencode($accessToken->getToken()));

if ($validationResult !== false) {
$resultDecoded = \json_decode($validationResult, true);
$accessTokenStorage = array();
$accessTokenStorage['access_token'] = $accessToken->getToken();
$accessTokenStorage['access_expiry'] = $accessToken->getExpires();
$accessTokenStorage['access_cluster'] = $resultDecoded["twf.clusterUrl"];

SaveAccessTokenToStore($accessTokenStorage);
}
} catch (\League\OAuth2\Client\Provider\Exception\IdentityProviderException $e) {
// Failed to get the access token or user details.
exit($e->getMessage());
}
}
Loading