Official Java SDK for the PassTools API
- The SDK makes it easy to manage Apple Passbook passes through the PassTools API.
- Please refer to the API Doc for the raw apis.
- Indexed documentation for the Java SDK is available at http://tello.github.com/passtools-java/.
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 email@example.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.
- Fork it
- Create your feature branch (
git checkout -b my-new-feature)
- Commit your changes (
git commit -am 'Added some feature')
- Push to the branch (
git push origin my-new-feature)
- Create new Pull Request