Skip to content

Commit afc356b

Browse files
committed
Prepare for 1.7.0
1 parent ca486a6 commit afc356b

File tree

13 files changed

+233
-79
lines changed

13 files changed

+233
-79
lines changed

Pipfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ pytest-vcr = "~=1.0.2"
1010
pytest-cov = "~=4.0"
1111
pylint = "~= 2.15"
1212
pytest-pylint = "~= 0.19"
13-
mypy = "~= 0.982"
13+
mypy = "~= 0.991"
1414
python-dotenv = "~= 0.21"
1515
autopep8 = "~= 2.0"
1616
importlib-metadata = "*"

Pipfile.lock

Lines changed: 58 additions & 52 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/_templates/globaltoc.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ <h3><a href="{{ pathto(master_doc) }}">{{ _('Table Of Contents') }}</a></h3>
77
<li><a href="{{ pathto('api/comments') }}">Comments</a></li>
88
<li><a href="{{ pathto('api/contributors') }}">Contributors</a></li>
99
<li><a href="{{ pathto('api/files') }}">Files</a></li>
10+
<li><a href="{{ pathto('api/jwt') }}">JWT</a></li>
1011
<li><a href="{{ pathto('api/keys') }}">Keys</a></li>
1112
<li><a href="{{ pathto('api/languages') }}">Languages</a></li>
1213
<li><a href="{{ pathto('api/orders') }}">Orders</a></li>

docs/additional_info/changelog.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,16 @@
33
Changelog
44
=========
55

6+
1.7.0 (30-Nov-2022)
7+
-------------------
8+
9+
* Added support for the `JWT endpoint <https://developers.lokalise.com/reference/get-ota-jwt>`_.
10+
11+
.. code-block:: python
12+
13+
response = client.jwt()
14+
response.jwt # => "eyJ0eXAiOiJK..."
15+
616
1.6.0 (05-Oct-2022)
717
-------------------
818

docs/api/jwt.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
JWT endpoint
2+
============
3+
4+
Get OTA JWT
5+
-----------
6+
7+
.. py:function:: jwt()
8+
9+
:return: JWT model
10+
11+
Example:
12+
13+
.. code-block:: python
14+
15+
response = client.jwt()
16+
response.jwt # => "eyJ0eXAiOiJK..."

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ Usage
4747
api/comments
4848
api/contributors
4949
api/files
50+
api/jwt
5051
api/keys
5152
api/languages
5253
api/orders

lokalise/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
This module contains plugin metadata.
55
"""
66

7-
__version__: str = "1.6.0"
7+
__version__: str = "1.7.0"

lokalise/base_client.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
"""
2+
lokalise.base_client
3+
~~~~~~~~~~~~~~~~~~~~
4+
This module contains base API client definition.
5+
"""
6+
from typing import Optional, Union
7+
8+
9+
class BaseClient:
10+
"""Base client used to send API requests.
11+
"""
12+
13+
def __init__(self,
14+
token: str,
15+
connect_timeout: Optional[Union[int, float]] = None,
16+
read_timeout: Optional[Union[int, float]] = None,
17+
enable_compression: Optional[bool] = False) -> None:
18+
"""Instantiate a new Lokalise API client.
19+
20+
:param str token: Your Lokalise API token.
21+
:param connect_timeout: (optional) Server connection timeout
22+
(the value is in seconds). By default, the client will wait indefinitely.
23+
:type connect_timeout: int or float
24+
:param read_timeout: (optional) Server read timeout
25+
(the value is in seconds). By default, the client will wait indefinitely.
26+
:type read_timeout: int or float
27+
:param enable_compression: (optional) Whether to enable gzip compression.
28+
By default it's off.
29+
:type enable_compression: bool
30+
"""
31+
self.token = token
32+
self.connect_timeout = connect_timeout
33+
self.read_timeout = read_timeout
34+
self.enable_compression = enable_compression
35+
self.token_header = 'X-Api-Token'

lokalise/client.py

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from typing import Any, Optional, Union, Dict, Callable, List
77
import importlib
88
from lokalise.utils import snake_to_camel
9+
from .base_client import BaseClient
910
from .collections.branches import BranchesCollection
1011
from .collections.comments import CommentsCollection
1112
from .collections.contributors import ContributorsCollection
@@ -30,6 +31,7 @@
3031
from .models.branch import BranchModel
3132
from .models.comment import CommentModel
3233
from .models.contributor import ContributorModel
34+
from .models.jwt import JwtModel
3335
from .models.key import KeyModel
3436
from .models.language import LanguageModel
3537
from .models.order import OrderModel
@@ -49,7 +51,7 @@
4951
from .models.team_user_billing_details import TeamUsersBillingDetailsModel
5052

5153

52-
class Client:
54+
class Client(BaseClient):
5355
"""Client used to send API requests.
5456
5557
Usage:
@@ -59,30 +61,6 @@ class Client:
5961
client.projects()
6062
"""
6163

62-
def __init__(self,
63-
token: str,
64-
connect_timeout: Optional[Union[int, float]] = None,
65-
read_timeout: Optional[Union[int, float]] = None,
66-
enable_compression: Optional[bool] = False) -> None:
67-
"""Instantiate a new Lokalise API client.
68-
69-
:param str token: Your Lokalise API token.
70-
:param connect_timeout: (optional) Server connection timeout
71-
(the value is in seconds). By default, the client will wait indefinitely.
72-
:type connect_timeout: int or float
73-
:param read_timeout: (optional) Server read timeout
74-
(the value is in seconds). By default, the client will wait indefinitely.
75-
:type read_timeout: int or float
76-
:param enable_compression: (optional) Whether to enable gzip compression.
77-
By default it's off.
78-
:type enable_compression: bool
79-
"""
80-
self.token = token
81-
self.connect_timeout = connect_timeout
82-
self.read_timeout = read_timeout
83-
self.enable_compression = enable_compression
84-
self.token_header = 'X-Api-Token'
85-
8664
def reset_client(self) -> None:
8765
"""Resets the API client by clearing all attributes.
8866
"""
@@ -413,6 +391,14 @@ def delete_file(self, project_id: str,
413391
delete(parent_id=project_id, resource_id=file_id)
414392
return response
415393

394+
def jwt(self) -> JwtModel:
395+
"""Fetches OTA JWT.
396+
397+
:return: JWT model
398+
"""
399+
raw_jwt = self.get_endpoint("jwt").find()
400+
return JwtModel(raw_jwt)
401+
416402
def keys(self,
417403
project_id: str,
418404
params: Optional[Dict[str, Any]] = None

lokalise/endpoints/jwt_endpoint.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
"""
2+
lokalise.endpoints.jwt_endpoint
3+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4+
Module containing JWT endpoint.
5+
"""
6+
from .base_endpoint import BaseEndpoint
7+
8+
9+
class JwtEndpoint(BaseEndpoint):
10+
"""Describes JWT endpoint.
11+
"""
12+
PATH = "jwt-tokens/ota"

0 commit comments

Comments
 (0)