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