cloudinary / cloudinary_ios

Cloudinary iOS SDK
MIT License
165 stars 106 forks source link

Allow polymorphic return types on CLDRequestParams #412

Closed allenhumphreys closed 1 year ago

allenhumphreys commented 1 year ago

Brief Summary of Changes

Currently if you form a signature manually, setting the signature on an CLDUploadRequestParams returns a CLDRequestParams which requires the caller to cast the type back to CLDUploadRequestParams.

This change fixes it so setSignature(_:) correctly returns the subclass type. You'll notice this is already in place for setApiKey(_:).

let parameters = CLDUploadRequestParams()
    .setSignature(
        .init(
            signature: decodedSignature.signature,
            timestamp: decodedSignature.timestamp as NSNumber
        )
    )
let uploadParameters = parameters as! CLDUploadRequestParams

What does this PR address?

Are tests included?

Reviewer, please note:

Checklist:

allenhumphreys commented 1 year ago

@const-cloudinary Let me know if I need to change anything here.

adimiz1 commented 1 year ago

@allenhumphreys Thank you very much!

allenhumphreys commented 1 year ago

😉On Sep 21, 2023, at 2:17 AM, adimiz1 @.***> wrote: Since setSignature is not only used or upload but for other functions as well (destroy) for examples it returns CLDRequestParams There are other methods that do the same and that's intentional, since both CLDUploadRequestParams and CLDDestroyRequestParams (for example) inherits CLDRequestParams Therefore I suggest doing this: let parameters: CLDUploadRequestParams = CLDUploadRequestParams() .setSignature( .init( signature: decodedSignature.signature, timestamp: decodedSignature.timestamp as NSNumber ) ) Instead of let uploadParameters = parameters as! CLDUploadRequestParams

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: @.***>