Skip to content

Commit

Permalink
feat: added credentials
Browse files Browse the repository at this point in the history
  • Loading branch information
Allan-Nava authored Nov 15, 2023
1 parent aaf0939 commit 2235342
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 2 deletions.
25 changes: 25 additions & 0 deletions compress/api_customer.go
Original file line number Diff line number Diff line change
@@ -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

Check failure on line 13 in compress/api_customer.go

View workflow job for this annotation

GitHub Actions / build (1.18.x)

cannot use nil as ResponseServer value in return statement

Check failure on line 13 in compress/api_customer.go

View workflow job for this annotation

GitHub Actions / build (1.19.x)

cannot use nil as ResponseServer value in return statement

Check failure on line 13 in compress/api_customer.go

View workflow job for this annotation

GitHub Actions / build (1.20.x)

cannot use nil as ResponseServer value in return statement

Check failure on line 13 in compress/api_customer.go

View workflow job for this annotation

GitHub Actions / build (1.21.x)

cannot use nil as ResponseServer value in return statement
}
o.debugPrint(resp)
if resp.IsError() {
return nil, fmt.Errorf("")

Check failure on line 17 in compress/api_customer.go

View workflow job for this annotation

GitHub Actions / build (1.18.x)

cannot use nil as ResponseServer value in return statement

Check failure on line 17 in compress/api_customer.go

View workflow job for this annotation

GitHub Actions / build (1.19.x)

cannot use nil as ResponseServer value in return statement

Check failure on line 17 in compress/api_customer.go

View workflow job for this annotation

GitHub Actions / build (1.20.x)

cannot use nil as ResponseServer value in return statement

Check failure on line 17 in compress/api_customer.go

View workflow job for this annotation

GitHub Actions / build (1.21.x)

cannot use nil as ResponseServer value in return statement
}
var obj ResponseServer
if err := json.Unmarshal(resp.Body(), &obj); err != nil {
return nil, err

Check failure on line 21 in compress/api_customer.go

View workflow job for this annotation

GitHub Actions / build (1.18.x)

cannot use nil as ResponseServer value in return statement

Check failure on line 21 in compress/api_customer.go

View workflow job for this annotation

GitHub Actions / build (1.19.x)

cannot use nil as ResponseServer value in return statement

Check failure on line 21 in compress/api_customer.go

View workflow job for this annotation

GitHub Actions / build (1.20.x)

cannot use nil as ResponseServer value in return statement

Check failure on line 21 in compress/api_customer.go

View workflow job for this annotation

GitHub Actions / build (1.21.x)

cannot use nil as ResponseServer value in return statement
}
o.debugPrint(obj)
return obj, nil
}
6 changes: 6 additions & 0 deletions compress/compress.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
}

Expand Down
3 changes: 2 additions & 1 deletion compress/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const (
CATEGORIES = "/external/upload/categories"
RESTREAMERS = "/external/restreamers"
UPLOADS = "/external/upload"
CREDENTIALS = "/external/credentials/"
)
//
var (
Expand Down Expand Up @@ -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"
}
//
)
8 changes: 7 additions & 1 deletion compress/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,10 @@ type BaseModel struct {
//client_id: `${this.customer_name}_client`,
ClientId string `json:"client_id"`
ApiKey string `json:"api_key"`
}
}

type ResponseServer struct {
Message string `json:"message"`
Response string `json:"response"`
Data interface{} `json:"data"`
}

0 comments on commit 2235342

Please sign in to comment.