Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added cancel method to pre-auth and subscription resources

  • Loading branch information...
commit 6e5b219c8552a9b90c1f05e72d6a8f812ef1fc83 1 parent 90168f0
@alexjg alexjg authored
View
4 CHANGELOG.md
@@ -1,3 +1,7 @@
+## 0.1.3 - August 6, 2012
+
+- Added cancel method for pre-authorizations and subscriptions.
+
## 0.1.2 - May 14, 2012
- Fixed gocardless.Client.validate_webhook, it was not returning a value.
View
2  gocardless/client.py
@@ -127,7 +127,7 @@ def merchant(self):
Returns the current Merchant's details.
"""
merchant_url = '/merchants/%s' % self._merchant_id
- return Merchant(self.api_get(mechant_url), self)
+ return Merchant(self.api_get(merchant_url), self)
def user(self, id):
"""
View
4 gocardless/resources.py
@@ -146,6 +146,10 @@ def create_bill(self, amount, name=None, description=None):
return Bill.create_under_preauth(amount, self.id, self.client,
name=name, description=description)
+ def cancel(self):
+ path = "{0}/cancel".format(self.endpoint.replace(":id", self.id))
+ self.client.api_put(path)
+
class Bill(Resource):
endpoint = "/bills/:id"
View
1  requirements.txt
@@ -1,2 +1,3 @@
mock==0.8.0
nose==1.1.2
+requests==0.13.6
View
10 test/test_resources.py
@@ -195,6 +195,16 @@ def test_cancel_puts(self):
client.api_put.assert_called_with("/subscriptions/{0}/cancel".format(
fixtures.subscription_json["id"]))
+class PreAuthCancelTestCase(unittest.TestCase):
+
+ def test_cancel_puts(self):
+ client = mock.Mock()
+ preauth= PreAuthorization(fixtures.preauth_json, client)
+ preauth.cancel()
+ client.api_put.assert_called_with(
+ "/pre_authorizations/{0}/cancel".format(
+ fixtures.preauth_json["id"]))
+
class PreAuthBillCreationTestCase(unittest.TestCase):
Please sign in to comment.
Something went wrong with that request. Please try again.