Compare commits

..

No commits in common. "2d1dba808fe7e3d09a01f9bf978a8a0332000769" and "717301fce571b7d752255bb94aeee47f8257b0fe" have entirely different histories.

2 changed files with 4 additions and 21 deletions

View File

@ -52,7 +52,7 @@ AUTH_TOKEN=bearer-token-here # Put your token generated from the server .env fil
Info: "This is a camera app",
Pub: "matu6968",
}
newApp, err := client.UploadApp(metadata, "./index.js", "123456789011") // custom app id is optional
newApp, err := c.UploadApp(metadata, "./index.js")
if err != nil {
log.Fatal("Failed to upload app:", err)
}

View File

@ -33,12 +33,6 @@ type AppMetadata struct {
Pub string `json:"pub"`
}
// Extended metadata struct to include optional AppID
type uploadMetadata struct {
AppMetadata
AppID string `json:"appid,omitempty"`
}
// NewClient creates a new AppStore client
func NewClient(baseURL, authToken string) *AppStoreClient {
return &AppStoreClient{
@ -68,20 +62,14 @@ func (c *AppStoreClient) GetApps() ([]App, error) {
return apps, nil
}
// UploadApp uploads a new app to the store with an optional custom app ID
func (c *AppStoreClient) UploadApp(metadata AppMetadata, filePath string, customAppID string) (*App, error) {
// Create extended metadata with optional AppID
extendedMetadata := uploadMetadata{
AppMetadata: metadata,
AppID: customAppID, // Will be omitted from JSON if empty
}
// UploadApp uploads a new app to the store
func (c *AppStoreClient) UploadApp(metadata AppMetadata, filePath string) (*App, error) {
// Create multipart form
body := &bytes.Buffer{}
writer := multipart.NewWriter(body)
// Add metadata
metadataBytes, err := json.Marshal(extendedMetadata)
metadataBytes, err := json.Marshal(metadata)
if err != nil {
return nil, err
}
@ -136,11 +124,6 @@ func (c *AppStoreClient) UploadApp(metadata AppMetadata, filePath string, custom
return &newApp, nil
}
// Backwards compatibility wrapper
func (c *AppStoreClient) UploadAppSimple(metadata AppMetadata, filePath string) (*App, error) {
return c.UploadApp(metadata, filePath, "")
}
// EditApp updates an existing app
func (c *AppStoreClient) EditApp(appID string, metadata AppMetadata, filePath string) error {
body := &bytes.Buffer{}