-
Notifications
You must be signed in to change notification settings - Fork 19
/
ReportTransaction.php
62 lines (56 loc) · 2.49 KB
/
ReportTransaction.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
namespace MaxMind;
use MaxMind\Exception\InvalidInputException;
class ReportTransaction extends ServiceClient
{
/**
* @param int $accountId Your MaxMind account ID
* @param string $licenseKey Your MaxMind license key
* @param array $options An array of options. Possible keys:
*
* * `host` - The host to use when connecting to the web service.
* * `userAgent` - The prefix for the User-Agent header to use in the
* request.
* * `caBundle` - The bundle of CA root certificates to use in the request.
* * `connectTimeout` - The connect timeout to use for the request.
* * `timeout` - The timeout to use for the request.
* * `proxy` - The HTTP proxy to use. May include a schema, port,
* username, and password, e.g., `http://username:password@127.0.0.1:10`.
* * `validateInput` - Default is `true`. Determines whether values passed
* to the `with*()` methods are validated. It is recommended that you
* leave validation on while developing and only (optionally) disable it
* before deployment.
*/
public function __construct(
$accountId,
$licenseKey,
$options = []
) {
parent::__construct($accountId, $licenseKey, $options);
}
/**
* @param array $values the transaction parameters
*
* @throws InvalidInputException when the request has missing or invalid
* data
* @throws AuthenticationException when there is an issue authenticating the
* request
* @throws InvalidRequestException when the request is invalid for some
* other reason, e.g., invalid JSON in the POST.
* @throws HttpException when an unexpected HTTP error occurs
* @throws WebServiceException when some other error occurs. This also
* serves as the base class for the above exceptions.
*/
public function reportTransaction($values)
{
$values = $this->cleanAndValidate('TransactionReport', $values);
if (!isset($values['ip_address'])) {
throw new InvalidInputException('Key ip_address must be present in request');
}
if (!isset($values['tag'])) {
throw new InvalidInputException('Key tag must be present in request');
}
$url = self::$basePath . 'transactions/report';
$this->client->post('ReportTransaction', $url, $values);
}
}