Skip to content

Commit

Permalink
Merge pull request #72 from xendit/feat/set-httpcli
Browse files Browse the repository at this point in the history
feat(http_client): Enable setting of custom HTTP client
  • Loading branch information
stanleynguyen authored Apr 28, 2020
2 parents f3c4e45 + 178cf74 commit b96327a
Show file tree
Hide file tree
Showing 12 changed files with 2,396 additions and 26 deletions.
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
root = true

[*]
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = space
indent_size = 4

[*.md]
trim_trailing_whitespace = false
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ clover.xml

.env

composer.lock
composer-setup.php
bin/
17 changes: 13 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ This library is the abstraction of Xendit API for access from applications writt
- [Running test suite](#running-test-suite)
- [Running examples](#running-examples)


---

## Documentation
Expand Down Expand Up @@ -94,7 +93,17 @@ Configure package with your account's secret key obtained from [Xendit Dashboard
Xendit::setApiKey('secretKey');
```

See example codes for more details.
See [example codes](./examples) for more details.

### Use Custom HTTP Client

A custom HTTP Client that implements [HttpClientInterface](./src/HttpClientInterface.php) can be injected like so

```php
Xendit::setHttpClient($client);
```

Checkout [custom http client example](./examples/CustomHttpClient.php) for implementation reference.

## Methods' Signature and Examples

Expand Down Expand Up @@ -837,7 +846,7 @@ For example, there are required arguments such as `external_id`, `payer_email`,

### ApiException

`ApiException` wraps up Xendit API error. This exception will be thrown if there are errors from Xendit API side, e.g. get fixed virtual account with invalid `id`.
`ApiException` wraps up Xendit API error. This exception will be thrown if there are errors from Xendit API side, e.g. get fixed virtual account with invalid `id`.

To get exception message:

Expand Down Expand Up @@ -887,4 +896,4 @@ vendor\bin\phpunit tests
php examples\InvoiceExample.php
```

There is a pre-commit hook to run phpcs and phpcbf. Please make sure they passed before making commits/pushes.
There is a pre-commit hook to run phpcs and phpcbf. Please make sure they passed before making commits/pushes.
10 changes: 7 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
{
"name": "xendit/xendit-php",
"description": "PHP clients for Xendit API",
"version": "2.3.1",
"keywords": ["xendit"],
"version": "2.4.0",
"keywords": [
"xendit"
],
"homepage": "https://github.com/xendit/xendit-php",
"type": "library",
"minimum-stability": "stable",
Expand All @@ -13,7 +15,9 @@
"ext-json": "*"
},
"autoload": {
"psr-4": { "Xendit\\": "src/" }
"psr-4": {
"Xendit\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
Expand Down
Loading

0 comments on commit b96327a

Please sign in to comment.