-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCustomFlagsProxyCheckExample.kt
190 lines (170 loc) · 6.99 KB
/
CustomFlagsProxyCheckExample.kt
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
package io.proxycheck.api.v2.examples
import io.proxycheck.api.v2.client.ProxyCheckApiAdapter
import io.proxycheck.api.v2.client.ProxyCheckApiClientAdapter
import io.proxycheck.api.v2.client.ProxyCheckApiInterface
import io.proxycheck.api.v2.models.ProxyCheckOptions
import io.proxycheck.api.v2.models.enum.ResponseStatus
import io.proxycheck.api.v2.models.flag.*
/**
* Example usage of the ProxyCheck.io API client with different query flags and custom settings.
* This example demonstrates how to use various flag enums to customize API requests.
*/
object CustomFlagsProxyCheckExample {
/**
* Main method to demonstrate the usage of the ProxyCheck.io API client with custom flags.
*/
@JvmStatic
fun main(args: Array<String>) {
// Create a new API client using the adapter (implements ProxyCheckApiInterface)
// Replace "YOUR_API_KEY" with your actual API key
val apiClient: ProxyCheckApiInterface = ProxyCheckApiClientAdapter(apiKey = "YOUR_API_KEY")
// Example 1: Using VPN flag with different settings
println("Example 1: Using VPN flag with different settings")
try {
// Create options with VPN flag set to ENABLED
val options = ProxyCheckOptions.builder()
.vpnFlag(VpnFlag.ENABLED)
.useSSL(true)
.build()
val response = apiClient.checkIp(
ip = "8.8.8.8",
options = options
)
println("Status: ${response.statusEnum} (${response.status.value})")
println("IP: ${response.ip}")
println("Proxy: ${response.proxyEnum} (${response.proxyString})")
println("VPN: ${response.vpn}")
println()
} catch (e: Exception) {
println("Error: ${e.message}")
}
// Example 2: Using ASN flag with different settings
println("Example 2: Using ASN flag with different settings")
try {
// Create options with ASN flag set to ENABLED
val options = ProxyCheckOptions.builder()
.asnFlag(AsnFlag.ENABLED)
.useSSL(true)
.build()
val response = apiClient.checkIp(
ip = "8.8.8.8",
options = options
)
println("Status: ${response.statusEnum} (${response.status.value})")
println("IP: ${response.ip}")
println("ASN: ${response.asn}")
println("Provider: ${response.provider}")
println()
} catch (e: Exception) {
println("Error: ${e.message}")
}
// Example 3: Using RISK flag with different settings
println("Example 3: Using RISK flag with different settings")
try {
// Create options with RISK flag set to ENHANCED
val options = ProxyCheckOptions.builder()
.riskFlag(RiskFlag.ENHANCED)
.useSSL(true)
.build()
val response = apiClient.checkIp(
ip = "8.8.8.8",
options = options
)
println("Status: ${response.statusEnum} (${response.status.value})")
println("IP: ${response.ip}")
println("Risk: ${response.risk}")
println()
} catch (e: Exception) {
println("Error: ${e.message}")
}
// Example 4: Using TIME flag with different settings
println("Example 4: Using TIME flag with different settings")
try {
// Create options with TIME flag set to ENABLED
val options = ProxyCheckOptions.builder()
.timeFlag(TimeFlag.ENABLED)
.useSSL(true)
.build()
val response = apiClient.checkIp(
ip = "8.8.8.8",
options = options
)
println("Status: ${response.statusEnum} (${response.status.value})")
println("IP: ${response.ip}")
println("Time: ${response.time}")
println()
} catch (e: Exception) {
println("Error: ${e.message}")
}
// Example 5: Combining multiple flags with different settings
println("Example 5: Combining multiple flags with different settings")
try {
// Create options with multiple flags
val options = ProxyCheckOptions.builder()
.vpnFlag(VpnFlag.ENABLED)
.asnFlag(AsnFlag.ENABLED)
.riskFlag(RiskFlag.ENHANCED)
.timeFlag(TimeFlag.ENABLED)
.nodeFlag(NodeFlag.ENABLED)
.useSSL(true)
.build()
val response = apiClient.checkIp(
ip = "8.8.8.8",
options = options
)
println("Status: ${response.statusEnum} (${response.status.value})")
println("IP: ${response.ip}")
println("Proxy: ${response.proxyEnum} (${response.proxyString})")
println("VPN: ${response.vpn}")
println("ASN: ${response.asn}")
println("Provider: ${response.provider}")
println("Risk: ${response.risk}")
println("Time: ${response.time}")
println("Node: ${response.node}")
println()
} catch (e: Exception) {
println("Error: ${e.message}")
}
// Example 6: Using additional query flags
println("Example 6: Using additional query flags")
try {
// Create options with additional query flags
val options = ProxyCheckOptions.builder()
.flags(listOf(
QueryFlag.VPN,
QueryFlag.ASN,
QueryFlag.COUNTRY,
QueryFlag.ISOCODE,
QueryFlag.PROXY_TYPE,
QueryFlag.PROVIDER,
QueryFlag.CITY,
QueryFlag.REGION,
QueryFlag.ORGANIZATION,
QueryFlag.HOSTNAME,
QueryFlag.ISP
))
.useSSL(true)
.build()
val response = apiClient.checkIp(
ip = "8.8.8.8",
options = options
)
println("Status: ${response.statusEnum} (${response.status.value})")
println("IP: ${response.ip}")
println("Proxy: ${response.proxyEnum} (${response.proxyString})")
println("VPN: ${response.vpn}")
println("ASN: ${response.asn}")
println("Country: ${response.country}")
println("ISO Code: ${response.isoCode}")
println("Provider: ${response.provider}")
println("City: ${response.city}")
println("Region: ${response.region}")
println("Organization: ${response.organization}")
println("Hostname: ${response.hostname}")
println("ISP: ${response.isp}")
println()
} catch (e: Exception) {
println("Error: ${e.message}")
}
}
}