-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathprofile.go
235 lines (222 loc) · 7.7 KB
/
profile.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
package tindergo
import (
"encoding/json"
"strings"
"time"
)
type Profile struct {
ID string `json:"_id"`
AgeFilterMax int `json:"age_filter_max"`
AgeFilterMin int `json:"age_filter_min"`
Badges []interface{} `json:"badges"`
Bio string `json:"bio"`
BirthDate time.Time `json:"birth_date"`
Blend string `json:"blend"`
CanCreateSquad bool `json:"can_create_squad"`
ConnectionCount int `json:"connection_count"`
CreateDate time.Time `json:"create_date"`
Discoverable bool `json:"discoverable"`
DistanceFilter int `json:"distance_filter"`
FacebookID string `json:"facebook_id"`
Gender int `json:"gender"`
GenderFilter int `json:"gender_filter"`
InterestedIn []int `json:"interested_in"`
Interests []struct {
ID string `json:"id"`
Name string `json:"name"`
} `json:"interests"`
Jobs []struct {
Title struct {
Displayed bool `json:"displayed"`
Name string `json:"name"`
ID string `json:"id"`
} `json:"title"`
Company struct {
Displayed bool `json:"displayed"`
Name string `json:"name"`
ID string `json:"id"`
} `json:"company"`
} `json:"jobs"`
Location interface{} `json:"location"`
Name string `json:"name"`
Photos []struct {
YoffsetPercent float64 `json:"yoffset_percent,omitempty"`
ID string `json:"id"`
XdistancePercent float64 `json:"xdistance_percent,omitempty"`
Main bool `json:"main,omitempty"`
YdistancePercent float64 `json:"ydistance_percent,omitempty"`
XoffsetPercent float64 `json:"xoffset_percent,omitempty"`
FileName string `json:"fileName"`
Extension string `json:"extension"`
ProcessedFiles []struct {
Width int `json:"width"`
Height int `json:"height"`
URL string `json:"url"`
} `json:"processedFiles"`
URL string `json:"url"`
SuccessRate float64 `json:"successRate"`
SelectRate float64 `json:"selectRate"`
Shape string `json:"shape,omitempty"`
} `json:"photos"`
PhotoOptimizerEnabled bool `json:"photo_optimizer_enabled"`
PhotoOptimizerHasResult bool `json:"photo_optimizer_has_result"`
PingTime time.Time `json:"ping_time"`
Pos struct {
At int64 `json:"at"`
Lat float64 `json:"lat"`
Lon float64 `json:"lon"`
} `json:"pos"`
PosInfo struct {
City struct {
Name string `json:"name"`
Bounds struct {
Ne struct {
Lat float64 `json:"lat"`
Lng float64 `json:"lng"`
} `json:"ne"`
Sw struct {
Lat float64 `json:"lat"`
Lng float64 `json:"lng"`
} `json:"sw"`
} `json:"bounds"`
} `json:"city"`
Country struct {
Name string `json:"name"`
Bounds struct {
Ne struct {
Lat float64 `json:"lat"`
Lng float64 `json:"lng"`
} `json:"ne"`
Sw struct {
Lat float64 `json:"lat"`
Lng float64 `json:"lng"`
} `json:"sw"`
} `json:"bounds"`
Cc string `json:"cc"`
} `json:"country"`
} `json:"pos_info"`
Schools []interface{} `json:"schools"`
SquadsOnly bool `json:"squads_only"`
SquadsDiscoverable bool `json:"squads_discoverable"`
SquadAdsShown bool `json:"squad_ads_shown"`
Username string `json:"username"`
}
func (t *TinderGo) Profile() (Profile, error) {
pfl := Profile{}
url := "https://api.gotinder.com/profile"
b, errs := t.requester.Get(url)
if errs != nil {
return pfl, errs[0]
}
b = strings.Replace(b, "\"main\",", "true, ", -1)
err := json.Unmarshal([]byte(b), &pfl)
if err != nil {
return pfl, err
}
return pfl, nil
}
type ProfileUpdateResponse struct {
ID string `json:"_id"`
ActiveTime time.Time `json:"active_time"`
AgeFilterMax int `json:"age_filter_max"`
AgeFilterMin int `json:"age_filter_min"`
APIToken string `json:"api_token"`
Badges []interface{} `json:"badges"`
Bio string `json:"bio"`
BirthDate time.Time `json:"birth_date"`
Blend string `json:"blend"`
CanCreateSquad bool `json:"can_create_squad"`
College []interface{} `json:"college"`
ConnectionCount int `json:"connection_count"`
CreateDate time.Time `json:"create_date"`
Discoverable bool `json:"discoverable"`
DistanceFilter int `json:"distance_filter"`
DistanceFilterMin int `json:"distance_filter_min"`
Friends []string `json:"friends"`
FullName string `json:"full_name"`
Gender int `json:"gender"`
GenderFilter int `json:"gender_filter"`
Groups []interface{} `json:"groups"`
HighSchool []interface{} `json:"high_school"`
InterestedIn []int `json:"interested_in"`
Interests []struct {
CreatedTime string `json:"created_time"`
ID string `json:"id"`
Name string `json:"name"`
} `json:"interests"`
Jobs []struct {
Title struct {
Displayed bool `json:"displayed"`
Name string `json:"name"`
ID string `json:"id"`
} `json:"title"`
Company struct {
Displayed bool `json:"displayed"`
Name string `json:"name"`
ID string `json:"id"`
} `json:"company"`
} `json:"jobs"`
LatestUpdateDate time.Time `json:"latest_update_date"`
Location interface{} `json:"location"`
Name string `json:"name"`
Photos []struct {
YoffsetPercent int `json:"yoffset_percent,omitempty"`
ID string `json:"id"`
XdistancePercent int `json:"xdistance_percent,omitempty"`
Main bool `json:"main,omitempty"`
YdistancePercent int `json:"ydistance_percent,omitempty"`
XoffsetPercent int `json:"xoffset_percent,omitempty"`
FileName string `json:"fileName"`
Extension string `json:"extension"`
ProcessedFiles []struct {
Width int `json:"width"`
Height int `json:"height"`
URL string `json:"url"`
} `json:"processedFiles"`
URL string `json:"url"`
SuccessRate float64 `json:"successRate"`
SelectRate int `json:"selectRate"`
Shape string `json:"shape,omitempty"`
} `json:"photos"`
PhotoOptimizerEnabled bool `json:"photo_optimizer_enabled"`
PhotoOptimizerHasResult bool `json:"photo_optimizer_has_result"`
PingTime time.Time `json:"ping_time"`
Pos struct {
At int64 `json:"at"`
Lat float64 `json:"lat"`
Lon float64 `json:"lon"`
} `json:"pos"`
PosMajor struct {
Lat float64 `json:"lat"`
Lon float64 `json:"lon"`
At int64 `json:"at"`
} `json:"pos_major"`
PromotedOutOfDate bool `json:"promoted_out_of_date"`
Schools []interface{} `json:"schools"`
SquadsOnly bool `json:"squads_only"`
SquadsDiscoverable bool `json:"squads_discoverable"`
SquadAdsShown bool `json:"squad_ads_shown"`
Username string `json:"username"`
}
type ProfileUpdateRequest struct {
DistanceFilter int `json:"distance_filter"`
}
func (t *TinderGo) UpdateDistance(miles int) (ProfileUpdateResponse, error) {
pfl := ProfileUpdateResponse{}
req := ProfileUpdateRequest{DistanceFilter: miles}
bReq, err := json.Marshal(req)
if err != nil {
return pfl, err
}
url := "https://api.gotinder.com/profile"
b, errs := t.requester.Post(url, string(bReq))
if errs != nil {
return pfl, errs[0]
}
b = strings.Replace(b, "\"main\",", "true, ", -1)
err = json.Unmarshal([]byte(b), &pfl)
if err != nil {
return pfl, err
}
return pfl, nil
}