Skip to content

Commit

Permalink
Merge pull request #11 from WouterToering/fix_write_operations
Browse files Browse the repository at this point in the history
Use correct parameter for sending form data to API
  • Loading branch information
WouterToering authored Nov 19, 2019
2 parents 0bfda2d + 31af9fb commit 4cf8130
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 11 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.1.0
1.1.1
4 changes: 2 additions & 2 deletions bynder_sdk/client/asset_bank_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def set_media_properties(self, media_id, query: dict = None):
"""
return self.session.post(
'/v4/media/{0}/'.format(media_id),
payload=query or {}
data=query or {}
)

def delete_media(self, media_id):
Expand All @@ -66,7 +66,7 @@ def create_usage(self, integration_id, asset_id, query: dict = None):
query['integration_id'] = integration_id
query['asset_id'] = asset_id

return self.session.post('/media/usage/', payload=query)
return self.session.post('/media/usage/', data=query)

def usage(self, query: dict = None):
""" Gets all the media assets usage records.
Expand Down
6 changes: 3 additions & 3 deletions bynder_sdk/client/collection_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def create_collection(self, name, query: dict = None):
if query is None:
query = {}
query['name'] = name
return self.session.post('/v4/collections/', payload=query)
return self.session.post('/v4/collections/', data=query)

def delete_collection(self, collection_id):
""" Deletes a collection.
Expand All @@ -47,7 +47,7 @@ def add_media_to_collection(self, collection_id, media_ids: list):
}
return self.session.post(
'/v4/collections/{0}/media/'.format(collection_id),
payload=query
data=query
)

def remove_media_from_collection(self, collection_id, media_ids: list):
Expand Down Expand Up @@ -77,5 +77,5 @@ def share_collection(self, collection_id, collection_option,
query['recipients'] = ','.join(map(str, recipients))
return self.session.post(
'/v4/collections/{0}/share/'.format(collection_id),
payload=query
data=query
)
5 changes: 5 additions & 0 deletions example/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ def token_saver(token):
)
pp.pprint(media_info)

print('\n Set media description:')
media = asset_bank_client.set_media_properties(
media_id,
{'description': 'Description set using SDK'}
)

print('\n> Get download url:')
download_url = asset_bank_client.media_download_url(
Expand Down
4 changes: 2 additions & 2 deletions test/asset_bank_client_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def test_set_media_properties(self):
self.asset_bank_client.set_media_properties(media_id=1111)
self.asset_bank_client.session.post.assert_called_with(
'/v4/media/1111/',
payload={}
data={}
)

def test_delete_media(self):
Expand All @@ -133,7 +133,7 @@ def test_create_usage(self):
)
self.asset_bank_client.session.post.assert_called_with(
'/media/usage/',
payload=payload
data=payload
)

def test_get_usage(self):
Expand Down
6 changes: 3 additions & 3 deletions test/collection_client_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def test_create_collection(self):
)
self.collection_client.session.post.assert_called_with(
'/v4/collections/',
payload={'name': collection_name}
data={'name': collection_name}
)

def test_delete_collection(self):
Expand Down Expand Up @@ -77,7 +77,7 @@ def test_add_media_to_collection(self):
collection_id=1111, media_ids=media_ids)
self.collection_client.session.post.assert_called_with(
'/v4/collections/1111/media/',
payload={'data': json.dumps(media_ids)}
data={'data': json.dumps(media_ids)}
)

def test_remove_media_from_collection(self):
Expand All @@ -104,7 +104,7 @@ def test_share_collection(self):
)
self.collection_client.session.post.assert_called_with(
'/v4/collections/1111/share/',
payload={
data={
'collectionOptions': 'view',
'recipients': ','.join(map(str, []))
}
Expand Down

0 comments on commit 4cf8130

Please sign in to comment.