Skip to content

Commit 50dc470

Browse files
authored
Merge pull request #13 from xelab/master
Give the ability to change the endpoint
2 parents 85ba3c5 + 8fee6f3 commit 50dc470

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

README.md

100644100755
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ If you need to pass any options to the guzzle client instance which is making th
4242
'open_tracking' => false,
4343
'click_tracking' => false,
4444
'transactional' => true,
45+
'endpoint' => 'https://api.sparkpost.com/api/v1/transmissions',
4546
],
4647
],
4748
```

src/Transport/SparkPostTransportFiveFive.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function send(Swift_Mime_SimpleMessage $message, &$failedRecipients = nul
3333
$options['json']['options'] = $this->options;
3434
}
3535

36-
return $this->client->post('https://api.sparkpost.com/api/v1/transmissions', $options);
36+
return $this->client->post($this->getEndpoint(), $options);
3737
}
3838

3939
/**

src/Transport/SparkPostTransportTrait.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function send(Swift_Mime_Message $message, &$failedRecipients = null)
6262
$options['json']['options'] = $this->options;
6363
}
6464

65-
return $this->client->post('https://api.sparkpost.com/api/v1/transmissions', $options);
65+
return $this->client->post($this->getEndpoint(), $options);
6666
}
6767

6868
/**
@@ -95,6 +95,21 @@ protected function getRecipients(Swift_Mime_Message $message)
9595
return $recipients;
9696
}
9797

98+
/**
99+
* Get the endpoint used by transport, depends if option endpoint is specified
100+
* Maybe https://api.sparkpost.com/api/v1/transmissions (default) or https://api.eu.sparkpost.com/api/v1/transmissions
101+
*
102+
* @return string
103+
*/
104+
public function getEndpoint()
105+
{
106+
$endpoint = 'https://api.sparkpost.com/api/v1/transmissions';
107+
if ($this->options && !empty($this->options['endpoint'])) {
108+
$endpoint = $this->options['endpoint'];
109+
}
110+
return $endpoint;
111+
}
112+
98113
/**
99114
* Get the API key being used by the transport.
100115
*

0 commit comments

Comments
 (0)