Skip to content

Commit

Permalink
feat(cancellation): Added cancellation functionality to postcards, le…
Browse files Browse the repository at this point in the history
…tters, and checks
  • Loading branch information
shrav committed Jun 27, 2016
1 parent 70573f5 commit 6551da5
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 37 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,6 @@ Make sure you provide a `test` API Key in your `phpunit.xml`.

=======================

Copyright © 2013 Lob.com
Copyright © 2016 Lob.com

Released under the MIT License, which can be found in the repository in `LICENSE.txt`.
5 changes: 0 additions & 5 deletions src/Lob/Resource/Checks.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,8 @@

namespace Lob\Resource;

use BadMethodCallException;
use Lob\Resource as ResourceBase;

class Checks extends ResourceBase
{
public function delete($id)
{
throw new BadMethodCallException(__CLASS__.'::'.__FUNCTION__.'() is not supported.');
}
}
5 changes: 0 additions & 5 deletions src/Lob/Resource/Letters.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,8 @@

namespace Lob\Resource;

use BadMethodCallException;
use Lob\Resource as ResourceBase;

class Letters extends ResourceBase
{
public function delete($id)
{
throw new BadMethodCallException(__CLASS__.'::'.__FUNCTION__.'() is not supported.');
}
}
7 changes: 1 addition & 6 deletions src/Lob/Resource/Postcards.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,8 @@

namespace Lob\Resource;

use BadMethodCallException;
use Lob\Resource as ResourceBase;

class Postcards extends ResourceBase
{
public function delete($id)
{
throw new BadMethodCallException(__CLASS__.'::'.__FUNCTION__.'() is not supported.');
}
}
}
33 changes: 23 additions & 10 deletions tests/Lob/Tests/Resource/ChecksTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,31 @@ public function testGet()
$this->assertTrue(array_key_exists('id', $getCheck));
}

public function testAll()
public function testDelete()
{
$checks = $this->resource->all();
$this->assertTrue(is_array($checks));
}
$account = $this->verifyBankAccount();
$check = $this->resource->create(array(
'description' => 'Demo Check',
'to[name]' => 'Amrit Ayalur',
'to[address_line1]' => '123 Test Street',
'to[address_city]' => 'Mountain View',
'to[address_state]' => 'CA',
'to[address_zip]' => '94041',
'to[address_country]' => 'US',
'from[name]' => 'Bryan Adams',
'from[address_line1]' => '123 Hello Ave',
'from[address_city]' => 'Providence',
'from[address_state]' => 'RI',
'from[address_zip]' => '02912',
'from[address_country]' => 'US',
'bank_account' => $this->getBankAccountId(),
'amount' => '2200',
'memo' => 'rent'
));
$id = $check['id'];
$deleted = $this->resource->delete($id);

/**
* @expectedException BadMethodCallException
*/
public function testDeleteFail()
{
$this->resource->delete('1');
$this->assertTrue(is_array($deleted));
}

}
17 changes: 12 additions & 5 deletions tests/Lob/Tests/Resource/LettersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,19 @@ public function testColorCreate()
$this->assertTrue(array_key_exists('id', $letter));
}

/**
* @expectedException BadMethodCallException
*/
public function testDeleteFail()
public function testDelete()
{
$create = $this->resource->delete('1');
$letter = $this->resource->create(array(
'to' => AddressesTest::$validCreateData,
'from' => AddressesTest::$validCreateData,
'description' => 'This an example message on back of the postcard',
'file' => 'https://lob.com/goblue.pdf',
'color' => FALSE
));
$id = $letter['id'];
$deleted = $this->resource->delete($id);

$this->assertTrue(is_array($deleted));
}

}
17 changes: 12 additions & 5 deletions tests/Lob/Tests/Resource/PostcardsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,19 @@ public function testCreateWithBackFile()
$this->assertTrue(array_key_exists('id', $postcard));
}

/**
* @expectedException BadMethodCallException
*/
public function testDeleteFail()
public function testDelete()
{
$create = $this->resource->delete('1');
$postcard = $this->resource->create(array(
'description' => 'Demo Postcard job', // Required
'to' => AddressesTest::$validCreateData,
'from' => AddressesTest::$validCreateData,
'message' => 'This an example message on back of the postcard',
'front' => 'https://lob.com/postcardfront.pdf'
));
$id = $postcard['id'];
$deleted = $this->resource->delete($id);

$this->assertTrue(is_array($deleted));
}

}

0 comments on commit 6551da5

Please sign in to comment.