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.2.tar.gz
(46.5 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
yemot_api-0.1.2-py3-none-any.whl
(37.5 kB
view details)
File details
Details for the file yemot_api-0.1.2.tar.gz.
File metadata
- Download URL: yemot_api-0.1.2.tar.gz
- Upload date:
- Size: 46.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3075502b18d97d3843b05393f6213b40ae1fce97e168ccb79526e7110499076b
|
|
| MD5 |
e975aa5a068bf8314d34aa1a3a5450b0
|
|
| BLAKE2b-256 |
91d5771ef4cd89d28668ab3fed06d74ee1384322ee0edd5e41456647153493f7
|
File details
Details for the file yemot_api-0.1.2-py3-none-any.whl.
File metadata
- Download URL: yemot_api-0.1.2-py3-none-any.whl
- Upload date:
- Size: 37.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ea3c268a6388eab187d81be67aedc487bee5d5431adc56f8afae0fecb6c7600e
|
|
| MD5 |
e47244fc98eeea26b402ca173207a898
|
|
| BLAKE2b-256 |
478b7bea4b1e2b106861f3e3e21f31001e306c237bbc3b12894ce8167502b901
|