Skip to content

Commit

Permalink
Merge pull request #7 from mblsolutions/feature/D00782JB-bulk-ecodes
Browse files Browse the repository at this point in the history
Feature/d00782 jb bulk ecodes
  • Loading branch information
rsloan-mlbsolutions authored Jan 11, 2024
2 parents 52cd917 + 2ab9071 commit 18ce4c3
Show file tree
Hide file tree
Showing 15 changed files with 127 additions and 19 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/simfoni-php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ on:
- fix/*
jobs:
simfoni-php-tests:
runs-on: ubuntu-18.04
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 7.1
php-version: 8.1
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite
coverage: none
- name: Install Dependencies
Expand Down
6 changes: 6 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## v2.5.0

+ PHP ^8.0 compatability
+ Add ability to pass id type to cancel and show order methods
+ Add new resend webhook function

## v2.4.1

+ PHP 7.1 compatability
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
}
],
"require": {
"php": ">=7.1",
"php": ">=7.1|^8.0",
"ext-json": "*",
"ext-openssl": "*",
"guzzlehttp/guzzle": "^6.0|^7.0"
},
"require-dev": {
"phpunit/phpunit": "^7.0"
"phpunit/phpunit": "^7.0|^9.3"
},
"autoload": {
"psr-4": {
Expand Down
13 changes: 7 additions & 6 deletions src/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ public function create(array $params = []): array
* @param string $id
* @return array
*/
public function cancel(string $id): array
public function cancel(string $id, string $type = 'id'): array
{
return $this->getApiRequestor()->deleteRequest('/api/order/'.$id);
return $this->getApiRequestor()->deleteRequest('/api/order/'.$id.'?type='.$type);
}

/**
Expand All @@ -41,14 +41,15 @@ public function search(array $params = []): array
}

/**
* Show Product
* Show Order
*
* @param string $id
* @param string $id
* @param string $type
* @return array
*/
public function show(string $id): array
public function show(string $id, string $type = 'id'): array
{
return $this->getApiRequestor()->getRequest('/api/order/'.$id);
return $this->getApiRequestor()->getRequest('/api/order/'.$id.'?type='.$type);
}

/**
Expand Down
21 changes: 21 additions & 0 deletions src/Webhook.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace MBLSolutions\Simfoni;

use MBLSolutions\Simfoni\Api\ApiResource;

class Webhook extends ApiResource
{

/**
* Create an Order
*
* @param array $params
* @return array
*/
public function resend(string $id, array $params = []): array
{
return $this->getApiRequestor()->postRequest('/api/webhook/resend/'.$id, $params);
}

}
2 changes: 1 addition & 1 deletion tests/AccountTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class AccountTest extends TestCase
protected $account;

/** {@inheritdoc} **/
public function setUp()
public function setUp(): void
{
parent::setUp();

Expand Down
2 changes: 1 addition & 1 deletion tests/AuthenticationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class AuthenticationTest extends TestCase
protected $authentication;

/** {@inheritdoc} **/
public function setUp()
public function setUp(): void
{
parent::setUp();

Expand Down
2 changes: 1 addition & 1 deletion tests/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class ClientTest extends TestCase
protected $client;

/** {@inheritdoc} **/
public function setUp()
public function setUp(): void
{
parent::setUp();

Expand Down
2 changes: 1 addition & 1 deletion tests/ContactTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class ContactTest extends TestCase
protected $contact;

/** {@inheritdoc} **/
public function setUp()
public function setUp(): void
{
parent::setUp();

Expand Down
2 changes: 1 addition & 1 deletion tests/DeliveryMethodTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class DeliveryMethodTest extends TestCase
protected $deliveryMethod;

/** {@inheritdoc} **/
public function setUp()
public function setUp(): void
{
parent::setUp();

Expand Down
2 changes: 1 addition & 1 deletion tests/IssuedInfoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class IssuedInfoTest extends TestCase
protected $issuedInfo;

/** {@inheritdoc} **/
public function setUp()
public function setUp(): void
{
parent::setUp();

Expand Down
2 changes: 1 addition & 1 deletion tests/OrderItemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class OrderItemTest extends TestCase
protected $orderItem;

/** {@inheritdoc} **/
public function setUp()
public function setUp(): void
{
parent::setUp();

Expand Down
27 changes: 26 additions & 1 deletion tests/OrderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class OrderTest extends TestCase
protected $order;

/** {@inheritdoc} **/
public function setUp()
public function setUp(): void
{
parent::setUp();

Expand Down Expand Up @@ -53,6 +53,16 @@ public function can_cancel_order(): void
self::assertEquals($this->order->cancel(1), $this->getMockedResponseBody());
}

/** @test * */
public function can_cancel_order_by_ref(): void
{
$this->mockExpectedHttpResponse([
'message' => 'Order ref-1111 cancelled.'
]);

self::assertEquals($this->order->cancel('ref-1111', 'ref'), $this->getMockedResponseBody());
}

/** @test * */
public function can_search_orders(): void
{
Expand Down Expand Up @@ -85,6 +95,21 @@ public function can_show_order(): void
self::assertEquals($this->order->show(1), $this->getMockedResponseBody());
}

/** @test * */
public function can_show_order_by_reference(): void
{
$this->mockExpectedHttpResponse([
'data' => [
[
'id' => 1,
'reference' => 'ref-1111',
],
]
]);

self::assertEquals($this->order->show('ref-1111', 'ref'), $this->getMockedResponseBody());
}

/** @test * */
public function can_list_all_orders(): void
{
Expand Down
2 changes: 1 addition & 1 deletion tests/ProductTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class ProductTest extends TestCase
protected $product;

/** {@inheritdoc} **/
public function setUp()
public function setUp(): void
{
parent::setUp();

Expand Down
55 changes: 55 additions & 0 deletions tests/WebhookTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php

namespace MBLSolutions\Simfoni\Tests;

use MBLSolutions\Simfoni\Order;
use MBLSolutions\Simfoni\Simfoni;
use MBLSolutions\Simfoni\Webhook;

class WebhookTest extends TestCase
{
/** @var Order $order */
protected $order;

/** {@inheritdoc} **/
public function setUp(): void
{
parent::setUp();

Simfoni::setToken('test-token');

$this->webhook = new Webhook();
}

/** @test * */
public function can_request_webhook_resend()
{
$id = 'test-1111';
$params = ['event' => 'order.cancelled', 'type' => 'reference'];

$this->mockExpectedHttpResponse([
'message' => 'Webhook order.cancelled for order 123 resent'
]);

self::assertEquals($this->webhook->resend($id, $params), $this->getMockedResponseBody());
}

/** @test * */
public function can_request_webhook_resend_with_defaults()
{
$id = '123';

$this->mockExpectedHttpResponse([
'message' => 'Webhook order.complete for order 123 resent'
]);

self::assertEquals($this->webhook->resend($id), $this->getMockedResponseBody());
}

/** @test * */
public function can_not_request_webhook_without_id()
{
self::expectException('ArgumentCountError');
$this->webhook->resend();
}
}

0 comments on commit 18ce4c3

Please sign in to comment.