/// <summary> /// Insert a new gateway named "TEST: C#-api-gateway-insert" /// </summary> /// <param name="parkingLotId">The Id of the parking lot inserted earlier</param> /// <returns>New gateway's Id</returns> private static async Task <string> InsertGateway(string parkingLotId) { Console.WriteLine("Testing '/api/gateway/insert'"); const string gatewayName = "TEST: C#-api-gateway-insert"; // Sample JSON to send JObject json = new JObject { ["gatewayMac"] = "cdef78904321dcb0", ["gatewayName"] = gatewayName, ["parkingLotId"] = parkingLotId }; await GatewayApi.InsertGateway(json.ToString()); Console.WriteLine("Gateway Insert Success"); // Get the gateway Id of the inserted gateway List <Gateway> gateways = await GatewayApi.GetGateways(); string gatewayId = null; foreach (Gateway gateway in gateways) { if (gateway.Name == gatewayName) { gatewayId = gateway.Id; break; } } Console.WriteLine("ID of inserted gateway: " + gatewayId + "\n"); return(gatewayId); }
/// <summary> /// Fetch all of the gateways and print them out /// </summary> private static async Task GetGateways() { Console.WriteLine("Testing '/api/gateways'"); List <Gateway> gateways = await GatewayApi.GetGateways(); Console.WriteLine("Got " + gateways.Count + " Gateways:"); foreach (Gateway gateway in gateways) { Console.WriteLine("--> " + gateway.GatewayMac + ": " + gateway.Name); } Console.WriteLine(); }