API

CBSEventsModule.GetEvents - Get list of cbs event by active state or category

using CBS;
using CBS.Models;
using UnityEngine;
public class EventsExample : MonoBehaviour
{
    private IEventsModule CBSEvents { get; set; }

    private void Start()
    {
        CBSEvents = CBSModule.Get<CBSEventsModule>();

        var request = new CBSGetEventsRequest
        {
            ActiveOnly = true,
            ByCategory = "you events category" // leave empty if you want ot load all events
        };
        CBSEvents.GetEvents(request, OnGet);
    }

    private void OnGet(CBSGetEventsResult result)
    {
        if (result.IsSuccess)
        {
            var events = result.Events;
            foreach (var myEvent in events)
            {
                var id = myEvent.ID;
                var instanceID = myEvent.InstanceID;
                var displayNAme = myEvent.DisplayName;
                var description = myEvent.Description;
                var cron = myEvent.CronExpression;
                var category = myEvent.Category;
                var isRunning = myEvent.IsRunning;
                var lastRunTime = myEvent.LastRunTime;
                var nextRunTime = myEvent.NextRunTime;
                var startDate = myEvent.StartDate;
                var endDate = myEvent.EndDate;

                var customData = myEvent.GetCustomData<CBSEventsCustomData>();
            }
        }
    }
}

CBSEventsModule.GetEventByID - Get detail information about cbs event by id

using CBS;
using CBS.Models;
using UnityEngine;
public class EventsExample : MonoBehaviour
{
    private IEventsModule CBSEvents { get; set; }

    private void Start()
    {
        CBSEvents = CBSModule.Get<CBSEventsModule>();

        var eventID = "your event id";
        CBSEvents.GetEventByID(eventID, OnGet);
    }

    private void OnGet(CBSGetEventResult result)
    {
        if (result.IsSuccess)
        {
            var myEvent = result.Event;
            
            var id = myEvent.ID;
            var instanceID = myEvent.InstanceID;
            var displayNAme = myEvent.DisplayName;
            var description = myEvent.Description;
            var cron = myEvent.CronExpression;
            var category = myEvent.Category;
            var isRunning = myEvent.IsRunning;
            var lastRunTime = myEvent.LastRunTime;
            var nextRunTime = myEvent.NextRunTime;
            var startDate = myEvent.StartDate;
            var endDate = myEvent.EndDate;

            var customData = myEvent.GetCustomData<CBSEventsCustomData>();
        }
    }
}

CBSEventsModule.GetEventsBadge - Get number of active events. If category is null - get badge of all events

using CBS;
using CBS.Models;
using UnityEngine;
public class EventsExample : MonoBehaviour
{
    private IEventsModule CBSEvents { get; set; }

    private void Start()
    {
        CBSEvents = CBSModule.Get<CBSEventsModule>();

        var category = "your events category";
        CBSEvents.GetEventsBadge(category, OnGet);
    }

    private void OnGet(CBSBadgeResult result)
    {
        if (result.IsSuccess)
        {
            var badgeCount = result.Count;
        }
    }
}

Last updated