Upload
others
View
3
Download
0
Embed Size (px)
Citation preview
Mobile Application DevelopmentMyRent Service
Waterford Institute of Technology
November 1, 2016
John Fitzgerald
Waterford Institute of Technology, Mobile Application Development MyRent Service 1/1
MyRent serviceLearning objectives
• Service being provided to facilitate client dev.• Service provided for deployment to localhost.• Service also deployed on Heroku (access provided).
Waterford Institute of Technology, Mobile Application Development MyRent Service 2/1
MyRent service appFile structure
Waterford Institute of Technology, Mobile Application Development MyRent Service 3/1
MyRent service appService JUnit Play tested
Waterford Institute of Technology, Mobile Application Development MyRent Service 4/1
MyRent service appAndroid client development
Waterford Institute of Technology, Mobile Application Development MyRent Service 5/1
MyRent service appModel
• GenericModel extended.• Play Model an alternative.• Generic: allows bespoke id.• Model: auto-generates id.
Waterford Institute of Technology, Mobile Application Development MyRent Service 6/1
MyRent service appUtility class
Enables controller actions to translate to & from Json objects.
Waterford Institute of Technology, Mobile Application Development MyRent Service 7/1
MyRent service appJavaScript Object Notation (JSON)
• Text-based open standard.• Douglas Crockford
originator.• Transmit network data.• Replacing XML.
Waterford Institute of Technology, Mobile Application Development MyRent Service 8/1
MyRent service appGoogle Gson
Waterford Institute of Technology, Mobile Application Development MyRent Service 9/1
MyRent service appController: ResidencesAPI
• Actions do not renderviews.
• Use renderJson toreturn data.
• HTTP responsecodes: OK,notFound.
Waterford Institute of Technology, Mobile Application Development MyRent Service 10/1
MyRent service appController: ResidencesAPI
Waterford Institute of Technology, Mobile Application Development MyRent Service 11/1
MyRent service appController: ResidencesAPI
Waterford Institute of Technology, Mobile Application Development MyRent Service 12/1
MyRent service appController: ResidencesAPI
Waterford Institute of Technology, Mobile Application Development MyRent Service 13/1
MyRent service appController: ResidencesAPI
Waterford Institute of Technology, Mobile Application Development MyRent Service 14/1
MyRent service appController: ResidencesAPI
Waterford Institute of Technology, Mobile Application Development MyRent Service 15/1
MyRent service appRoutes - API
Client application uses these patterns to communicate with service.
Waterford Institute of Technology, Mobile Application Development MyRent Service 16/1
MyRent service appRoutes - API
Waterford Institute of Technology, Mobile Application Development MyRent Service 17/1
MyRent service appTest your API with Postman
GET localhost:9000/api/residences
Waterford Institute of Technology, Mobile Application Development MyRent Service 18/1
MyRent service appPreload sample data
Not compatible with unit testing.
// Bootstrap.java@OnApplicationStartpublic class Bootstrap extends Job {
public void doJob() {if (Residence.count() == 0) {Fixtures.deleteDatabase();Fixtures.loadModels("data.yml");
}}
}
Waterford Institute of Technology, Mobile Application Development MyRent Service 19/1
MyRent service appPreload sample data
Not compatible with unit testing.
// data.ymlResidence(residence_1):
id: 1234geolocation: "52.258136,−7.127810"date: 1448196498688rented: truetenant: Homerzoom: 12.0photo: "photo 1"
Waterford Institute of Technology, Mobile Application Development MyRent Service 20/1
ReferencesRetrofit from Square Open Source
1.Gson User Guidehttps://goo.gl/ZPXTsI [Accessed 2016-10-30]3. Postman (Chrome Web Store)https://goo.gl/1we0lx [Accessed 2016-10-30]
Waterford Institute of Technology, Mobile Application Development MyRent Service 21/1
Waterford Institute of Technology, Mobile Application Development MyRent Service 22/1