|
| 1 | +package qiita |
| 2 | + |
| 3 | +import ( |
| 4 | + "fmt" |
| 5 | + "net/http" |
| 6 | +) |
| 7 | + |
| 8 | +type UsersService struct { |
| 9 | + client *Client |
| 10 | +} |
| 11 | + |
| 12 | +type User struct { |
| 13 | + Name *string `json:"name"` |
| 14 | + Description *string `json:"description"` |
| 15 | + FacebookId *string `json:"facebook_id"` |
| 16 | + FolloweesCount *int `json:"followees_count"` |
| 17 | + FollowersCount *int `json:"followers_count"` |
| 18 | + GithubLoginName *string `json:"github_login_name"` |
| 19 | + Id *string `json:"id"` |
| 20 | + ItemsCount *int `json:"items_count"` |
| 21 | + LinkedInId *string `json:"linkedin_id"` |
| 22 | + Location *string `json:"location"` |
| 23 | + Organization *string `json:"organization"` |
| 24 | + PermanentId *int `json:"permanent_id"` |
| 25 | + ProfileImageURL *string `json:"profile_image_url"` |
| 26 | + TwitterScreenName *string `json:"twitter_screen_name"` |
| 27 | + WebsiteURL *string `json:"website_url"` |
| 28 | +} |
| 29 | + |
| 30 | +type StocksOptions struct { |
| 31 | + ListOptions |
| 32 | +} |
| 33 | + |
| 34 | +func (s *UsersService) ListItems(opt *ListOptions) ([]Item, *http.Response, error) { |
| 35 | + u, err := addOptions("authenticated_user/items", opt) |
| 36 | + if err != nil { |
| 37 | + return nil, nil, err |
| 38 | + } |
| 39 | + req, err := s.client.NewRequest("GET", u, nil) |
| 40 | + if err != nil { |
| 41 | + return nil, nil, err |
| 42 | + } |
| 43 | + items := new([]Item) |
| 44 | + resp, err := s.client.Do(req, items) |
| 45 | + if err != nil { |
| 46 | + return nil, nil, err |
| 47 | + } |
| 48 | + |
| 49 | + return *items, resp, err |
| 50 | +} |
| 51 | + |
| 52 | +func (s *UsersService) ListStocks(userId string, opt *StocksOptions) ([]Item, *http.Response, error) { |
| 53 | + u := fmt.Sprintf("users/%s/stocks", userId) |
| 54 | + u, err := addOptions(u, opt) |
| 55 | + if err != nil { |
| 56 | + return nil, nil, err |
| 57 | + } |
| 58 | + req, err := s.client.NewRequest("GET", u, nil) |
| 59 | + if err != nil { |
| 60 | + return nil, nil, err |
| 61 | + } |
| 62 | + items := new([]Item) |
| 63 | + resp, err := s.client.Do(req, items) |
| 64 | + if err != nil { |
| 65 | + return nil, nil, err |
| 66 | + } |
| 67 | + |
| 68 | + return *items, resp, err |
| 69 | +} |
0 commit comments