public IList <Trip> GetRangeForDrivers(List <long> driverIds, DateTime from, DateTime to, bool includeSubTrips = false)
        {
            IHttpRestRequest request = GetRequest(APIControllerRoutes.TripsController.GETRANGEFORDRIVERS, HttpMethod.Post);

            request.AddUrlSegment("from", from.ToString(DataFormats.DateTime_Format));
            request.AddUrlSegment("to", to.ToString(DataFormats.DateTime_Format));
            request.AddQueryParameter("includeSubTrips", includeSubTrips.ToString());
            request.AddJsonBody(driverIds);
            IHttpRestResponse <List <Trip> > response = Execute <List <Trip> >(request);

            return(response.Data);
        }
        public async Task <IList <Trip> > GetRangeForAssetsAsync(List <long> assetIds, DateTime from, DateTime to, bool includeSubTrips = false)
        {
            IHttpRestRequest request = GetRequest(APIControllerRoutes.TripsController.GETRANGEFORASSETS, HttpMethod.Post);

            request.AddUrlSegment("from", from.ToString(DataFormats.DateTime_Format));
            request.AddUrlSegment("to", to.ToString(DataFormats.DateTime_Format));
            request.AddQueryParameter("includeSubTrips", includeSubTrips.ToString());
            request.AddJsonBody(assetIds);
            IHttpRestResponse <List <Trip> > response = await ExecuteAsync <List <Trip> >(request).ConfigureAwait(false);

            return(response.Data);
        }
Exemplo n.º 3
0
        public async Task <List <Position> > GetLatestByGroupIdsAsync(List <long> groupIds, byte quantity, DateTime?cachedSince = null)
        {
            IHttpRestRequest request = GetRequest(APIControllerRoutes.PositionsController.GETLATESTFORGROUPS, HttpMethod.Post);

            request.AddUrlSegment("quantity", quantity.ToString());
            if (cachedSince.HasValue)
            {
                request.AddQueryParameter("cachedSince", cachedSince.Value.ToUniversalTime().ToString(DataFormats.DateTime_Format));
            }
            request.AddJsonBody(groupIds);
            IHttpRestResponse <List <Position> > response = await ExecuteAsync <List <Position> >(request).ConfigureAwait(false);

            return(response.Data);
        }
Exemplo n.º 4
0
        public List <Position> GetLatestByAssetIds(List <long> assetIds, byte quantity, DateTime?cachedSince = null)
        {
            IHttpRestRequest request = GetRequest(APIControllerRoutes.PositionsController.GETLATESTFORASSETS, HttpMethod.Post);

            request.AddUrlSegment("quantity", quantity.ToString());
            if (cachedSince.HasValue)
            {
                request.AddQueryParameter("cachedSince", cachedSince.Value.ToUniversalTime().ToString(DataFormats.DateTime_Format));
            }
            request.AddJsonBody(assetIds);
            IHttpRestResponse <List <Position> > response = Execute <List <Position> >(request);

            return(response.Data);
        }
        public async Task <long> SendDisarmUnitMessageAsync(long groupId, long assetId, MessageTransport?preferredTransport = null)
        {
            IHttpRestRequest request = GetRequest(APIControllerRoutes.DeviceCommandsController.SENDDISARMUNITMESSAGE, HttpMethod.Get);

            request.AddUrlSegment("groupId", groupId.ToString());
            request.AddUrlSegment("assetId", assetId.ToString());
            if (preferredTransport.HasValue)
            {
                request.AddQueryParameter("preferredTransport", preferredTransport.ToString());
            }
            IHttpRestResponse <long> response = await ExecuteAsync <long>(request).ConfigureAwait(false);

            return(response.Data);
        }
        public long SendStopTrackingRequest(long groupId, long assetId, MessageTransport?preferredTransport = null)
        {
            IHttpRestRequest request = GetRequest(APIControllerRoutes.DeviceCommandsController.SENDSTOPTRACKINGREQUEST, HttpMethod.Get);

            request.AddUrlSegment("groupId", groupId.ToString());
            request.AddUrlSegment("assetId", assetId.ToString());
            if (preferredTransport.HasValue)
            {
                request.AddQueryParameter("preferredTransport", preferredTransport.ToString());
            }
            IHttpRestResponse <long> response = Execute <long>(request);

            return(response.Data);
        }
        public async Task <long> SendProgressiveShutdownCommandAsync(long groupId, long assetId, uint relayDrive, MessageTransport?preferredTransport = null)
        {
            IHttpRestRequest request = GetRequest(APIControllerRoutes.DeviceCommandsController.SENDPROGRESSIVESHUTDOWNCOMMAND, HttpMethod.Get);

            request.AddUrlSegment("groupId", groupId.ToString());
            request.AddUrlSegment("assetId", assetId.ToString());
            request.AddUrlSegment("relayDrive", relayDrive.ToString());
            if (preferredTransport.HasValue)
            {
                request.AddQueryParameter("preferredTransport", preferredTransport.ToString());
            }
            IHttpRestResponse <long> response = await ExecuteAsync <long>(request).ConfigureAwait(false);

            return(response.Data);
        }
        public long SendFreeTextMessage(string message, long groupId, long assetId, MessageTransport?preferredTransport = null)
        {
            IHttpRestRequest request = GetRequest(APIControllerRoutes.DeviceCommandsController.SENDFREETEXTMESSAGE, HttpMethod.Post);

            request.AddUrlSegment("groupId", groupId.ToString());
            request.AddUrlSegment("assetId", assetId.ToString());
            if (preferredTransport.HasValue)
            {
                request.AddQueryParameter("preferredTransport", preferredTransport.ToString());
            }
            request.AddJsonBody(message);
            IHttpRestResponse <long> response = Execute <long>(request);

            return(response.Data);
        }
        public async Task <long> SendTrackingRequestAsync(long groupId, long assetId, uint intervalSeconds, uint durationSeconds, MessageTransport?preferredTransport = null)
        {
            IHttpRestRequest request = GetRequest(APIControllerRoutes.DeviceCommandsController.SENDTRACKINGREQUEST, HttpMethod.Get);

            request.AddUrlSegment("groupId", groupId.ToString());
            request.AddUrlSegment("assetId", assetId.ToString());
            request.AddUrlSegment("intervalSeconds", intervalSeconds.ToString());
            request.AddUrlSegment("durationSeconds", durationSeconds.ToString());
            if (preferredTransport.HasValue)
            {
                request.AddQueryParameter("preferredTransport", preferredTransport.ToString());
            }
            IHttpRestResponse <long> response = await ExecuteAsync <long>(request).ConfigureAwait(false);

            return(response.Data);
        }
        public long SendRelayCommand(long groupId, long assetId, uint relayDrive, uint relayState, MessageTransport?preferredTransport = null)
        {
            IHttpRestRequest request = GetRequest(APIControllerRoutes.DeviceCommandsController.SENDRELAYCOMMAND, HttpMethod.Get);

            request.AddUrlSegment("groupId", groupId.ToString());
            request.AddUrlSegment("assetId", assetId.ToString());
            request.AddUrlSegment("relayDrive", relayDrive.ToString());
            request.AddUrlSegment("relayState", relayState.ToString());
            if (preferredTransport.HasValue)
            {
                request.AddQueryParameter("preferredTransport", preferredTransport.ToString());
            }
            IHttpRestResponse <long> response = Execute <long>(request);

            return(response.Data);
        }
        public long SendSetAcronymCommand(long groupId, long assetId, uint?param1 = null, uint?param2 = null, uint?param3 = null, MessageTransport?preferredTransport = null)
        {
            IHttpRestRequest request = GetRequest(APIControllerRoutes.DeviceCommandsController.SENDSETACRONYMCOMMAND, HttpMethod.Get);

            request.AddUrlSegment("groupId", groupId.ToString());
            request.AddUrlSegment("assetId", assetId.ToString());
            request.AddUrlSegment("param1", param1.HasValue ? param1.Value.ToString() : "0");
            request.AddUrlSegment("param2", param2.HasValue ? param2.Value.ToString() : "0");
            request.AddUrlSegment("param3", param3.HasValue ? param3.Value.ToString() : "0");
            if (preferredTransport.HasValue)
            {
                request.AddQueryParameter("preferredTransport", preferredTransport.ToString());
            }
            IHttpRestResponse <long> response = Execute <long>(request);

            return(response.Data);
        }
        public async Task <IList <Event> > GetLatestForDriversAsync(List <long> driverIds, byte quantity = 1, DateTime?cachedSince = null, List <long> eventTypeIds = null, string menuId = null)
        {
            EventFilter eventFilter = new EventFilter()
            {
                EntityIds = driverIds, EventTypeIds = eventTypeIds, MenuId = menuId
            };
            IHttpRestRequest request = GetRequest(APIControllerRoutes.EventsController.GETLATESTFORDRIVERS, HttpMethod.Post);

            request.AddUrlSegment("quantity", quantity.ToString());
            if (cachedSince.HasValue)
            {
                request.AddQueryParameter("cachedSince", cachedSince.Value.ToUniversalTime().ToString(DataFormats.DateTime_Format));
            }
            request.AddJsonBody(eventFilter);
            IHttpRestResponse <List <Event> > response = await ExecuteAsync <List <Event> >(request).ConfigureAwait(false);

            return(response.Data);
        }
        public IList <Event> GetLatestForAssets(List <long> assetIds, byte quantity = 1, DateTime?cachedSince = null, List <long> eventTypeIds = null, string menuId = null)
        {
            EventFilter eventFilter = new EventFilter()
            {
                EntityIds = assetIds, EventTypeIds = eventTypeIds, MenuId = menuId
            };
            IHttpRestRequest request = GetRequest(APIControllerRoutes.EventsController.GETLATESTFORASSETS, HttpMethod.Post);

            request.AddUrlSegment("quantity", quantity.ToString());
            if (cachedSince.HasValue)
            {
                request.AddQueryParameter("cachedSince", cachedSince.Value.ToUniversalTime().ToString(DataFormats.DateTime_Format));
            }
            request.AddJsonBody(eventFilter);
            IHttpRestResponse <List <Event> > response = Execute <List <Event> >(request);

            return(response.Data);
        }
        public CreatedSinceResult <Trip> GetCreatedSinceForDrivers(List <long> driverIds, string sinceToken, int quantity, bool includeSubTrips = false)
        {
            IHttpRestRequest request = GetRequest(APIControllerRoutes.TripsController.GETCREATEDSINCEFORDRIVERSASYNC, HttpMethod.Post);

            request.AddUrlSegment("sinceToken", sinceToken);
            request.AddUrlSegment("quantity", quantity.ToString());
            request.AddQueryParameter("includeSubTrips", includeSubTrips.ToString());
            request.AddJsonBody(driverIds);
            IHttpRestResponse <List <Trip> > response = Execute <List <Trip> >(request);
            string sHasMoreItems = GetResponseHeader(response.Headers, "HasMoreItems");
            string getSinceToken = GetResponseHeader(response.Headers, "GetSinceToken");
            bool   hasMoreItems  = false;

            if (!bool.TryParse(sHasMoreItems, out hasMoreItems))
            {
                throw new Exception("Could not read the HasMoreItems header");
            }
            return(new CreatedSinceResult <Trip>()
            {
                HasMoreItems = hasMoreItems, GetSinceToken = getSinceToken, Items = response.Data
            });
        }
Exemplo n.º 15
0
        public async Task <CreatedSinceResult <Trip> > GetCreatedSinceForOrganisationAsync(long organisationId, string sinceToken, int quantity, bool includeSubTrips = false)
        {
            IHttpRestRequest request = GetRequest(APIControllerRoutes.TripsController.GETCREATEDSINCEFORORGANISATION, HttpMethod.Get);

            request.AddUrlSegment("organisationId", organisationId.ToString());
            request.AddUrlSegment("sinceToken", sinceToken);
            request.AddUrlSegment("quantity", quantity.ToString());
            request.AddQueryParameter("includeSubTrips", includeSubTrips.ToString());
            IHttpRestResponse <List <Trip> > response = await ExecuteAsync <List <Trip> >(request).ConfigureAwait(false);

            string sHasMoreItems = GetResponseHeader(response.Headers, "HasMoreItems");
            string getSinceToken = GetResponseHeader(response.Headers, "GetSinceToken");
            bool   hasMoreItems  = false;

            if (!bool.TryParse(sHasMoreItems, out hasMoreItems))
            {
                throw new Exception("Could not read the HasMoreItems header");
            }
            return(new CreatedSinceResult <Trip>()
            {
                HasMoreItems = hasMoreItems, GetSinceToken = getSinceToken, Items = response.Data
            });
        }
        public async Task <CreatedSinceResult <Trip> > GetCreatedSinceForGroupsAsync(List <long> groupIds, string entityType, string sinceToken, int quantity, bool includeSubTrips = false)
        {
            IHttpRestRequest request = GetRequest(APIControllerRoutes.TripsController.GETCREATEDSINCEFORGROUPSASYNC, HttpMethod.Post);

            request.AddUrlSegment("entityType", entityType);
            request.AddUrlSegment("sinceToken", sinceToken);
            request.AddUrlSegment("quantity", quantity.ToString());
            request.AddQueryParameter("includeSubTrips", includeSubTrips.ToString());
            request.AddJsonBody(groupIds);
            IHttpRestResponse <List <Trip> > response = await ExecuteAsync <List <Trip> >(request).ConfigureAwait(false);

            string sHasMoreItems = GetResponseHeader(response.Headers, "HasMoreItems");
            string getSinceToken = GetResponseHeader(response.Headers, "GetSinceToken");
            bool   hasMoreItems  = false;

            if (!bool.TryParse(sHasMoreItems, out hasMoreItems))
            {
                throw new Exception("Could not read the HasMoreItems header");
            }
            return(new CreatedSinceResult <Trip>()
            {
                HasMoreItems = hasMoreItems, GetSinceToken = getSinceToken, Items = response.Data
            });
        }