Skip to main content

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 id_list_message_text, 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(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_text("הנך מועבר למערכת אחרת")
    res_2 = routing_yemot("0773137770")
    res = join(res_1, res_2)
    return responses.PlainTextResponse(res, 200)

Project details


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.33.tar.gz (66.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

yemot_api-0.1.33-py3-none-any.whl (50.1 kB view details)

Uploaded Python 3

File details

Details for the file yemot_api-0.1.33.tar.gz.

File metadata

  • Download URL: yemot_api-0.1.33.tar.gz
  • Upload date:
  • Size: 66.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","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

Hashes for yemot_api-0.1.33.tar.gz
Algorithm Hash digest
SHA256 b20b11c5f3f3a8c027bc70d3886b643b273a4b05064c38f3bde5bb8b0e0bcd7e
MD5 1e8e71a81ca58c3e9b8c8ff9c49f415c
BLAKE2b-256 cb716d6b2ef63b4d7bc5c913edd467aa6dca29a9d6136dfb6015214fe99d3ec1

See more details on using hashes here.

File details

Details for the file yemot_api-0.1.33-py3-none-any.whl.

File metadata

  • Download URL: yemot_api-0.1.33-py3-none-any.whl
  • Upload date:
  • Size: 50.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","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

Hashes for yemot_api-0.1.33-py3-none-any.whl
Algorithm Hash digest
SHA256 942e10d99c73e3d54f12f67e5a033cdc2c40cb2cdae4265b8b0d3d561a1da032
MD5 a13b230046fda30a1ba58f6cfb19d32d
BLAKE2b-256 a65ec13938995f7073aea384954f62c7d8a326cc7dfde97e572bce5e88205291

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page