Skip to content

Commit faad4fe

Browse files
1.1.0
1 parent 04804bc commit faad4fe

File tree

3 files changed

+14
-12
lines changed

3 files changed

+14
-12
lines changed

T/Basic.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ function t01_orders() {print_r(df_json_encode(df_oro_get_list(
1515
function t02_orders_stripe() {
1616
$customers = df_map_r(function(array $a) {return [
1717
$a['id'], $a['country']
18-
];}, df_oro_get_list('customers', [], [], true, false));
18+
];}, df_oro_get_list('customers', [], [], true));
1919
$websites = array_values(df_map(
2020
df_sort_names(
2121
array_filter(

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mage2pro/oro"
3-
,"version": "1.0.3"
3+
,"version": "1.1.0"
44
,"description": "Oro Platform integration with Magento 2"
55
,"type": "magento2-module"
66
,"homepage": "https://ocrm.pro"
@@ -11,6 +11,6 @@
1111
"homepage": "https://mage2.pro/users/dmitry_fedyuk",
1212
"role": "Developer"
1313
}]
14-
,"require": {"mage2pro/core": ">=2.12.21"}
14+
,"require": {"mage2pro/core": ">=4.4.0"}
1515
,"autoload": {"files": ["registration.php"], "psr-4": {"Df\\Oro\\": ""}}
1616
}

lib/main.php

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
<?php
2+
use Df\Core\Exception as DFE;
23
use Df\Oro\Settings\General as S;
34
use Zend_Http_Client as C;
45
/**
56
* 2017-06-04
7+
* @used-by dfe_portal_stripe_customers()
68
* @param string $entity
79
* «How to apply a filter to a «get list» Web API request?» https://oplatform.club/t/103
810
* @param array(string => mixed) $filter [optional]
@@ -12,12 +14,10 @@
1214
* @param bool $local [optional]
1315
* «What is the difference between the «application/json» and «application/vnd.api+json»
1416
* content types of a Web API response?» https://oplatform.club/t/104
15-
* @param bool $vnd [optional]
1617
* @return array(string => mixed)
18+
* @throws DFE
1719
*/
18-
function df_oro_get_list(
19-
$entity, array $filter = [], array $include = [], $local = false, $vnd = true
20-
) {
20+
function df_oro_get_list($entity, array $filter = [], array $include = [], $local = false) {
2121
// 2017-06-28
2222
// Due to a Oro Platform bug, a Web API request can randomly fail
2323
// with the «Unauthorized» response message.
@@ -27,23 +27,25 @@ function df_oro_get_list(
2727
$c = null; /** @var C $c */
2828
while (!$raw && $attempt++ <= $maxAttempts) {
2929
$c = df_zf_http('https://'
30-
. ($local ? 'localhost.com:848/app_dev.php' : 'erp.mage2.pro')
30+
. ($local ? 'localhost.com:848/index_dev.php' : 'erp.mage2.pro')
3131
. "/api/extenddf$entity"
3232
)
3333
// 2017-06-28
3434
// Due to a Oro Platform bug, the «content-type» headers is required for the «vnd» case,
3535
// even it does not have any sense here.
3636
// «Difference between the Accept and Content-Type HTTP headers»
3737
// https://webmasters.stackexchange.com/questions/31212
38-
->setHeaders(df_oro_headers() + (!$vnd ? ['accept' => 'application/json'] : array_fill_keys(
38+
->setHeaders(df_oro_headers() + (array_fill_keys(
3939
['accept', 'content-type'], 'application/vnd.api+json'
4040
)))
41-
->setParameterGet(df_clean(['filter' => $filter, 'include' => df_csv($include)]))
41+
->setParameterGet(df_clean([
42+
'filter' => $filter, 'include' => df_csv($include), 'page' => ['size' => -1]
43+
]))
4244
;
4345
$raw = $c->request()->getBody();
4446
}
45-
if (!$raw) {
46-
$res = $c->getLastResponse(); /** @var \Zend_Http_Response $res */
47+
$res = $c->getLastResponse(); /** @var \Zend_Http_Response $res */
48+
if (!$raw || $res->isError()) {
4749
df_error("The last Oro Web API request fails with the message «{$res->getMessage()}».\n"
4850
."The response headers:\n%s\n.The request:\n%s\n."
4951
,$res->getHeadersAsString(), $c->getLastRequest()

0 commit comments

Comments
 (0)