Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PSR-ify the CourierClient 🔌 #29

Merged
merged 12 commits into from
Feb 3, 2022
14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,32 @@ For a full description of request and response payloads and properties, please s
## Requirements

- PHP 7.2+
- ext-curl
- ext-json

## Installation

This library uses [HTTPlug](https://github.com/php-http/httplug) as HTTP client. HTTPlug is an abstraction that allows
this library to support different HTTP Clients. Therefore, you need to provide it with an client and/or adapter for the HTTP
library you prefer. You can find all the available adapters [in Packagist](https://packagist.org/providers/php-http/client-implementation).
This documentation assumes you use the Guzzle Client, but you can replace it with any client that you prefer.

The recommended way to install courier-php is through Composer:

```bash
composer require trycourier/courier
composer require trycourier/courier guzzlehttp/guzzle
```

## Configuration

Instantiate the Courier client class with your authorization token OR username and password. Providing just a authorization token will generate a "Bearer" authorization header, while providing a username and password will generate a "Basic" (base64-encoded) authorization header
Instantiate the Courier client class with your authorization token OR username and password. Providing just an authorization token will generate a "Bearer" authorization header, while providing a username and password will generate a "Basic" (base64-encoded) authorization header

```php
$client = new CourierClient("base-url", "authorization-token", "username", "password");
```

### Options

Many methods allow the passing of optional data to the Courier endoint. This data should be an associative array of key/value pairs. The exact options supported are dependent on the endpoint being called. Please refer to the official Courier documentation for more information.
Many methods allow the passing of optional data to the Courier endpoints. This data should be an associative array of key/value pairs. The exact options supported are dependent on the endpoint being called. Please refer to the official Courier documentation for more information.

```php
$profile = [
Expand Down
10 changes: 8 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,20 @@
"require": {
"php": ">=7.2",
"ext-json": "*",
"ext-curl": "*",
"nimbly/shuttle": "^0.3"
"psr/http-message": "^1.0",
"psr/http-client-implementation": "^1.0",
"php-http/httplug": "^2.0",
"php-http/message-factory": "^1.0",
"php-http/discovery": "^1.0"
},
"require-dev": {
"phpunit/phpunit": "^8.1",
"vimeo/psalm": "^3.3",
"symfony/var-dumper": "^4.2",
"php-coveralls/php-coveralls": "^2.1",
"php-http/mock-client": "^1.0",
"php-http/message": "^1.0",
"guzzlehttp/psr7": "^2.1",
"illuminate/support": ">=6.0"
},
"autoload": {
Expand Down
Loading