| 30 | } |
| 31 | |
| 32 | func (api appsHTMLPublishAPI) HTMLPublish(ctx context.Context, appID string, tarball *htmlPublishTarball) (*htmlPublishResponse, error) { |
| 33 | fd := larkcore.NewFormdata() |
| 34 | fd.AddFile("file", bytes.NewReader(tarball.Body)) |
| 35 | |
| 36 | apiResp, err := api.runtime.DoAPI(&larkcore.ApiReq{ |
| 37 | HttpMethod: http.MethodPost, |
| 38 | ApiPath: fmt.Sprintf("%s/apps/%s/upload_and_release_html_code", apiBasePath, validate.EncodePathSegment(appID)), |
| 39 | Body: fd, |
| 40 | }, larkcore.WithFileUpload()) |
| 41 | if err != nil { |
| 42 | return nil, client.WrapDoAPIError(err) |
| 43 | } |
| 44 | data, err := api.runtime.ClassifyAPIResponse(apiResp) |
| 45 | if err != nil { |
| 46 | return nil, enrichHTMLPublishAPIError(err) |
| 47 | } |
| 48 | url, _ := data["url"].(string) |
| 49 | if url == "" { |
| 50 | return nil, errs.NewInternalError(errs.SubtypeInvalidResponse, |
| 51 | "html-publish response is missing the published app url") |
| 52 | } |
| 53 | return &htmlPublishResponse{URL: url}, nil |
| 54 | } |
| 55 | |
| 56 | // OAPI business error codes returned by the |
| 57 | // /apps/{id}/upload_and_release_html_code endpoint. Owned by the backend |