System-to-Mobile API

S2M gateway is a communication gateway with RESTful interface. It offers an interface for mobile devices or applications.

Supported operations

POST addQuestionForm
appends a new question form

You can develop a client application in any programming language, just generate the REST client from WADL descriptor in your favorite IDE. If you are using Java, there is another (and more comfortable) way.

First, include our module in your Maven's pom.xml configuration:

<dependencies>
    ...
    <dependency>
        <groupId>cythres</groupId>
        <artifactId>sensnet-cli</artifactId>
        <version>0.9.5-SNAPSHOT</version>
    </dependency>
    ...
</dependencies>

Second, use cythres.sensnet.cli.RestClient class to access the API:

// prepare the data object
QuestionFormMobi qf = new QuestionFormMobi();

qf.setGpsX(48.4);
qf.setGpsY(33.2);
qf.setIdUnit("0000000000002");
qf.setNote("CLI test");
qf.setReadAt(Calendar.getInstance().getTimeInMillis());
qf.setReceivedAt(Calendar.getInstance().getTimeInMillis());

ArrayList<QuestionMobi> questions = new ArrayList<>();

for (String code : new String[]{"1", "2", "11", "12", "13", "14", "21", "22"}) {
    QuestionMobi q = new QuestionMobi();
    q.setQuestionCode(code);
    q.setChecked(false);

    if (code.endsWith("2")) {
        ImageMobi im = new ImageMobi();
        im.setMimetype("image/jpeg-version-" + code);
        im.setFilesize(1234);
        im.setContent("dummy image content just for tests".getBytes(Charset.forName("UTF-8")));
        q.setImage(im);
    }

    questions.add(q);
}

qf.setQuestionCollection(questions);

// do the job
try (RestClient client = new RestClient("https://sensnet.cythres.cz/sn/rest")) {
    LoginSessionNoJpa session;

    // login - the user must have "android" role
    session = client.login("arnold@cythres.cz", "arnold@cythres.cz", "Java client");

    // post a single form
    client.addQuestionForm(session, qf);

    // post another form or execute other operations as requested
    // ...
}