Skip to content

Commit 30687a4

Browse files
authored
Merge pull request #17 from klaviyo/guzzle-options
Guzzle options
2 parents f37526e + 97721d4 commit 30687a4

4 files changed

Lines changed: 45 additions & 42 deletions

File tree

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Klaviyo PHP SDK
22

3-
- SDK version: 2.0.1
3+
- SDK version: 2.0.2
44
- API Revision: 2023-02-22
55

66
## Helpful Resources
@@ -88,7 +88,8 @@ use KlaviyoAPI\KlaviyoAPI;
8888
$klaviyo = new KlaviyoAPI(
8989
'YOUR_API_KEY',
9090
$num_retries = 3,
91-
$wait_seconds = 3);
91+
$wait_seconds = 3,
92+
$guzzle_options = []);
9293

9394
$response = $klaviyo->Metrics->getMetrics();
9495
```

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "klaviyo/api",
3-
"version": "2.0.1",
3+
"version": "2.0.2",
44
"description": "PHP SDK for Klaviyo's API.",
55
"keywords": [
66
"openapitools",

lib/Configuration.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ class Configuration
101101
*
102102
* @var string
103103
*/
104-
protected $userAgent = 'klaviyo/api/2.0.1';
104+
protected $userAgent = 'klaviyo/api/2.0.2';
105105

106106
/**
107107
* Debug switch (default set to false)
@@ -434,7 +434,7 @@ public static function toDebugReport()
434434
$report .= ' OS: ' . php_uname() . PHP_EOL;
435435
$report .= ' PHP Version: ' . PHP_VERSION . PHP_EOL;
436436
$report .= ' The version of the OpenAPI document: 2023-02-22' . PHP_EOL;
437-
$report .= ' SDK Package Version: 2.0.1' . PHP_EOL;
437+
$report .= ' SDK Package Version: 2.0.2' . PHP_EOL;
438438
$report .= ' Temp Folder Path: ' . self::getDefaultConfiguration()->getTempFolderPath() . PHP_EOL;
439439

440440
return $report;

lib/KlaviyoAPI.php

Lines changed: 39 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class KlaviyoAPI {
2626
public $wait_seconds;
2727
public $num_retries;
2828
public $config;
29+
public $guzzle_options;
2930
public $Campaigns;
3031
public $Catalogs;
3132
public $Client;
@@ -41,7 +42,7 @@ class KlaviyoAPI {
4142

4243

4344

44-
public function __construct($api_key, $num_retries = 3, $wait_seconds = 3) {
45+
public function __construct($api_key, $num_retries = 3, $wait_seconds = 3, $guzzle_options = []) {
4546

4647
if (gettype($num_retries) == 'NULL'){
4748
$num_retries = 3;
@@ -54,81 +55,82 @@ public function __construct($api_key, $num_retries = 3, $wait_seconds = 3) {
5455
$this->api_key = $api_key;
5556
$this->num_retries = $num_retries;
5657
$this->wait_seconds = $wait_seconds;
58+
$this->guzzle_options = $guzzle_options;
5759

5860
$this->config = clone Configuration::getDefaultConfiguration();
5961
$this->config->setApiKey('Authorization',"Klaviyo-API-Key $this->api_key");
6062

6163

6264
$this->Campaigns = new Subclient(
63-
new CampaignsApi(new GuzzleClient(),$this->config),
64-
$wait_seconds = 3,
65-
$num_retries = 3,
65+
new CampaignsApi(new GuzzleClient($this->guzzle_options),$this->config),
66+
$wait_seconds = $this->$wait_seconds,
67+
$num_retries = $this->$num_retries,
6668
);
6769

6870
$this->Catalogs = new Subclient(
69-
new CatalogsApi(new GuzzleClient(),$this->config),
70-
$wait_seconds = 3,
71-
$num_retries = 3,
71+
new CatalogsApi(new GuzzleClient($this->guzzle_options),$this->config),
72+
$wait_seconds = $this->$wait_seconds,
73+
$num_retries = $this->$num_retries,
7274
);
7375

7476
$this->Client = new Subclient(
75-
new ClientApi(new GuzzleClient(),$this->config),
76-
$wait_seconds = 3,
77-
$num_retries = 3,
77+
new ClientApi(new GuzzleClient($this->guzzle_options),$this->config),
78+
$wait_seconds = $this->$wait_seconds,
79+
$num_retries = $this->$num_retries,
7880
);
7981

8082
$this->DataPrivacy = new Subclient(
81-
new DataPrivacyApi(new GuzzleClient(),$this->config),
82-
$wait_seconds = 3,
83-
$num_retries = 3,
83+
new DataPrivacyApi(new GuzzleClient($this->guzzle_options),$this->config),
84+
$wait_seconds = $this->$wait_seconds,
85+
$num_retries = $this->$num_retries,
8486
);
8587

8688
$this->Events = new Subclient(
87-
new EventsApi(new GuzzleClient(),$this->config),
88-
$wait_seconds = 3,
89-
$num_retries = 3,
89+
new EventsApi(new GuzzleClient($this->guzzle_options),$this->config),
90+
$wait_seconds = $this->$wait_seconds,
91+
$num_retries = $this->$num_retries,
9092
);
9193

9294
$this->Flows = new Subclient(
93-
new FlowsApi(new GuzzleClient(),$this->config),
94-
$wait_seconds = 3,
95-
$num_retries = 3,
95+
new FlowsApi(new GuzzleClient($this->guzzle_options),$this->config),
96+
$wait_seconds = $this->$wait_seconds,
97+
$num_retries = $this->$num_retries,
9698
);
9799

98100
$this->Lists = new Subclient(
99-
new ListsApi(new GuzzleClient(),$this->config),
100-
$wait_seconds = 3,
101-
$num_retries = 3,
101+
new ListsApi(new GuzzleClient($this->guzzle_options),$this->config),
102+
$wait_seconds = $this->$wait_seconds,
103+
$num_retries = $this->$num_retries,
102104
);
103105

104106
$this->Metrics = new Subclient(
105-
new MetricsApi(new GuzzleClient(),$this->config),
106-
$wait_seconds = 3,
107-
$num_retries = 3,
107+
new MetricsApi(new GuzzleClient($this->guzzle_options),$this->config),
108+
$wait_seconds = $this->$wait_seconds,
109+
$num_retries = $this->$num_retries,
108110
);
109111

110112
$this->Profiles = new Subclient(
111-
new ProfilesApi(new GuzzleClient(),$this->config),
112-
$wait_seconds = 3,
113-
$num_retries = 3,
113+
new ProfilesApi(new GuzzleClient($this->guzzle_options),$this->config),
114+
$wait_seconds = $this->$wait_seconds,
115+
$num_retries = $this->$num_retries,
114116
);
115117

116118
$this->Segments = new Subclient(
117-
new SegmentsApi(new GuzzleClient(),$this->config),
118-
$wait_seconds = 3,
119-
$num_retries = 3,
119+
new SegmentsApi(new GuzzleClient($this->guzzle_options),$this->config),
120+
$wait_seconds = $this->$wait_seconds,
121+
$num_retries = $this->$num_retries,
120122
);
121123

122124
$this->Tags = new Subclient(
123-
new TagsApi(new GuzzleClient(),$this->config),
124-
$wait_seconds = 3,
125-
$num_retries = 3,
125+
new TagsApi(new GuzzleClient($this->guzzle_options),$this->config),
126+
$wait_seconds = $this->$wait_seconds,
127+
$num_retries = $this->$num_retries,
126128
);
127129

128130
$this->Templates = new Subclient(
129-
new TemplatesApi(new GuzzleClient(),$this->config),
130-
$wait_seconds = 3,
131-
$num_retries = 3,
131+
new TemplatesApi(new GuzzleClient($this->guzzle_options),$this->config),
132+
$wait_seconds = $this->$wait_seconds,
133+
$num_retries = $this->$num_retries,
132134
);
133135

134136

0 commit comments

Comments
 (0)