Get parameters as list of tuples, formatting collections. :param params: Parameters as dict or list of two-tuples :param dict collection_formats: Parameter collection formats :return: Parameters as list of tuples, collections formatted
(self, params, collection_formats)
| 439 | return self.__deserialize_model(data, klass) |
| 440 | |
| 441 | def parameters_to_tuples(self, params, collection_formats): |
| 442 | """Get parameters as list of tuples, formatting collections. |
| 443 | |
| 444 | :param params: Parameters as dict or list of two-tuples |
| 445 | :param dict collection_formats: Parameter collection formats |
| 446 | :return: Parameters as list of tuples, collections formatted |
| 447 | """ |
| 448 | new_params: List[Tuple[str, str]] = [] |
| 449 | if collection_formats is None: |
| 450 | collection_formats = {} |
| 451 | for k, v in params.items() if isinstance(params, dict) else params: |
| 452 | if k in collection_formats: |
| 453 | collection_format = collection_formats[k] |
| 454 | if collection_format == 'multi': |
| 455 | new_params.extend((k, value) for value in v) |
| 456 | else: |
| 457 | if collection_format == 'ssv': |
| 458 | delimiter = ' ' |
| 459 | elif collection_format == 'tsv': |
| 460 | delimiter = '\t' |
| 461 | elif collection_format == 'pipes': |
| 462 | delimiter = '|' |
| 463 | else: # csv is the default |
| 464 | delimiter = ',' |
| 465 | new_params.append( |
| 466 | (k, delimiter.join(str(value) for value in v))) |
| 467 | else: |
| 468 | new_params.append((k, v)) |
| 469 | return new_params |
| 470 | |
| 471 | def parameters_to_url_query(self, params, collection_formats): |
| 472 | """Get parameters as list of tuples, formatting collections. |