blob: 855806731392668f942ec5608ad4ca5e1d35b2da [file] [log] [blame]
{
"name": "MyCheckDine",
"version": "1.4.0",
"summary": "A SDK that enables the developer to open a table at a restaurant, follow the order and reorder items.",
"description": "# MyCheck Dine SDK\n\nAn SDK that enables the developer to open a table at a restaurant, follow the order and reorder items (payment - coming soon).\n\nThis SDK will enable your app to access an open check on a table at a restaurant, view the check (bill), reorder items and pay the check (payment functions coming soon).\n\nThe basic flow of the transactions is:\n- The guest accesses the app to get a four digit code\n- The code is given to the guest's food server who will access the open check on the POS and enter the code.\n- The POS will connect the check with MyCheck services\n- The guest will then be able to see the check and interact with the check by reordering existing items and paying.\n- Once the guest pays the check he/she no longer has access to the check.\n\n\n## Requirements\n\niOS 9 or above.\n\nSwift 3.0\n\n## Installation\n\nMyCheck Restaurant SDK is available through [CocoaPods](http://cocoapods.org). You will first need to ask a MyCheck team member to give you read privileges to the MyCheck Repository. Once you have gotten the privileges, install it by simply adding the following lines to the top of your Podfile:\n\n```\nsource 'http://bitbucket.org/erez_spatz/pod-spec-repo.git'\nsource 'http://github.com/CocoaPods/Specs.git'\n```\nThis will set both the public CocoaPods repo and the MyCheck private repo as targets for CocoaPods to search for frameworks from.\n\nYou can add YOUR_USER_NAME@ before the 'bitbucket.org' so the pod tool won't need to ask you for it every time you update or install.\n\nInside the target add:\n\n```\npod \"MyCheckDine\"\n```\nNow you can run 'pod install'\n\n## Use\nThe Dine Singleton will be the point of contact that will allow you to create, follow and make actions on the users order. In order to manage the users session (login, logout etc.) you will need to use the session singleton.\n\nStart by adding\n```\nimport MyCheckCore\n```\n\n\nto the top of the class where you want to use MyCheck.\n\nIn your app delegate's `application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?)` function call the configure function of the Session singleton:\n\n```\nSession.shared.configure(YOUR_PUBLISHABLE_KEY, environment: .sandbox)\n```\nThis will setup the SDK to work with the desired environment.\n\nBefore using any other functions you will have to login the user. Login is done by first obtaining a refresh token from your server (that, in turn, will obtain it from the MyCheck server using the secret). Once you have the refresh token call the login function on the Session singleton:\n\n\n```\nSession.shared.login(REFRESH_TOKEN, success: HANDLE_SUCCESS\n}, fail: HANDLE_FAIL)\n\n```\nOnce you are logged in, you can open a table. Now you can start doing dine in specific actions using the Dine singleton. Import the Dine module of the SDK.\n```\nimport MyCheckDine\n```\n\nBellow is a flow chart that explains the Dine in flow and explains what functions need to be called in each stage of the user experience.\n![Dine flow chart](https://s3-eu-west-1.amazonaws.com/docs.mycheckapp.com/Resources/flowChart.jpg \"Dine flow chart\")\nThe first step in the process is generating a 4 digit code. The code generated by the MyCheck server is valid for a limited time, for a specific user in a specific location. This code, when entered into the POS enables MyCheck to sync the client with his order on the POS and can start receiving order updates and perform actions on it. The user will need to have a method of payment in order for this to succeed. Once you have received a code, display it to the user so he, in turn, can show it to his waiter / bartender. If you wish to support Apple Pay you will need some additional setup, please read the Apple Pay section.\n\n```\nDine.shared.generateCode(hotelId: HOTEL_ID , restaurantId: RESTUARANT_ID, success: HANDLE_SUCCESS\n}, fail: HANDLE_FAIL)\n\n```\n\nNow that a code was generated and displayed you will probably want to start polling the MyCheck server in order to get order updates. You will get an update when the order is opened, and on every change made to the bill. In order to poll the order, turn on the poller and implement the 'OrderPollerDelegate'.\n\n```\nDine.shared.poller.delegate = self\n\nMyCheck.shared.poller.startPolling()\n\n```\n\nThe delegate example implementation:\n\n```\nextension YOUR_VIEWCONTROLLER : OrderPollerDelegate{\n\nfunc orderUpdated(order:Order){\n\n//Deal with order updates. Check the 'status' variable to make sure the status didn't change, otherwise update the order displayed to the user with the updated bill.\n}\n\n\nfunc failingToReceiveUpdates(lastReceivedError: NSError , failCount:Int){\n//this callback will be called if the poller failed the last few calls to the MyCheck server. This means your app may not be in sync with the POS.\n}\n}\n```\n\n\nIn order to reorder items send an array of tuples to the reorder call. Each tuple has an Int representing the amount to order and the item to reorder.\n\n```\nMyCheck.shared.reorderItems(items: [(3, order.items.first!)], success: {\n//Handle success\n}, fail: {error in\n// handle fail\n})\n```\n### Payment\nIf you have an open table with a non zero balance and a payment method you can make a payment.\nThe first step is to create a `PaymentDetails` object\n\n```\nlet details = PaymentDetails(order: THE_ORDER, amount: THE_AMOUNT_TO_CHARGE, tip: TIP_AMOUNT, paymentMethod: A_PAYMENT_METHOD)\n\n// OR\n\nlet details = PaymentDetails(order: THE_ORDER, items: ITEMS_THAT_SHOULD_BE_BOUGHT, tip: TIP_AMOUNT, paymentMethod: A_PAYMENT_METHOD)\n```\n\nThe `PaymentDetails` has 2 failable constructors. One is for paying by amount and the second is for paying by items. The constructors will fail if the order supplied is not open or if the amount is greater than the order balance.\nYou will also need to get a `PaymentMethodInterface` object, For more on this please review the MyCheckWalletUI documents.\nOnce you have a `PaymentDetails` object call the `makePayment` function.\n\n```\nDine.shared.makePayment(paymentDetails: details, displayDelegate: self, success: {\n\n}, fail: {error in\n\n})\n```\n\n## Apple Pay\n\nIn order to set up Apple Pay please review the MyCheckWallet or MyCheckWalletUI docs. Once Apple Pay is set up their are 2 additional changes you will need to make in order for it to work with the Dine SDK.\n### Generate Code\nWhen generating a code MyCheck must be able to charge the default payment method without the users interaction in certain cases (for example if the user walks out and forgets to pay). Apple Pay creates tokens that can be used only once that expires after some time. For this reason we will need to prompt the user to Pay with Apple Pay at this point.\nIn order to accomplish this the generateCode function has 2 extra optional parameters (that are required for Apple Pay support):\n1. DisplayViewControllerDelegate : The delegate function will be called when a Apple Pay view controller needs to be displayed or dismissed.\n2. ApplePayController - The controller will supply the Dine SDK with the means to query the wallet about Apple Pay and create Apple Pay tokens. You should get the instance of the ApplePayController from the Wallet singleton (e.g. 'Wallet.shared.applePayController')\n\nThe code snippet bellow demonstrates how the generate code is called when Apple Pay must be supported\n\n```\nDine.shared.generateCode(hotelId: nil, restaurantId: THE_ID, displayDelegate: self, applePayController: Wallet.shared.applePayController, success: {\ncode in\n\n}\n}, fail: {error in\n\n})\n\n\n//DisplayViewControllerDelegate implementation\nfunc display(viewController: UIViewController) {\n\nself.present(viewController, animated: true, completion: nil)\n\n}\n\n\nfunc dismiss(viewController: UIViewController) {\n\nviewController.dismiss(animated: true, completion: nil)\n\n}\n```\nIn the same manner, you must pass the `displayDelegate` to the payment function in order for Apple Pay to work.\n\n\n##Benefits\n\nIn order to support benefits add the following line to your podfile:\n```\npod \"MyCheckDine/Benefits\"\n```\n\nYou can now use the static functions in the Benefits class to query and redeem benefits. Please refer to the API docs for more information.\n## Authors\n\nElad Schiller, eladsc@mycheck.co.il\n## License\n\nPlease read the LICENSE file available in the project",
"homepage": "http://www.mycheck.io/",
"license": {
"type": "Custom",
"file": "LICENSE"
},
"authors": {
"elad schiller": "eladsc@mycheck.co.il"
},
"source": {
"git": "https://github.com/eladMyCheck/MyCheckDine.git",
"tag": "1.4.0"
},
"platforms": {
"ios": "9.0"
},
"source_files": [
"MyCheckDine/Classes/*",
"MyCheckDine/Classes/extenshions tools/**",
"MyCheckDine/Classes/Networking/**",
"MyCheckDine/Classes/objects/**",
"MyCheckDine/Classes/OrderPoller/**"
],
"dependencies": {
"MyCheckCore": [
],
"Gloss": [
]
},
"subspecs": [
{
"name": "Benefits",
"dependencies": {
"MyCheckCore": [
"~> 1.0.6"
]
},
"source_files": "MyCheckDine/Classes/Benefits/**/*",
"platforms": {
"ios": "9.0"
}
}
]
}