@@ -59,11 +59,12 @@ geoParams.SetIPAddress("1.1.1.1");
59
59
geoParams .SetFields (" geo,time_zone,currency" );
60
60
geoParams .SetIncludeSecurity (true );
61
61
62
- Geolocation geolocation = api .GetGeolocation (geoParams );
62
+ Dictionary < String , Object > response = api .GetGeolocation (geoParams );
63
63
64
64
// Check if geolocation lookup was successful
65
- if (geolocation . GetStatus () == 200 )
65
+ if (response [ " status " ] == 200 )
66
66
{
67
+ Geolocation geolocation = (Geolocation ) response [" response" ];
67
68
Console .WriteLine (geolocation .GetCountryName ());
68
69
Console .WriteLine (geolocation .GetCurrency ().GetName ());
69
70
Console .WriteLine (geolocation .GetTimezone ().GetCurrentTime ());
@@ -79,38 +80,40 @@ if(geolocation.GetStatus() == 200)
79
80
}
80
81
else
81
82
{
82
- Console .WriteLine (geolocation . GetMessage () );
83
+ Console .WriteLine (response [ " message " ] );
83
84
}
84
85
85
86
// Get geolocation in Russian** for IP address (1.1.1.1) and all fields
86
87
GeolocationParams geoParams = new GeolocationParams ();
87
88
geoParams .SetIPAddress (" 1.1.1.1" );
88
89
geoParams .SetLang (" ru" );
89
90
90
- Geolocation geolocation = api .GetGeolocation (geoParams );
91
+ Dictionary < String , Object > response = api .GetGeolocation (geoParams );
91
92
92
93
// Check if geolocation lookup was successful
93
- if (geolocation . GetStatus () == 200 )
94
+ if (response [ " status " ] == 200 )
94
95
{
96
+ Geolocation geolocation = (Geolocation ) response [" response" ];
95
97
Console .WriteLine (geolocation .GetIPAddress ());
96
98
Console .WriteLine (geolocation .GetCountryName ());
97
99
}
98
100
else
99
101
{
100
- Console .WriteLine (geolocation . GetMessage () );
102
+ Console .WriteLine (response [ " message " ] );
101
103
}
102
104
103
105
// Query geolocation for the calling machine's IP address for all fields
104
- Geolocation geolocation = api .GetGeolocation ();
106
+ Dictionary < String , Object > response = api .GetGeolocation ();
105
107
106
- if (geolocation . GetStatus () == 200 )
108
+ if (response [ " status " ] == 200 )
107
109
{
110
+ Geolocation geolocation = (Geolocation ) response [" response" ];
108
111
Console .WriteLine (geolocation .GetCountryCode2 ());
109
112
Console .WriteLine (geolocation .GetTimezone ().GetCurrentTime ());
110
113
}
111
114
else
112
115
{
113
- Console .WriteLine (geolocation . GetMessage () );
116
+ Console .WriteLine (response [ " message " ] );
114
117
}
115
118
```
116
119
@@ -120,89 +123,110 @@ else
120
123
String [] ips = new String []{" 1.1.1.1" , " 2.2.2.2" , " 3.3.3.3" };
121
124
GeolocationParams geoParams = new GeolocationParams ();
122
125
geoParams .SetIPAddresses (ips );
123
- geoParams .setLang (" de" );
126
+ geoParams .SetLang (" de" );
124
127
125
- List < Geolocation > geolocations = api .GetBulkGeolocation (geoParams );
128
+ Dictionary < String , Object > response = api .GetBulkGeolocation (geoParams );
126
129
130
+ if (response [" status" ] == 200 )
131
+ {
132
+
133
+ List < Geolocation > geolocations = (List <Geolocation >) response [" response" ];
127
134
Console .WriteLine (geolocations .Count );
128
135
Console .WriteLine (geolocations [0 ].GetCountryName ());
129
136
Console .WriteLine (geolocations [1 ].GetLanguages ());
130
137
Console .WriteLine (geolocations [2 ].GetTimezone ().GetCurrentTime ());
138
+ }
139
+ else
140
+ {
141
+ Console .WriteLine (response [" message" ]);
142
+ }
131
143
132
144
// Query geolocations for multiple IP addresses but only geo field
133
145
String [] ips = new String []{" 1.1.1.1" , " 2.2.2.2" , " 3.3.3.3" };
134
146
GeolocationParams geoParams = new GeolocationParams ();
135
147
geoParams .SetIPAddresses (ips );
136
148
geoParams .SetFields (" geo" );
137
149
138
- List < Geolocation > geolocations = api .GetBulkGeolocation (geoParams );
150
+ Dictionary < String , Object > response = api .GetBulkGeolocation (geoParams );
139
151
140
- Console .WriteLine (geolocations .Count );
141
- Console .WriteLine (geolocations [0 ].GetCountryCode2 ());
142
- Console .WriteLine (geolocations [1 ].GetCountryName ());
143
- Console .WriteLine (geolocations [2 ].GetLatitude ());
152
+ if (response [" status" ] == 200 )
153
+ {
154
+ List < Geolocation > geolocations = (List <Geolocation >) response [" response" ];
155
+ Console .WriteLine (geolocations .Count );
156
+ Console .WriteLine (geolocations [0 ].GetCountryCode2 ());
157
+ Console .WriteLine (geolocations [0 ].GetCountryName ());
158
+ Console .WriteLine (geolocations [0 ].GetLatitude ());
159
+ }
160
+ else
161
+ {
162
+ Console .WriteLine (response [" message" ]);
163
+ }
144
164
```
145
165
146
166
### Timezone API
147
167
``` c#
148
168
// Query time zone information by time zone ID
149
169
TimezoneParams tzParams = new TimezoneParams ();
150
- tzParams .SetTimezone (“ America / New_York ” );
170
+ tzParams .SetTimezone (" America/New_York" );
151
171
152
- Timezone tz = api .GetTimezone (tzParams );
172
+ Dictionary < String , Object > response = api .GetTimezone (tzParams );
153
173
154
- if (tz . GetStatus () == 200 )
174
+ if (response [ " status " ] == 200 )
155
175
{
176
+ Timezone tz = (Timezone ) response [" response" ];
156
177
Console .WriteLine (tz .GetDateTimeWti ());
157
178
Console .WriteLine (tz .GetDateTimeTxt ());
158
179
}
159
180
else
160
181
{
161
- Console .WriteLine (tz . GetMessage () );
182
+ Console .WriteLine (response [ " message " ] );
162
183
}
163
184
164
185
// Query time zone information by latitude and longitude of the location
165
186
TimezoneParams tzParams = new TimezoneParams ();
166
- tzParams .SetLocation (37 . 1838139 , - 123 . 8105225 );
187
+ tzParams .SetCoordinates (37 . 1838139 , - 123 . 8105225 );
167
188
168
- Timezone tz = api .GetTimezone (tzParams );
189
+ Dictionary < String , Object > response = api .GetTimezone (tzParams );
169
190
170
- if (tz . GetStatus () == 200 )
191
+ if (response [ " status " ] == 200 )
171
192
{
193
+ Timezone tz = (Timezone ) response [" response" ];
172
194
Console .WriteLine (tz .GetTimezone ());
173
195
}
174
196
else
175
197
{
176
- Console .WriteLine (tz . GetMessage () );
198
+ Console .WriteLine (response [ " message " ] );
177
199
}
178
200
179
201
// Get time zone information for IP address (1.1.1.1) and geolocation information Japanese**
180
202
TimezoneParams tzParams = new TimezoneParams ();
181
203
tzParams .SetIPAddress (" 1.1.1.1" );
182
- tzParams .setLang (" ja" );
204
+ tzParams .SetLang (" ja" );
183
205
184
- Timezone tz = api .GetTimezone (tzParams );
206
+ Dictionary < String , Object > response = api .GetTimezone (tzParams );
185
207
186
- if (tz . GetStatus () == 200 )
208
+ if (response [ " status " ] == 200 )
187
209
{
210
+ Timezone tz = (Timezone ) response [" response" ];
188
211
Console .WriteLine (tz .GetTimezone ());
189
212
}
190
213
else
191
214
{
192
- Console .WriteLine (tz . GetMessage () );
215
+ Console .WriteLine (response [ " message " ] );
193
216
}
194
217
195
218
// Query time zone information for calling machine’s IP address
196
- Timezone tz = api .GetTimezone ();
219
+ Dictionary < String , Object > response = api .GetTimezone ();
197
220
198
- if (tz . getMessage () )
221
+ if (response [ " status " ] == 200 )
199
222
{
223
+ Timezone tz = (Timezone ) response [" response" ];
200
224
Console .WriteLine (tz .GetTimezone ());
201
225
Console .WriteLine (tz .GetDateTimeYmd ());
202
226
}
203
227
else
204
228
{
205
- Console .WriteLine (tz . GetMessage () );
229
+ Console .WriteLine (response [ " message " ] );
206
230
}
207
231
```
208
232
0 commit comments