Skip to content
Official Java SDK for the PassTools API
Java
Find file
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
src
.gitignore
LICENSE.txt
README.md
pom.xml

README.md

passtools-java

Official Java SDK for the PassTools API

Overview

How to use the SDK

Let's say you wanted to create a personalized coupon for one of your customers. You would

  • create a coupon template through the PassTools UI where you could for instance create secondary fields to capture the first and last name of your customer. Let's say those fields have the keys first_name, last_name.
  • You then get the template ID from the template list page. Say the ID is 5.

From the java code, you first step is to set your API key to PassTools. You API key is supplied after you contact PassTools at help@passtools.com for early access to the API program. Please build the code with mvn clean install and load passtools-java-1.0.jar into your app from the target dir. (p.s: We are working on publishing the passtools-java library to public maven repositories and will update when done).

PassTools.apiKey = "yourKey"

You then call Template.get() to retrieve your newly created template

Template template = Template.getTemplate(5L);

and set the 2 secondary fields for your customer "Marie Lie"

JSONObject firstNameField = template.fieldsModel.get("first_name");
firstNameField.put("value", "Marie");

JSONObject lastNameField = template.fieldsModel.get("last_name");
lastNameField.put("value", "Lie");

You can then create Marie's pass

Pass coupon = Pass.create(template.getId(), template.fieldsModel);

And finally, you could either update the pass or download the pass and then email it to Marie

JSONObject price = template.fieldsModel.get("price"); //assuming you set up the "price" in the UI template builder
price.put("value","$10"); //it was $20 default before

coupon.fields=template.fieldsModel;
Pass.update(coupon);//from the created coupon above

Pass.downloadPass(coupon.id,"MarieCoupon.pkpass");//the pass is downloaded locally to your file

//you can now deliver the pass to Marie by email, sms or through a hosted URL.

Please note that we are currently deploying the com.passtools.* maven artifacts to the the central repositories. If they do not currently show on search results, please build the project with "mvn install" in the mean time. Thanks.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request
Something went wrong with that request. Please try again.