/// <summary> /// Converts the time by using a LocationId, a ISO-string and optionally a list of IDs to convert to. /// </summary> /// <returns> /// The converted time. /// </returns> /// <param name='fromId'> /// The places identifier /// </param> /// <param name='iso'> /// ISO 8601-formatted string. /// </param> /// <param name='toIds'> /// The place IDs to convert to. /// </param> public ConvertedTimes ConvertTime(LocationId fromId, string iso, IList <LocationId> toIds = null) { if (fromId == null || string.IsNullOrEmpty(iso)) { throw new ArgumentException("A required argument is null or empty"); } var id = fromId.GetIdAsString(); if (string.IsNullOrEmpty(id)) { throw new ArgumentException("A required argument is null or empty"); } var arguments = GetCommonArguments(id); arguments.Set("iso", iso); if (toIds != null) { arguments.Add(GetArgumentsForToIds(toIds)); } return(CallService <ConvertedTimes>(arguments)); }
/// <summary> /// Gets the specified object type (Moon, Sun) for a specified place by start date. /// </summary> /// <returns> /// A list of astronomical information. /// </returns> /// <param name='objectType'> /// The astronomical object type (Moon or Sun) /// </param> /// <param name='placeId'> /// Place identifier. /// </param> /// <param name='startDate'> /// Start date. /// </param> /// <param name='endDate'> /// End date. /// </param> public IList <AstronomyLocation> GetAstronomicalInfo(AstronomyObjectType objectType, LocationId placeId, DateTime startDate, DateTime endDate) { if (placeId == null || startDate.Year == 0 || endDate.Year == 0) { throw new ArgumentException("A required argument is null or empty"); } var id = placeId.GetIdAsString(); if (string.IsNullOrEmpty(id)) { throw new ArgumentException("A required argument is null or empty"); } if (endDate.Ticks < startDate.Ticks) { throw new QueriedDateOutOfRangeException("End date cannot be before Start date"); } var args = GetOptionalArguments(); args.Set("placeid", id); args.Set("object", objectType.ToString().ToLower()); args.Set("startdt", startDate.ToString("yyyy-MM-dd")); args.Set("enddt", endDate.ToString("yyyy-MM-dd")); return(CallService(args, x => (AstronomyLocation)x)); }
public BusinessDuration GetDuration(DateTime startDate, DateTime endDate, LocationId placeId) { if (endDate.CompareTo(startDate) < 0) { throw new ArgumentException("End Date cannot be earlier than Start Date"); } var args = GetArguments(startDate, endDate); args.Set("placeid", placeId.GetIdAsString()); return(CallService <BusinessDuration>(args)); }
private BusinessDates CommonCallService(string op, DateTime startDate, int[] days, LocationId placeId) { if (days.Length > 1 && Repeat > 0) { throw new ArgumentException("Cannot set Repeat when querying for more than 1 day"); } var args = GetArguments(op, startDate, days); args.Set("placeid", placeId.GetIdAsString()); return(CallService <BusinessDates>(args)); }
/// <summary> /// Retrieves the current time for place by ID. /// </summary> /// <returns> /// The current time for place. /// </returns> /// <param name='placeId'> /// Place identifier. /// </param> public IList <Location> CurrentTimeForPlace(LocationId placeId) { if (placeId == null) { throw new ArgumentException("A required argument is null or empty"); } var id = placeId.GetIdAsString(); if (string.IsNullOrEmpty(id)) { throw new ArgumentException("A required argument is null or empty"); } var args = GetArguments(id); return(CallService(args, x => (Location)x)); }
/// <summary> /// Gets the dial code for the location you want to call /// </summary> /// <returns> /// The dial code. /// </returns> /// <param name='toLocation'> /// To location. /// </param> public DialCodes GetDialCode(LocationId toLocation) { if (toLocation == null) { throw new ArgumentException("A required argument is null or empty"); } var id = toLocation.GetIdAsString(); if (string.IsNullOrEmpty(id)) { throw new ArgumentException("A required argument is null or empty"); } var opts = GetOptionalArguments(); opts.Set("toid", id); return(RetrieveDialCode(opts)); }
/// <summary> /// Gets the dial code for the location you want to call, from where /// </summary> /// <returns> /// The dial code. /// </returns> /// <param name='toLocation'> /// To location. /// </param> /// <param name='fromLocation'> /// From location. /// </param> public DialCodes GetDialCode(LocationId toLocation, LocationId fromLocation) { if (toLocation == null || fromLocation == null) { throw new ArgumentException("A required argument is null or empty"); } var toId = toLocation.GetIdAsString(); var fromId = fromLocation.GetIdAsString(); if (string.IsNullOrEmpty(toId) || string.IsNullOrEmpty(fromId)) { throw new ArgumentException("A required argument is null or empty"); } var opts = GetOptionalArguments(); opts.Set("toid", toId); opts.Set("fromid", fromId); return(RetrieveDialCode(opts)); }