Skip to content

SwiftRequesto it's a lightweight network layer for iOS application that can execute async and sync URLRequests.

License

Notifications You must be signed in to change notification settings

pavserg/SwiftRequesto

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SwiftRequesto

Requesto it's a lightweight network layer for iOS application that can execute async and sync URLRequests.

Install via CocoaPods:

 pod 'Requesto'

https://cocoapods.org/pods/Requesto

First of all you need to make import:

import Requesto

For common REST requests please use Request().

Example:

let request = Request(owner: ObjectIdentifier.init(self),
          url: "...your url...",
          requestType: .get,
          onSuccess: { response in
               //...response here
          }, onFail: { error in
               //...error here
          })

For synchronous execution use:

request.executeSync(parseAs: ...your type for parsing...)

For asynchronous execution use:

request.executeAsync(parseAs: ...your type for parsing...)

For download operation if you need to download some file:

DownloadRequest.init(owner: ObjectIdentifier(self), url: "https://compote.slate.com/images/18ba92e4-e39b-44a3-af3b-88f735703fa7.png?width=1440&rect=1560x1040&offset=0x0", requestType: .get) { progress in
      // progress
  } onDownloadSuccess: { response in
      let data = try? Data(contentsOf: (response?.location!)!) 
  } onFail: { error in
      // error
  }.executeSync()

We're still working on this network layer, new updates will be available soon. If you have any propositions fell free to contact me: pavlo.dumiak@gmail.com