github.com/cobalt77/jfrog-client-go@v0.14.5/bintray/auth/btdetails.go (about)

     1  package auth
     2  
     3  import (
     4  	"encoding/json"
     5  
     6  	"github.com/cobalt77/jfrog-client-go/utils/io/httputils"
     7  )
     8  
     9  const BINTRAY_API_URL = "https://bintray.com/api/v1/"
    10  const BINTRAY_DOWNLOAD_SERVER_URL = "https://dl.bintray.com/"
    11  
    12  func NewBintrayDetails() BintrayDetails {
    13  	return &bintrayDetails{
    14  		ApiUrl:            BINTRAY_API_URL,
    15  		DownloadServerUrl: BINTRAY_DOWNLOAD_SERVER_URL,
    16  	}
    17  }
    18  
    19  type BintrayDetails interface {
    20  	GetApiUrl() string
    21  	GetDownloadServerUrl() string
    22  	GetUser() string
    23  	GetKey() string
    24  	GetDefPackageLicense() string
    25  
    26  	SetApiUrl(apiUrl string)
    27  	SetDownloadServerUrl(downloadUrl string)
    28  	SetUser(user string)
    29  	SetKey(key string)
    30  	SetDefPackageLicense(license string)
    31  
    32  	CreateHttpClientDetails() httputils.HttpClientDetails
    33  
    34  	Marshal() ([]byte, error)
    35  }
    36  
    37  type bintrayDetails struct {
    38  	ApiUrl            string `json:"-"`
    39  	DownloadServerUrl string `json:"-"`
    40  	User              string `json:"user,omitempty"`
    41  	Key               string `json:"key,omitempty"`
    42  	DefPackageLicense string `json:"defPackageLicense,omitempty"`
    43  }
    44  
    45  func (bt *bintrayDetails) GetApiUrl() string {
    46  	return bt.ApiUrl
    47  }
    48  
    49  func (bt *bintrayDetails) GetDownloadServerUrl() string {
    50  	return bt.DownloadServerUrl
    51  }
    52  
    53  func (bt *bintrayDetails) GetUser() string {
    54  	return bt.User
    55  }
    56  
    57  func (bt *bintrayDetails) GetKey() string {
    58  	return bt.Key
    59  }
    60  
    61  func (bt *bintrayDetails) GetDefPackageLicense() string {
    62  	return bt.DefPackageLicense
    63  }
    64  
    65  func (bt *bintrayDetails) SetApiUrl(apiUrl string) {
    66  	bt.ApiUrl = apiUrl
    67  }
    68  
    69  func (bt *bintrayDetails) SetDownloadServerUrl(downloadUrl string) {
    70  	bt.DownloadServerUrl = downloadUrl
    71  }
    72  
    73  func (bt *bintrayDetails) SetUser(user string) {
    74  	bt.User = user
    75  }
    76  
    77  func (bt *bintrayDetails) SetKey(key string) {
    78  	bt.Key = key
    79  }
    80  
    81  func (bt *bintrayDetails) SetDefPackageLicense(license string) {
    82  	bt.DefPackageLicense = license
    83  }
    84  
    85  func (bt *bintrayDetails) CreateHttpClientDetails() httputils.HttpClientDetails {
    86  	return httputils.HttpClientDetails{
    87  		User:     bt.GetUser(),
    88  		Password: bt.GetKey()}
    89  }
    90  
    91  func (bt *bintrayDetails) Marshal() ([]byte, error) {
    92  	return json.Marshal(bt)
    93  }