added request body payload templates

This commit is contained in:
adityamayukhsom
2024-03-28 03:53:56 +05:30
parent 402670619c
commit cf3ff17580

View File

@ -23,6 +23,23 @@ require 'faraday/multipart'
final String kTemplateRequestUrl = """
\nREQUEST_URL = URI("{{ url }}")\n\n
""";
final String kTemplateBody = """
PAYLOAD = <<-{{ boundary }}
{{ body }}
{{ boundary }}\n\n
""";
final String kTemplateFormParamsWithFile = """
PAYLOAD = {
{% for param in params %}{% if param.type == "text" %} "{{ param.name }}" => Faraday::Multipart::ParamPart.new("{{ param.value }}", "text/plain"),
{% elif param.type == "file" %} "{{ param.name }}" => Faraday::Multipart::FilePart.new("{{ param.value }}", "application/octet-stream"),{% endif %}{% endfor %}
}\n\n
""";
final String kTemplateFormParamsWithoutFile = """
PAYLOAD = URI.encode_www_form({\n{% for param in params %} "{{ param.name }}" => "{{ param.value }}",\n{% endfor %}})\n\n
""";
}