Swiftpack.co - Package - flomio/passninja-swift

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-java once it loads, please refer to the PassNinja JS 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: ["passTitle": "Example PassTitle Value", "logoText": "Example LogoText Value", "organizationName": "Example OrganizationName Value", "description": "Example description Value", "expiration": "Example expiration Value", "memberName": "Example memberName Value", "specialOffer": "Example specialOffer Value", "loyaltyLevel": "Example loyaltyLevel Value", "barcode": "Example barcode Value", "eventDate": "Example eventDate Value"]), 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)
}

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

Github

link
Stars: 0

Dependencies

Used By

Total: 0

Releases

1.0.5 -

error model change

1.0.4 -

  • added validation for pass keys before creating a pass

1.0.3 -

Create and put pass payload updated with dynamic key pair values

1.0.2 -

Changed pass parameters as optional which are not compulsory.

1.0.1 -

Version 1.0 -

Main functionality implemented