forked from maximn/google-maps
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
No tests added to MapsApiTest No backward compatibility to deprecated MapsAPIEngine.
- Loading branch information
Michael Vivet
committed
Feb 22, 2013
1 parent
8032590
commit 1f3897f
Showing
6 changed files
with
163 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
GoogleMapsApi/Entities/TimeZone/Request/TimeZoneRequest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
using System; | ||
using GoogleMapsApi.Engine; | ||
using GoogleMapsApi.Entities.Common; | ||
|
||
namespace GoogleMapsApi.Entities.TimeZone.Request | ||
{ | ||
public class TimeZoneRequest : SignableRequest | ||
{ | ||
protected internal override string BaseUrl | ||
{ | ||
get { return "maps.googleapis.com/maps/api/timezone/"; } | ||
} | ||
|
||
/// <summary> | ||
/// location: a comma-separated lat,lng tuple (eg. location=-33.86,151.20), representing the location to look up | ||
/// </summary> | ||
public Location Location { get; set; } // required | ||
|
||
/// <summary> | ||
/// Timestamp specifies the desired time as seconds since midnight, January 1, 1970 UTC. The Time Zone API uses the timestamp to determine whether or not Daylight Savings should be applied. Times before 1970 can be expressed as negative values. | ||
/// </summary> | ||
public DateTime TimeStamp { get; set; } // required | ||
|
||
/// <summary> | ||
/// The language in which to return results. See the list of supported domain languages. Note that we often update supported languages so this list may not be exhaustive. Defaults to en | ||
/// </summary> | ||
public string Language { get; set; } // optional | ||
|
||
/// <summary> | ||
/// The language in which to return results. See the list of supported domain languages. Note that we often update supported languages so this list may not be exhaustive. Defaults to en. | ||
/// </summary> | ||
public override bool IsSSL | ||
{ | ||
get { return true; } | ||
set { throw new NotSupportedException("This operation is not supported, TimeZoneRequest must use SSL"); } | ||
} | ||
|
||
protected override QueryStringParametersList GetQueryStringParameters() | ||
{ | ||
if (Location == null) | ||
throw new ArgumentException("Location is required"); | ||
|
||
if (TimeStamp == null) | ||
throw new ArgumentException("TimeStamp is required"); | ||
|
||
var _parameters = base.GetQueryStringParameters(); | ||
|
||
_parameters.Add("location", this.Location.LocationString); | ||
_parameters.Add("timestamp", UnixTimeConverter.DateTimeToUnixTimestamp(this.TimeStamp).ToString()); | ||
|
||
if (!string.IsNullOrWhiteSpace(Language)) _parameters.Add("language", Language); | ||
|
||
return _parameters; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using System.Runtime.Serialization; | ||
|
||
namespace GoogleMapsApi.Entities.TimeZone.Response | ||
{ | ||
[DataContract] | ||
public enum Status | ||
{ | ||
[EnumMember(Value = "OK")] | ||
OK, // indicates that no errors occurred; the place was successfully detected and at least one result was returned. | ||
[EnumMember(Value = "ZERO_RESULTS")] | ||
ZERO_RESULTS, // indicates that the search was successful but returned no results. This may occur if the search was passed a latlng in a remote location. | ||
[EnumMember(Value = "OVER_QUERY_LIMIT")] | ||
OVER_QUERY_LIMIT, // indicates that you are over your quota. | ||
[EnumMember(Value = "REQUEST_DENIED")] | ||
REQUEST_DENIED, // indicates that your request was denied, generally because of lack of a sensor parameter. | ||
[EnumMember(Value = "INVALID_REQUEST")] | ||
INVALID_REQUEST, // generally indicates that the query parameter (location or radius) is missing. | ||
[EnumMember(Value = "UNKNOWN_ERROR")] | ||
UNKNOWN_ERROR // indicates an unknown error | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
GoogleMapsApi/Entities/TimeZone/Response/TimeZoneResponse.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
using System; | ||
using System.Runtime.Serialization; | ||
using GoogleMapsApi.Entities.Common; | ||
using GoogleMapsApi.Entities.TimeZone.Request; | ||
|
||
namespace GoogleMapsApi.Entities.TimeZone.Response | ||
{ | ||
[DataContract] | ||
public class TimeZoneResponse : IResponseFor<TimeZoneRequest> | ||
{ | ||
/// <summary> | ||
/// "status" contains metadata on the request. | ||
/// </summary> | ||
public Status Status { get; set; } | ||
|
||
[DataMember(Name = "status")] | ||
internal string StatusStr | ||
{ | ||
get | ||
{ | ||
return Status.ToString(); | ||
} | ||
set | ||
{ | ||
Status = (Status)Enum.Parse(typeof(Status), value); | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// DstOffset: the offset for daylight-savings time in seconds. This will be zero if the time zone is not in Daylight Savings Time during the specified timestamp. | ||
/// </summary> | ||
[DataMember(Name = "dstOffset")] | ||
public double OffSet { get; set; } | ||
|
||
/// <summary> | ||
/// RawOffset: the offset from UTC (in seconds) for the given location. This does not take into effect daylight savings. | ||
/// </summary> | ||
[DataMember(Name = "rawOffset")] | ||
public double RawOffSet { get; set; } | ||
|
||
/// <summary> | ||
/// TimeZoneId: a string containing the ID of the time zone, such as "America/Los_Angeles" or "Australia/Sydney". | ||
/// </summary> | ||
[DataMember(Name = "timeZoneId")] | ||
public string TimeZoneId { get; set; } | ||
|
||
/// <summary> | ||
/// TimeZoneName: a string containing the long form name of the time zone. This field will be localized if the language parameter is set. eg. "Pacific Daylight Time" or "Australian. | ||
/// </summary> | ||
[DataMember(Name = "timeZoneName")] | ||
public string TimeZoneName { get; set; } | ||
} | ||
} | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters