Giter Site home page Giter Site logo

jcronofy's Introduction

CI Status

Build Status SonarCube

jcronofy

Java implementation of Cronofy API

How to use

Installation

First of all, you need any implementation of javax.ws.rs.client.Client For example you can use jersey client

Add the following dependency to your maven pom.xml file

<dependency>
    <groupId>org.glassfish.jersey.core</groupId>
    <artifactId>jersey-client</artifactId>
    <version>${jersey.client.version}</version>
</dependency>

Then you need pass client implementation to CronofyClient as constructor param.

Example to construct client implementation in spring framework.

In application context XML add the following XML definition

<bean id="cronofyJerseyClientBuilder"
          class="com.sfl.cronofy.api.configuration.impl.CronofyJerseyClientBuilderImpl"/>

<bean id="cronofyJerseyClient" factory-bean="cronofyJerseyClientBuilder" factory-method="build"/>

<bean id="cronofyClient" class="com.sfl.cronofy.api.client.impl.CronofyClientImpl">
    <constructor-arg name="client" ref="cronofyJerseyClient"/>
</bean>

If you simply need to test cronofy API.

Then construct jersey client as follows

package my.application;

import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
import com.sfl.cronofy.api.client.CronofyClient;
import com.sfl.cronofy.api.client.impl.CronofyClientImpl;
import com.sfl.cronofy.api.model.common.CronofyResponse;
import com.sfl.cronofy.api.model.request.ListCalendarsRequest;
import com.sfl.cronofy.api.model.response.ListCalendarsResponse;

import javax.ws.rs.client.ClientBuilder;

public class MainApplication {
    public static void main(String[] args) {
        // Construct cronofy java client
        final CronofyClient cronofyClient = new CronofyClientImpl(ClientBuilder.newBuilder().register(JacksonJsonProvider.class).build());
        // List calendars
        final CronofyResponse<ListCalendarsResponse> calendarsResult = cronofyClient.listCalendars(new ListCalendarsRequest("your access token here"));
        System.out.println(calendarsResult.getResponse().toString());
        // Read events
        final CronofyResponse<ReadEventsResponse> eventsResult = cronofyClient.readEvents(new ReadEventsRequest("your access token here", "Etc/UTC"));
        // If an error occur
        if (eventsResult.hasError()) {
            System.out.println(eventsResult.getError().toString());
        } else {
            System.out.println(eventsResult.getResponse().toString());
        }
    }
}

You can find test access token in Cronofy Calendar Sendbox

jcronofy's People

Contributors

biacode avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.