Skip to content

Commit

Permalink
add /item/remove (#110)
Browse files Browse the repository at this point in the history
* make /item/remove primary item removal endpoint

* update docs
  • Loading branch information
michaelckelly authored Dec 1, 2017
1 parent 494244b commit bd166bf
Show file tree
Hide file tree
Showing 14 changed files with 67 additions and 29 deletions.
Empty file removed docs/.nojekyll
Empty file.
6 changes: 4 additions & 2 deletions docs/genindex.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Index &#8212; Plaid Python 2.0.2 documentation</title>
<title>Index &#8212; Plaid Python 2.0.3 documentation</title>

<link rel="stylesheet" href="_static/alabaster.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />

<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: './',
VERSION: '2.0.2',
VERSION: '2.0.3',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: false,
Expand Down Expand Up @@ -224,6 +224,8 @@ <h2 id="R">R</h2>
</li>
</ul></td>
<td style="width: 33%; vertical-align: top;"><ul>
<li><a href="index.html#plaid.api.Item.remove">remove() (plaid.api.Item method)</a>
</li>
<li><a href="index.html#plaid.api.sandbox.Sandbox.Item.Item.reset_login">reset_login() (plaid.api.sandbox.Sandbox.Item.Item method)</a>
</li>
</ul></td>
Expand Down
20 changes: 18 additions & 2 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Plaid Python Documentation! &#8212; Plaid Python 2.0.2 documentation</title>
<title>Plaid Python Documentation! &#8212; Plaid Python 2.0.3 documentation</title>

<link rel="stylesheet" href="_static/alabaster.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />

<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: './',
VERSION: '2.0.2',
VERSION: '2.0.3',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: false,
Expand Down Expand Up @@ -535,6 +535,22 @@ <h2>API Endpoints<a class="headerlink" href="#api-endpoints" title="Permalink to
</table>
</dd></dl>

<dl class="method">
<dt id="plaid.api.Item.remove">
<code class="descclassname">Item.</code><code class="descname">remove</code><span class="sig-paren">(</span><em>access_token</em><span class="sig-paren">)</span><a class="headerlink" href="#plaid.api.Item.remove" title="Permalink to this definition"></a></dt>
<dd><p>Remove an item.
(<a class="reference external" href="https://plaid.com/docs/api/#remove-an-item">HTTP docs</a>)</p>
<p>This also deactivates the access_token.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>access_token</strong> (<em>str</em>) &#8211; </td>
</tr>
</tbody>
</table>
</dd></dl>

</dd></dl>

<dl class="class">
Expand Down
4 changes: 2 additions & 2 deletions docs/py-modindex.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Python Module Index &#8212; Plaid Python 2.0.2 documentation</title>
<title>Python Module Index &#8212; Plaid Python 2.0.3 documentation</title>

<link rel="stylesheet" href="_static/alabaster.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />

<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: './',
VERSION: '2.0.2',
VERSION: '2.0.3',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: false,
Expand Down
4 changes: 2 additions & 2 deletions docs/search.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Search &#8212; Plaid Python 2.0.2 documentation</title>
<title>Search &#8212; Plaid Python 2.0.3 documentation</title>

<link rel="stylesheet" href="_static/alabaster.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />

<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: './',
VERSION: '2.0.2',
VERSION: '2.0.3',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: false,
Expand Down
2 changes: 1 addition & 1 deletion docs/searchindex.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions plaid/api/item.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,3 +216,16 @@ def delete(self, access_token):
return self.client.post('/item/delete', {
'access_token': access_token,
})

def remove(self, access_token):
'''
Remove an item.
(`HTTP docs <https://plaid.com/docs/api/#remove-an-item>`__)
This also deactivates the access_token.
:param str access_token:
'''
return self.client.post('/item/remove', {
'access_token': access_token,
})
2 changes: 1 addition & 1 deletion tests/integration/test_accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def setup_module(module):

def teardown_module(module):
client = create_client()
client.Item.delete(access_token)
client.Item.remove(access_token)


def test_get():
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/test_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def setup_module(module):

def teardown_module(module):
client = create_client()
client.Item.delete(access_token)
client.Item.remove(access_token)


def test_get():
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/test_credit_details.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def setup_module(module):

def teardown_module(module):
client = create_client()
client.Item.delete(access_token)
client.Item.remove(access_token)


def test_get():
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/test_identity.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def setup_module(module):

def teardown_module(module):
client = create_client()
client.Item.delete(access_token)
client.Item.remove(access_token)


def test_get():
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/test_income.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def setup_module(module):

def teardown_module(module):
client = create_client()
client.Item.delete(access_token)
client.Item.remove(access_token)


def test_get():
Expand Down
35 changes: 21 additions & 14 deletions tests/integration/test_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,21 @@
)


# Ensure that any items created are also deleted
# Ensure that any items created are also removed
@contextmanager
def ensure_item_deleted(access_token):
def ensure_item_removed(access_token):
try:
yield
finally:
create_client().Item.delete(access_token)
create_client().Item.remove(access_token)


def test_create():
client = create_client()
response = client.Item.create(
CREDENTIALS, SANDBOX_INSTITUTION, ['transactions'])

with ensure_item_deleted(response['access_token']):
with ensure_item_removed(response['access_token']):
assert response['access_token'] is not None
assert response['item']['billed_products'] == ['transactions']
assert response['item']['institution_id'] == SANDBOX_INSTITUTION
Expand All @@ -65,7 +65,7 @@ def test_create_with_options():
webhook='https://plaid.com/webhook-test',
)

with ensure_item_deleted(response['access_token']):
with ensure_item_removed(response['access_token']):
assert response['access_token'] is not None
assert response['item'] is not None
assert response['item']['webhook'] == 'https://plaid.com/webhook-test'
Expand All @@ -76,7 +76,7 @@ def test_mfa_device():
item_response = client.Item.create(
MFA_DEVICE_CREDENTIALS, SANDBOX_INSTITUTION, ['transactions'])

with ensure_item_deleted(item_response['access_token']):
with ensure_item_removed(item_response['access_token']):
assert item_response['mfa_type'] == 'device_list'

# Send MFA indicating which device should receive the code
Expand All @@ -99,7 +99,7 @@ def test_mfa_questions():
item_response = client.Item.create(
MFA_QUESTIONS_CREDENTIALS, SANDBOX_INSTITUTION, ['transactions'])

with ensure_item_deleted(item_response['access_token']):
with ensure_item_removed(item_response['access_token']):
assert item_response['mfa_type'] == 'questions'

mfa_response = client.Item.mfa(
Expand All @@ -112,7 +112,7 @@ def test_mfa_selections():
item_response = client.Item.create(
MFA_SELECTIONS_CREDENTIALS, SANDBOX_INSTITUTION, ['transactions'])

with ensure_item_deleted(item_response['access_token']):
with ensure_item_removed(item_response['access_token']):
assert item_response['mfa_type'] == 'selections'

mfa_response = client.Item.mfa(
Expand All @@ -125,7 +125,7 @@ def test_credentials_update():
create_response = client.Item.create(
CREDENTIALS, SANDBOX_INSTITUTION, ['transactions'])

with ensure_item_deleted(create_response['access_token']):
with ensure_item_removed(create_response['access_token']):
client.Sandbox.item.reset_login(create_response['access_token'])

update_response = client.Item.credentials.update(
Expand All @@ -138,7 +138,7 @@ def test_get():
create_response = client.Item.create(
CREDENTIALS, SANDBOX_INSTITUTION, ['transactions'])

with ensure_item_deleted(create_response['access_token']):
with ensure_item_removed(create_response['access_token']):
get_response = client.Item.get(create_response['access_token'])
assert get_response['item'] is not None

Expand All @@ -151,13 +151,20 @@ def test_delete():
delete_response = client.Item.delete(create_response['access_token'])
assert delete_response['deleted']

def test_remove():
client = create_client()
create_response = client.Item.create(
CREDENTIALS, SANDBOX_INSTITUTION, ['transactions'])

remove_response = client.Item.remove(create_response['access_token'])
assert remove_response['removed']

def test_public_token():
client = create_client()
item_response = client.Item.create(
CREDENTIALS, SANDBOX_INSTITUTION, ['transactions'])

with ensure_item_deleted(item_response['access_token']):
with ensure_item_removed(item_response['access_token']):
# access token -> public token
create_response = client.Item.public_token.create(
item_response['access_token'])
Expand All @@ -177,10 +184,10 @@ def test_access_token_invalidate():
try:
invalidate_response = client.Item.access_token.invalidate(
create_response['access_token'])
with ensure_item_deleted(invalidate_response['new_access_token']):
with ensure_item_removed(invalidate_response['new_access_token']):
assert invalidate_response['new_access_token'] is not None
except Exception:
with ensure_item_deleted(create_response['access_token']):
with ensure_item_removed(create_response['access_token']):
raise


Expand All @@ -189,7 +196,7 @@ def test_webhook_update():
create_response = client.Item.create(
CREDENTIALS, SANDBOX_INSTITUTION, ['transactions'])

with ensure_item_deleted(create_response['access_token']):
with ensure_item_removed(create_response['access_token']):
webhook_response = client.Item.webhook.update(
create_response['access_token'], 'https://plaid.com/webhook-test')
assert (webhook_response['item']['webhook'] ==
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/test_transactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def setup_module(module):

def teardown_module(module):
client = create_client()
client.Item.delete(access_token)
client.Item.remove(access_token)


def test_get():
Expand Down

0 comments on commit bd166bf

Please sign in to comment.