@@ -135,6 +135,56 @@ func (s *UsersService) Edit(ctx context.Context, user *User) (*User, *Response,
135
135
return uResp , resp , nil
136
136
}
137
137
138
+ // HovercardOptions specifies optional parameters to the UsersService.GetHovercard
139
+ // method.
140
+ type HovercardOptions struct {
141
+ // SubjectType specifies the additional information to be received about the hovercard.
142
+ // Possible values are: organization, repository, issue, pull_request. (Required when using subject_id.)
143
+ SubjectType string `url:"subject_type"`
144
+
145
+ // SubjectID specifies the ID for the SubjectType. (Required when using subject_type.)
146
+ SubjectID string `url:"subject_id"`
147
+ }
148
+
149
+ // Hovercard represents hovercard information about a user.
150
+ type Hovercard struct {
151
+ Contexts []* UserContext `json:"contexts,omitempty"`
152
+ }
153
+
154
+ // UserContext represents the contextual information about user.
155
+ type UserContext struct {
156
+ Message * string `json:"message,omitempty"`
157
+ Octicon * string `json:"octicon,omitempty"`
158
+ }
159
+
160
+ // GetHovercard fetches contextual information about user. It requires authentication
161
+ // via Basic Auth or via OAuth with the repo scope.
162
+ //
163
+ // GitHub API docs: https://developer.github.com/v3/users/#get-contextual-information-about-a-user
164
+ func (s * UsersService ) GetHovercard (ctx context.Context , user string , opt * HovercardOptions ) (* Hovercard , * Response , error ) {
165
+ u := fmt .Sprintf ("users/%v/hovercard" , user )
166
+ u , err := addOptions (u , opt )
167
+ if err != nil {
168
+ return nil , nil , err
169
+ }
170
+
171
+ req , err := s .client .NewRequest ("GET" , u , nil )
172
+ if err != nil {
173
+ return nil , nil , err
174
+ }
175
+
176
+ // TODO: remove custom Accept header when this API fully launches.
177
+ req .Header .Set ("Accept" , mediaTypeHovercardPreview )
178
+
179
+ hc := new (Hovercard )
180
+ resp , err := s .client .Do (ctx , req , hc )
181
+ if err != nil {
182
+ return nil , resp , err
183
+ }
184
+
185
+ return hc , resp , nil
186
+ }
187
+
138
188
// UserListOptions specifies optional parameters to the UsersService.ListAll
139
189
// method.
140
190
type UserListOptions struct {
0 commit comments