public TideInformation ParseTide(int year, int month, int day, string time, string height, int tideNumerThatDay) { if (string.IsNullOrWhiteSpace(time)) return null; var tideInfo = new TideInformation(); tideInfo.TideOccurence = GetTideTime(year, month, day, time); tideInfo.HeightMeters = double.Parse(height); tideInfo.TideNumberThisDay = tideNumerThatDay; return tideInfo; }
public string GetTideNotification(TideInformation tideInfo) { var notificationTitle = string.Format("tide-auckland-{0}-{1}", tideInfo.TideOccurence.ToString("yyyyMMdd"), tideInfo.TideNumberThisDay); var curlString = string.Format( "curl -X PUT https://timeline-api.getpebble.com/v1/shared/pins/{0} --header 'Content-Type: application/json' --header 'X-API-Key: {1}' --header 'X-Pin-Topics: auckland'", notificationTitle, _apiKey); curlString = curlString + " -d '{\"id\": \"" + notificationTitle + "\",\"time\": \"" + tideInfo.TideOccurence.ToString("yyyy-MM-ddTHH:mm:ss+12:00") + "\",\"layout\": {\"type\": \"genericPin\",\"title\": \"" + tideInfo.Type + " Tide (" + tideInfo.HeightMeters + "m)\",\"tinyIcon\": \"system://images/NOTIFICATION_FLAG\"}}'"; return curlString; }
public void CanGetCurlString() { var tideinfo = new TideInformation() { Type = "Low", HeightMeters = 1.2, TideOccurence = new DateTime(2015,09,05,1,45,00), TideNumberThisDay = 1 }; var notificationFactory = new PebbleTimeTideNotificationFactory("testKey"); var opstring = notificationFactory.GetTideNotification(tideinfo); Assert.That(opstring, Is.Not.Null); }