From 3d9ff23009069504646fdeaaec71d70e2a60fd28 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Fri, 5 Jan 2018 13:18:26 +0000 Subject: [PATCH 1/2] Get the media id from the response --- bynder_sdk/client/asset_bank_client.py | 9 +++++---- bynder_sdk/client/upload_client.py | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/bynder_sdk/client/asset_bank_client.py b/bynder_sdk/client/asset_bank_client.py index 1bb2deb..82b7812 100644 --- a/bynder_sdk/client/asset_bank_client.py +++ b/bynder_sdk/client/asset_bank_client.py @@ -103,14 +103,15 @@ def delete_usage(self, integration_id, asset_id, query: dict = None): params=query ) - def upload_file(self, file_path, brand_id, media_id: str = '', query: dict = None): - """ Upload file. - """ + def upload_file(self, file_path: str, brand_id: str, + media_id: str = '', query: dict = None): + """ Upload file.""" if query is None: query = {} query['brandId'] = brand_id - self.upload_client.upload( + response = self.upload_client.upload( file_path=file_path, media_id=media_id, upload_data=query ) + return response['mediaid'] diff --git a/bynder_sdk/client/upload_client.py b/bynder_sdk/client/upload_client.py index 3755938..4630194 100644 --- a/bynder_sdk/client/upload_client.py +++ b/bynder_sdk/client/upload_client.py @@ -126,7 +126,7 @@ def _save_media(self, import_id, data, media_id=None): save_endpoint = '/api/v4/media/{}/save/{}/'.format(media_id, import_id) data = {} - save_success = self.bynder_request_handler.post( + return self.bynder_request_handler.post( endpoint=save_endpoint, payload=data ) From a3b756df8b28b977d261b8fa1b5eea4286448dd7 Mon Sep 17 00:00:00 2001 From: Ubuntu Date: Fri, 5 Jan 2018 14:01:45 +0000 Subject: [PATCH 2/2] fix the comments --- bynder_sdk/client/asset_bank_client.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/bynder_sdk/client/asset_bank_client.py b/bynder_sdk/client/asset_bank_client.py index 82b7812..853ce3b 100644 --- a/bynder_sdk/client/asset_bank_client.py +++ b/bynder_sdk/client/asset_bank_client.py @@ -104,14 +104,25 @@ def delete_usage(self, integration_id, asset_id, query: dict = None): ) def upload_file(self, file_path: str, brand_id: str, - media_id: str = '', query: dict = None): - """ Upload file.""" + media_id: str = '', query: dict = None) -> dict: + """ Upload file. + Params: + file_path: the local filepath of the file to upload. + brand_id: the brandid of the brand that belong the asset. + query: extra dict parameters of information to add to the + asset. (See api documentation for more information) + Return a dict with the keys: + - success: boolean that indicate the result of the upload call. + - mediaitems: a list of mediaitems created, with at least the + original. + - batchId: the batchId of the upload. + - mediaid: the mediaId update or created. + """ if query is None: query = {} query['brandId'] = brand_id - response = self.upload_client.upload( + return self.upload_client.upload( file_path=file_path, media_id=media_id, upload_data=query ) - return response['mediaid']