Skip to content

Commit 4f57602

Browse files
authored
Merge pull request #9 from bayonetio/fixes-for-technical-review
Fixes for technical review
2 parents e8d3023 + 4a74f95 commit 4f57602

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+2066
-851
lines changed

Block/Adminhtml/OrderEdit/Tab/View.php

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,42 +65,58 @@ public function getTabLabel()
6565

6666
/**
6767
* Gets the Bayonet Tracking ID of an order
68-
*
68+
*
6969
* @return string
7070
*/
7171
public function getTrackingId()
7272
{
73-
return $this->directQuery->getTrackingId($this->getOrderId());
73+
return $this->directQuery->customQuery(
74+
'bayonet_antifraud_orders',
75+
'bayonet_tracking_id',
76+
['order_id' => $this->getOrderId()]
77+
);
7478
}
7579

7680
/**
7781
* Gets the Bayonet API response of an order
78-
*
82+
*
7983
* @return string
8084
*/
8185
public function getApiResponse()
8286
{
83-
return $this->directQuery->getApiResponse($this->getOrderId());
87+
return $this->directQuery->customQuery(
88+
'bayonet_antifraud_orders',
89+
'consulting_api_response',
90+
['order_id' => $this->getOrderId()]
91+
);
8492
}
8593

8694
/**
8795
* Gets the Decision from the Bayonet API of an order
88-
*
96+
*
8997
* @return string
9098
*/
9199
public function getDecision()
92100
{
93-
return $this->directQuery->getDecision($this->getOrderId());
101+
return $this->directQuery->customQuery(
102+
'bayonet_antifraud_orders',
103+
'decision',
104+
['order_id' => $this->getOrderId()]
105+
);
94106
}
95107

96108
/**
97109
* Gets the Bayonet API triggered rules (if exist) of an order
98-
*
110+
*
99111
* @return string
100112
*/
101113
public function getRules()
102114
{
103-
return $this->directQuery->getRules($this->getOrderId());
115+
return $this->directQuery->customQuery(
116+
'bayonet_antifraud_orders',
117+
'triggered_rules',
118+
['order_id' => $this->getOrderId()]
119+
);
104120
}
105121

106122
/**

Block/Fingerprint.php

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function __construct(
2828

2929
/**
3030
* Gets the controller URL
31-
*
31+
*
3232
* @return string
3333
*/
3434
public function getAjaxUrl()
@@ -38,46 +38,62 @@ public function getAjaxUrl()
3838

3939
/**
4040
* Gets the current value of the 'enable' configuration field
41-
*
41+
*
4242
* @return int
4343
*/
4444
public function getEnabled()
4545
{
46-
return intval($this->directQuery->getEnabled());
46+
return (int)$this->directQuery->customQuery(
47+
'core_config_data',
48+
'value',
49+
['path' => 'bayonetantifraud_general/general/enable']
50+
);
4751
}
4852

4953
/**
5054
* Gets the API key in order to generate the fingerprint token
5155
* It checks whether the the API mode is in live or sandbox in order
5256
* to return the corresponding key
53-
*
57+
*
5458
* @return string
5559
*/
5660
public function getApiKey()
5761
{
58-
$apiMode = intval($this->directQuery->getApiMode());
59-
$apiKey = $apiMode === 1 ? $this->directQuery->getApiKey('js_live_key') : $this->directQuery->getApiKey('js_sandbox_key');
62+
$apiMode = (int)$this->directQuery->customQuery(
63+
'core_config_data',
64+
'value',
65+
['path' => 'bayonetantifraud_general/general/api_mode']
66+
);
67+
$apiKey = $apiMode === 1 ? $this->directQuery->customQuery(
68+
'core_config_data',
69+
'value',
70+
['path' => 'bayonetantifraud_general/general/js_live_key']
71+
) : $this->directQuery->customQuery(
72+
'core_config_data',
73+
'value',
74+
['path' => 'bayonetantifraud_general/general/js_sandbox_key']
75+
);
6076

6177
return $apiKey;
6278
}
6379

6480
/**
6581
* Gets a bool that indicates whether a customer is logged in or not
66-
*
82+
*
6783
* @return bool
6884
*/
6985
public function getCustomerIsLoggedIn()
7086
{
71-
return (bool)$this->httpContext->getValue(\Magento\Customer\Model\Context::CONTEXT_AUTH);
87+
return (bool)$this->httpContext->getValue(\Magento\Customer\Model\Context::CONTEXT_AUTH);
7288
}
7389

7490
/**
7591
* Gets the ID of the logged in customer
76-
*
92+
*
7793
* @return string
7894
*/
7995
public function getCustomerId()
8096
{
81-
return $this->httpContext->getValue('customer_id');
97+
return $this->httpContext->getValue('customer_id');
8298
}
8399
}

Block/System/Config/Backfill.php

Lines changed: 0 additions & 79 deletions
This file was deleted.

0 commit comments

Comments
 (0)