imagekit-developer / imagekit-python

ImageKit.io Python SDK
https://imagekit.io
MIT License
53 stars 18 forks source link

Calling list_files on an ImageKit object throws unexpected keyword "created_by" error #40

Closed seandevs closed 1 year ago

seandevs commented 1 year ago

Hi There,

When calling list_files on an ImageKit object, it throws a "created_by" error on any new image uploaded to ImageKit in the Media Library. This may have to do with a new attribute called "created" that is appearing in the web interface. To reproduce the error:

    imagekit_obj = ImageKit(
        private_key=IMAGEKIT_PRIVATE_KEY,
        public_key=IMAGEKIT_PUBLIC_KEY,
        url_endpoint=IMAGEKIT_URL_ENDPOINT,
    )

    options = ListAndSearchFileRequestOptions(
        type="file", sort="ASC_CREATED", file_type="all"
    )

    results = imagekit_obj.list_files(options=options)

This throws TypeError: FileResult.__init__() got an unexpected keyword argument 'created_by.

Seems to be related to utils/utils.py

def convert_to_list_response_object(
    resp: Response, response_object, list_response_object
):
    response_list = []
    for item in resp.json():
        res_new = loads(dumps(camel_dict_to_snake_dict(item)))
        u = response_object(**res_new)
        response_list.append(u)

    u = list_response_object(response_list)
    u.response_metadata = ResponseMetadata(resp.json(), resp.status_code, resp.headers)
    return u
imagekitio commented 1 year ago

Thanks for reporting this issue @seandevs , we are looking into this.

nikniv commented 1 year ago

Hey @seandevs, this is fixed now. Please give it a try and let us know.

seandevs commented 1 year ago

Hi @nikniv. Confirmed it is working our end. Thanks for the quick fix.