Skip to content

Developers' Guide

Neil O'Keeffe edited this page Jun 27, 2022 · 5 revisions

Developers' Guide

Introduction

This page outlines how the API may be used in your code.

Web Methods

The API has the following Web request classes:

  • JSONRPC
  • RESTFUL
  • STATIC
  • HEAD

Each of these classes has its own request and response classes. The request and response classes are abstracted to an IRequest and IResponse interface. However, you are free to choose whether to use the abstract or concrete classes.

Exposing your code to the web

Any public method in your code will be available to the API and therefore to any external user. Therefore it is important that you do not inadvertently expose sensitive methods to users. Up until version 5.0.0 this was done by ensuring that only the exposed classes and methods can be declared as public. Everything else had to be declared as, at most, external. From 5.0.0, public methods are no longer visible to the API by default. If you want your class to be visible to the API then you MUST now decorate any exposed classes with the AllowAPICall attribute. For example, the first piece of code shown below is not visible to the API. The second class is visible:

    
    public class CanNotBeCalled
    {
        public static dynamic Read()
        {
            return "something";
        }
    }

    [AllowAPICall]
    public class CanBeCalled
    {
        public static dynamic Read()
        {
            return "something";
        }
    }

IRequest Interface

The API will pass a request to your application. If you wish to remain flexible as to whether the request is JSONRPC, RESTful or STATIC, you may set the input parameter as IRequest and deal with the differences in your code. However you may also simply request a concrete version of the request.

IResponse Interface

Each version of the Request will have a corresponding Response version. Ensure you use the corresponding response type when returning control back to the API.