Introduction
Welcome to the official API documentation for Shoyu, a powerful data retrieval and manipulation library.
Installation
To begin using Shoyu in your project, follow these installation steps:
- Open your terminal and navigate to the root directory of your project
- Run the following command to install Shoyu via CocoaPods:
pod 'Shoyu'
Basic Usage
Shoyu provides a straightforward syntax for fetching and modifying data. Below are some examples of common tasks:
Fetching Data
To fetch data from a source, use the fetch()
function. Here’s an example:
let data = Shoyu.fetch(from: "https://api.example.com/data")
Modifying Data
To modify data, you can use the various methods provided by Shoyu. Here’s an example of modifying an array:
var array = [1, 2, 3]
array.append(4)
array.remove(at: 1)
Advanced Features
Caching
Shoyu offers built-in caching functionality. To enable caching, use the enableCaching()
method:
Shoyu.enableCaching()
Error Handling
Shoyu provides robust error handling capabilities. You can catch and handle errors using Swift’s do-try-catch
syntax:
do {
try Shoyu.fetch(from: "https://api.example.com/data")
} catch {
print("An error occurred: \(error)")
}
Pagination
Shoyu simplifies pagination by providing a pagination
property. Here’s an example:
let pagination = Shoyu.pagination(pageSize: 20, pageNumber: 1)
Shoyu.fetch(from: "https://api.example.com/data", pagination: pagination)
Conclusion
Congratulations! You now have a basic understanding of Shoyu’s API. Feel free to explore the documentation further to discover more advanced features and capabilities.