From 22353428cafca390db1f714d4d5556d028ce66d6 Mon Sep 17 00:00:00 2001 From: Allan Nava Date: Wed, 15 Nov 2023 11:56:35 +0100 Subject: [PATCH] feat: added credentials --- compress/api_customer.go | 25 +++++++++++++++++++++++++ compress/compress.go | 6 ++++++ compress/constants.go | 3 ++- compress/model.go | 8 +++++++- 4 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 compress/api_customer.go diff --git a/compress/api_customer.go b/compress/api_customer.go new file mode 100644 index 0000000..accdf47 --- /dev/null +++ b/compress/api_customer.go @@ -0,0 +1,25 @@ +package compress + +import ( + "encoding/json" + "fmt" +) + + +func (o *compress) GetCredentials() (ResponseServer, error) { + // + resp, err := o.restyPost(CREDENTIALS, BaseModel{ClientId: o.GetCliendId(), ApiKey: o.apiKey}) + if err != nil { + return nil, err + } + o.debugPrint(resp) + if resp.IsError() { + return nil, fmt.Errorf("") + } + var obj ResponseServer + if err := json.Unmarshal(resp.Body(), &obj); err != nil { + return nil, err + } + o.debugPrint(obj) + return obj, nil +} diff --git a/compress/compress.go b/compress/compress.go index 1ceed5c..dec2479 100644 --- a/compress/compress.go +++ b/compress/compress.go @@ -10,6 +10,7 @@ type ICompress interface { // HealthCheck() error IsDebug() bool + GetCredentials() (ResponseServer, error) GetUploads(uploadsPaginated UploadsPaginated) ([]VideoUploadInfo, error) GetSingleUpload( jobid int ) (*VideoUploadInfo, error) GetJobidProgress( jobid int ) (*VideoUploadInfo, error) @@ -44,6 +45,11 @@ func NewCompress(customerName, apiKey string, isDebug bool) (ICompress, error) { c.restClient.SetBaseURL(TNGRM_BASE_URL) c.restClient.SetDebug(isDebug) // + _, err := c.GetCredentials() + if err != nil { + return nil, err + } + // return c, nil } diff --git a/compress/constants.go b/compress/constants.go index c995642..fea0a6b 100644 --- a/compress/constants.go +++ b/compress/constants.go @@ -5,6 +5,7 @@ const ( CATEGORIES = "/external/upload/categories" RESTREAMERS = "/external/restreamers" UPLOADS = "/external/upload" + CREDENTIALS = "/external/credentials/" ) // var ( @@ -36,8 +37,8 @@ var ( SET_PUBLISHED_UPLOAD = func(jobId int) string { return TNGRM_BASE_URL+UPLOADS+"/set_published" } - // PRESIGNED_URL_S3 = func() string { return TNGRM_BASE_URL+UPLOADS+"/presignedUrl" } + // ) \ No newline at end of file diff --git a/compress/model.go b/compress/model.go index 861b2bd..dd2e0dc 100644 --- a/compress/model.go +++ b/compress/model.go @@ -4,4 +4,10 @@ type BaseModel struct { //client_id: `${this.customer_name}_client`, ClientId string `json:"client_id"` ApiKey string `json:"api_key"` -} \ No newline at end of file +} + +type ResponseServer struct { + Message string `json:"message"` + Response string `json:"response"` + Data interface{} `json:"data"` +}