Skip to content

Commit

Permalink
change fraud list management (#98)
Browse files Browse the repository at this point in the history
* change fraud list management
  • Loading branch information
tuncaserhat authored Jan 8, 2024
1 parent d717397 commit da9458c
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 14 deletions.
14 changes: 14 additions & 0 deletions samples/add_card_fingerprint_to_fraud_value_list.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

use Craftgate\Model\FraudValueType;

require_once('config/sample_config.php');

$response = SampleConfig::craftgate()->fraud()->addValueToValueList(array(
'listName' => "cardList",
'type' => FraudValueType::CARD,
'label' => "John Doe's Card",
'paymentId' => 11675,
));

print_r($response);
10 changes: 9 additions & 1 deletion samples/add_temporary_value_to_fraud_value_list.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
<?php

use Craftgate\Model\FraudValueType;

require_once('config/sample_config.php');

$response = SampleConfig::craftgate()->fraud()->addValueToValueList("ipList", "127.0.0.2", 60);
$response = SampleConfig::craftgate()->fraud()->addValueToValueList(array(
'listName' => "ipList",
'label' => "local ip 2",
'type' => FraudValueType::IP,
'value' => "127.0.0.2",
'durationInSeconds' => 60
));

print_r($response);
9 changes: 8 additions & 1 deletion samples/add_value_to_fraud_value_list.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
<?php

use Craftgate\Model\FraudValueType;

require_once('config/sample_config.php');

$response = SampleConfig::craftgate()->fraud()->addValueToValueList("ipList", "127.0.0.1");
$response = SampleConfig::craftgate()->fraud()->addValueToValueList(array(
'listName' => "ipList",
'type' => FraudValueType::IP,
'label' => "local ip 1",
'value' => "127.0.0.1",
));

print_r($response);
4 changes: 3 additions & 1 deletion samples/create_fraud_value_list.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<?php

use Craftgate\Model\FraudValueType;

require_once('config/sample_config.php');

$response = SampleConfig::craftgate()->fraud()->createValueList("ipList");
$response = SampleConfig::craftgate()->fraud()->createValueList("ipList", FraudValueType::IP);

print_r($response);
2 changes: 1 addition & 1 deletion samples/remove_value_from_fraud_value_list.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

require_once('config/sample_config.php');

$response = SampleConfig::craftgate()->fraud()->removeValueFromValueList("ipList", "127.0.0.1");
$response = SampleConfig::craftgate()->fraud()->removeValueFromValueList("ipList", "16d85c18-459d-4e44-820f-18ec7a4ed3a5");

print_r($response);
16 changes: 6 additions & 10 deletions src/Adapter/FraudAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,12 @@ public function retrieveValueList($listName)
return $this->httpGet($path);
}

public function createValueList($listName)
public function createValueList($listName, $type)
{
$path = "/fraud/v1/value-lists";
$request = array(
'listName' => $listName
'listName' => $listName,
'type' => $type
);
return $this->httpPost($path, $request);
}
Expand All @@ -48,20 +49,15 @@ public function deleteValueList($listName)
return $this->httpDelete($path);
}

public function addValueToValueList($listName, $value, $expireInSeconds = null)
public function addValueToValueList($request)
{
$path = "/fraud/v1/value-lists";
$request = array(
'listName' => $listName,
'value' => $value,
'durationInSeconds' => $expireInSeconds
);
return $this->httpPost($path, $request);
}

public function removeValueFromValueList($listName, $value)
public function removeValueFromValueList($listName, $valueId)
{
$path = "/fraud/v1/value-lists/" . $listName . "/values/" . $value;
$path = "/fraud/v1/value-lists/" . $listName . "/values/" . $valueId;
return $this->httpDelete($path);
}
}
12 changes: 12 additions & 0 deletions src/Model/FraudValueType.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

namespace Craftgate\Model;

class FraudValueType
{
const CARD = 'CARD';
const IP = 'IP';
const PHONE_NUMBER = 'PHONE_NUMBER';
const EMAIL = 'EMAIL';
const OTHER = 'OTHER';
}

0 comments on commit da9458c

Please sign in to comment.