imavroukakis / passninja-java

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

passninja-java

Use passninja-java as a Maven package.

Contents

Installation

Include the following in your pom.xml for Maven:

<dependencies>
  <dependency>
    <groupId>com.github.javadev</groupId>
    <artifactId>passninja</artifactId>
    <version>1.2</version>
  </dependency>
  ...
</dependencies>

Gradle:

compile 'com.github.javadev:passninja:1.2'

Usage

PassNinjaClient

Use this class to init a Passninja object. Make sure to pass your user credentials to make any authenticated requests.

import com.passninja.Passninja;

String accountId = "**your-account-id**";
String apiKey = "**your-api-key**";

Passninja.init(accountId, apiKey);

We've placed our demo user API credentials in this example. Replace it with your actual API credentials to test this code through your PassNinja account and don't hesitate to contact PassNinja with our built in chat system if you'd like to subscribe and create your own custom pass type(s).

For more information on how to use passninja-java once it loads, please refer to the PassNinja JS API reference

PassNinjaClientMethods

This library currently supports methods for creating, getting, updating, and deleting passes via the PassNinja api. The methods are outlined below.

Create

Map<String, Object> pass = new HashMap<>();
pass.put("discount", "50%");
pass.put("memberName", "John");
PassninjaResponse<Pass> response = Pass.create("demo.coupon", /* passType */
    pass /* passData */);

System.out.println(response.getResponseBody().getUrls());
System.out.println(response.getResponseBody().getPassType());
System.out.println(response.getResponseBody().getSerialNumber());

Get

PassninjaResponse<Pass> response = Pass.get("demo.coupon", /* passType */
    "97694bd7-3493-4b39-b805-20e3e5e4c770" /* serialNumber */);

Update

Map<String, Object> pass = new HashMap<>();
pass.put("discount", "100%");
pass.put("memberName", "Ted");
PassninjaResponse<Pass> response = Pass.put("demo.coupon", /* passType */
    "97694bd7-3493-4b39-b805-20e3e5e4c770", /* serialNumber */
    pass /* passData */);

Delete

PassninjaResponse<Pass> response = Pass.delete("demo.coupon", /* passType */
    "97694bd7-3493-4b39-b805-20e3e5e4c770" /* serialNumber */);
System.out.println("Pass deleted. Serial_number: ", response.getResponseBody().getSerialNumber());
PassninjaResponse<Pass> response = Pass.deleteForce("demo.coupon", /* passType */
    "97694bd7-3493-4b39-b805-20e3e5e4c770" /* serialNumber */);
System.out.println("Pass deleted. Serial_number: ", response.getResponseBody().getSerialNumber());

Documentation

About

License:MIT License


Languages

Language:Java 100.0%