Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add AI-based Invoice Generation Method to Chimoney API Integration #460

Merged
merged 3 commits into from
Oct 31, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions submissions/Chimoney-Python/chimoney/AI.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
from chimoney import BaseAPI

class AI(BaseAPI):
"""
A class that extends the BaseAPI class to handle AI-based invoice generation requests.

Methods:
--------
invoice_gen(instruction: str) -> dict
Generates an invoice based on a given instruction.
"""
def invoice_gen(self, instruction: str):
"""
Generates an invoice by sending a POST request with the given instruction to the AI endpoint.

Parameters:
-----------
instruction : str
A description or set of details required to generate the invoice. It should specify key elements
like items, quantities, prices, and any additional instructions for the invoice layout.

Returns:
--------
dict
A dictionary containing the response from the invoice generation API, which includes details of the generated invoice.

Raises:
-------
ValueError
If the 'instruction' parameter is empty or None.
"""
if not instruction:
raise ValueError("Instruction is required")

payload = {
"instruction": instruction
}

return self._handle_request("POST", "/v0.2/ai/invoice/generate", payload)
Loading