-
Notifications
You must be signed in to change notification settings - Fork 5
/
user.go
68 lines (59 loc) · 1.8 KB
/
user.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package tindergo
import (
"encoding/json"
"errors"
"strings"
"time"
)
type User struct {
ConnectionCount int `json:"connection_count"`
CommonLikes []interface{} `json:"common_likes"`
CommonFriends []interface{} `json:"common_friends"`
UID string `json:"_id"`
Bio string `json:"bio"`
BirthDate time.Time `json:"birth_date"`
Name string `json:"name"`
PingTime time.Time `json:"ping_time"`
Photos []UserPhoto `json:"photos"`
Jobs []interface{} `json:"jobs"`
Schools []interface{} `json:"schools"`
Teasers []interface{} `json:"teasers"`
Gender int `json:"gender"`
BirthDateInfo string `json:"birth_date_info"`
ID string `json:"id"`
DistanceMi int `json:"distance_mi"`
}
type UserPhoto struct {
URL string `json:"url"`
ProcessedFiles []struct {
URL string `json:"url"`
Height int `json:"height"`
Width int `json:"width"`
} `json:"processedFiles"`
Extension string `json:"extension"`
FileName string `json:"fileName"`
Shape string `json:"shape"`
Main bool `json:"main,omitempty"`
ID string `json:"id"`
}
type UserResponse struct {
Status int `json:"status"`
Results User `json:"results"`
}
func (t *TinderGo) User(userID string) (User, error) {
user := UserResponse{}
url := "https://api.gotinder.com/user/" + userID
b, errs := t.requester.Get(url)
if errs != nil {
return user.Results, errs[0]
}
b = strings.Replace(b, "\"main\",", "true, ", -1)
err := json.Unmarshal([]byte(b), &user)
if err != nil {
return user.Results, err
}
if user.Status != 200 {
return user.Results, errors.New("Error getting user information.")
}
return user.Results, nil
}