You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* made changes to readme.md and composer.json
* switched bold to header
* updated README.md
* made review changes
* small change to wording
* another small wording change
Copy file name to clipboardExpand all lines: README.md
+102-43
Original file line number
Diff line number
Diff line change
@@ -12,6 +12,8 @@ The official PHP library for using [the SparkPost REST API](https://developers.s
12
12
Before using this library, you must have a valid API Key. To get an API Key, please log in to your SparkPost account and generate one in the Settings page.
13
13
14
14
## Installation
15
+
**Please note: The composer package `sparkpost/php-sparkpost` has been changed to `sparkpost/sparkpost` starting with version 2.0.**
16
+
15
17
The recommended way to install the SparkPost PHP Library is through composer.
Next, run the Composer command to install the SparkPost PHP Library:
23
25
24
26
```
25
-
composer require sparkpost/php-sparkpost
27
+
composer require sparkpost/sparkpost
26
28
```
27
29
28
30
After installing, you need to require Composer's autoloader:
@@ -36,13 +38,15 @@ use SparkPost\SparkPost;
36
38
37
39
Because of dependency collision, we have opted to use a request adapter rather than
38
40
requiring a request library. This means that your application will need to pass in
39
-
a request adapter to the constructor of the SparkPost Library. We use the [HTTPlug](https://github.com/php-http/httplug) in SparkPost. Please visit their repo for a list of supported adapters. If you don't currently use a request library, you will
40
-
need to require one and create an adapter from it and pass it along. The example below uses the GuzzleHttp Client Library.
41
+
a request adapter to the constructor of the SparkPost Library. We use the [HTTPlug](https://github.com/php-http/httplug) in SparkPost. Please visit their repo for a list of supported [clients and adapters](http://docs.php-http.org/en/latest/clients.html). If you don't currently use a request library, you will
42
+
need to require one and create a client from it and pass it along. The example below uses the GuzzleHttp Client Library.
41
43
42
-
An Adapter can be setup like so:
44
+
An Client can be setup like so:
43
45
44
46
```php
45
47
<?php
48
+
require 'vendor/autoload.php';
49
+
46
50
use SparkPost\SparkPost;
47
51
use GuzzleHttp\Client;
48
52
use Http\Adapter\Guzzle6\Client as GuzzleAdapter;
@@ -81,10 +85,11 @@ $sparky = new SparkPost($httpClient, ['key'=>'YOUR_API_KEY']);
81
85
* Required: No
82
86
* Type: `String`
83
87
* Default: `v1`
84
-
*`options.timeout`
88
+
*`options.async`
85
89
* Required: No
86
-
* Type: `Number`
87
-
* Default: `10`
90
+
* Type: `Boolean`
91
+
* Default: `true`
92
+
*`async` defines if the `request` function sends an asynchronous or synchronous request. If your client does not support async requests set this to `false`
88
93
89
94
90
95
## Methods
@@ -106,6 +111,12 @@ $sparky = new SparkPost($httpClient, ['key'=>'YOUR_API_KEY']);
106
111
* Type: `Array`
107
112
* Custom headers to be sent with the request.
108
113
114
+
### syncRequest(method, uri [, payload [, headers]])
115
+
Sends a synchronous request to the SparkPost API and returns a `SparkPostResponse`
116
+
117
+
### asyncRequest(method, uri [, payload [, headers]])
118
+
Sends an asynchronous request to the SparkPost API and returns a `SparkPostPromise`
119
+
109
120
### setHttpClient(httpClient)
110
121
*`httpClient`
111
122
* Required: Yes
@@ -115,7 +126,7 @@ $sparky = new SparkPost($httpClient, ['key'=>'YOUR_API_KEY']);
115
126
*`options`
116
127
* Required: Yes
117
128
* Type: `Array`
118
-
* See initialization
129
+
* See constructor
119
130
120
131
121
132
## Endpoints
@@ -141,38 +152,60 @@ $sparky = new SparkPost($httpClient, ['key'=>'YOUR_API_KEY']);
141
152
### Send An Email Using The Transmissions Endpoint
142
153
```php
143
154
<?php
155
+
require 'vendor/autoload.php';
156
+
144
157
use SparkPost\SparkPost;
145
158
use GuzzleHttp\Client;
146
159
use Http\Adapter\Guzzle6\Client as GuzzleAdapter;
147
160
148
161
$httpClient = new GuzzleAdapter(new Client());
149
162
$sparky = new SparkPost($httpClient, ['key'=>'YOUR_API_KEY']);
### Send An API Call Using The Base Request Function
173
-
We may not wrap every resource available in the SparkPost Client Library, for example the PHP Client Library does not wrap the Metrics resource. To allow you to use the full power of our API we created the `request` function which allows you to access the unwrapped resources.
204
+
We provide a base request function to access any of our API resources.
174
205
```php
175
206
<?php
207
+
require 'vendor/autoload.php';
208
+
176
209
use SparkPost\SparkPost;
177
210
use GuzzleHttp\Client;
178
211
use Http\Adapter\Guzzle6\Client as GuzzleAdapter;
@@ -181,58 +214,84 @@ $httpClient = new GuzzleAdapter(new Client());
181
214
$sparky = new SparkPost($httpClient, ['key'=>'YOUR_API_KEY']);
0 commit comments