|
1
|
|
|
package minfraud |
|
2
|
|
|
|
|
3
|
|
|
// BaseResponse is common response of minFraud API. |
|
4
|
|
|
// ref: https://dev.maxmind.com/minfraud/api-documentation/responses |
|
5
|
|
|
type BaseResponse struct { |
|
6
|
|
|
ErrData |
|
7
|
|
|
Disposition Disposition `json:"disposition"` |
|
8
|
|
|
FundsRemaining float64 `json:"funds_remaining"` |
|
9
|
|
|
ID string `json:"id"` |
|
10
|
|
|
QueriesRemaining int64 `json:"queries_remaining"` |
|
11
|
|
|
RiskScore float64 `json:"risk_score"` // from 0.01 to 99 |
|
12
|
|
|
Warnings []Warning `json:"warnings"` |
|
13
|
|
|
} |
|
14
|
|
|
|
|
15
|
|
|
func (r BaseResponse) HasError() bool { |
|
16
|
|
|
return r.ErrData.Code != "" |
|
17
|
|
|
} |
|
18
|
|
|
|
|
19
|
|
|
type ErrData struct { |
|
20
|
|
|
Code string `json:"code"` |
|
21
|
|
|
Error string `json:"error"` |
|
22
|
|
|
} |
|
23
|
|
|
|
|
24
|
|
|
type Disposition struct { |
|
25
|
|
|
Action string `json:"action"` |
|
26
|
|
|
Reason string `json:"reason"` |
|
27
|
|
|
RuleLabel string `json:"rule_label"` |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
type Warning struct { |
|
31
|
|
|
Code string `json:"code"` |
|
32
|
|
|
InputPointer string `json:"input_pointer"` |
|
33
|
|
|
Warning string `json:"warning"` |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
type IPAddress struct { |
|
37
|
|
|
Risk float64 `json:"risk"` // from 0.01 to 99 |
|
38
|
|
|
City City `json:"city"` |
|
39
|
|
|
Continent Continent `json:"continent"` |
|
40
|
|
|
Country Country `json:"country"` |
|
41
|
|
|
Location Location `json:"location"` |
|
42
|
|
|
Postal Postal `json:"postal"` |
|
43
|
|
|
RegisteredCountry RegisteredCountry `json:"registered_country"` |
|
44
|
|
|
RepresentedCountry RepresentedCountry `json:"represented_country"` |
|
45
|
|
|
RiskReasons []RiskReason `json:"risk_reasons"` |
|
46
|
|
|
Subdivisions []Subdivision `json:"subdivisions"` |
|
47
|
|
|
Traits Traits `json:"traits"` |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
type City struct { |
|
51
|
|
|
Confidence Confidence `json:"confidence"` |
|
52
|
|
|
GeoNameID GeoNameID `json:"geoname_id"` |
|
53
|
|
|
Names Names `json:"names"` |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
type Continent struct { |
|
57
|
|
|
Code string `json:"code"` // [AF, AN, AS, EU, NA, OC, SA] |
|
58
|
|
|
GeoNameID GeoNameID `json:"geoname_id"` |
|
59
|
|
|
Names Names `json:"names"` |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
// common data for country type object. |
|
63
|
|
|
type CountryData struct { |
|
64
|
|
|
GeoNameID GeoNameID `json:"geoname_id"` |
|
65
|
|
|
IsInEuropeanUnion bool `json:"is_in_european_union"` |
|
66
|
|
|
ISOCode string `json:"iso_code"` // ISO 3166-1 alpha-2 |
|
67
|
|
|
Names Names `json:"names"` |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
type Country struct { |
|
71
|
|
|
Confidence Confidence `json:"confidence"` |
|
72
|
|
|
CountryData |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
type Location struct { |
|
76
|
|
|
AccuracyRadius int64 `json:"accuracy_radius"` // in Killometers |
|
77
|
|
|
AverageIncome float64 `json:"average_income"` // in USD |
|
78
|
|
|
Latitude float64 `json:"latitude"` |
|
79
|
|
|
LocalTime string `json:"local_time"` |
|
80
|
|
|
Longitude float64 `json:"longitude"` |
|
81
|
|
|
MetroCode int64 `json:"metro_code"` |
|
82
|
|
|
PopulationDensity int64 `json:"population_density"` // only for US |
|
83
|
|
|
TimeZone string `json:"time_zone"` |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
type Postal struct { |
|
87
|
|
|
Code string `json:"code"` |
|
88
|
|
|
Confidence Confidence `json:"confidence"` |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
type RegisteredCountry struct { |
|
92
|
|
|
CountryData |
|
93
|
|
|
} |
|
94
|
|
|
|
|
95
|
|
|
type RepresentedCountry struct { |
|
96
|
|
|
CountryData |
|
97
|
|
|
Type string `json:"type"` |
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
|
|
type RiskReason struct { |
|
101
|
|
|
Code string `json:"code"` |
|
102
|
|
|
Reason string `json:"reason"` |
|
103
|
|
|
} |
|
104
|
|
|
|
|
105
|
|
|
type Subdivision struct { |
|
106
|
|
|
GeoNameID GeoNameID `json:"geoname_id"` |
|
107
|
|
|
ISOCode string `json:"iso_code"` // ISO 3166-1 alpha-2 |
|
108
|
|
|
Names Names `json:"names"` |
|
109
|
|
|
Confidence Confidence `json:"confidence"` |
|
110
|
|
|
} |
|
111
|
|
|
|
|
112
|
|
|
type Traits struct { |
|
113
|
|
|
AutonomousSystemNumber int64 `json:"autonomous_system_number"` |
|
114
|
|
|
AutonomousSystemOrganization string `json:"autonomous_system_organization"` |
|
115
|
|
|
Domain string `json:"domain"` |
|
116
|
|
|
IPAddress string `json:"ip_address"` |
|
117
|
|
|
IsAnonymous bool `json:"is_anonymous"` |
|
118
|
|
|
IsAnonymousVPN bool `json:"is_anonymous_vpn"` |
|
119
|
|
|
IsHostingProvider bool `json:"is_hosting_provider"` |
|
120
|
|
|
IsPublicProxy bool `json:"is_public_proxy"` |
|
121
|
|
|
IsResidentialProxy bool `json:"is_residential_proxy"` |
|
122
|
|
|
IsTorExitNode bool `json:"is_tor_exit_node"` |
|
123
|
|
|
ISP string `json:"isp"` |
|
124
|
|
|
Network string `json:"network"` |
|
125
|
|
|
Organization string `json:"organization"` |
|
126
|
|
|
StaticIPScore float64 `json:"static_ip_score"` // 0 ~ 99.99 |
|
127
|
|
|
UserCount int64 `json:"user_count"` |
|
128
|
|
|
UserType string `json:"user_type"` |
|
129
|
|
|
} |
|
130
|
|
|
|
|
131
|
|
|
type BillingAddress struct { |
|
132
|
|
|
DistanceToIPLocation int64 `json:"distance_to_ip_location"` |
|
133
|
|
|
IsInIPCountry bool `json:"is_in_ip_country"` |
|
134
|
|
|
IsPostalInCity bool `json:"is_postal_in_city"` |
|
135
|
|
|
Latitude float64 `json:"latitude"` |
|
136
|
|
|
Longitude float64 `json:"longitude"` |
|
137
|
|
|
} |
|
138
|
|
|
|
|
139
|
|
|
type CreditCard struct { |
|
140
|
|
|
Brand string `json:"brand"` |
|
141
|
|
|
Country string `json:"country"` |
|
142
|
|
|
IsBusiness bool `json:"is_business"` |
|
143
|
|
|
IsIssuedInBillingAddressCountry bool `json:"is_issued_in_billing_address_country"` |
|
144
|
|
|
IsPrepaid bool `json:"is_prepaid"` |
|
145
|
|
|
IsVirtual bool `json:"is_virtual"` |
|
146
|
|
|
Issuer Issuer `json:"issuer"` |
|
147
|
|
|
Type string `json:"type"` |
|
148
|
|
|
} |
|
149
|
|
|
|
|
150
|
|
|
type Issuer struct { |
|
151
|
|
|
MatchesProvidedName bool `json:"matches_provided_name"` |
|
152
|
|
|
MatchesProvidedPhoneNumber bool `json:"matches_provided_phone_number"` |
|
153
|
|
|
Name string `json:"name"` |
|
154
|
|
|
PhoneNumber string `json:"phone_number"` |
|
155
|
|
|
} |
|
156
|
|
|
|
|
157
|
|
|
type Device struct { |
|
158
|
|
|
Confidence Confidence `json:"confidence"` |
|
159
|
|
|
ID string `json:"id"` |
|
160
|
|
|
LastSeen string `json:"last_seen"` |
|
161
|
|
|
LocalTime string `json:"local_time"` |
|
162
|
|
|
} |
|
163
|
|
|
|
|
164
|
|
|
type Email struct { |
|
165
|
|
|
Domain Domain `json:"domain"` |
|
166
|
|
|
FirstSeen string `json:"first_seen"` |
|
167
|
|
|
IsDisposable bool `json:"is_disposable"` |
|
168
|
|
|
IsFree bool `json:"is_free"` |
|
169
|
|
|
IsHighRisk bool `json:"is_high_risk"` |
|
170
|
|
|
} |
|
171
|
|
|
|
|
172
|
|
|
type Domain struct { |
|
173
|
|
|
FirstSeen string `json:"first_seen"` |
|
174
|
|
|
} |
|
175
|
|
|
|
|
176
|
|
|
type ShippingAddress struct { |
|
177
|
|
|
DistanceToBillingAddress int64 `json:"distance_to_billing_address"` |
|
178
|
|
|
DistanceToIPLocation int64 `json:"distance_to_ip_location"` |
|
179
|
|
|
IsHighRisk bool `json:"is_high_risk"` |
|
180
|
|
|
IsInIPCountry bool `json:"is_in_ip_country"` |
|
181
|
|
|
IsPostalInCity bool `json:"is_postal_in_city"` |
|
182
|
|
|
Latitude float64 `json:"latitude"` |
|
183
|
|
|
Longitude float64 `json:"longitude"` |
|
184
|
|
|
} |
|
185
|
|
|
|
|
186
|
|
|
type Subscores struct { |
|
187
|
|
|
AVSResult float64 `json:"avs_result"` |
|
188
|
|
|
BillingAddress float64 `json:"billing_address"` |
|
189
|
|
|
BillingAddressDistanceToIPLocation float64 `json:"billing_address_distance_to_ip_location"` |
|
190
|
|
|
Browser float64 `json:"browser"` |
|
191
|
|
|
Chargeback float64 `json:"chargeback"` |
|
192
|
|
|
Country float64 `json:"country"` |
|
193
|
|
|
CountryMismatch float64 `json:"country_mismatch"` |
|
194
|
|
|
CVVResult float64 `json:"cvv_result"` |
|
195
|
|
|
Device float64 `json:"device"` |
|
196
|
|
|
EmailAddress float64 `json:"email_address"` |
|
197
|
|
|
EmailDomain float64 `json:"email_domain"` |
|
198
|
|
|
EmailLocalPart float64 `json:"email_local_part"` |
|
199
|
|
|
IssuerIDNumber float64 `json:"issuer_id_number"` |
|
200
|
|
|
OrderAmount float64 `json:"order_amount"` |
|
201
|
|
|
PhoneNumber float64 `json:"phone_number"` |
|
202
|
|
|
ShippingAddress float64 `json:"shipping_address"` |
|
203
|
|
|
ShippingAddressDistanceToIPLocation float64 `json:"shipping_address_distance_to_ip_location"` |
|
204
|
|
|
TimeOfDay float64 `json:"time_of_day"` |
|
205
|
|
|
} |
|
206
|
|
|
|
|
207
|
|
|
type Names struct { |
|
208
|
|
|
DE string `json:"de"` |
|
209
|
|
|
EN string `json:"en"` |
|
210
|
|
|
ES string `json:"es"` |
|
211
|
|
|
FR string `json:"fr"` |
|
212
|
|
|
JA string `json:"ja"` |
|
213
|
|
|
PtBR string `json:"pt-BR"` |
|
214
|
|
|
RU string `json:"ru"` |
|
215
|
|
|
ZhCN string `json:"zh-CN"` |
|
216
|
|
|
} |
|
217
|
|
|
|
|
218
|
|
|
// ======= single value type =========== |
|
219
|
|
|
|
|
220
|
|
|
// from 0 to 100 |
|
221
|
|
|
type Confidence int64 |
|
222
|
|
|
|
|
223
|
|
|
// ref: https://www.geonames.org/ |
|
224
|
|
|
type GeoNameID int64 |
|
225
|
|
|
|
|
226
|
|
|
// APIResponse is used to align the type from API request. |
|
227
|
|
|
type APIResponse struct { |
|
228
|
|
|
BaseResponse |
|
229
|
|
|
IPAddress IPAddress `json:"ip_address"` |
|
230
|
|
|
BillingAddress BillingAddress `json:"billing_address"` |
|
231
|
|
|
CreditCard CreditCard `json:"credit_card"` |
|
232
|
|
|
Device Device `json:"device"` |
|
233
|
|
|
Email Email `json:"email"` |
|
234
|
|
|
ShippingAddress ShippingAddress `json:"shipping_address"` |
|
235
|
|
|
Subscores Subscores `json:"subscores"` |
|
236
|
|
|
} |
|
237
|
|
|
|