Skip to content

Commit

Permalink
0.0.6
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitrii-fediuk committed Jun 4, 2017
1 parent 7aadfab commit 0f8a2b4
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 4 deletions.
28 changes: 27 additions & 1 deletion T/Basic.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,38 @@
namespace Df\Oro\T;
// 2017-06-01
final class Basic extends TestCase {
/** @test
/**
* 2017-06-04
* «How to include related entities to a response on a Web API «get list» request?»
* https://oplatform.club/t/105
*/
function t01_orders() {echo df_json_encode_pretty(df_oro_get_list(
'orders', ['product' => 1], ['product', 'website'], true
));}

/** @test */
function t02_orders_stripe() {
$customers = df_map_r(function(array $a) {return [
$a['id'], $a['country']
];}, df_oro_get_list('customers', [], [], true, false));
$websites = array_values(df_map(
df_sort_names(
array_filter(
df_oro_get_list('orders', ['product' => 1], ['website'], true)['included']
,function(array $a) {return
'extenddfwebsites' === $a['type']
&& 'magento_2' === dfa_deep($a, 'relationships/platform/data/id')
;}
), null, function(array $a) {return dfa_deep($a, 'attributes/domain');}
), function(array $a) use($customers) {$at = $a['attributes']; return [
'country' => $customers[dfa_deep($a, 'relationships/dfcustomer_websites/data/id')]
,'edition' => $at['m2_is_enterprise'] ? 'Enterprise' : 'Community'
,'url' => ($u = $at['m2_version_url']) ? df_trim_text_right($u, '/magento_version') :
"http://{$at['domain']}"
,'version' => $at['m2_version']
];
}
));
echo df_json_encode_pretty($websites);
}
}
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mage2pro/oro"
,"version": "0.0.5"
,"version": "0.0.6"
,"description": "A custom integration between Magento 2 and Oro Platform."
,"type": "magento2-module"
,"homepage": "https://ocrm.pro"
Expand Down
6 changes: 4 additions & 2 deletions lib/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@
* @param bool $vnd [optional]
* @return array(string => mixed)
*/
function df_oro_get_list($entity, array $filter = [], array $include = [], $local = false, $vnd = true) {
function df_oro_get_list(
$entity, array $filter = [], array $include = [], $local = false, $vnd = true
) {
/** @var C $c */
$c = (new C)
->setConfig(['timeout' => 120])
->setHeaders(df_oro_headers() + (!$vnd ? ['application/json'] : array_fill_keys(
->setHeaders(df_oro_headers() + (!$vnd ? ['content-type' => 'application/json'] : array_fill_keys(
['accept', 'content-type'], 'application/vnd.api+json'
)))
->setUri(
Expand Down

0 comments on commit 0f8a2b4

Please sign in to comment.