From 04cbdc90c33c2cbae0da9ce1f84acba4fc3cf10c Mon Sep 17 00:00:00 2001 From: Wouter Toering Date: Tue, 19 Nov 2019 13:37:32 +0100 Subject: [PATCH 1/2] Use correct parameter for sending form data to API This fixes #10 --- bynder_sdk/client/asset_bank_client.py | 4 ++-- bynder_sdk/client/collection_client.py | 6 +++--- example/app.py | 5 +++++ test/asset_bank_client_test.py | 4 ++-- test/collection_client_test.py | 6 +++--- 5 files changed, 15 insertions(+), 10 deletions(-) diff --git a/bynder_sdk/client/asset_bank_client.py b/bynder_sdk/client/asset_bank_client.py index 24c919a..0625d95 100644 --- a/bynder_sdk/client/asset_bank_client.py +++ b/bynder_sdk/client/asset_bank_client.py @@ -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): @@ -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. diff --git a/bynder_sdk/client/collection_client.py b/bynder_sdk/client/collection_client.py index acd9bd8..e178208 100644 --- a/bynder_sdk/client/collection_client.py +++ b/bynder_sdk/client/collection_client.py @@ -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. @@ -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): @@ -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 ) diff --git a/example/app.py b/example/app.py index 8f2cdf0..a959178 100644 --- a/example/app.py +++ b/example/app.py @@ -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( diff --git a/test/asset_bank_client_test.py b/test/asset_bank_client_test.py index 011b62f..5936a7e 100644 --- a/test/asset_bank_client_test.py +++ b/test/asset_bank_client_test.py @@ -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): @@ -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): diff --git a/test/collection_client_test.py b/test/collection_client_test.py index cd1daa1..2f4dcb6 100644 --- a/test/collection_client_test.py +++ b/test/collection_client_test.py @@ -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): @@ -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): @@ -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, [])) } From 31af9fbbe8a9a26e2b7a754f70c1141da7f1ebeb Mon Sep 17 00:00:00 2001 From: Wouter Toering Date: Tue, 19 Nov 2019 13:39:09 +0100 Subject: [PATCH 2/2] Bump version to 1.1.1 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 9084fa2..524cb55 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.1.0 +1.1.1