Webdesk App Market client API for Go
Go to file
2024-11-21 12:12:08 +01:00
LICENSE init 2024-11-21 00:45:22 +01:00
README.md Merge branch 'main' of https://git.fluffy.pw/matu6968/webdesk-appmarket-golang 2024-11-21 12:12:08 +01:00
webdesk-appmarket-golang.go add custom appid specifying support 2024-11-21 12:11:12 +01:00

WebDesk 3rd party App Market client API for Go

This allows you to make custom (known as 3rd party) App Market server clients for your intended purpose.

Features

  • Listing currently uploaded apps
  • Uploading new apps
  • Editing app info
  • Delete apps

Prerequisites

  • Go (1.23.1 or later, older versions could work under the assumption of no guarantee)

Usage

Import in your Go code:

import (
 "git.fluffy.pw/matu6968/webdesk-appmarket-golang"
)

Configuration

In the .env file this is the only thing you can set

AUTH_TOKEN=bearer-token-here # Put your token generated from the server .env file

API usage

  1. List uploaded apps:
	// Create new client
	c := client.NewClient("http://localhost:8080", os.Getenv("AUTH_TOKEN"))

	// List all apps
	apps, err := c.GetApps()
	if err != nil {
		log.Fatal("Failed to get apps:", err)
	}
	fmt.Printf("Found %d apps\n", len(apps))
  1. Upload an app:
	// Upload new app
	metadata := client.AppMetadata{
		Name: "Camera",
		Ver:  "6",
		Info: "This is a camera app",
		Pub:  "matu6968",
	}
	newApp, err := client.UploadApp(metadata, "./index.js", "123456789011") // custom app id is optional
	if err != nil {
		log.Fatal("Failed to upload app:", err)
	}
	fmt.Printf("Uploaded app with ID: %s\n", newApp.AppID)
  1. Edit an app:
	// Edit app
	metadata := client.AppMetadata{ // only specify what you need
	    Name: "Camera",
	    Ver:  "7",
	    Info: "This is a new camera app",
	    Pub:  "matu6968",
	}
	err = c.EditApp(newApp.AppID, metadata, "./index.js") // replace newApp.AppID with the app id you want to delete
	if err != nil {
		log.Fatal("Failed to edit app:", err)
	}
	fmt.Println("App updated successfully")
  1. Delete an app:
	// Delete app
	err = c.DeleteApp(newApp.AppID) // replace newApp.AppID with the app id you want to delete
	if err != nil {
		log.Fatal("Failed to delete app:", err)
	}
	fmt.Println("App deleted successfully")