Improvement token
This commit is contained in:
		
							
								
								
									
										18
									
								
								discogs.go
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								discogs.go
									
									
									
									
									
								
							@@ -14,14 +14,11 @@ const (
 | 
			
		||||
type Options struct {
 | 
			
		||||
	Currency  string
 | 
			
		||||
	UserAgent string
 | 
			
		||||
	Token     string
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Client is a Discogs client for making Discogs API requests.
 | 
			
		||||
type Client struct {
 | 
			
		||||
	api      *apirequest.API
 | 
			
		||||
	currency string
 | 
			
		||||
 | 
			
		||||
	// services
 | 
			
		||||
	Release *ReleaseService
 | 
			
		||||
	Master  *MasterService
 | 
			
		||||
	Artist  *ArtistService
 | 
			
		||||
@@ -41,9 +38,12 @@ func NewClient(o *Options) (*Client, error) {
 | 
			
		||||
		return nil, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return &Client{
 | 
			
		||||
		api: base,
 | 
			
		||||
	// set token, it's required for some queries like search
 | 
			
		||||
	if o.Token != "" {
 | 
			
		||||
		base.Set("Authorization", "Discogs token="+o.Token)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return &Client{
 | 
			
		||||
		Release: newReleaseService(base.New(), cur),
 | 
			
		||||
		Artist:  newArtistService(base.New()),
 | 
			
		||||
		Label:   newLabelService(base.New()),
 | 
			
		||||
@@ -52,12 +52,6 @@ func NewClient(o *Options) (*Client, error) {
 | 
			
		||||
	}, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Token sets tokens, it's required for some queries like search
 | 
			
		||||
func (c *Client) Token(token string) *Client {
 | 
			
		||||
	c.api.Set("Authorization", "Discogs token="+token)
 | 
			
		||||
	return c
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// currency validates currency for marketplace data.
 | 
			
		||||
// Defaults to the authenticated users currency. Must be one of the following:
 | 
			
		||||
// USD GBP EUR CAD AUD JPY CHF MXN BRL NZD SEK ZAR
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user