| 35 | |
| 36 | @classmethod |
| 37 | def from_args( |
| 38 | cls, |
| 39 | request_item_args: List[KeyValueArg], |
| 40 | request_type: Optional[RequestType] = None, |
| 41 | ) -> 'RequestItems': |
| 42 | instance = cls(request_type=request_type) |
| 43 | rules: Dict[str, Tuple[Callable, dict]] = { |
| 44 | SEPARATOR_HEADER: ( |
| 45 | process_header_arg, |
| 46 | instance.headers, |
| 47 | ), |
| 48 | SEPARATOR_HEADER_EMPTY: ( |
| 49 | process_empty_header_arg, |
| 50 | instance.headers, |
| 51 | ), |
| 52 | SEPARATOR_HEADER_EMBED: ( |
| 53 | process_embed_header_arg, |
| 54 | instance.headers, |
| 55 | ), |
| 56 | SEPARATOR_QUERY_PARAM: ( |
| 57 | process_query_param_arg, |
| 58 | instance.params, |
| 59 | ), |
| 60 | SEPARATOR_QUERY_EMBED_FILE: ( |
| 61 | process_embed_query_param_arg, |
| 62 | instance.params, |
| 63 | ), |
| 64 | SEPARATOR_FILE_UPLOAD: ( |
| 65 | process_file_upload_arg, |
| 66 | instance.files, |
| 67 | ), |
| 68 | SEPARATOR_DATA_STRING: ( |
| 69 | process_data_item_arg, |
| 70 | instance.data, |
| 71 | ), |
| 72 | SEPARATOR_DATA_EMBED_FILE_CONTENTS: ( |
| 73 | process_data_embed_file_contents_arg, |
| 74 | instance.data, |
| 75 | ), |
| 76 | SEPARATOR_GROUP_NESTED_JSON_ITEMS: ( |
| 77 | process_data_nested_json_embed_args, |
| 78 | instance.data, |
| 79 | ), |
| 80 | SEPARATOR_DATA_RAW_JSON: ( |
| 81 | convert_json_value_to_form_if_needed( |
| 82 | in_json_mode=instance.is_json, |
| 83 | processor=process_data_raw_json_embed_arg |
| 84 | ), |
| 85 | instance.data, |
| 86 | ), |
| 87 | SEPARATOR_DATA_EMBED_RAW_JSON_FILE: ( |
| 88 | convert_json_value_to_form_if_needed( |
| 89 | in_json_mode=instance.is_json, |
| 90 | processor=process_data_embed_raw_json_file_arg, |
| 91 | ), |
| 92 | instance.data, |
| 93 | ), |
| 94 | } |