Giter Club home page Giter Club logo

jcronofy's Introduction

CI Status

Build Status SonarCube

jcronofy

Java implementation of Cronofy API

How to use

Installation

Maven

<dependency>
    <groupId>org.biacode.jcronofy</groupId>
    <artifactId>jcronofy</artifactId>
    <version>1.0.0</version>
</dependency>

Gradle

compile 'org.biacode.jcronofy:jcronofy:1.0.0'

Getting started

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="org.biacode.jcronofy.api.configuration.impl.CronofyJerseyClientBuilderImpl"/>

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

<bean id="cronofyClient" class="org.biacode.jcronofy.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 org.biacode.jcronofy.api.client.CronofyClient;
import org.biacode.jcronofy.api.client.impl.CronofyClientImpl;
import org.biacode.jcronofy.api.model.common.CronofyResponse;
import org.biacode.jcronofy.api.model.request.ListCalendarsRequest;
import org.biacode.jcronofy.api.model.response.ListCalendarsResponse;

import javax.ws.rs.client.ClientBuilder;

public class MainApplication {
    public static void main(final 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 gshutler avatar

Watchers

Syuzanna Eprikyan 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.