From 9209663593dd76bfe7610f4a90aa2bd45a5fda9a Mon Sep 17 00:00:00 2001 From: Victor Lacasse-Beaudoin Date: Thu, 22 Aug 2024 13:27:22 -0400 Subject: [PATCH] merge: apiclient dans api.go --- api/api.go => api.go | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) rename api/api.go => api.go (90%) diff --git a/api/api.go b/api.go similarity index 90% rename from api/api.go rename to api.go index e89e5ac..201be4d 100644 --- a/api/api.go +++ b/api.go @@ -1,4 +1,4 @@ -package api +package main import ( "bytes" @@ -10,9 +10,6 @@ import ( "net/url" "codeberg.org/vlbeaudoin/voki/v3" - "git.agecem.com/agecem/agecem-org/apirequest" - "git.agecem.com/agecem/agecem-org/apiresponse" - "git.agecem.com/agecem/agecem-org/config" "github.com/spf13/viper" ) @@ -24,7 +21,7 @@ type API struct { // provided the configuration options are managed by // https://git.agecem.com/agecem/agecem-org/config func NewFromViper(client *http.Client) (api *API, err error) { - var config config.Config + var config Config if err = viper.Unmarshal(&config); err != nil { return nil, err } @@ -36,7 +33,7 @@ func New(client *http.Client, host, key string, port int, protocol string) (*API return &API{Voki: voki.New(client, host, key, port, protocol)}, nil } -func (a *API) UploadDocuments(bucketName string, fileHeaders ...*multipart.FileHeader) (response apiresponse.V1DocumentsPOST, err error) { +func (a *API) UploadDocuments(bucketName string, fileHeaders ...*multipart.FileHeader) (response CreateDocumentsResponse, err error) { if count := len(fileHeaders); count == 0 { err = fmt.Errorf("api.(*API).UploadDocuments requiert au moins 1 fichier") return @@ -110,8 +107,7 @@ func (a *API) UploadDocuments(bucketName string, fileHeaders ...*multipart.FileH return response, json.NewDecoder(httpResponse.Body).Decode(&response) } -func (a *API) UploadDocument(bucket string, file_header *multipart.FileHeader) (apiresponse.V1DocumentPOST, error) { - var response apiresponse.V1DocumentPOST +func (a *API) UploadDocument(bucket string, file_header *multipart.FileHeader) (response CreateDocumentResponse, err error) { endpoint := fmt.Sprintf("%s://%s:%d", a.Voki.Protocol, a.Voki.Host, @@ -175,12 +171,12 @@ func (a *API) UploadDocument(bucket string, file_header *multipart.FileHeader) ( return response, err } -func (a *API) ListBuckets() (response apiresponse.V1BucketsGET, err error) { +func (a *API) ListBuckets() (response ListBucketsResponse, err error) { return response, a.Voki.Unmarshal(http.MethodGet, "/v1/bucket", nil, true, &response) } -func (a *API) Seed() (response apiresponse.V1SeedPOST, err error) { - request, err := apirequest.NewV1SeedPOST() +func (a *API) Seed() (response ExecuteSeedResponse, err error) { + request, err := NewV1SeedPOST() if err != nil { return }