-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated README and initial Documentation. Provided basic app samples.
- Loading branch information
Showing
7 changed files
with
156 additions
and
167 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import UIKit | ||
import Fridge | ||
|
||
//MARK: - Basic network Grab example | ||
|
||
// define your URL endpoint | ||
let todoEndpoint = URL(string: "https://jsonplaceholder.typicode.com/todos/")! | ||
|
||
// conform your struct to Decodable | ||
struct ToDo: Decodable { | ||
var id: Int | ||
var title: String | ||
var completed: Bool | ||
} | ||
|
||
//TODO: Use other async methods that serve your needs | ||
async { | ||
print("---> Grabbing all TODO objects from URL endpoint using Fridge") | ||
do { | ||
// ** Grab with Fridge !! ** | ||
let results: [ToDo] = try await Fridge.grab🔮(from: todoEndpoint) | ||
|
||
// do something with results.... | ||
for item in results { | ||
print("ID:\t\(item.id)") | ||
print("Title:\t\(item.title)") | ||
} | ||
} catch let fridgeError { | ||
// handle any errors that we received | ||
print("Grab failed. Error: \(fridgeError)") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import UIKit | ||
import Fridge | ||
|
||
//MARK: - Simple network Push example | ||
|
||
// define your URL endpoint | ||
let networkEndpoint = URL(string: "https://jsonplaceholder.typicode.com/comments/")! | ||
|
||
// Conform your struct to Codable | ||
struct Comment: Codable, CustomDebugStringConvertible { | ||
let postId: Int | ||
let id: Int | ||
let name: String | ||
let email: String | ||
let body: String | ||
|
||
var debugDescription: String { | ||
return "[Comment] (ID:\(id)) \(name) - \(email). Body: \(body)" | ||
} | ||
} | ||
|
||
//TODO: Use other async methods that serve your needs | ||
async { | ||
print("---> Pushing custom struct to URL endpoint using Fridge...") | ||
do { | ||
let newComment = Comment( | ||
postId: 12, | ||
id: 100, | ||
name: "New comment", | ||
email: "[email protected]", | ||
body: "Body of the new comment" | ||
) | ||
|
||
// ** Push data using Fridge !! ** | ||
let response: Comment = try await Fridge.push📡(newComment, to: networkEndpoint) | ||
|
||
// handle response... | ||
print("New comment successfuly pushed") | ||
print("Returned response: ", response) | ||
} catch let fridgeError { | ||
// handle any errors that we received | ||
print("Grab failed. Error: \(fridgeError)") | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
4 changes: 0 additions & 4 deletions
4
Guides/Examples/Fridge basics.playground/contents.xcplayground
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters