Metadata-Version: 2.4
Name: yemot-api
Version: 0.1.6
Summary: python client for yemot api module and yemot rest api
Project-URL: Homepage, https://github.com/zevisvei/yemot_api
Project-URL: Issues, https://github.com/zevisvei/yemot_api/issues
Author-email: zevisvei <zszszszs491@gmail.com>
License: GPL-3.0-or-later
License-File: LICENSE
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
Requires-Python: >=3.13
Requires-Dist: httpx>=0.28.1
Requires-Dist: pydantic>=2.12.3
Requires-Dist: requests>=2.32.5
Description-Content-Type: text/markdown

```python
from typing import Annotated, Literal

from fastapi import Depends, FastAPI, HTTPException, Request, responses

from yemot_api.api_model import ApiModel
from yemot_api.api_response import IdListMessageType, id_list_message, join, routing_yemot
from yemot_api.input_types import FileAction
from yemot_api.yemot_api import Yemot


def verify_yemot(request: Request) -> Literal[True]:
    user_agent = request.headers.get("user-agent")
    if user_agent != "yemot-core-api/1.0":
        raise HTTPException(status_code=403, detail=f"Access denied: {user_agent}")
    return True


class ApiModelExample(ApiModel):
    path: str
    token: str


# app = FastAPI(dependencies=[Depends(verify_yemot)])
app = FastAPI()


@app.get("/foo")
def foo(q: Annotated[ApiModelExample, Depends()]) -> responses.PlainTextResponse:
    yemot_ins = Yemot(f"{q.api_did}:{q.token}")
    if not yemot_ins.check_if_file_exists(q.path):
        return responses.PlainTextResponse("ERROR", 404)
    content = yemot_ins.download_file(q.path)
    with open("testtt.wav", "wb") as f:
        f.write(content)
    yemot_ins.file_action(FileAction.MOVE, q.path, "1")
    res_1 = id_list_message(IdListMessageType.Text, "הנך מועבר למערכת אחרת")
    res_2 = routing_yemot("0773137770")
    res = join([res_1, res_2])
    return responses.PlainTextResponse(res, 200)
```