Skip to content

Commit 8bc076c

Browse files
committed
Enhancements & Documentation changes
1 parent db03262 commit 8bc076c

File tree

7 files changed

+315
-204
lines changed

7 files changed

+315
-204
lines changed

composer.json

Lines changed: 37 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,38 @@
11
{
2-
"name": "greip/api",
3-
"description": "Greip, protects your business from fraud and abuse by deploying AI-powered modules into your system.",
4-
"keywords": [
5-
"api",
6-
"ip",
7-
"location",
8-
"fraud",
9-
"abuse",
10-
"profanity",
11-
"geoip"
12-
],
13-
"license": "MIT",
14-
"authors": [
15-
{
16-
"name": "Greip",
17-
"email": "info@greip.io",
18-
"homepage": "https://greip.io/",
19-
"role": "Developer"
20-
}
21-
],
22-
"type": "library",
23-
"require": {
24-
"php": ">=7.4"
25-
},
26-
"autoload": {
27-
"psr-4": {
28-
"Greip\\API\\": "src/"
29-
}
30-
},
31-
"minimum-stability": "stable"
32-
}
2+
"name": "greip/api",
3+
"description": "Greip, protects your business from fraud and abuse by deploying AI-powered modules into your system.",
4+
"keywords": [
5+
"api",
6+
"ip",
7+
"location",
8+
"fraud",
9+
"abuse",
10+
"profanity",
11+
"geoip",
12+
"bin lookup",
13+
"email verification",
14+
"phone verification",
15+
"ip reputation",
16+
"ip intelligence",
17+
"iban validation"
18+
],
19+
"license": "MIT",
20+
"authors": [
21+
{
22+
"name": "Greip",
23+
"email": "info@greip.io",
24+
"homepage": "https://greip.io/",
25+
"role": "Developer"
26+
}
27+
],
28+
"type": "library",
29+
"require": {
30+
"php": ">=7.4"
31+
},
32+
"autoload": {
33+
"psr-4": {
34+
"Greip\\API\\": "src/"
35+
}
36+
},
37+
"minimum-stability": "stable"
38+
}

src/Config.php

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44

55
class Config
66
{
7-
public static $APIKey = "";
7+
public static $APIKey = null;
88

99
/**
10-
* setKey method
10+
* Set the API Key
1111
*
12-
* @param string $key Pass you API Key as a string here. You can also store it in a .env file and pass a variable that returns the API Key as a string.
12+
* @param string $key The API Key
1313
*
1414
* @return bool
1515
*/
16-
public function setKey($key): bool
16+
public function setToken($key): bool
1717
{
1818
if (!empty($key)) {
1919
self::$APIKey = $key;
@@ -23,7 +23,24 @@ public function setKey($key): bool
2323
}
2424
}
2525

26-
public function getKey(): string
26+
/**
27+
* Set the API Key
28+
*
29+
* @param string $key The API Key
30+
*
31+
* @return bool
32+
*/
33+
public function setKey($key): bool
34+
{
35+
return self::setToken($key);
36+
}
37+
38+
/**
39+
* Get the API Key
40+
*
41+
* @return string
42+
*/
43+
public function getToken(): string
2744
{
2845
return self::$APIKey;
2946
}

src/Enums/Language.php

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
namespace Greip\API\Enums;
3+
4+
use ReflectionClass;
5+
6+
abstract class Language
7+
{
8+
const AR = "AR";
9+
const EN = "EN";
10+
const DE = "DE";
11+
const FR = "FR";
12+
const ES = "ES";
13+
const JA = "JA";
14+
const ZH = "ZH";
15+
const RU = "RU";
16+
17+
/**
18+
* Get all constants of this class
19+
*
20+
* @return array
21+
*/
22+
public static function values()
23+
{
24+
$reflector = new ReflectionClass(__CLASS__);
25+
return $reflector->getConstants();
26+
}
27+
28+
/**
29+
* Checks if a constant exist by value
30+
*
31+
* @param string $constant_value E.g: `isExist('dash')`.
32+
* @return boolean
33+
*/
34+
public static function isExist($constant_value)
35+
{
36+
$constants = self::values();
37+
return in_array($constant_value, $constants, true);
38+
}
39+
}

src/Enums/Mode.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
namespace Greip\API\Enums;
3+
4+
use ReflectionClass;
5+
6+
abstract class Mode
7+
{
8+
const LIVE = "live";
9+
const DEVELOPMENT = "test";
10+
11+
/**
12+
* Get all constants of this class
13+
*
14+
* @return array
15+
*/
16+
public static function values()
17+
{
18+
$reflector = new ReflectionClass(__CLASS__);
19+
return $reflector->getConstants();
20+
}
21+
22+
/**
23+
* Checks if a constant exist by value
24+
*
25+
* @param string $constant_value E.g: `isExist('dash')`.
26+
* @return boolean
27+
*/
28+
public static function isExist($constant_value)
29+
{
30+
$constants = self::values();
31+
return in_array($constant_value, $constants, true);
32+
}
33+
}

src/Enums/Param.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
namespace Greip\API\Enums;
3+
4+
use ReflectionClass;
5+
6+
abstract class Param
7+
{
8+
const LANGUAGE = "language";
9+
const FLAG = "flag";
10+
const CURRENCY = "currency";
11+
const TIMEZONE = "timezone";
12+
const LOCATION = "location";
13+
const SECURITY = "security";
14+
const DEVICE = "device";
15+
16+
/**
17+
* Get all constants of this class
18+
*
19+
* @return array
20+
*/
21+
public static function values()
22+
{
23+
$reflector = new ReflectionClass(__CLASS__);
24+
return $reflector->getConstants();
25+
}
26+
27+
/**
28+
* Checks if a constant exist by value
29+
*
30+
* @param string $constant_value E.g: `isExist('dash')`.
31+
* @return boolean
32+
*/
33+
public static function isExist($constant_value)
34+
{
35+
$constants = self::values();
36+
return in_array($constant_value, $constants, true);
37+
}
38+
}

0 commit comments

Comments
 (0)