PatronProxy
public class PatronProxy
Class to manage all Ticketing SDK
-
Success data handler for any request
- Response: Data callback
Declaration
Swift
public typealias SuccessDataHandler = ((_ responseObject: Data?) -> Void) -
Success handler with JSON object callback
- Response: JSON data callback
Declaration
Swift
public typealias SuccessHandler = ((_ responseObject: [String : Any]?) -> Void) -
Failure handler
- Response: Error callback
Declaration
Swift
public typealias FailureHandler = ((_ error: Error) -> Void) -
Check internet status
Declaration
Swift
public var isReachable: Bool { get } -
Current logged in token This token will be get from patron login The token session management will be done by BO through expire status
Declaration
Swift
public var currentToken: String { get }
-
Initialize with configuration
- Params: PatronConfiguration
Declaration
Swift
public init(configuration: PatronConfiguration)
-
Check app version
Declaration
Swift
public func checkAppVersion(bundle: String, versionCallback: @escaping (Version?) -> (), failure: FailureHandler?)Parameters
buldeThe app bundle identitier com.xyz.appname
-
Send a request to the Patron API that will activate a user.
Declaration
Swift
public func patronActivate(activateToken: String, patronActivateCallback: @escaping (Bool) -> (), failure: FailureHandler?)Parameters
activateTokenThis token will be received from Deep link
-
Send a request to the Patron API that creates a token. This API is call at first in order to invoke next one
Sample response: { “token_type”: “Bearer”, “expires_in”: 31622400, “access_token”: “eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6IjcxNTBmYjllODdjNmY1YTUzYWUyY2QyM2Y5ZjlhYWExMDc5ZDU1YWMzY2FlY2E4YWM5ZDFjYjg0M2I0NzdiZjQwYTUwZjU3ZjNiNGJiM2NhIn0.eyJhdWQiOiIwMDAwMDAwMC0wMDAwLTAwMDAtMDAwMC0wMDAwMDAwMDAwMDIiLCJqdGkiOiI3MTUwZmI5ZTg3YzZmNWE1M2FlMmNkMjNmOWY5YWFhMTA3OWQ1NWFjM2NhZWNhOGFjOWQxY2I4NDNiNDc3YmY0MGE1MGY1N2YzYjRiYjNjYSIsImlhdCI6MTU1NTkyMzQyNCwibmJmIjoxNTU1OTIzNDI0LCJleHAiOjE1ODc1NDU4MjQsInN1YiI6IiIsInNjb3BlcyI6WyJtb2JpbGUiXX0.ZuPYh_Kd5qdJQEgjMcEjsuxQUr9HDIbjPKHbXAULt472jdpUliyM9skKkfAno6qeJyA0OeVdOvyh16Exvt_YhUSljZ7wOic8KUI2WAhUwOwdE7BKVSAG5ajRy9xoVzfXgcFrq8Oqo2uS6tJhET9YoNHHo_4WwSG5I4GS4lN_NryFT96pV79KtHtIQCOgxX-bsLcTzDpOZGktXG6iDqsikdOdumkFkiRfIlh1RUS63K3yEJyD2zUJoZv0KDIJFO8CdunIAaGXMZHuQJ5x8CplL1nLa-F0_zfPkIn0sE_HFk95qUxX3jUZfUE3iQQmcQgGsgVLPYOm09wZ9VRZh9Hjt3a3uJIsX8AOa5cMYnI9w6A91n6B23ypLMuGBf2VHKUfcjn4gso5G694iZKX9kz2abAjsRozEiCkYPgT6pSNVoayFD4qprk7VKX8aQumwjaofP0_WfusSg0ruwadhZ1WbiHfDCqbIFI_NzMf_LGgEM79Bcc7eaM2ME55nQFIs6HbnREq9qlBhsNr7R1fKsqwHNY-JxQSpQsfnujVPuY2ly_JB9C4UCOdffjRqn6hgUlqimn7DgcvPqGNfezd2Fuq5c77aTmUm-2LUqZfDdCFvVQYYpi-UIMX8yBvMRTGs4wqICN4Zozg5pZo-lqpdx6MA15AbnalPyGZZBkN9EUhCrQ” }, “refresh_token”: “def50200383ef381596ed9f12e798a6741b396831d6fed712fc2de00abf682cf72f72f1063636bc3c52a2af3c2798d5312c92495d6ce32395f97f4c0b09f037a309ca712c2525ca1dd6d4740b63a57acf725e7c1dae591a09e66520cfd739c0649dab509d08e0e5727d312fa0c9ed676b78447042602d4d7bd910d8d0c3bb9007cb60dd11158aed4427b75b0a5f060de09ff04b4661568cd8ce8df6c55bc2a0f56c4e6fe018cbd15e571e4c5d92f3fd81eeda5af3b5ff177bfae4577a47e7f02e758390e08f117a156b4e54d8d6917c29c06fd916b4fddb56160864bcb57b0209131d76c60fff79c22a50f3dda2949a126731c444dddc8ab83436b2d7be13466ae0a158065d27d6b1daf03054e7166907ce516655848bceee346e8ccdb6628b24689b0843e92258246604fcdf043066ac5148039f00dfce03dbf4bf2f324540312c2c1c4873e7172c19ccf19344421a21687292a8b4b294e66a9c1450b179f039a0fde647c62e4f39588968ad00cc017fc8f7bd3c07b426faa11b58591793a562b44988153”
The token will be collect as:
Declaration
Swift
public func refreshToken(_ refreshToken: String, successCallback: @escaping (MKToken?) -> (), failure: FailureHandler?)Parameters
refresh_tokenthe the token for refresh
clientIdthe client id - fixed one
clientSecretThe secret id - fixed one
grant_typerefresh_token
callbackCallback executed after the request end.
-
Send a request to the Patron API that creates a patron (user). This API is involve after mobile login
Sample response: { “data”: { “id”: 19, “client_id”: 1, “name”: null, “email”: “ext-dang.than1@flowbird.group”, “phone”: null, “birthday”: null, “company_name”: null, “company_employee_id”: null, “patron_status_id”: 1, “pin”: null, “created_at”: “2019-04-22 08:58:27”, “updated_at”: “2019-04-22 08:58:27” } }
Declaration
Swift
public func createPatron(email: String, password: String, profileCallback: @escaping (Patron?) -> (), failure: FailureHandler?)Parameters
emailuser email
passworduser password - This point can be secured
tokentoken response from mobile login API
callbackCallback executed after the request end.
-
Send a request to the Patron API that request a login session. This API is to login and get user info
Sample response: { “token_type”: “Bearer”, “expires_in”: 31622400, “access_token”: “eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6ImRkNmM5NzcyZGExODE3Nzk1NmVmNzBjZTcyMWM5ZmE0ZGMzNGI1ZGQyNjk1NDkzYTMwOTlmNGM1YTQ5MzkzMDNmNDI4ZDk2M2U1MmE3Y2VhIn0.eyJhdWQiOiIwMDAwMDAwMC0wMDAwLTAwMDAtMDAwMC0wMDAwMDAwMDAwMDIiLCJqdGkiOiJkZDZjOTc3MmRhMTgxNzc5NTZlZjcwY2U3MjFjOWZhNGRjMzRiNWRkMjY5NTQ5M2EzMDk5ZjRjNWE0OTM5MzAzZjQyOGQ5NjNlNTJhN2NlYSIsImlhdCI6MTU1NTkyNDUzNCwibmJmIjoxNTU1OTI0NTM0LCJleHAiOjE1ODc1NDY5MzQsInN1YiI6IjEyIiwic2NvcGVzIjpbXX0.hqbRb6W4eA1skvItaRjUj7vnNBVnkDvvsDVPuu3K1vF74uCHRRvlSTWv3me8OyFudL-7KVUmeR_PajjziKItb4JTsGupGMNaPr6p3NKxf_UN_SDhwD8a-0UVxZXurgIpdvOVCu2vwSWBz_ofw91XFNipFzzgTejjbB4UK9DH3MXOtTiMJLUaNgpaS7NV9XDYim9YiGL0tCIOWxMN3W2k9cW5lZE3rN6sK_H5mlYPDxk1ZWjpJ2ECDHoTXKs-Q_I75hjoFb-W_zTWH_P5mjvS2adP77GRVZfcvwt3F6oI0_BTJPmiYyumc_tNwQARaDknNcoUk2wBUnP_Ks88k797DSzc6EIO5hNhX-ZWu2C7pum5TebH1nkYpL0IpjTOho0XjZ0NlnAIYBhksjebjUIA2BTZYQr883cVw7PDYfGI9zrJF-B1M2p86E-TJsh-DXsot71niXnR9JG0kmYQjPvg9ALLIKxmwhA7fyYlDtMycq0jTolbLmyDuV0PNz1wzN4fnWpqV-C0LYaQooaVPA6VIHwecd1bDU3KHEHS5b8Qdzyo8aykGUj6VI-CEh6Jcp-0-cuk__kxoJBS5bG8pGrWrhde15Hhl2WKaReqdfyJTd74j9Nt0U08TBUAbUnqVXk90SzuM8OKqf1Ku_jpcTEDMKURg-zhEg8bX91L3CZqprE”, “refresh_token”: “def50200383ef381596ed9f12e798a6741b396831d6fed712fc2de00abf682cf72f72f1063636bc3c52a2af3c2798d5312c92495d6ce32395f97f4c0b09f037a309ca712c2525ca1dd6d4740b63a57acf725e7c1dae591a09e66520cfd739c0649dab509d08e0e5727d312fa0c9ed676b78447042602d4d7bd910d8d0c3bb9007cb60dd11158aed4427b75b0a5f060de09ff04b4661568cd8ce8df6c55bc2a0f56c4e6fe018cbd15e571e4c5d92f3fd81eeda5af3b5ff177bfae4577a47e7f02e758390e08f117a156b4e54d8d6917c29c06fd916b4fddb56160864bcb57b0209131d76c60fff79c22a50f3dda2949a126731c444dddc8ab83436b2d7be13466ae0a158065d27d6b1daf03054e7166907ce516655848bceee346e8ccdb6628b24689b0843e92258246604fcdf043066ac5148039f00dfce03dbf4bf2f324540312c2c1c4873e7172c19ccf19344421a21687292a8b4b294e66a9c1450b179f039a0fde647c62e4f39588968ad00cc017fc8f7bd3c07b426faa11b58591793a562b44988153” }
The expected behavior in this case is to get token. In order to use for different API as Auth, we need to combine token to following format:
Example: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6ImRkNmM5NzcyZGExODE3Nzk1NmVmNzBjZTcyMWM5ZmE0ZGMzNGI1ZGQyNjk1NDkzYTMwOTlmNGM1YTQ5MzkzMDNmNDI4ZDk2M2U1MmE3Y2VhIn0.eyJhdWQiOiIwMDAwMDAwMC0wMDAwLTAwMDAtMDAwMC0wMDAwMDAwMDAwMDIiLCJqdGkiOiJkZDZjOTc3MmRhMTgxNzc5NTZlZjcwY2U3MjFjOWZhNGRjMzRiNWRkMjY5NTQ5M2EzMDk5ZjRjNWE0OTM5MzAzZjQyOGQ5NjNlNTJhN2NlYSIsImlhdCI6MTU1NTkyNDUzNCwibmJmIjoxNTU1OTI0NTM0LCJleHAiOjE1ODc1NDY5MzQsInN1YiI6IjEyIiwic2NvcGVzIjpbXX0.hqbRb6W4eA1skvItaRjUj7vnNBVnkDvvsDVPuu3K1vF74uCHRRvlSTWv3me8OyFudL-7KVUmeR_PajjziKItb4JTsGupGMNaPr6p3NKxf_UN_SDhwD8a-0UVxZXurgIpdvOVCu2vwSWBz_ofw91XFNipFzzgTejjbB4UK9DH3MXOtTiMJLUaNgpaS7NV9XDYim9YiGL0tCIOWxMN3W2k9cW5lZE3rN6sK_H5mlYPDxk1ZWjpJ2ECDHoTXKs-Q_I75hjoFb-W_zTWH_P5mjvS2adP77GRVZfcvwt3F6oI0_BTJPmiYyumc_tNwQARaDknNcoUk2wBUnP_Ks88k797DSzc6EIO5hNhX-ZWu2C7pum5TebH1nkYpL0IpjTOho0XjZ0NlnAIYBhksjebjUIA2BTZYQr883cVw7PDYfGI9zrJF-B1M2p86E-TJsh-DXsot71niXnR9JG0kmYQjPvg9ALLIKxmwhA7fyYlDtMycq0jTolbLmyDuV0PNz1wzN4fnWpqV-C0LYaQooaVPA6VIHwecd1bDU3KHEHS5b8Qdzyo8aykGUj6VI-CEh6Jcp-0-cuk__kxoJBS5bG8pGrWrhde15Hhl2WKaReqdfyJTd74j9Nt0U08TBUAbUnqVXk90SzuM8OKqf1Ku_jpcTEDMKURg-zhEg8bX91L3CZqprE
We also need to handle the expires time. Here is the flow: In case of unauth(401) for every request, we need to kick user out in order to re-authenticate
Declaration
Swift
public func patronLogin(username: String, password: String, success: @escaping (MKToken?) -> (), failure: FailureHandler?)Parameters
usernameuser email
passworduser password - This point can be secured
callbackCallback executed after the request end.
-
Send a request to the Patron API that update patron password.
Sample response:
Declaration
Swift
public func updatePassword(token: String? = nil, currentPassword: String, newPassword: String, profileCallback: @escaping (Patron?) -> (), failure: FailureHandler?)Parameters
tokenuser current login token
mediaIdget from get Ticket as field
numberlabelcard label we would edit
callbackCallback executed after the request end.
-
Send a request to the Patron API that update phatron phone nunber
Sample response:
Declaration
Swift
public func updatePhone(token: String? = nil, phoneCode: String, phone: String, profileCallback: @escaping (Patron?) -> (), failure: FailureHandler?)Parameters
tokenuser current login token
mediaIdget from get Ticket as field
numberlabelcard label we would edit
callbackCallback executed after the request end.
-
Send a request to the Patron API that update PIN for patron
Sample response:
Declaration
Swift
public func updatePin(token: String? = nil, pin: String, profileCallback: @escaping (Patron?) -> (), failure: FailureHandler?)Parameters
tokenuser current login token
mediaIdget from get Ticket as field
numberlabelcard label we would edit
callbackCallback executed after the request end.
-
Send a request to the Patron API that Update patron info
Sample response:
Declaration
Swift
public func updatePatron(token: String? = nil, patron: Patron, profileCallback: @escaping (Patron?) -> (), failure: FailureHandler?)Parameters
tokenuser current login token
patronPatron info data
callbackCallback executed after the request end.
-
Send a request to the Patron API to delete patron.
Sample response:
Declaration
Swift
public func deletePatron(token: String? = nil, password: String, success: SuccessHandler?, failure: FailureHandler?)Parameters
tokenuser current login token
passwordThe password for confirmation
successSuccess callback
failureFailure callback
-
Send a request to the Patron API to reset the patron’s password.
Sample response:
Declaration
Swift
public func resetPatronPassword(email: String, patronActivateCallback: @escaping (Bool) -> (), failure: FailureHandler?)Parameters
emailEmail of the patron
callbackCallback executed after the request end.
-
Send a request to the Patron API to get transaction histories.
Sample response:
Declaration
Swift
public func updatePatronPassword(password: String, forgotPwdToken: String, patronActivateCallback: @escaping (Bool) -> (), failure: FailureHandler?)Parameters
tokenuser current login token
mediaIdId of the media
callbackCallback executed after the request end.
-
Send a request to the Patron API that request tickets list. =
Sample response: { “data”: [ { “number”: 5966215829816894, “secret”: null, “balance”: “$0.00”, “ticket_status_id”: 1, “ticket_status_name”: “Unassigned”, “ticket_type_id”: 3, “ticket_type_name”: “Digital”, “client_id”: 1, “patron_id”: null, “linked_patron_id”: null, “device_id”: null, “external_number”: null, “batch_number”: null, “roll_number”: null, “activated_date”: null, “expired_date”: null, “auto_refill_threshold”: null, “auto_refill_amount”: null }, { … }, { … }, { … } ] }
Declaration
Swift
public func getTickets(token: String? = nil, ticketsCallback: @escaping ([Ticket]) -> (), failure: FailureHandler?)Parameters
tokenuser current login token
callbackCallback executed after the request end.
-
Send a request to the Patron API to get details of a ticket.
Sample response:
Declaration
Swift
public func getTicket(token: String? = nil, mediaId: String, ticketCallback: @escaping (Ticket?) -> (), failure: FailureHandler?)Parameters
tokenuser current login token
mediaIdId of the ticket
ticketCallbackSuccess callback
failureFailure callback
-
Send a request to the Patron API that request a Tickets list. =
Sample response: { “data”: { “number”: 3454995658706575, “secret”: “JPYzVd”, “balance”: “$0.00”, “balance_int”: “0”, “ticket_status_id”: 1, “ticket_status_name”: “Unassigned”, “ticket_type_id”: 3, “ticket_type_name”: “Digital”, “client_id”: 1, “patron_id”: null, “linked_patron_id”: null, “device_id”: null, “external_number”: null, “batch_number”: null, “roll_number”: null, “activated_date”: null, “expired_date”: null, “auto_refill_threshold”: null, “auto_refill_threshold_int”: null, “auto_refill_amount”: null, “auto_refill_amount_int”: null, “label”: null } }
Declaration
Swift
public func getRideNow(token: String? = nil, ticketCallback: @escaping (Ticket?) -> (), failure: FailureHandler?)Parameters
tokenuser current login token
callbackCallback executed after the request end.
-
Send a request to the Patron API to get wallets. =
Sample response: { “data”: [ { “card_name”: “Nolan Braun V”, “card_brand”: “Discover Card”, “last_4_digits”: “4991”, “expiration_date”: “2020-06-30”, “is_default”: 1 } ] }
Declaration
Swift
public func getWallets(token: String? = nil, walletsCallback: @escaping ([Wallet]) -> (), failure: FailureHandler?)Parameters
tokenuser current login token
mediaIdget from get Ticket as field
numbercallbackCallback executed after the request end.
-
Send a request to the Patron API to create a wallet.
Sample response:
Declaration
Swift
public func addWallet(token: String? = nil, walletToken: String, wallet: Wallet, walletCallback: @escaping (Wallet) -> (), failure: FailureHandler?)Parameters
tokenuser current login token
walletTokenSimplePay token
walletWallet object, contain the info needed
walletCallbackSuccess callback
failureFailure callback
-
Send a request to the Patron API to update a wallet.
Sample response:
Declaration
Swift
public func updateWallet(token: String? = nil, isDefault: Int, walletId: Int, walletCallback: @escaping (Wallet) -> (), failure: FailureHandler?)Parameters
tokenuser current login token
walletIdId of the wallet
isDefaultMake this wallet to be default for selection or not
walletCallbackSuccess callback
failureFailure callback
-
Send a request to the Patron API to delete a wallet.
Sample response:
Declaration
Swift
public func deleteWallet(token: String? = nil, walletId: Int, success: SuccessHandler?, failure: FailureHandler?)Parameters
tokenuser current login token
walletIdId of the wallet
walletCallbackSuccess callback
failureFailure callback
-
Send a request to the Patron API to get patron (profile info). =
Sample response: { “data”: { “id”: 11, “client_id”: 1, “name”: null, “email”: “ext-dang.than14@flowbird.group”, “phone”: null, “birthday”: null, “company_name”: null, “company_employee_id”: null, “patron_status_id”: 1, “pin”: null, “created_at”: “2019-04-24 05:31:42”, “updated_at”: “2019-04-24 05:31:42” } }
Declaration
Swift
public func getPatron(token: String? = nil, profileCallback: @escaping (Patron?) -> (), failure: FailureHandler?)Parameters
tokenuser current login token
callbackCallback executed after the request end.
-
Send a request to the Patron API that add value to a ticket. =
Sample response: { “data”: { “number”: 5966215829816894, “secret”: null, “balance”: “$40.00”, “ticket_status_id”: 1, “ticket_status_name”: “Unassigned”, “ticket_type_id”: 3, “ticket_type_name”: “Digital”, “client_id”: 1, “patron_id”: null, “linked_patron_id”: null, “device_id”: null, “external_number”: null, “batch_number”: null, “roll_number”: null, “activated_date”: null, “expired_date”: null, “auto_refill_threshold”: null, “auto_refill_amount”: null } }
Declaration
Swift
public func addValue(token: String? = nil, mediaId: String, value: Int, walletId: Int, ticketCallback: @escaping (Ticket) -> (), failure: FailureHandler?)Parameters
tokenuser current login token
mediaIdget from get Ticket as field
numbercallbackCallback executed after the request end.
-
Send a request to the Patron API that transfer balance from an account to other account. =
Sample response: { “data”: { “number”: 7356282788845858, “secret”: “$2y$10$WN3JCpYO0WFf/dzDt27iKORIRVDxu33Ldl.XFd1pcKZtsQOfLVQJq”, “balance”: “$0.45”, “ticket_status_id”: 1, “ticket_status_name”: “Unassigned”, “ticket_type_id”: 1, “ticket_type_name”: “Paper”, “client_id”: 1, “patron_id”: null, “linked_patron_id”: null, “device_id”: null, “external_number”: null, “batch_number”: null, “roll_number”: null, “activated_date”: null, “expired_date”: null, “auto_refill_threshold”: null, “auto_refill_amount”: null } }
Declaration
Swift
public func transferBalance(token: String? = nil, mediaId: String, transferNumber: String, value: Int, ticketCallback: @escaping (Ticket) -> (), failure: FailureHandler?)Parameters
tokenuser current login token
mediaIdget from get Ticket as field
numbertransferNumberthe target number for transfer
valuethe number of money to transfer
callbackCallback executed after the request end.
-
Send a request to the Patron API that edit a card label. =
Sample response:
Declaration
Swift
public func editCardLabel(token: String? = nil, mediaId: String, label: String, ticketCallback: @escaping (Ticket) -> (), failure: FailureHandler?)Parameters
tokenuser current login token
mediaIdget from get Ticket as field
numberlabelcard label we would edit
callbackCallback executed after the request end.
-
Send a request to the Patron API that link an email to a fare card. =
Sample response:
Declaration
Swift
public func linkMyFareCard(token: String? = nil, mediaId: String, email: String, ticketCallback: @escaping (Ticket) -> (), failure: FailureHandler?)Parameters
tokenuser current login token
mediaIdget from get Ticket as field
numberemailemail to link to set card
callbackCallback executed after the request end.
-
Send a request to the Patron API that add a fare card to current user. =
Sample response:
Declaration
Swift
public func addFareCard(token: String? = nil, secretCode: String, mediaId: String, label: String, ticketCallback: @escaping (Ticket) -> (), failure: FailureHandler?)Parameters
tokenuser current login token
mediaIdget from get Ticket as field
numbertransferNumberthe target number for transfer
valuethe number of money to transfer
callbackCallback executed after the request end.
-
Send a request to the Patron API to delete a fare card.
Sample response:
Declaration
Swift
public func deleteFareCard(token: String? = nil, cardId: String, success: SuccessHandler?, failure: FailureHandler?)Parameters
tokenThe token of current logged user
cardIdId of the fare card
successSuccess callback
failureFailure callback
-
Send a request to the Patron API that paring a fare card. =
Sample response:
Declaration
Swift
public func paringFareCard(token: String? = nil, pairingToken: String, label: String?, success: SuccessHandler?, failure: FailureHandler?)Parameters
tokenuser current login token
mediaIdget from get Ticket as field
numbertransferNumberthe target number for transfer
valuethe number of money to transfer
callbackCallback executed after the request end.
-
Send a request to the Patron API to delete a linked fare card.
Sample response:
Declaration
Swift
public func deleteCardLink(token: String? = nil, mediaId: String, patronId: Int, success: SuccessHandler?, failure: FailureHandler?)Parameters
tokenThe token of current logged user
mediaIdId of media aka fare card
patronIdId of the linked patron
successSuccess callback
failureFailure callback
-
Send a request to the Patron API to report lost or slolen of a fare card.
Sample response:
Declaration
Swift
public func reportLostOrStolen(token: String? = nil, mediaId: String, ticketCallback: @escaping (Ticket) -> (), failure: FailureHandler?)Parameters
tokenThe token of current logged user
mediaIdId of media aka fare card
ticketCallbackSuccess callback
failureFailure callback
-
Send a request to the Patron API to get linked patrons.
Sample response:
Declaration
Swift
public func getLinkedPatrons(token: String? = nil, mediaId: String, patronsCallback: @escaping ([Patron]) -> (), failure: FailureHandler?)Parameters
tokenThe token of current logged user
mediaIdId of media
patronsCallbackSuccess callback
failureFailure callback
-
Send a request to the Patron API to add an user profile.
Sample response:
Declaration
Swift
public func addProfile(token: String? = nil, enrollmentCode: String, mediaId: String, profileCallback: @escaping (Profile) -> (), failure: FailureHandler?)Parameters
tokenThe token of current logged user
enrollmentCodeEnrollment code
mediaIdId of media
profilesCallbackSuccess callback
failureFailure callback
-
Send a request to the Patron API to get user profiles.
Sample response:
Declaration
Swift
public func getProfiles(token: String? = nil, mediaId: String, profilesCallback: @escaping ([Profile]) -> (), failure: FailureHandler?)Parameters
tokenThe token of current logged user
mediaIdId of media
profilesCallbackSuccess callback
failureFailure callback
-
Send a request to the Patron API to create a message.
Sample response:
Declaration
Swift
public func createMessage(token: String? = nil, title: String?, body: String, attachments: [Attachment]?, callback: @escaping (Message) -> Void, failure: FailureHandler?)Parameters
tokenThe token of current logged user
titleThe title of message
bodyThe content of message
attachmentsThe list of attachments
successSuccess callback
failureFailure callback
-
Send a request to the Patron API to get messages.
Sample response:
Declaration
Swift
public func getMessages(token: String? = nil, page: Int? = 1, callback: @escaping (WrapMessage?) -> Void, failure: FailureHandler?)Parameters
tokenThe token of current logged user
pageFor pagination , page index of messages, start at 1
successSuccess callback
failureFailure callback
-
Send a request to the Patron API to update a message.
Sample response:
Declaration
Swift
public func updateMessage(token: String? = nil, messageId: Int, title: String?, body: String?, callback: @escaping (Message) -> Void, failure: FailureHandler?)Parameters
tokenThe token of current logged user
messageIdId of the parent message
successSuccess callback
failureFailure callback
-
Send a request to the Patron API to delete a message.
Sample response:
Declaration
Swift
public func deleteMessage(token: String? = nil, messageId: Int, success: SuccessHandler?, failure: FailureHandler?)Parameters
tokenThe token of current logged user
messageIdId of the parent message
successSuccess callback
failureFailure callback
-
Send a request to the Patron API to get replies.
Sample response:
Declaration
Swift
public func getReplies(token: String? = nil, messageId: Int, page: Int? = 1, callback: @escaping (WrapMessage?) -> Void, failure: FailureHandler?)Parameters
tokenThe token of current logged user
messageIdId of the parent message
pageFor pagination , page index of relies
successSuccess callback
failureFailure callback
-
Send a request to the Patron API to get a reply.
Sample response:
Declaration
Swift
public func getReply(token: String? = nil, messageId: Int, replyId: Int, callback: @escaping (Message) -> Void, failure: FailureHandler?)Parameters
tokenThe token of current logged user
messageIdId of the parent message
replyIdId of the reply
successSuccess callback
failureFailure callback
-
Send a request to the Patron API to create a reply.
Sample response:
Declaration
Swift
public func createReply(token: String? = nil, messageId: Int, body: String?, attachments: [Attachment]?, callback: @escaping (Message) -> Void, failure: FailureHandler?)Parameters
tokenThe token of current logged user
messageIdId of the parent message
attachmentsAttachment list
successSuccess callback
failureFailure callback
-
Send a request to the Patron API to update a reply.
Sample response:
Declaration
Swift
public func updateReply(token: String? = nil, messageId: Int, replyId: Int, body: String?, callback: @escaping (Message) -> Void, failure: FailureHandler?)Parameters
tokenThe token of current logged user
messageIdId of the parent message
replyIdId of the reply
successSuccess callback
failureFailure callback
-
Send a request to the Patron API to delete a reply.
Sample response:
Declaration
Swift
public func deleteReply(token: String? = nil, messageId: Int, replyId: Int, success: SuccessHandler?, failure: FailureHandler?)Parameters
tokenThe token of current logged user
messageIdId of the parent message
replyIdId of the reply
successSuccess callback
failureFailure callback
-
Send a request to the Patron API to get details of an attachment.
Sample response:
Declaration
Swift
public func getAttachment(token: String? = nil, attachmentId: Int, success: SuccessDataHandler?, failure: FailureHandler?)Parameters
tokenThe token of current logged user
attachmentIdId of the attachment
successSuccess callback
failureFailure callback
-
Send a request to the Patron API to delete an attachment.
Sample response:
Declaration
Swift
public func deleteAttachment(token: String? = nil, attachmentId: Int, success: SuccessHandler?, failure: FailureHandler?)Parameters
tokenThe token of current logged user
attachmentIdId of the attachment
successSuccess callback
failureFailure callback
-
showMessage - Deprecated
Declaration
Swift
@available(*, deprecated, message: "Not available anymore") public func showMessage(token: String, messageId: String, messageCallback: @escaping (Message) -> (), failure: FailureHandler?) -
readAllMessages - Deprecated
Declaration
Swift
@available(*, deprecated, message: "Not available anymore") public func readAllMessages(token: String, success: SuccessHandler?, failure: FailureHandler?) -
getUnReadMessages - Deprecated
Declaration
Swift
@available(*, deprecated, message: "Not available anymore - unread count will be get inside GetMessages") public func getUnReadMessages(token: String, callback: @escaping (Int) -> (), failure: FailureHandler?) -
markMessageAsRead - Deprecated
Declaration
Swift
@available(*, deprecated, message: "Not available anymore") public func markMessageAsRead(token: String, messageId: String, messageCallback: @escaping (Message) -> (), failure: FailureHandler?) -
markThreadAsRead - Deprecated
Declaration
Swift
@available(*, deprecated, message: "Not available anymore") public func markThreadAsRead(token: String, threadId: String, threadCallback: @escaping (Thread?) -> (), failure: FailureHandler?) -
indexThreads - Deprecated
Declaration
Swift
@available(*, deprecated, message: "Not available anymore") public func indexThreads(token: String, success: SuccessHandler?, failure: FailureHandler?) -
availableThreads - Deprecated
Declaration
Swift
@available(*, deprecated, message: "Not available anymore - Use get Messages instead") public func availableThreads(token: String, threadsCallback: @escaping ([ThreadMessage]) -> (), failure: FailureHandler?) -
showThread - Deprecated
Declaration
Swift
@available(*, deprecated, message: "Not available anymore - Use Get Message instead") public func showThread(token: String, threadId: String, threadCallback: @escaping (Thread?) -> (), failure: FailureHandler?) -
readThreadMessages - Deprecated
Declaration
Swift
@available(*, deprecated, message: "Not available anymore") public func readThreadMessages(token: String, threadId: String, messagesCallback: @escaping ([Message]) -> (), failure: FailureHandler?) -
Send a request to the Patron API that post a message to thread. =
Sample response: post id only, you need to call show thread in order to load all message, or load local one
Declaration
Swift
@available(*, deprecated, message: "Not available anymore - use Create Message API instead") public func postToThread(token: String, threadId: String, body: String, messageCallback: @escaping (Message?) -> (), failure: FailureHandler?)Parameters
tokenuser current login token
threadIdthread id
bodybody message
callbackCallback executed after the request end.
-
deleteMessage - Deprecated
Declaration
Swift
@available(*, deprecated, message: "Not available anymore") public func deleteMessage(token: String, messageId: String, success: SuccessHandler?, failure: FailureHandler?) -
deleteThread - Deprecated
Declaration
Swift
@available(*, deprecated, message: "Not available anymore") public func deleteThread(token: String, threadId: String, success: SuccessHandler?, failure: FailureHandler?)
-
Send a request to the Patron API to get application parameters.
Sample response:
Declaration
Swift
public func getAppParams(packageName: String, versionName: String, paramsCallback: @escaping ([AppParam]) -> (), failure: FailureHandler?)Parameters
packageNameThe Bundle identifier of the app
versionNameCurrent app version
paramsCallbackSuccess callback
failureFailure callback
-
Send a request to the Patron API to citation list.
Sample response:
Declaration
Swift
public func getCitations(token: String? = nil, citationsCallback: @escaping ([[String : [Citation]]]) -> (), failure: FailureHandler?)Parameters
tokenThe token of current logged user
citationsCallbackThe callback on request end
-
Send a request to the Patron API to make the payment of a single citation.
Sample response:
Declaration
Swift
public func payCitation(token: String? = nil, citationId: Int, cardId: Int, citationCallback: @escaping (Citation?) -> (), failure: FailureHandler?)Parameters
tokenThe token of current logged user
citationIdId of citation
cardIdId of a wallet
citationsCallbackThe callback on request end
-
Send a request to the Patron API to make the payment of a list of citations.
Sample response:
Declaration
Swift
public func payCitations(token: String? = nil, citationIds: [Int], cardId: Int, citationsCallback: @escaping ([String : [Citation]]) -> (), failure: FailureHandler?)Parameters
tokenThe token of current logged user
citationIdsList of citation Ids
cardIdId of a wallet
citationsCallbackThe callback on request end
-
Send a request to the Patron API to create an address.
Sample response:
Declaration
Swift
public func createAddress(token: String? = nil, address: Address, complete: @escaping (Address?) -> (), failure: FailureHandler?)Parameters
tokenThe token of current logged user
addressAddress object
completeSuccess callback
failureFailure callback
-
Send a request to the Patron API to update an address.
Sample response:
Declaration
Swift
public func updateAddress(token: String? = nil, address: Address, complete: @escaping (Address?) -> (), failure: FailureHandler?)Parameters
tokenThe token of current logged user
addressAddress object
completeSuccess callback
failureFailure callback
-
Send a request to the Patron API to get address list.
Sample response:
Declaration
Swift
public func getAddresses(token: String? = nil, complete: @escaping ([Address]) -> (), failure: FailureHandler?)Parameters
tokenThe token of current logged user
completeSuccess callback
failureFailure callback
-
Send a request to the Patron API to delete an address.
Sample response:
Declaration
Swift
public func deleteAddress(token: String? = nil, addressId: Int, success: SuccessHandler?, failure: FailureHandler?)Parameters
tokenToken of current logged user
addressIdId of the address
successSuccess callback
failureFailure callback
-
getSimplePayToken(cardNumber:expMonth:expYear:cvv:cardBrand:cardHolder:simplePayUrl:simplePayAuthenToken:entityId:complete:)Send a request to the SIMPLE PAY Server to get the simple-pay token.
Sample response:
Declaration
Swift
public func getSimplePayToken(cardNumber: String, expMonth: String, expYear: String, cvv: String, cardBrand: String, cardHolder: String, simplePayUrl: String, simplePayAuthenToken: String, entityId: String, complete: @escaping (_ token: String?) -> Void)Parameters
tokenToken of current logged user
cardNumberCredit card number
expMonthCredit card expiry month
expYearCredit card expiry year
cvvCredit card cvv
cardBrandCredit card brand
cardHolderCredit card name
simplePayUrlSimplePay server url
simplePayAuthenTokenSimplePay authentication token
entityIdEntity Id
completeCallback executed after the request end.
-
Send a request to the Patron API to get notifation settings by email.
Sample response:
Declaration
Swift
public func getNotificationByEmail(token: String? = nil, notificationCallback: @escaping (Bool) -> (), failure: FailureHandler?)Parameters
tokenToken of current logged user
notificationCallbackCallback executed after the request end.
-
Send a request to the Patron API to change notifation settings by email.
Sample response:
Declaration
Swift
public func setNotificationByEmail(token: String, isOn: Int, notificationCallback: @escaping (Bool) -> (), failure: FailureHandler?)Parameters
tokenToken of current logged user
isOnTo turn on/off for receiving notification
notificationCallbackCallback executed after the request end.
-
Send a request to the Patron API to get notifation settings by text.
Sample response:
Declaration
Swift
public func getNotificationByText(token: String? = nil, notificationCallback: @escaping (Bool) -> (), failure: FailureHandler?)Parameters
tokenToken of current logged user
notificationCallbackCallback executed after the request end.
-
Send a request to the Patron API to change notifation settings by text.
Sample response:
Declaration
Swift
public func setNotificationByText(token: String? = nil, isOn: Int, notificationCallback: @escaping (Bool) -> (), failure: FailureHandler?)Parameters
tokenToken of current logged user
isOnTo turn on/off for receiving notification
notificationCallbackCallback executed after the request end.
-
Send a request to the Patron API to get notifation settings by credit card.
Sample response:
Declaration
Swift
public func getNotificationByCreditCard(token: String? = nil, notificationCallback: @escaping (Bool) -> (), failure: FailureHandler?)Parameters
tokenToken of current logged user
notificationCallbackCallback executed after the request end.
-
Send a request to the Patron API to change notifation settings by credit card.
Sample response:
Declaration
Swift
public func setNotificationByCreditCard(token: String? = nil, isOn: Int, notificationCallback: @escaping (Bool) -> (), failure: FailureHandler?)Parameters
tokenToken of current logged user
isOnTo turn on/off for receiving notification
notificationCallbackCallback executed after the request end.
-
Send a request to the Patron API to get transaction histories.
Sample response:
Declaration
Swift
public func getTransactionHistories(token: String? = nil, mediaId: String? = nil, callback: @escaping ([TransactionHistory]) -> (), failure: FailureHandler?)Parameters
tokenuser current login token
mediaIdId of the media
callbackCallback executed after the request end.
-
Send a request to the Patron API to get recent transaction history.
Sample response:
Declaration
Swift
public func getRecentTransactionHistories(token: String? = nil, mediaId: String? = nil, callback: @escaping ([TransactionHistory]) -> (), failure: FailureHandler?)Parameters
tokenuser current login token
mediaIdId of the media
callbackCallback executed after the request end.
-
Send a request to the Patron API to get the pass list.
Sample response:
Declaration
Swift
public func getPasses(token: String? = nil, callback: @escaping ([Pass]) -> (), failure: FailureHandler?)Parameters
tokenuser current login token
callbackCallback executed after the request end.
-
Send a request to the Patron API to get the detais of a pass.
Sample response:
Declaration
Swift
public func showPass(token: String? = nil, passId: Int, callback: @escaping (Pass?) -> (), failure: FailureHandler?)Parameters
tokenuser current login token
passIdId of the pass
callbackCallback executed after the request end.
-
Send a request to the Patron API to create a pass.
Sample response:
Declaration
Swift
public func createPass(token: String? = nil, productId: Int, concessionId: Int, programId: Int?, callback: @escaping (Pass) -> (), failure: FailureHandler?)Parameters
tokenuser current login token
productIdId of the product
concessionIdId of the concession
programIdId of the program
callbackCallback executed after the request end.
-
Send a request to the Patron API to active a pass.
Sample response:
Declaration
Swift
public func activePass(token: String? = nil, passId: Int, createdAt: Int, callback: @escaping (Pass) -> (), failure: FailureHandler?)Parameters
tokenuser current login token
passIdId of the pass
createdAtThe timestamp
callbackCallback executed after the request end.
-
Send a request to the Patron API to get locations for displaying in the map.
Sample response:
Declaration
Swift
public func getLocations(token: String? = nil, callback: @escaping ([PFareLocation]) -> (), failure: FailureHandler?)Parameters
tokenuser current login token
callbackCallback executed after the request end.
-
Send a request to the Patron API to get fare list.
Sample response:
Declaration
Swift
public func getFares(token: String? = nil, callback: @escaping ([PProvider]) -> (), failure: FailureHandler?)Parameters
tokenuser current login token
callbackCallback executed after the request end.
-
Send a request to the Patron API to get product list of a location.
Sample response:
Declaration
Swift
public func getProductsLocation(token: String? = nil, locationId: Int, callback: @escaping ([PProduct]) -> (), failure: FailureHandler?)Parameters
tokenuser current login token
locationIdId of a location
callbackCallback executed after the request end.
-
Send a request to the Patron API to get the details of a location.
Sample response:
Declaration
Swift
public func getLocation(token: String? = nil, locationId: Int, callback: @escaping (PFareLocation?) -> (), failure: FailureHandler?)Parameters
tokenuser current login token
locationIdId of a location
callbackCallback executed after the request end.
-
Add pass to cart
The result will be PCart object, where contains items
Declaration
Swift
public func addToCart(productFareItemId: Int, locationId: Int, quantity: Int, callback: @escaping (PCart?) -> (), failure: FailureHandler?)Parameters
productFareItemIdThe product fare item that under concession object, where the consession is under product
locationIdThe root object of id
quantityThe number of item need to be added
-
Check out a cart
Response 204 if success
Declaration
Swift
public func checkoutCart(paymentCartId: Int, success: SuccessHandler?, failure: FailureHandler?)Parameters
paymentCartIdThe payment cart id that is used to checkout (payment)
-
Get list cart summary
- Return PCart object, where contains items
Declaration
Swift
public func getCartSummary(callback: @escaping (PCart?) -> (), failure: FailureHandler?) -
Delete cart item
Response Code 204 if success
Declaration
Swift
public func deleteCartItem(itemId: Int, success: SuccessHandler?, failure: FailureHandler?)Parameters
cartIdThe cart id needs to be deleted
-
Delete all cart summary. All carts in Cart summary list will be deleted and empty
- Result Code 204 if success
Declaration
Swift
public func deleteCartSummary(success: SuccessHandler?, failure: FailureHandler?) -
Update cart item
Response PCart object with new items
Declaration
Swift
public func updateCartItem(cartId: Int, quantity: Int, callback: @escaping (PCart?) -> (), failure: FailureHandler?)Parameters
cartIdThe cart need to be updated
quantityThe number of new item need to be adjusted
PatronProxy Class Reference