@@ -59,11 +59,12 @@ geoParams.SetIPAddress("1.1.1.1");
5959geoParams .SetFields (" geo,time_zone,currency" );
6060geoParams .SetIncludeSecurity (true );
6161
62- Geolocation geolocation = api .GetGeolocation (geoParams );
62+ Dictionary < String , Object > response = api .GetGeolocation (geoParams );
6363
6464// Check if geolocation lookup was successful
65- if (geolocation . GetStatus () == 200 )
65+ if (response [ " status " ] == 200 )
6666{
67+ Geolocation geolocation = (Geolocation ) response [" response" ];
6768 Console .WriteLine (geolocation .GetCountryName ());
6869 Console .WriteLine (geolocation .GetCurrency ().GetName ());
6970 Console .WriteLine (geolocation .GetTimezone ().GetCurrentTime ());
@@ -79,38 +80,40 @@ if(geolocation.GetStatus() == 200)
7980}
8081else
8182{
82- Console .WriteLine (geolocation . GetMessage () );
83+ Console .WriteLine (response [ " message " ] );
8384}
8485
8586// Get geolocation in Russian** for IP address (1.1.1.1) and all fields
8687GeolocationParams geoParams = new GeolocationParams ();
8788geoParams .SetIPAddress (" 1.1.1.1" );
8889geoParams .SetLang (" ru" );
8990
90- Geolocation geolocation = api .GetGeolocation (geoParams );
91+ Dictionary < String , Object > response = api .GetGeolocation (geoParams );
9192
9293// Check if geolocation lookup was successful
93- if (geolocation . GetStatus () == 200 )
94+ if (response [ " status " ] == 200 )
9495{
96+ Geolocation geolocation = (Geolocation ) response [" response" ];
9597 Console .WriteLine (geolocation .GetIPAddress ());
9698 Console .WriteLine (geolocation .GetCountryName ());
9799}
98100else
99101{
100- Console .WriteLine (geolocation . GetMessage () );
102+ Console .WriteLine (response [ " message " ] );
101103}
102104
103105// Query geolocation for the calling machine's IP address for all fields
104- Geolocation geolocation = api .GetGeolocation ();
106+ Dictionary < String , Object > response = api .GetGeolocation ();
105107
106- if (geolocation . GetStatus () == 200 )
108+ if (response [ " status " ] == 200 )
107109{
110+ Geolocation geolocation = (Geolocation ) response [" response" ];
108111 Console .WriteLine (geolocation .GetCountryCode2 ());
109112 Console .WriteLine (geolocation .GetTimezone ().GetCurrentTime ());
110113}
111114else
112115{
113- Console .WriteLine (geolocation . GetMessage () );
116+ Console .WriteLine (response [ " message " ] );
114117}
115118```
116119
@@ -120,89 +123,110 @@ else
120123String [] ips = new String []{" 1.1.1.1" , " 2.2.2.2" , " 3.3.3.3" };
121124GeolocationParams geoParams = new GeolocationParams ();
122125geoParams .SetIPAddresses (ips );
123- geoParams .setLang (" de" );
126+ geoParams .SetLang (" de" );
124127
125- List < Geolocation > geolocations = api .GetBulkGeolocation (geoParams );
128+ Dictionary < String , Object > response = api .GetBulkGeolocation (geoParams );
126129
130+ if (response [" status" ] == 200 )
131+ {
132+
133+ List < Geolocation > geolocations = (List <Geolocation >) response [" response" ];
127134Console .WriteLine (geolocations .Count );
128135Console .WriteLine (geolocations [0 ].GetCountryName ());
129136Console .WriteLine (geolocations [1 ].GetLanguages ());
130137Console .WriteLine (geolocations [2 ].GetTimezone ().GetCurrentTime ());
138+ }
139+ else
140+ {
141+ Console .WriteLine (response [" message" ]);
142+ }
131143
132144// Query geolocations for multiple IP addresses but only geo field
133145String [] ips = new String []{" 1.1.1.1" , " 2.2.2.2" , " 3.3.3.3" };
134146GeolocationParams geoParams = new GeolocationParams ();
135147geoParams .SetIPAddresses (ips );
136148geoParams .SetFields (" geo" );
137149
138- List < Geolocation > geolocations = api .GetBulkGeolocation (geoParams );
150+ Dictionary < String , Object > response = api .GetBulkGeolocation (geoParams );
139151
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+ }
144164```
145165
146166### Timezone API
147167``` c#
148168// Query time zone information by time zone ID
149169TimezoneParams tzParams = new TimezoneParams ();
150- tzParams .SetTimezone (“ America / New_York ” );
170+ tzParams .SetTimezone (" America/New_York" );
151171
152- Timezone tz = api .GetTimezone (tzParams );
172+ Dictionary < String , Object > response = api .GetTimezone (tzParams );
153173
154- if (tz . GetStatus () == 200 )
174+ if (response [ " status " ] == 200 )
155175{
176+ Timezone tz = (Timezone ) response [" response" ];
156177 Console .WriteLine (tz .GetDateTimeWti ());
157178 Console .WriteLine (tz .GetDateTimeTxt ());
158179}
159180else
160181{
161- Console .WriteLine (tz . GetMessage () );
182+ Console .WriteLine (response [ " message " ] );
162183}
163184
164185// Query time zone information by latitude and longitude of the location
165186TimezoneParams tzParams = new TimezoneParams ();
166- tzParams .SetLocation (37 . 1838139 , - 123 . 8105225 );
187+ tzParams .SetCoordinates (37 . 1838139 , - 123 . 8105225 );
167188
168- Timezone tz = api .GetTimezone (tzParams );
189+ Dictionary < String , Object > response = api .GetTimezone (tzParams );
169190
170- if (tz . GetStatus () == 200 )
191+ if (response [ " status " ] == 200 )
171192{
193+ Timezone tz = (Timezone ) response [" response" ];
172194 Console .WriteLine (tz .GetTimezone ());
173195}
174196else
175197{
176- Console .WriteLine (tz . GetMessage () );
198+ Console .WriteLine (response [ " message " ] );
177199}
178200
179201// Get time zone information for IP address (1.1.1.1) and geolocation information Japanese**
180202TimezoneParams tzParams = new TimezoneParams ();
181203tzParams .SetIPAddress (" 1.1.1.1" );
182- tzParams .setLang (" ja" );
204+ tzParams .SetLang (" ja" );
183205
184- Timezone tz = api .GetTimezone (tzParams );
206+ Dictionary < String , Object > response = api .GetTimezone (tzParams );
185207
186- if (tz . GetStatus () == 200 )
208+ if (response [ " status " ] == 200 )
187209{
210+ Timezone tz = (Timezone ) response [" response" ];
188211 Console .WriteLine (tz .GetTimezone ());
189212}
190213else
191214{
192- Console .WriteLine (tz . GetMessage () );
215+ Console .WriteLine (response [ " message " ] );
193216}
194217
195218// Query time zone information for calling machine’s IP address
196- Timezone tz = api .GetTimezone ();
219+ Dictionary < String , Object > response = api .GetTimezone ();
197220
198- if (tz . getMessage () )
221+ if (response [ " status " ] == 200 )
199222{
223+ Timezone tz = (Timezone ) response [" response" ];
200224 Console .WriteLine (tz .GetTimezone ());
201225 Console .WriteLine (tz .GetDateTimeYmd ());
202226}
203227else
204228{
205- Console .WriteLine (tz . GetMessage () );
229+ Console .WriteLine (response [ " message " ] );
206230}
207231```
208232
0 commit comments