A set of helpers to enable creation of extensions for Vend Register
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
Example
VendRegisterExtension
.gitignore
.swift-version
.travis.yml
LICENSE
README.md
VendRegisterExtension.podspec
_Pods.xcodeproj

README.md

VendRegisterExtension

CI Status Version License Platform

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Inputs

Data is provided to the extension in a JSON format. Here is an example payload:

{
  "payload": {
    "sale": {
      "identifier": "654321-1234-4321-1234-654321",
      "lineItems": [{
        "unitTax": "45",
        "name": "Shoes",
        "quantity": "1",
        "taxIdentifier": "AAAAAAA-BBBB-DDDD-CCCC-AAAAAAA",
        "unitPrice": "300",
        "identifier": "123456-AAAA-BBBB-CCCC-DDDDDDD"
      }],
      "customer": {
        "identifier": "123456-ABCD-ABCD-ABCD-00000000"
      },
      "totals": {
        "toPay": "345",
        "paid": "0",
        "price": "345",
        "tax": "45"
      }
    },
    "retailer": {
      "domainPrefix": "aTestStore",
      "identifier": "123456-1234-1234-1234-123456"
    }
  },
  "version": 1
}

Outputs

The simplest way to send data back to VendRegister is to use the VendRegisterExtensionOperation enum which provides a helper to create a valid NSExtensionItem.

Otherwise, you must create a valid NSExtensionItem that contains a dictionary with the following format:

{
  "operation" : "addLineItems",
  "version" : 1,
  "parameters" : [
    {
      "unitTax": "45",
      "name": "Shoes",
      "quantity": "1",
      "taxIdentifier": "AAAAAAA-BBBB-DDDD-CCCC-AAAAAAA",
      "unitPrice": "300",
      "identifier": "123456-AAAA-BBBB-CCCC-DDDDDDD"
    }
  ]
}

Please note that the NSExtensionItem is not expecting a JSON object but instead an NSDictionary representation of that object and that the decimal numbers are represented as strings.

Requirements

Installation

VendRegisterExtension is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "VendRegisterExtension"

Author

TomCarey

License

VendRegisterExtension is available under the MIT license. See the LICENSE file for more info.