Skip to content
This repository was archived by the owner on Jun 7, 2024. It is now read-only.

Latest commit

 

History

History
 
 

generate_invoice

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

README.md

💻 Generate invoice

A Java Cloud Function for generating invoice.

{
  "currency":"EUR",
  "items":[{"name":"Web development","price":15}],
  "issuer":"Some\nIssuer",
  "customer":"Some\nCustomer",
  "vat":21
}

Example output:

{
    "success":true,
    "invoice":"iVBORw0KGgoAAAANSUhEUgAAAaQAAALiCAY...QoH9hbkTPQAAAABJRU5ErkJggg=="
}

Error Example output:

{
    "success": false,
    "message":"Please provide currency"
}

📝 Environment Variables

This function does not require any variables.

🚀 Deployment

  1. Clone this repository, and enter this function folder:
$ git clone https://github.com/open-runtimes/examples.git && cd examples
$ cd java/generate_invoice
  1. Enter this function folder and build the code:
docker run -e INTERNAL_RUNTIME_ENTRYPOINT=Index.java --rm --interactive --tty --volume $PWD:/usr/code openruntimes/java:v2-18.0 sh /usr/local/src/build.sh

As a result, a code.tar.gz file will be generated.

  1. Start the Open Runtime:
docker run -p 3000:3000 -e INTERNAL_RUNTIME_KEY=secret-key --rm --interactive --tty --volume $PWD/code.tar.gz:/tmp/code.tar.gz:ro openruntimes/java:v2-18.0 sh /usr/local/src/start.sh

Your function is now listening on port 3000, and you can execute it by sending POST request with appropriate authorization headers. To learn more about runtime, you can visit Java runtime README.

  1. Execute function:
curl http://localhost:3000/ -d '{"payload":"{\"currency\":\"EUR\",\"items\":[{\"name\":\"Web development\",\"price\":15}],\"issuer\":\"Some\nIssuer\",\"customer\":\"Some\nCustomer\",\"vat\":21}"}' -H "X-Internal-Challenge: secret-key" -H "Content-Type: application/json"

📝 Notes

  • This function is designed for use with Appwrite Cloud Functions. You can learn more about it in Appwrite docs.
  • This example is compatible with Java 18.0. Other versions may work but are not guarenteed to work as they haven't been tested.