ActiveCampaign / postmark-php

The official PHP library for Postmark.

Home Page:https://postmarkapp.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Setting custom Guzzle client tha wasn't instantiated with the correct 'base_url' option will cause all requests to fail

webignition opened this issue · comments

PostmarkClientBase::processRestRequest() creates a request using only the provided path as the uri.

The default Guzzle client is instantiated with a base_uri config option of https://api.postmarkapp.com. HTTP requests only succeed if the default Guzzle client is used or if a custom client is provided that just so happens to have been instantiated with the correct base_uri config option.

PostmarkClientBase is assuming a Guzzle client with the correct base uri. If a custom Guzzle client is set that doesn't have the correct base uri, all requests will fail. It's not readily obvious that this will occur without digging around in the code.

This can be resolved by not setting the base_uri config option when instantiating the Guzzle client and instead prefixing the provided path with the correct uri when the request is created.

Doing so will allow a custom Guzzle client with no base uri to be used.

I'm happy to work up a fix and submit a PR.