account.go
changeset 206 9197fdf25388
parent 205 b27e7d229fdd
child 207 301d5b94be3f
equal deleted inserted replaced
205:b27e7d229fdd 206:9197fdf25388
    23 
    23 
    24 // getAccountsOptions contains option fields for POST and DELETE API calls
    24 // getAccountsOptions contains option fields for POST and DELETE API calls
    25 type getAccountsOptions struct {
    25 type getAccountsOptions struct {
    26 	// The ID is used for most commands
    26 	// The ID is used for most commands
    27 	ID int64
    27 	ID int64
       
    28 
       
    29 	// Following can be set to true to limit a search to "following" accounts
       
    30 	Following bool
    28 
    31 
    29 	// The Q field (query) is used when searching for accounts
    32 	// The Q field (query) is used when searching for accounts
    30 	Q string
    33 	Q string
    31 
    34 
    32 	Limit *LimitParams
    35 	Limit *LimitParams
   147 
   150 
   148 	// Handle target-specific query parameters
   151 	// Handle target-specific query parameters
   149 	params := make(apiCallParams)
   152 	params := make(apiCallParams)
   150 	if op == "search" {
   153 	if op == "search" {
   151 		params["q"] = opts.Q
   154 		params["q"] = opts.Q
       
   155 		if opts.Following {
       
   156 			params["following"] = "true"
       
   157 		}
   152 	}
   158 	}
   153 
   159 
   154 	return mc.getMultipleAccounts(endPoint, params, lopt)
   160 	return mc.getMultipleAccounts(endPoint, params, lopt)
   155 }
   161 }
   156 
   162 
   297 	return rel, nil
   303 	return rel, nil
   298 }
   304 }
   299 
   305 
   300 // SearchAccounts returns a list of accounts matching the query string
   306 // SearchAccounts returns a list of accounts matching the query string
   301 // The lopt parameter is optional (can be nil) or can be used to set a limit.
   307 // The lopt parameter is optional (can be nil) or can be used to set a limit.
   302 func (mc *Client) SearchAccounts(query string, lopt *LimitParams) ([]Account, error) {
   308 func (mc *Client) SearchAccounts(query string, following bool, lopt *LimitParams) ([]Account, error) {
   303 	o := &getAccountsOptions{Q: query, Limit: lopt}
   309 	o := &getAccountsOptions{Q: query, Limit: lopt, Following: following}
   304 	return mc.getMultipleAccountsHelper("search", o)
   310 	return mc.getMultipleAccountsHelper("search", o)
   305 }
   311 }
   306 
   312 
   307 // GetBlockedAccounts returns the list of blocked accounts
   313 // GetBlockedAccounts returns the list of blocked accounts
   308 // The lopt parameter is optional (can be nil).
   314 // The lopt parameter is optional (can be nil).