Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explicitly specify boolEncoding and arrayEncoding strategies when adding parameters in bulk via formURLEncodedBody() #67

Closed
nashfive opened this issue Oct 25, 2022 · 1 comment
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@nashfive
Copy link

What problem are you facing?

I have a private method in my custom client to build my HTTPRequests as follow:

func buildRequest(
        path: String,
        method: HTTPMethod,
        parameters: HTTPRequestParametersDict?,
        timeout: TimeInterval?
    ) -> HTTPRequest {
        let request = HTTPRequest {
            $0.method = method
            $0.path = path
            $0.timeout = timeout

            if let parameters = parameters {
                $0.body = .formURLEncodedBody(defaultParameters.merging(parameters, uniquingKeysWith: { $1 }))
            } else {
                $0.body = .formURLEncodedBody(defaultParameters)
            }
        }
        return request
    }

The problem with this is that I couldn't find a way to specify the boolEncoding and arrayEncoding.

So my question is:
Is there a way to specify it without iterating over all the parameters and manually use the request.addParameter(..., boolEncoding:, arrayEncoding:)? Or do you seen it as a new feature, like specifying it in the .formURLEncodedBody() method ?

Other Information

No response

@malcommac
Copy link
Collaborator

Hi @nashfive, currently, there is no a way to explicitly declare it. However, I exposed both of them inside the formURLEncodedBody() in order to avoid iterating over each parameter which, obviously does not make sense. You will find in 1.8.0.

@malcommac malcommac self-assigned this Nov 27, 2022
@malcommac malcommac added the enhancement New feature or request label Nov 27, 2022
@malcommac malcommac added this to the 1.8.0 milestone Nov 27, 2022
@malcommac malcommac changed the title [Feature]: Possibility to specify boolEncoding and arrayEncoding strategies when adding parameters in bulk Explicitly specify boolEncoding and arrayEncoding strategies when adding parameters in bulk via formURLEncodedBody() Nov 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants