GitXplorerGitXplorer
g

citymapper-api-java

public
0 stars
0 forks
7 issues

Commits

List of commits on branch master.
Unverified
e874fadd4077b224c9777c7237d106bee8f086c5

Fix version

committed 9 years ago
Unverified
f0e9ba591cdaafbaf7db6eb20078d2c770e2a1db

Add single coverage api and multiple point coverage api

committed 9 years ago
Unverified
999c8828ac335730022a41e5ddedab6d51460cfc

README updates

committed 9 years ago
Unverified
b60a917903bfc133b888113c2e54b4c0b0ded60d

README updates

committed 9 years ago
Unverified
d4e1b7a991b7237687c55806cda1c125d7d75ce6

README updates

committed 9 years ago
Unverified
a9d6aa2f60ffa590fc0a13c251344a8dc3fee0da

README updates

committed 9 years ago

README

The README file for this repository.

Citymapper Java API Wrapper

This Java module allows you to quickly connect the the Citymapper API. Code is generated using Swagger with Retrofit and Gson as supporting libraries.

Citymapper API Description file

The Citymapper API description file is based on the Open API Specification. This description file can be used to generate an API client in a variety of programming languages. Please refer to swagger-codegen to generate client code in other languages.

Citymapper API key

An api key can be obtained by signing up here

Installation

Clone this repo to your local working directory.

git clone  https://github.com/genericmethod/citymapper-api-java.git

Install the dependency to your local repo. This will use the citymapper.yaml API definition file found in the resources folder to generate the API client.

mvn clean install

Add the following maven dependency to your pom.xml

<dependency>
    <groupId>com.citymapper.api</groupId>
    <artifactId>citymapper-api-java</artifactId>
    <version>1.0</version>
</dependency>

Usage

To begin using this library, build a retrofit instance

Retrofit retrofit = new ApiClient().getAdapterBuilder().build();

Create an API instance

TravelTimeApi travelTimeApi = retrofit.create(TravelTimeApi.class);

Execute an API call and get the body

    Retrofit retrofit = new ApiClient("apikey", API_KEY).getAdapterBuilder().build();
    TravelTimeApi travelTimeApi = retrofit.create(TravelTimeApi.class);
    final TravelTime time = travelTimeApi.traveltimeGet("51.5258156,-0.08833669999999999",
            "51.5094,-0.002124",
            null,
            null).execute().body();
    assertNotNull(time);

Travel Time API call example:

    Retrofit retrofit = new ApiClient("apikey",API_KEY).getAdapterBuilder().build();
    TravelTimeApi travelTimeApi = retrofit.create(TravelTimeApi.class);
    final TravelTime time = travelTimeApi.traveltimeGet("51.5258156,-0.08833669999999999",
            "51.5094,-0.002124",
            null,
            null).execute().body();

Single Point Coverage API call example:

    Retrofit retrofit = new ApiClient("apikey", API_KEY).getAdapterBuilder().build();
    CoverageApi coverageApi = retrofit.create(CoverageApi.class);
    final Coverage coverage = coverageApi.singlepointcoverageGet("51.5258156,-0.08833669999999999").execute().body();

Multiple Point Coverage API call example:

    Retrofit retrofit = new ApiClient("apikey",API_KEY).getAdapterBuilder().build();
    CoverageApi coverageApi = retrofit.create(CoverageApi.class);

    Coverage coverage = new Coverage();
    List<Point> points = new ArrayList<Point>();
    Point londonPoint = new Point();
    londonPoint.setCoord(Arrays.asList(51.5072,0.1275));
    points.add(londonPoint);
    Point pyongyangPoint = new Point();
    pyongyangPoint.setCoord(Arrays.asList(39.0194, 125.7381));
    pyongyangPoint.setId("Pyongyang");
    points.add(pyongyangPoint);

    coverage.setPoints(points);

    final Coverage coverageResult = coverageApi.coveragePost(coverage).execute().body();