Skip to content

Commit

Permalink
updated to v 2.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
dmi-nikhil committed Oct 29, 2018
2 parents 0e1871e + 04a1979 commit c0797c8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 35 deletions.
Binary file modified .DS_Store
Binary file not shown.
8 changes: 8 additions & 0 deletions Documentation/Usage.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Twister


## Thanks for checking this repo

We appreciate your patience, we are working on updating the Usage document.

If you are willing to contribute please go through the Contribution section of Readme.md
36 changes: 1 addition & 35 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)
[![CocoaPods Compatible](https://img.shields.io/cocoapods/v/Twister.svg)](https://cocoapods.org/pods/Twister)
![Platform](https://img.shields.io/cocoapods/p/Twister.svg?style=flat)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)

Twister makes it easy to write a type safe network layer for any API. What it only needs is a model expected as API response, to confirm 'Codable(Encodable&Decodable)' protocol.

Expand Down Expand Up @@ -36,41 +37,6 @@ github "nikksindia/Twister"
2. Download and drop ```Twister.swift``` in your project.
3. Congratulations!

## Usage

Follows these steps:

1. Create a codable model for your response. See example below:
```swift
struct Channel:Codable{
var id:String?
var kind:String?
var etag:String?
var userId:String?
}
```
2. Create a struct to manage all your endpoints. See example below:
```swift
let baseUrl = "https://www.yourdomain.com/v3/"
struct TwistRoutes{
static let channelList = Route<Channel>(baseUrl:baseUrl,endPoint:"channels",methodType:.get)
static let productList = Route<Product>(baseUrl:baseUrl,endPoint:"products",methodType:.post)
}
```
3. Now you are ready to call API using Twister. Go to your view controller and use 'apiRequest' method as follows:
```swift
let params = ["mine":true,"part":"contentDetails"] as [String : AnyObject]
let header = ["authKey":"CRREW11472"]
Twister.sharedInstance.apiRequest(fromRoute: TwistRoutes.channelList,params,header) { (result) in
switch result {
case .success(let model):
print (model)
case .failure(let error):
print (error)
}
}
```

## Contribute

We would love you for the contribution to **Twister**, check the ``LICENSE`` file for more info.
Expand Down

0 comments on commit c0797c8

Please sign in to comment.