Skip to content

Commit 2c235e4

Browse files
authored
BGSTB-328 | Fix error on GET letters with tracking events (#189)
* Remove faulty validation * Unrelated fix for letters API * Get unit tests running in PRs * Only run unit tests
1 parent 49fb887 commit 2c235e4

3 files changed

Lines changed: 19 additions & 24 deletions

File tree

.github/workflows/run_tests.yml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,11 @@ jobs:
1616

1717
- uses: php-actions/composer@v6
1818

19-
- name: Run Tests
20-
uses: php-actions/phpunit@v3
19+
- name: Run Unit Tests
20+
run: vendor/bin/phpunit --group unit--coverage-text --coverage-clover=coverage/coverage.xml --configuration=phpunit.xml.dist
2121
env:
2222
LOB_API_TEST_KEY: ${{ secrets.LOB_API_TEST_KEY }}
2323
LOB_API_LIVE_KEY: ${{ secrets.LOB_API_LIVE_KEY }}
2424
XDEBUG_MODE: coverage
25-
with:
26-
bootstrap: vendor/autoload.php
27-
configuration: phpunit.xml.dist
28-
php_extensions: xdebug
29-
args: --coverage-text --coverage-clover=coverage/coverage.xml
25+
26+
# TODO: Run Integration Tests

lib/Api/LettersApi.php

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -340,17 +340,21 @@ public function createWithHttpInfo($letter_editable, $idempotency_key = null, $f
340340
$options = $this->createHttpClientOption();
341341
$requestError = null;
342342
try {
343-
$response = $this->client->request(
344-
'POST',
345-
$request->getUri()->__toString(),
346-
[
347-
'multipart' => [[
348-
'name' => 'file',
349-
'contents' => Utils::tryFopen($file, 'r')
350-
]],
351-
'auth' => $options['auth']
352-
]
353-
);
343+
if ($file !== null) {
344+
$response = $this->client->request(
345+
'POST',
346+
$request->getUri()->__toString(),
347+
[
348+
'multipart' => [[
349+
'name' => 'file',
350+
'contents' => Utils::tryFopen($file, 'r')
351+
]],
352+
'auth' => $options['auth']
353+
]
354+
);
355+
} else {
356+
$response = $this->client->send($request, $options);
357+
}
354358
} catch (RequestException $e) {
355359
$errorBody = json_decode($e->getResponse()->getBody()->getContents())->error;
356360
$requestError = new LobError();

lib/Model/Letter.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,12 +1108,6 @@ public function getTrackingEvents()
11081108
*/
11091109
public function setTrackingEvents($tracking_events)
11101110
{
1111-
if (!method_exists($this, 'getId') || (!empty($this->getId()) && strpos($this->getId(), "fakeId") === False)) {
1112-
1113-
if (!is_null($tracking_events) && (count($tracking_events) > 0)) {
1114-
throw new \InvalidArgumentException('invalid value for $tracking_events when calling Letter., number of items must be less than or equal to 0.');
1115-
}
1116-
}
11171111
$this->container['tracking_events'] = [];
11181112
if ($tracking_events) {
11191113
foreach ($tracking_events as $point) {

0 commit comments

Comments
 (0)