Skip to content

Commit

Permalink
Merge pull request #1 from Cyber-Freak999/ai-branch
Browse files Browse the repository at this point in the history
Chore: Add AI-based Invoice Generation Method to Chimoney API Integration
  • Loading branch information
Cyber-Freak999 authored Oct 28, 2024
2 parents 9597551 + 49ee545 commit 46f8fb4
Showing 1 changed file with 39 additions and 0 deletions.
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)

0 comments on commit 46f8fb4

Please sign in to comment.