Skip to content

flomio/passninja-swift

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

passninja-swift

Use passninja-swift as an iOS package.

Contents

Installation

Swift Package Manager (Xcode 11 and above)

  1. Select File/Swift Packages/Add Package Dependency… from the menu.
  2. Paste https://github.com/flomio/passninja-swift.git.
  3. Follow the steps and select from main branch.

Usage

PassNinjaClient

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

import PassNinjaSwift

let accountId = "**your-account-id**"
let apiKey = "**your-api-key**"

PassNinja.initWith(accountId: accountId, apiKey: 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-swift once it loads, please refer to the PassNinja Swift 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

PassClient.shared.createPass(pass: PassRequest(passType: "demo.coupon", pass: [discount: '50%', memberName: 'John']), onSuccess: { (pass) in
    print(pass.urls as Any)
    print(pass.passType as Any)
    print(pass.serialNumber as Any)
    print(pass.pass?.logoText as Any)
    print(pass.pass?.descriptionField as Any)
}) { (error) in
    print(error as Any)
}

Get

PassClient.shared.getPass(passType: "demo.coupon", serialNumber: "#Your pass serial number", onSuccess: { (pass) in
    print(pass.urls as Any)
    print(pass.passType as Any)
    print(pass.serialNumber as Any)
    print(pass.pass?.logoText as Any)
    print(pass.pass?.descriptionField as Any)
}) { (error) in
    print(error as Any)
}

Get Pass Template Details

PassClient.shared.getPassTemplate(passType: "demo.coupon", onSuccess: { (passTemplate) in
    print(passTemplate.id as Any)
    print(passTemplate.passTypeId as Any)
    print(passTemplate.name as Any)
}) { (error) in
    print(error as Any)
}

Update

PassClient.shared.putPass(pass: PassRequest(passType: "demo.coupon", pass: ["passTitle": "Example passTitleValue", "logoText": "Example logoTextValue", "organizationName": "Example organizationNameValue", "description": "Example descriptionValue"], serialNumber: "#Your pass serial number"), onSuccess: { (pass) in
    print(pass.urls as Any)
    print(pass.passType as Any)
    print(pass.serialNumber as Any)
    print(pass.pass?.logoText as Any)
    print(pass.pass?.descriptionField as Any)
    print(pass.pass?.expiration as Any)
}) { (error) in
    print(error as Any)
}

Delete

PassClient.shared.deletePass(passType: "demo.coupon", serialNumber: pass?.serialNumber ?? "", clientPassData: [:], onSuccess: {
    print("Pass deleted successfully")
}) { (error) in
    print(error as Any)
}

Documentation

About

A PassNinja API helper library for Swift

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages