Skip to content

Commit

Permalink
Expanded documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
BobDeKort committed Jul 11, 2019
1 parent b31f00d commit 4068ebf
Showing 1 changed file with 54 additions and 14 deletions.
68 changes: 54 additions & 14 deletions README.md
Expand Up @@ -92,12 +92,63 @@ To use nstack for translations, you need to install the [nstack translations gen
}
~~~~

### Responses
Responses allow you to define and update JSON files on the NStack web console and retrieve them using the NStack sdk or using a normal get request.
~~~~swift
NStack.sharedInstance.getContentResponse(id) { (data, error) in
guard error == nil else {
print("Error fetching response with id: \(id)")
return
}

// Use data
}
~~~~

### Collections
Collections is a more structured version of Responses and can be used as an alternative to an simple read API.
See the [feature overview](https://nstack-io.github.io/documentation/features.html) for a more detailed explaination.

~~~~swift
let completion: (NStack.Result<Product>) -> Void = { result in
switch result {
case .success(let data):
print("Fetching collection successful")
print(data)
case .failure(let error):
print("Error fetching collection: \(error)")
}
}

NStack.sharedInstance.fetchCollectionResponse(for: id, completion: completion)
~~~~

### Files
With files you can retrieve files defined on the NStack web console using a normal get request.
The files functionality has not been implemented in the sdk.

~~~~swift
if let url = URL(string: url) {
URLSession.shared.downloadTask(with: url) { (localURL, urlResponse, error) in
guard error == nil else {
print("Error fetching file with url: \(url)")
print(error)
return
}

if let localURL = localURL {
print("Local URL: \(localURL)")
// Use the localURL to modify, use your newly downloaded file
}
}.resume()
}
~~~~

### Version control

Version control informs the user when a new version is available and what new changes are available.
You don't have to do anything to use the version control feature, just include the NStack sdk in your project.
To enable it create a new version on the NStack website.
To enable it create a new version on the NStack web console.
Checkout the [feature overview](https://nstack-io.github.io/documentation/features.html) on how to setup version control.

> **NOTE:** This feature is not yet supported on macOS and watchOS.
Expand All @@ -106,7 +157,7 @@ Checkout the [feature overview](https://nstack-io.github.io/documentation/featur

Messages shows the user a custom message when the app is launched, for example warning them about a server outage.
You don't have to do anything to use the messages feature, just include the NStack sdk in your project.
To show the users a message create one on the NStack website.
To show the users a message create one on the NStack web console.
Checkout the [feature overview](https://nstack-io.github.io/documentation/features.html) on how to setup messages.

> **NOTE:** This feature is not yet supported on macOS and watchOS.
Expand All @@ -115,7 +166,7 @@ Checkout the [feature overview](https://nstack-io.github.io/documentation/featur

Rate reminder shows the user Apple's build in rate reminder after the user has launched the app a certain amount of times.
You don't have to do anything to use the rate reminder feature, just include the NStack sdk in your project.
To enable the rate reminder configure it on the NStack website.
To enable the rate reminder configure it on the NStack web console.
Checkout the [feature overview](https://nstack-io.github.io/documentation/features.html) on how to setup rate reminders.

> **NOTE:** This feature is not yet supported on macOS and watchOS.
Expand All @@ -131,17 +182,6 @@ NStack.sharedInstance.timezone(lat: 12.0, lng: 55.0) { (timezone, error) in
}
~~~~

### Content responses

If you want to make a quick read API you can use NStacks Content Response feature. If you created a content response in the NStack web console fetch the data in the app as:
~~~~swift
NStack.sharedInstance.getContentResponse(60) { (response, error) in
if let _ = response {
//You have the content response
}
}
~~~~

### Validation

NStack makes it possible to validate the syntax and domain of an email, just use:
Expand Down

0 comments on commit 4068ebf

Please sign in to comment.