Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
mahabaleshwarhnr authored Apr 13, 2020
1 parent fa39945 commit 07f502c
Showing 1 changed file with 25 additions and 7 deletions.
32 changes: 25 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,43 @@
# Cheeta
Cheeta is very simple and lightweight networking library.

## How to use?
Download network folder and replace exisiting base URL your URL in `APIRequest` class
## Installation

## Example
1. Configure API Manager
dependencies: [
.package(url: "https://github.com/mahabaleshwarhnr/Cheeta.git", .exact(from: "1.0.1"))
]

## Documentation

1. Register your API base URL in `AppDelegate` . You can change base URL based on test or debug or production configuration.

func application(_ application: UIApplication, didFinishLaunchingWithOptions
launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
let baseURL = URL(string: "https://itunes.apple.com/")!
APIConfig.config.register(baseURL: baseURL)
return true
}
Note: Your base URL should always ends with path(/)

2. Configure API Manager
You can directly use APIManager static instance `APIManager.shared`. It uses default session configuration.

You can also pass your own session to initialize the APIManager

let apiManager = APIManager(session: .init(configuration: .default, delegate: nil, delegateQueue: .main))`

2. Create your request
3. Create your request

let query = ["term": searchTerm, "limit": "50"]
let apiRequest = APIRequest(endPoint: MusicEnpoints.search, method: .get, payload: nil, queryParams: query)
endPoint argumnent should conforms to APIEndPoint protocol. By default `String` is conformed to APIEndPoint Protocol.
You can also create a request following way

let apiRequest = APIRequest(endPoint: "search", method: .get, payload: nil, queryParams: query)


You can also write your own APIRequest Implementation.

3. Execute Request
4. Execute Request

apiManager.sendRequest(request: apiRequest, responseType: MusicSearchResultContainer.self) { (response) in
switch response {
Expand All @@ -32,3 +47,6 @@ Download network folder and replace exisiting base URL your URL in `APIRequest`
print("failed: \(error.userInfo)")
}
}


0 comments on commit 07f502c

Please sign in to comment.