📦 SDK

If your language of choice is C#, then the following SDK will run on NET Framework (>=4.8), Mono platforms or .NET Standard.

Download SDK (version 1.2024.0408.7735)

Here is a quick example of how to authenticate and request the list of bookings.

var username = "[email protected]";
var password = "YourPassword1234";
if (Auth.IsValidAuth(username, password))
{
    var bookings = Bookings.List();
    var booking = Bookings.Get(bookings.Records[0].Id);

    Console.Write(booking.Resource.Name);
}

If you are running in the context of a Web Request, you can actually use the SDK to generate the authentication token for you. Here is an example:

//Try to validate the request
var secret = "Your Application Key";

//Validate the request and create the auth token
var validRequest = Auth.Authenticate(secret);

//If we could not validate the request, redirect to Nexudus spaces auth URL.
if(!validRequest)
  return Redirect("Url To Login Page");

var appKey = Auth.GetAppKey();
var password = Auth.GetPassword();
var username = string.Format("{0}:{1}", appKey, password);

//Keep the auth token in the Forms Authentication Cookie for future requests
FormsAuthentication.SetAuthCookie(username, false);

return RedirectToAction("Url to your App Home Page");

The SDK has the following general namespaces inside the root namespace: "Nexudus.Coworking.API.Connector"

Nexudus.Coworking.API.Connector.Model
Contains classes representing each of the API record types. You will find a namespace for each of the API paths available (sys, security, community, billing, crm, content, spaces and support). The namespace always matches the path for those endpoints in the API. For example, if the api endpoint is /api/spaces/coworkers, you will find the data model for that record type in Nexudus.Coworking.API.Connector.Model.Spaces.Coworker

Nexudus.Coworking.API.Connector.Data
Contains classes to help you operate with API records such as list them, search for records, create, update, delete and run commands affecting those records. You will find a namespace for each of the API paths available (sys, security, community, billing, crm, content, spaces and support). The namespace always matches the path for those endpoints in the API. For example, if the api endpoint is /api/spaces/coworkers, you will find the data model for that record type in Nexudus.Coworking.API.Connector.Data.Spaces.Coworkers (note class names in the Data namespace are in plurarl)

In general, this classes contain the following methods

  • Create: creates a single record.
  • Update: updates a single record
  • List: lists or searches a set of records
  • Get: gets a single record
  • RunAction: runs a command for one or more record

Nexudus.Coworking.API.Connector.Extensions
These are static classes providing extensions methods to the Model classes. This are helpful to fetch related records based on a parent record.

For example, if you have a CoworkerContract record class you obtained from Nexudus.Coworking.API.Connector.Data.Billing.CoworkerContracts.Get(id) you can then easily use the CoworkerContractExtensions class extension methods to get the Coworker related to that contract like this.

using Nexudus.Coworking.API.Connector;
using Nexudus.Coworking.API.Connector.Data.Billing;
using Nexudus.Coworking.API.Connector.Extensions.Billing;

namespace SDKCore.Test
{
    class Program
    {
        static void Main(string[] args)
        {
            Auth.IsValidAuth("[email protected]", "password");
            var contract = CoworkerContracts.Get(123456); // Get a single contract.
            var coworker = contract.GetCoworker(); // Using extension method to get the customer 
        }
    }
}