github.com/ungtb10d/cli/v2@v2.0.0-20221110210412-98537dd9d6a1/api/queries_user.go (about)

     1  package api
     2  
     3  func CurrentLoginName(client *Client, hostname string) (string, error) {
     4  	var query struct {
     5  		Viewer struct {
     6  			Login string
     7  		}
     8  	}
     9  	err := client.Query(hostname, "UserCurrent", &query, nil)
    10  	return query.Viewer.Login, err
    11  }
    12  
    13  func CurrentUserID(client *Client, hostname string) (string, error) {
    14  	var query struct {
    15  		Viewer struct {
    16  			ID string
    17  		}
    18  	}
    19  	err := client.Query(hostname, "UserCurrent", &query, nil)
    20  	return query.Viewer.ID, err
    21  }