0.0
The project is in a healthy, maintained state
This gem provides a Ruby interface for the PassNinja API, allowing you to create, get, update, and delete passes.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

Runtime

>= 0
 Project Readme

passninja-ruby

Use passninja-ruby as a Ruby gem.

Contents

  • Contents
  • Installation
  • Usage
    • Passninja::Client
    • Passninja::Client Methods
    • Examples
  • Documentation

Installation

Install via RubyGems:

gem install passninja-ruby

Or add to your Gemfile:

gem 'passninja-ruby'

Usage

Passninja::Client

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

require 'passninja'

account_id = '**your-account-id**'
api_key = '**your-api-key**'
pass_ninja_client = Passninja::Client.new(account_id, api_key)

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

Passninja::Client Methods

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

Get Pass Template Details

pass_template = pass_ninja_client.pass_templates.find('ptk_0x14') # pass template key
puts pass_template['pass_type_id']

Create

simple_pass_object = pass_ninja_client.passes.create(
  'ptk_0x14', # passType
  { discount: '50%', memberName: 'John' } # passData
)
puts simple_pass_object['url']
puts simple_pass_object['passType']
puts simple_pass_object['serialNumber']

Find

Finds issued passes for a given pass template key

pass_objects = pass_ninja_client.passes.find('ptk_0x14') # passType aka pass template key

Get

detailed_pass_object = pass_ninja_client.passes.get(
  'ptk_0x14', # passType
  'ce61b0e13da9a7fe7e' # serialNumber
)

Decrypt

Decrypts issued passes payload for a given pass template key

decrypted_pass_object = pass_ninja_client.passes.decrypt(
  'ptk_0x14', # passType
  '55166a9700250a8c51382dd16822b0c763136090b91099c16385f2961b7d9392d31b386cae133dca1b2faf10e93a1f8f26343ef56c4b35d5bf6cb8cd9ff45177e1ea070f0d4fe88887' # payload
)

Update

updated_pass_object = pass_ninja_client.passes.update(
  'ptk_0x14', # passType
  'ce61b0e13da9a7fe7e', # serialNumber
  { discount: '100%', memberName: 'Ted' } # passData
)

Delete

deleted_pass_serial_number = pass_ninja_client.passes.delete(
  'ptk_0x14', # passType
  'ce61b0e13da9a7fe7e' # serialNumber
)
puts "Pass deleted. Serial_number: #{deleted_pass_serial_number}"

Documentation