File tree 3 files changed +15
-18
lines changed
3 files changed +15
-18
lines changed Original file line number Diff line number Diff line change @@ -8,20 +8,13 @@ A php library for interacting with AutopilotHQ API http://docs.autopilot.apiary.
8
8
$ composer require picr/php-autopilothq
9
9
```
10
10
11
- Create an ` .env ` file
12
- ``` env
13
- AUTOPILOT_SECRET=your-secret-key
14
- ```
15
-
16
11
## Usage
17
12
---
18
13
All interaction occurs in the ` AutopilotManager ` class.
19
14
20
15
### initialize manager
21
16
``` php
22
- // NOTE: AUTOPILOT_SECRET must be defined in .env file
23
- // NOTE: if AUTOPILOT_HOST is not defined in .env file, will use 'https://api2.autopilothq.com/v1/'
24
- $manager = new AutopilotManager();
17
+ $manager = new AutopilotManager($apiKey);
25
18
```
26
19
27
20
### getContact
Original file line number Diff line number Diff line change 14
14
],
15
15
"require" : {
16
16
"php" : " >=5.5.9" ,
17
- "guzzlehttp/guzzle" : " ~6.0" ,
18
- "vlucas/phpdotenv" : " ~2.2"
17
+ "guzzlehttp/guzzle" : " ~6.0"
19
18
},
20
19
"require-dev" : {
21
20
"codeception/codeception" : " ~2.1" ,
22
- "codeception/aspect-mock" : " dev-master"
21
+ "codeception/aspect-mock" : " dev-master" ,
22
+ "vlucas/phpdotenv" : " ~2.2"
23
+ },
24
+ "suggest" : {
25
+ "vlucas/phpdotenv" : " Allows secrets to be loaded from .env files."
23
26
},
24
27
"autoload" : {
25
28
"psr-4" : {
Original file line number Diff line number Diff line change @@ -30,18 +30,19 @@ class AutopilotManager
30
30
31
31
/**
32
32
* AutopilotManager constructor.
33
+ *
34
+ * @param string $apiKey
35
+ * Autopilot secret key.
36
+ * @param string $apiHost
37
+ * Autopilot host URI.
33
38
*/
34
- public function __construct ()
39
+ public function __construct ($ apiKey , $ apiHost = null )
35
40
{
36
- // load required apikey from config
37
- $ this ->apiKey = getenv ('AUTOPILOT_SECRET ' );
38
- if ($ this ->apiKey === null ) {
39
- throw AutopilotException::missingApiKey ();
40
- }
41
+ $ this ->apiKey = $ apiKey ;
41
42
42
43
// instantiate client
43
44
$ this ->client = new Client ([
44
- 'base_uri ' => getenv ( ' AUTOPILOT_HOST ' ) ?: 'https://api2.autopilothq.com/v1/ ' ,
45
+ 'base_uri ' => $ apiHost ?: 'https://api2.autopilothq.com/v1/ ' ,
45
46
]);
46
47
}
47
48
You can’t perform that action at this time.
0 commit comments