python client for yemot api module and yemot rest api
Project description
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)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
yemot_api-0.1.16.tar.gz
(65.1 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file yemot_api-0.1.16.tar.gz.
File metadata
- Download URL: yemot_api-0.1.16.tar.gz
- Upload date:
- Size: 65.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2ce79d1ffa6c455c45b4e6419ddd0464799c5e65c2d34b2a27bb2eca01b1c1be
|
|
| MD5 |
fac1256641523d152bad7cd9c7167220
|
|
| BLAKE2b-256 |
3e47bd218ba8507819519c1d665813f44beb2d4dab7053d297b28b4b6943fc22
|
File details
Details for the file yemot_api-0.1.16-py3-none-any.whl.
File metadata
- Download URL: yemot_api-0.1.16-py3-none-any.whl
- Upload date:
- Size: 49.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
70dca9df14ffa1111fa4e778b43591ccee2ab49c04148d8710dfb6587ce6ca7e
|
|
| MD5 |
ffc7190b2345b726f7a5e645aa32eebc
|
|
| BLAKE2b-256 |
0a7a6d5de91ea5a3c1f2fc37ab800709d81fd88302a4f27d181fc46c6a83e3f1
|