Skip to content

Commit 5f8eda6

Browse files
Release 5.1.1
1 parent 41379d9 commit 5f8eda6

File tree

8 files changed

+157
-58
lines changed

8 files changed

+157
-58
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ All notable changes to the library will be documented in this file.
55
The format of the file is based on [Keep a Changelog](http://keepachangelog.com/)
66
and this library adheres to [Semantic Versioning](http://semver.org/) as mentioned in [README.md][readme] file.
77

8+
## [ [5.1.1](https://github.com/infobip/infobip-api-python-client/releases/tag/5.1.1) ] - 2025-05-09
9+
10+
### Added
11+
* [FileParameter](https://github.com/infobip/infobip-api-python-client/blob/master/infobip_api_client/models/file_parameter.py) class that represents a File passed to the API as a Parameter, allows using different backends for files.
12+
13+
### Fixed
14+
* Adding trackingPixelPosition to Send fully featured email API method (https://github.com/infobip/infobip-api-python-client/issues/29).
15+
816
## [ [5.1.0](https://github.com/infobip/infobip-api-python-client/releases/tag/5.1.0) ] - 2025-03-21
917

1018
⚠️ **IMPORTANT NOTE:** This release contains breaking changes.

infobip_api_client/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
Do not edit the class manually.
1515
""" # noqa: E501
1616

17-
__version__ = "5.1.0"
17+
__version__ = "5.1.1"
1818

1919
# import apis into sdk package
2020
from infobip_api_client.api.call_routing_api import CallRoutingApi

infobip_api_client/api/email_api.py

Lines changed: 80 additions & 49 deletions
Large diffs are not rendered by default.

infobip_api_client/api_client.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
from typing import Tuple, Optional, List, Dict, Union
2727
from pydantic import SecretStr
2828

29+
from infobip_api_client.models.file_parameter import FileParameter
2930
from infobip_api_client.configuration import Configuration
3031
from infobip_api_client.api_response import ApiResponse, T as ApiResponseT
3132
import infobip_api_client.models
@@ -82,7 +83,7 @@ def __init__(
8283
self.default_headers[header_name] = header_value
8384
self.cookie = cookie
8485
# Set default User-Agent.
85-
self.user_agent = "infobip-api-client-python/5.1.0"
86+
self.user_agent = "infobip-api-client-python/5.1.1"
8687
self.client_side_validation = configuration.client_side_validation
8788

8889
def __enter__(self):
@@ -525,7 +526,7 @@ def parameters_to_url_query(self, params, collection_formats):
525526

526527
def files_parameters(
527528
self,
528-
files: Dict[str, Union[str, bytes, List[str], List[bytes], Tuple[str, bytes]]],
529+
files: Dict[str, Union[str, bytes, List[str], List[bytes], Tuple[str, bytes], List[Union[str, bytes, FileParameter]]]],
529530
):
530531
"""Builds form parameters.
531532
@@ -541,14 +542,22 @@ def files_parameters(
541542
with open(file_param_content, "rb") as f:
542543
filename = os.path.basename(f.name)
543544
filedata = f.read()
545+
mimetype = (
546+
mimetypes.guess_type(filename)[0]
547+
or "application/octet-stream"
548+
)
544549
elif isinstance(file_param_content, bytes):
545550
filename = k
546551
filedata = file_param_content
552+
mimetype = (
553+
mimetypes.guess_type(filename)[0] or "application/octet-stream"
554+
)
555+
elif isinstance(file_param_content, FileParameter):
556+
filename = file_param_content.name
557+
filedata = file_param_content.content.read()
558+
mimetype = file_param_content.content_type
547559
else:
548560
raise ValueError("Unsupported file value")
549-
mimetype = (
550-
mimetypes.guess_type(filename)[0] or "application/octet-stream"
551-
)
552561
params.append(tuple([k, tuple([filename, filedata, mimetype])]))
553562
return params
554563

infobip_api_client/configuration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ def to_debug_report(self):
415415
"OS: {env}\n"
416416
"Python Version: {pyversion}\n"
417417
"Version of the API: 1.0.0\n"
418-
"SDK Package Version: 5.1.0".format(env=sys.platform, pyversion=sys.version)
418+
"SDK Package Version: 5.1.1".format(env=sys.platform, pyversion=sys.version)
419419
)
420420

421421
def get_host_settings(self):
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import io
2+
import os
3+
from typing import Optional, Union
4+
from pydantic import BaseModel, ConfigDict
5+
6+
7+
class FileParameter(BaseModel):
8+
"""
9+
Represents a file passed to an API as a parameter.
10+
Supports raw bytes or file-like streams (binary).
11+
"""
12+
13+
content: io.IOBase
14+
name: str = "attachment"
15+
content_type: str = "application/octet-stream"
16+
17+
model_config = ConfigDict(arbitrary_types_allowed=True)
18+
19+
def __init__(
20+
self,
21+
content: Union[bytes, io.IOBase],
22+
name: Optional[str] = None,
23+
content_type: Optional[str] = None
24+
):
25+
"""
26+
Initialize FileParameter with content, name, and content_type.
27+
28+
:param content: Raw bytes or file-like binary stream (IOBase).
29+
:param name: Optional filename.
30+
:param content_type: Optional MIME type, defaults to 'application/octet-stream'.
31+
"""
32+
if isinstance(content, bytes):
33+
content = io.BytesIO(content)
34+
35+
if not isinstance(content, io.IOBase):
36+
raise TypeError("content must be bytes or a file-like IOBase stream")
37+
38+
inferred_name = name or getattr(content, 'name', None)
39+
if inferred_name:
40+
inferred_name = os.path.basename(inferred_name)
41+
else:
42+
inferred_name = "attachment"
43+
44+
super().__init__(
45+
content=content,
46+
name=inferred_name,
47+
content_type=content_type or "application/octet-stream"
48+
)
49+
50+
def __repr__(self):
51+
return f"<FileParameter name={self.name!r}, content_type={self.content_type!r}>"

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "infobip_api_client"
3-
version = "5.1.0"
3+
version = "5.1.1"
44
description = "This is a Python package for Infobip API and you can use it as a dependency to add Infobip APIs to your application."
55
authors = ["Infobip support <[email protected]>"]
66
license = "MIT License"

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
# prerequisite: setuptools
2222
# http://pypi.python.org/pypi/setuptools
2323
NAME = "infobip-api-python-client"
24-
VERSION = "5.1.0"
24+
VERSION = "5.1.1"
2525
PYTHON_REQUIRES = ">=3.8"
2626
REQUIRES = [
2727
"urllib3 >= 1.25.3, < 2.1.0",

0 commit comments

Comments
 (0)