GithubHelp home page GithubHelp logo

isabella232 / passtools-java Goto Github PK

View Code? Open in Web Editor NEW

This project forked from urbanairship/passtools-java

0.0 0.0 0.0 284 KB

Official Java SDK for the PassTools API

License: MIT License

Java 100.00%

passtools-java's Introduction

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 [email protected] 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

passtools-java's People

Contributors

captainstupid 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.