summaryrefslogtreecommitdiff
path: root/node_modules/@jet-app/app-store/tmp/src/foundation/network/http.js
blob: 34c6a9a90cbac068e249fc35eaff759d90bf5d85 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/**
 * Created by keithpk on 12/3/16.
 */
/**
 * The `FormBuilder` class can be used to construct HTTP
 * the form parameters for use with an HTTP post operation.
 */
export class FormBuilder {
    /**
     * The content type to use for form parameters.
     */
    static get contentType() {
        return "application/x-www-form-urlencoded";
    }
    /**
     * Construct an empty form builder.
     */
    constructor() {
        this._params = "";
    }
    /**
     *  Append a parameter to the builder's form parameters.
     *  @param  key   The key of the parameter.
     *  @param  value The value of the parameter.
     *  @return The builder.
     */
    param(key, value) {
        if (key && value) {
            const separator = this._params.length > 0 ? "&" : "";
            this._params += `${separator}${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
        }
        return this;
    }
    /**
     *  Create and return a form parameters string based on the contents of the builder.
     *  @return The form parameters string.
     */
    build() {
        return this._params;
    }
}
//# sourceMappingURL=http.js.map