NetworkServiceImpl
class NetworkServiceImpl : NetworkService
extension NetworkServiceImpl: OfflineRequestManagerDelegate
                Production implementation of NetworkService
- 
                  
                  
Direct accessor for connection status
Declaration
Swift
var isConnected: Bool { get } - 
                  
                  
Direct accessor for queued requests
Declaration
Swift
var requests: [OfflineRequest] { get } - 
                  
                  
Direct accessor for network controller
Declaration
Swift
let mtp: MTPNetworkController - 
                  
                  
Construction by injection
Declaration
Swift
init(controller: MTPNetworkController = MTPNetworkController())Parameters
controllerMTPNetworkController
 
- 
                  
                  
Send contact form
Declaration
Swift
func contact(payload: ContactPayload, then: @escaping NetworkCompletion<String>)Parameters
payloadContact payload
thenCompletion
 - 
                  
                  
Load location photos
Declaration
Swift
func loadPhotos(location id: Int, reload: Bool, then: @escaping NetworkCompletion<PhotosInfoJSON>)Parameters
idLocation ID
reloadForce reload
thenCompletion
 - 
                  
                  
Load logged in user photos
Declaration
Swift
func loadPhotos(page: Int, reload: Bool, then: @escaping NetworkCompletion<PhotosPageInfoJSON>)Parameters
pageIndex
reloadForce reload
thenCompletion
 - 
                  
                  
Load user photos
Declaration
Swift
func loadPhotos(profile id: Int, page: Int, reload: Bool, then: @escaping NetworkCompletion<PhotosPageInfoJSON>)Parameters
idUser ID
pageIndex
reloadForce reload
thenCompletion
 - 
                  
                  
Load location posts
Declaration
Swift
func loadPosts(location id: Int, reload: Bool, then: @escaping NetworkCompletion<PostsJSON>)Parameters
idLocation ID
reloadForce reload
thenCompletion
 - 
                  
                  
Load user posts
Declaration
Swift
func loadPosts(user id: Int, reload: Bool, then: @escaping NetworkCompletion<PostsJSON>)Parameters
idUser ID
reloadForce reload
thenCompletion
 - 
                  
                  
Load rankings
Declaration
Swift
func loadRankings(query: RankingsQuery, then: @escaping NetworkCompletion<RankingsPageInfoJSON>)Parameters
queryFilter
thenCompletion
 - 
                  
                  
Load scorecard
Declaration
Swift
func loadScorecard(list: Checklist, user id: Int, then: @escaping NetworkCompletion<ScorecardJSON>)Parameters
listChecklist
idUser ID
thenCompletion
 - 
                  
                  
Load user
Declaration
Swift
func loadUser(id: Int, then: @escaping NetworkCompletion<UserJSON>)Parameters
idUser ID
thenCompletion
 - 
                  
                  
Search
Declaration
Swift
func search(query: String, then: @escaping NetworkCompletion<SearchResultJSON>)Parameters
queryQuery
thenCompletion
 - 
                  
                  
Set places visit status
Declaration
Swift
func set(items: [Checklist.Item], visited: Bool, then: @escaping NetworkCompletion<Bool>)Parameters
itemsPlaces
visitedWhether visited
thenCompletion
 - 
                  
                  
Upload photo
Declaration
Swift
func upload(photo: Data, caption: String?, location id: Int?, then: @escaping NetworkCompletion<PhotoReply>)Parameters
photoData
captionString
idLocation ID if any
thenCompletion
 - 
                  
                  
Update photo
Declaration
Swift
func photoUpdate(payload: PhotoUpdatePayload, then: @escaping NetworkCompletion<Bool>)Parameters
payloadUserUpdatePayload
thenCompletion
 - 
                  
                  
Delete photo
Declaration
Swift
func delete(photo: Int, then: @escaping NetworkCompletion<Bool>)Parameters
photoInt
thenCompletion
 - 
                  
                  
Publish post
Declaration
Swift
func postPublish(payload: PostPayload, then: @escaping NetworkCompletion<PostReply>)Parameters
payloadPost payload
thenCompletion
 - 
                  
                  
Update post
Declaration
Swift
func postUpdate(payload: PostUpdatePayload, then: @escaping NetworkCompletion<Bool>)Parameters
payloadPostUpdatePayload
thenCompletion
 - 
                  
                  
Delete post
Declaration
Swift
func delete(post: Int, then: @escaping NetworkCompletion<Bool>)Parameters
oistInt
thenCompletion
 - 
                  
                  
Delete user account
Declaration
Swift
func userDeleteAccount(then: @escaping NetworkCompletion<String>)Parameters
thenCompletion
 - 
                  
                  
Send reset password link
Declaration
Swift
func userForgotPassword(email: String, then: @escaping NetworkCompletion<String>)Parameters
emailEmail
thenCompletion
 - 
                  
                  
Login user
Declaration
Swift
func userLogin(email: String, password: String, then: @escaping NetworkCompletion<UserJSON>)Parameters
emailEmail
passwordPassword
thenCompletion
 - 
                  
                  
Register new user
Declaration
Swift
func userRegister(payload: RegistrationPayload, then: @escaping NetworkCompletion<UserJSON>)Parameters
payloadRegistrationPayload
thenCompletion
 - 
                  
                  
Update user info
Declaration
Swift
func userUpdate(payload: UserUpdatePayload, then: @escaping NetworkCompletion<UserJSON>)Parameters
payloadUserUpdatePayload
thenCompletion
 - 
                  
                  
Update user token
Declaration
Swift
func userUpdate(token: String, then: @escaping NetworkCompletion<UserTokenReply>)Parameters
tokenString
thenCompletion
 - 
                  
                  
Resend verification email
Declaration
Swift
func userVerify(id: Int, then: @escaping NetworkCompletion<String>)Parameters
idUser ID
thenCompletion
 - 
                  
                  
Refresh first page of each list’s rankings
Declaration
Swift
func refreshRankings() - 
                  
                  
Refresh everything
Declaration
Swift
func refreshEverything() - 
                  
                  
Reset all networking
Declaration
Swift
func logout() 
- 
                  
                  
Method that the delegate uses to generate OfflineRequest objects from dictionaries written to disk
Declaration
Swift
func offlineRequest(withDictionary dictionary: [String : Any]) -> OfflineRequest?Parameters
dictionarydictionary saved to disk associated with an unfinished request
Return Value
OfflineRequest object to be queued
 - 
                  
                  
Callback indicating the OfflineRequestManager’s current progress
Declaration
Swift
func offlineRequestManager(_ manager: OfflineRequestManager, didUpdateProgress progress: Double)Parameters
managerOfflineRequestManager instance
progresscurrent progress for all ongoing requests (ranges from 0 to 1)
 - 
                  
                  
Callback indicating the OfflineRequestManager’s current connection status
Declaration
Swift
func offlineRequestManager(_ manager: OfflineRequestManager, didUpdateConnectionStatus connected: Bool)Parameters
managerOfflineRequestManager instance
connectedvalue indicating whether there is currently connectivity
 - 
                  
                  
Callback that can be used to block a request attempt
- manager: OfflineRequestManager instance
 - request: OfflineRequest to be performed
 
Declaration
Swift
func offlineRequestManager(_ manager: OfflineRequestManager, shouldAttemptRequest request: OfflineRequest) -> BoolReturn Value
value indicating whether the OfflineRequestManager should move forward with the request attempt
 - 
                  
                  
Callback to reconfigure and reattempt an OfflineRequest after a failure not related to connectivity issues
Declaration
Swift
func offlineRequestManager(_ manager: OfflineRequestManager, shouldReattemptRequest request: OfflineRequest, withError error: Error) -> BoolParameters
managerOfflineRequestManager instance
requestOfflineRequest that failed
errorNSError associated with the failure
Return Value
value indicating whether the OfflineRequestManager should reattempt the OfflineRequest action
 - 
                  
                  
Callback indicating that the OfflineRequest action has started
Declaration
Swift
func offlineRequestManager(_ manager: OfflineRequestManager, didStartRequest request: OfflineRequest)Parameters
managerOfflineRequestManager instance
requestOfflineRequest that started its action
 - 
                  
                  
Callback indicating that the OfflineRequest status has changed
Declaration
Swift
func offlineRequestManager(_ manager: OfflineRequestManager, didUpdateRequest request: OfflineRequest)Parameters
managerOfflineRequestManager instance
requestOfflineRequest that changed its subtitle
 - 
                  
                  
Callback indicating that the OfflineRequest action has successfully finished
Declaration
Swift
func offlineRequestManager(_ manager: OfflineRequestManager, didFinishRequest request: OfflineRequest)Parameters
managerOfflineRequestManager instance
requestOfflineRequest that finished its action
 - 
                  
                  
Callback indicating that the OfflineRequest action has failed for reasons unrelated to connectivity
Declaration
Swift
func offlineRequestManager(_ manager: OfflineRequestManager, requestDidFail request: OfflineRequest, withError error: Error)Parameters
managerOfflineRequestManager instance
requestOfflineRequest that failed
errorNSError associated with the failure
 
            View on GitHub
          
      NetworkServiceImpl Class Reference