iOS programming assignment specifications 2

Assignment specifications document 2.

.

This is the second specifications document for the programming assignment.

Here is a link back to the first specifications document.

Here is a link back to the programming assignment introduction.

.

March 20 design session whiteboards

Here are the whiteboard contents from our March 20 in-class design session.

Arranged from left-to-right.

mar-20-left

.

mar-20-middle

.

mar-20-right

.

Next due date, expectations and marking guide

The next due date and time is Monday, March 31, 2014, at 5:00pm ET.

Plan to do the following. (If you do more, that’s OK.)

  1. Fetch equipment items from the web service
  2. Enable ‘edit player’ (which also works for ‘add player’)
  3. Enable ‘set/configure equipment item’
  4. Enable ‘add new equipment item’ functionality

Submit your work by uploading to the My.Seneca/Blackboard link. The upload link will disappear after the due date and time, so don’t be late!

.

Use this web service

A web service has been created for this programming assignment.

If you have not worked with a web service, and need to know what a web service is: A web service is an application that runs on a web server, and is accessed programmatically.

Your iOS app will use this web service for the following tasks:

1. Login

2. As a data source, to load team and player data when the app launches for the first time

3. As a data source, for equipment information

The root of the web service is here: (to be announced)

(more to come)

.

Security topics

Many web service resources require authorization. Your request must include an authorization token for the resource.

How do you get a token?

From your professor’s authentication and token distribution service.

Your first task is to use the web site to create an account. Select the “Editor” role.

Then, you can use your credentials to get an access token. You can test this functionality by using the JSON Formatter & Validator web app. However, you will do this programmatically in your iOS app, specifically in your Login class.

Use the following URL to get an access token. Replace the red-coloured text with your own username and password:

http://warp.senecac.on.ca:81/bti420_121a42/mobileappgetaccesstoken.aspx?u=username&p=password&l=120

A successful request will return a JSON object, with one key-value pair. The value is the access token. The token is good for 120 minutes; after that time passes, it will not work, and you will need to get another.

If the request is not successful, the service will return HTTP 403.

For best results, create a declared property in your Model class, and save the token there.

(more to come)

.

Making web service requests

While you are waiting for this assignment’s web service to be completed, you can use this web service to test your work:
http://dps907fall2013.azurewebsites.net/api

Topics:

  • URL format, base + path
  • Collections and Items
  • Read requests – get all, get one, get some filtered
  • Model class requirements for read requests
  • Write requests – add new (and maybe later, update existing, and delete existing)
  • Model class requirements for write requests
  • Refresh (read again) – when? how?

.

URL format, base + path

The WebServiceRequest class has a declared property named “urlBase“. This is the typical format of that URL:
http://dps907fall2013.azurewebsites.net

When you create a WebServiceRequest object, and use its sendRequestToUrlPath:… method, use this typical format of the path portion of the URL (as suggested by the Link property in the web service response data):
/api/gradedworks

.

Collections and Items

Use the JSON Formatter & Validator to learn about a web service’s resources.

Pay attention – some resources are collections, while others are individual items.

.

Read requests – get all, get one, get some filtered

A WebServiceRequest object is initialized with an HTTP GET method, and it expects a JSON response.

Use the object as-is for typical read requests – get all, get one, and get some filtered. Simply configure the sendRequestToUrlPath:… method with the correct path and so on.

.

Model class requirements for read requests

The get all and get some filtered requests return a collection of objects. Therefore, you need a declared property of type NSArray for these.

The get one request returns an object. Therefore, you need a declared property of type NSDictionary for this.

.

Write requests – add new (and maybe later, update existing, and delete existing)

(We’ll start with add new, and time permitting, we’ll do the others.)

After initializing your WebServiceRequest object, set its properties:

The HTTP method is POST, so assign that string to the httpMethod property.

Assign the (NSDictionary) data to the messageBody property.

The web service returns an object. Why? Well, when you send data with your request, its unique object identifier is not yet known. It is assigned by the web service itself. Maybe other properties are configured as well. The point is that the new added object is ‘echoed’ back to you. The HTTP status code for this kind of successful response is 201.

Please note:

When you add equipment items, PLEASE use REAL data. Fetch the data from manufacturer web sites. Here’s some manufacturer/brand names: Bauer, CCM, Easton, Graf, TUUK, Reebok, Sherwood, Winwell, Jofa.

DO NOT add crappy data!

.

Model class requirements for write requests

The add new request returns an object, so it needs an NSDictionary declared property.

It obviously also needs a method that will create a suitable WebServiceRequest object and send it.

.

Refresh (read again) – when? how?

When creating a declared property custom getter for a web service collection, should you request the data every time the declared property is dereferenced by a user? Or should you request after the initial request, and never again? Or should you offer the user a way to ‘refresh’ the collection?

Questions to think about. There’s no right answer. Instead, the answers will be suggested by your app’s purpose and usage.

(more to come)

.

Submitting your work (to My.Seneca/Blackboard)

Follow these instructions to send me your work:

  1. Make sure your project works correctly
  2. Locate your project folder in Finder
  3. Right-click the folder, and choose Compress <ProjectName>, which creates a zip file (make sure the zip file is fairly small, around 500KB or less)
  4. Login to My.Seneca, and in this course’s Assignments area, look for the upload link, and submit your work there

.

.

.

.

.

.

.

.

.

.

.

.

  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: