Advertisement
Guest User

Untitled

a guest
Oct 9th, 2012
329
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 5.22 KB | None | 0 0
  1.  
  2.     [ServiceContract]
  3.     public interface IPublic
  4.     {
  5.  
  6.         #region GET
  7.  
  8.         /// <summary>
  9.         /// test
  10.         /// <para>appKey</para>
  11.         /// </summary>
  12.         /// <returns></returns>
  13.         [OperationContract]
  14.         [WebInvoke(Method = "GET", BodyStyle=WebMessageBodyStyle.Wrapped, UriTemplate = "GetOperators?appKey={apk}",
  15.             RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
  16.         ResultList GetOperators(string apk);
  17.  
  18.  
  19.  
  20.         /// <summary>
  21.         /// Get a list of all the stop names for a specific operator
  22.         /// </summary>
  23.         /// <param name=appKey>api access key</param>
  24.         /// <param name=op>operator name</param>
  25.         /// <returns>ResultList object</returns>
  26.         [OperationContract]
  27.         [WebInvoke(Method = "GET", BodyStyle = WebMessageBodyStyle.Wrapped, UriTemplate = "GetStopNames?appKey={apk}&op={op}"
  28.             ,RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
  29.         ResultList GetStopNames(string apk,string op);
  30.  
  31.  
  32.  
  33.  
  34.  
  35.         /// <summary>
  36.         /// Get the best route to take from one location to another,
  37.         /// using a specific operator.
  38.         /// </summary>
  39.         /// <param name=appKey>api access key</param>
  40.         /// <param name=op>operator name</param>
  41.         /// <returns>ScheduleResult object</returns>
  42.         [OperationContract]
  43.         [WebInvoke(Method = "GET", BodyStyle = WebMessageBodyStyle.Wrapped, UriTemplate = "GetSchedule?appKey={apk}&op={op}&loc={loc}&dest={dest}&date={date}&time={time}",
  44.               RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
  45.         ScheduleResult GetSchedule(string apk, string op, string loc, string dest, string date, string time);
  46.  
  47.  
  48.         #endregion
  49.  
  50.         #region POST
  51.  
  52.  
  53.         [OperationContract]
  54.         [WebInvoke(Method = "POST", UriTemplate = "OperatorFeedback",
  55.         RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
  56.         ResultList OperatorFeedback();
  57.  
  58.  
  59.         #endregion
  60.     }
  61.  
  62.     /// <summary>
  63.     /// Most basic DataContract, contains an array of strings and a status message
  64.     /// </summary>
  65.     [DataContract]
  66.     public class ResultList
  67.     {
  68.  
  69.         [DataMember]
  70.         public string Status = "No Data";
  71.  
  72.         [DataMember]
  73.         public string Error = "";
  74.  
  75.         [DataMember]
  76.         public string [] Results { get; set; }
  77.  
  78.         public ResultList(string [] result, string status, string error)
  79.         {
  80.             Results = result;
  81.             Status = status;
  82.             Error = error;
  83.         }
  84.     }
  85.  
  86.     /// <summary>
  87.     /// Represent the result of a routing query
  88.     /// </summary>
  89.     [DataContract]
  90.     public class ScheduleResult
  91.     {
  92.         /// <summary>
  93.         /// Status of the result.
  94.         /// Can be "SUCCESS", "ERROR" or "EMPTY"
  95.         /// </summary>
  96.         [DataMember]
  97.         public string Status = "No Data";
  98.  
  99.         /// <summary>
  100.         /// Any extra details regarding errors go here
  101.         /// </summary>
  102.         [DataMember]
  103.         public string Error = "";
  104.  
  105.         /// <summary>
  106.         /// Total cost to travel this route.
  107.         /// </summary>
  108.         [DataMember]
  109.         public string Cost;
  110.  
  111.         /// <summary>
  112.         /// Time from now until the first route starts.
  113.         /// </summary>
  114.         [DataMember]
  115.         public string StartingTime;
  116.  
  117.         /// <summary>
  118.         /// Array of SchedItems, containing the actual route information.
  119.         /// </summary>
  120.         [DataMember]
  121.         public SchedItem[] Path;
  122.  
  123.     }
  124.  
  125.     /// <summary>
  126.     /// A single segment of a route
  127.     /// </summary>
  128.     [DataContract]
  129.     public class SchedItem
  130.     {
  131.         [DataMember]
  132.         public SchedStop Stop;
  133.         [DataMember]
  134.         public string Time;
  135.         [DataMember]
  136.         public string Direction;
  137.         [DataMember]
  138.         public string Operator;
  139.         [DataMember]
  140.         public string Type;
  141.         [DataMember]
  142.         public string RouteName;
  143.         [DataMember]
  144.         public string RouteColor;
  145.         [DataMember]
  146.         public string Vehicle;
  147.  
  148.     }
  149.     /// <summary>
  150.     /// Information regarding a stop
  151.     /// </summary>
  152.     [DataContract]
  153.     public class SchedStop
  154.     {
  155.         [DataMember]
  156.         public string Name;
  157.         [DataMember]
  158.         public SchedLocation Location;
  159.     }
  160.  
  161.     /// <summary>
  162.     /// A location with latitude and longitude
  163.     /// </summary>
  164.     [DataContract]
  165.     public class SchedLocation
  166.     {
  167.         [DataMember]
  168.         public float latitude;
  169.         [DataMember]
  170.         public float longitude;
  171.     }
  172.  
  173.     /// <summary>
  174.     /// A list of stops with names and locations.
  175.     /// </summary>
  176.     [DataContract]
  177.     public class SchedStopList
  178.     {
  179.         [DataMember]
  180.         public string Status = "No Data";
  181.  
  182.         [DataMember]
  183.         public string Error = "";
  184.  
  185.         [DataMember]
  186.         public SchedStop[] Stops;
  187.  
  188.          public SchedStopList(int length, string status, string err)
  189.         {
  190.             Stops = new SchedStop[length];
  191.             Status = status;
  192.             Error = err;
  193.         }
  194.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement