From d0d64997ba53c5beabff964bb5fc03daf675e4f3 Mon Sep 17 00:00:00 2001 From: nixzhu Date: Thu, 19 May 2016 17:37:35 +0800 Subject: [PATCH] use YepNetworking framework --- Yep/AppDelegate.swift | 1 + Yep/Caches/ImageCache.swift | 1 + Yep/Extensions/UIViewController+Yep.swift | 1 + .../UploadAttachmentOperation.swift | 1 + Yep/Realm/Models.swift | 5 +++-- Yep/Services/OpenGraphService.swift | 1 + Yep/Services/SocialWorkService.swift | 7 +++--- Yep/Services/YepFayeService.swift | 1 + Yep/Services/YepNetworking.swift | 3 ++- Yep/Services/YepService.swift | 1 + Yep/Services/YepServiceSync.swift | 1 + Yep/Services/YepStorageService.swift | 1 + .../ChangeMobileViewController.swift | 1 + ...ersationViewController+TextIndicator.swift | 1 + .../ConversationViewController.swift | 1 + .../Discover/DiscoverViewController.swift | 1 + .../DoNotDisturbPeriodViewController.swift | 1 + .../EditNicknameAndBadgeViewController.swift | 1 + .../EditProfileViewController.swift | 1 + .../EditSkills/EditSkillsViewController.swift | 1 + .../Feedback/FeedbackViewController.swift | 1 + .../Feeds/FeedsViewController.swift | 1 + .../FriendsInContactsViewController.swift | 1 + .../Login/LoginByMobileViewController.swift | 1 + .../LoginVerifyMobileViewController.swift | 1 + .../NewFeed/NewFeedViewController.swift | 1 + .../NotificationsViewController.swift | 1 + .../OAuth/OAuthViewController.swift | 1 + .../Profile/ProfileViewController.swift | 5 +++-- .../RegisterPickAvatarViewController.swift | 1 + .../RegisterPickMobileViewController.swift | 1 + .../RegisterPickSkillsViewController.swift | 1 + .../RegisterSelectSkillsViewController.swift | 1 + .../RegisterVerifyMobileViewController.swift | 1 + .../SearchFeedsViewController.swift | 1 + .../SearchedUsersViewController.swift | 1 + .../SkillHome/SkillHomeViewController.swift | 1 + .../SocialWorkDribbbleViewController.swift | 1 + .../SocialWorkGithubViewController.swift | 1 + .../SocialWorkInstagramViewController.swift | 1 + .../VerifyChangedMobileViewController.swift | 1 + .../ProfileSocialAccountGithubCell.swift | 1 + .../ProfileSocialAccountImagesCell.swift | 1 + YepNetworking/YepNetworking.swift | 22 ++++++++++--------- YepTests/ServiceTests.swift | 8 +++---- 45 files changed, 67 insertions(+), 22 deletions(-) diff --git a/Yep/AppDelegate.swift b/Yep/AppDelegate.swift index 923d34ae9..04ad9c17f 100644 --- a/Yep/AppDelegate.swift +++ b/Yep/AppDelegate.swift @@ -7,6 +7,7 @@ // import UIKit +import YepNetworking import Fabric import AVFoundation import RealmSwift diff --git a/Yep/Caches/ImageCache.swift b/Yep/Caches/ImageCache.swift index 6bbe702f0..1913a55c6 100644 --- a/Yep/Caches/ImageCache.swift +++ b/Yep/Caches/ImageCache.swift @@ -8,6 +8,7 @@ import UIKit import RealmSwift +import YepNetworking import MapKit import Kingfisher diff --git a/Yep/Extensions/UIViewController+Yep.swift b/Yep/Extensions/UIViewController+Yep.swift index 452aaab2a..bbc3a9b11 100644 --- a/Yep/Extensions/UIViewController+Yep.swift +++ b/Yep/Extensions/UIViewController+Yep.swift @@ -7,6 +7,7 @@ // import UIKit +import YepNetworking import SafariServices // MAKR: - Heights diff --git a/Yep/Operations/UploadAttachmentOperation.swift b/Yep/Operations/UploadAttachmentOperation.swift index ff557b3e7..0f2fc59a5 100644 --- a/Yep/Operations/UploadAttachmentOperation.swift +++ b/Yep/Operations/UploadAttachmentOperation.swift @@ -7,6 +7,7 @@ // import Foundation +import YepNetworking final class UploadAttachmentOperation: ConcurrentOperation { diff --git a/Yep/Realm/Models.swift b/Yep/Realm/Models.swift index 6fee8d5e3..702ede0ab 100644 --- a/Yep/Realm/Models.swift +++ b/Yep/Realm/Models.swift @@ -7,8 +7,9 @@ // import UIKit -import RealmSwift import MapKit +import RealmSwift +import YepNetworking // 总是在这个队列里使用 Realm //let realmQueue = dispatch_queue_create("com.Yep.realmQueue", DISPATCH_QUEUE_SERIAL) @@ -1800,7 +1801,7 @@ func videoMetaOfMessage(message: Message) -> (width: CGFloat, height: CGFloat)? // MARK: Update with info -func updateUserWithUserID(userID: String, useUserInfo userInfo: JSONDictionary, inRealm realm: Realm) { +func updateUserWithUserID(userID: String, useUserInfo userInfo: [String: AnyObject], inRealm realm: Realm) { if let user = userWithUserID(userID, inRealm: realm) { diff --git a/Yep/Services/OpenGraphService.swift b/Yep/Services/OpenGraphService.swift index 099503115..2b1bbe0d2 100644 --- a/Yep/Services/OpenGraphService.swift +++ b/Yep/Services/OpenGraphService.swift @@ -6,6 +6,7 @@ // Copyright © 2016年 Catch Inc. All rights reserved. // +import YepNetworking import Alamofire import Kanna diff --git a/Yep/Services/SocialWorkService.swift b/Yep/Services/SocialWorkService.swift index d38d32105..bba1723e4 100644 --- a/Yep/Services/SocialWorkService.swift +++ b/Yep/Services/SocialWorkService.swift @@ -8,12 +8,13 @@ import Foundation import RealmSwift +import YepNetworking private let githubBaseURL = NSURL(string: "https://api.github.com")! private let dribbbleBaseURL = NSURL(string: "https://api.dribbble.com")! private let instagramBaseURL = NSURL(string: "https://api.instagram.com")! -private func githubResource(token token: String, path: String, method: Method, requestParameters: JSONDictionary, parse: JSONDictionary -> A?) -> Resource { +private func githubResource(token token: String, path: String, method: YepNetworking.Method, requestParameters: JSONDictionary, parse: JSONDictionary -> A?) -> Resource { let jsonParse: NSData -> A? = { data in if let json = decodeJSON(data) { @@ -32,7 +33,7 @@ private func githubResource(token token: String, path: String, method: Method return Resource(path: path, method: method, requestBody: jsonBody, headers: headers, parse: jsonParse) } -private func dribbbleResource(token token: String, path: String, method: Method, requestParameters: JSONDictionary, parse: JSONDictionary -> A?) -> Resource { +private func dribbbleResource(token token: String, path: String, method: YepNetworking.Method, requestParameters: JSONDictionary, parse: JSONDictionary -> A?) -> Resource { let jsonParse: NSData -> A? = { data in if let json = decodeJSON(data) { @@ -51,7 +52,7 @@ private func dribbbleResource(token token: String, path: String, method: Meth return Resource(path: path, method: method, requestBody: jsonBody, headers: headers, parse: jsonParse) } -private func instagramResource(token token: String, path: String, method: Method, requestParameters: JSONDictionary, parse: JSONDictionary -> A?) -> Resource { +private func instagramResource(token token: String, path: String, method: YepNetworking.Method, requestParameters: JSONDictionary, parse: JSONDictionary -> A?) -> Resource { let jsonParse: NSData -> A? = { data in if let json = decodeJSON(data) { diff --git a/Yep/Services/YepFayeService.swift b/Yep/Services/YepFayeService.swift index c33b8956b..91525d538 100644 --- a/Yep/Services/YepFayeService.swift +++ b/Yep/Services/YepFayeService.swift @@ -8,6 +8,7 @@ import Foundation import RealmSwift +import YepNetworking protocol YepFayeServiceDelegate: class { diff --git a/Yep/Services/YepNetworking.swift b/Yep/Services/YepNetworking.swift index 67faccc6a..9ec166237 100644 --- a/Yep/Services/YepNetworking.swift +++ b/Yep/Services/YepNetworking.swift @@ -6,6 +6,7 @@ // Copyright (c) 2015年 Catch Inc. All rights reserved. // +/* import UIKit public enum Method: String, CustomStringConvertible { @@ -358,4 +359,4 @@ public func jsonResource(token token: String?, path: String, method: Method, return Resource(path: path, method: method, requestBody: jsonBody, headers: headers, parse: jsonParse) } - +*/ diff --git a/Yep/Services/YepService.swift b/Yep/Services/YepService.swift index 4a023ba35..e3f4f50b0 100644 --- a/Yep/Services/YepService.swift +++ b/Yep/Services/YepService.swift @@ -7,6 +7,7 @@ // import Foundation +import YepNetworking import RealmSwift import CoreLocation import Alamofire diff --git a/Yep/Services/YepServiceSync.swift b/Yep/Services/YepServiceSync.swift index d40266de6..40b9e8ad6 100644 --- a/Yep/Services/YepServiceSync.swift +++ b/Yep/Services/YepServiceSync.swift @@ -7,6 +7,7 @@ // import Foundation +import YepNetworking import RealmSwift enum MessageAge: String { diff --git a/Yep/Services/YepStorageService.swift b/Yep/Services/YepStorageService.swift index 3c44d0a80..6fb26f359 100644 --- a/Yep/Services/YepStorageService.swift +++ b/Yep/Services/YepStorageService.swift @@ -8,6 +8,7 @@ import Foundation import MobileCoreServices.UTType +import YepNetworking import Alamofire /** diff --git a/Yep/ViewControllers/ChangeMobile/ChangeMobileViewController.swift b/Yep/ViewControllers/ChangeMobile/ChangeMobileViewController.swift index 2a227f575..6a252b38c 100644 --- a/Yep/ViewControllers/ChangeMobile/ChangeMobileViewController.swift +++ b/Yep/ViewControllers/ChangeMobile/ChangeMobileViewController.swift @@ -7,6 +7,7 @@ // import UIKit +import YepNetworking import Ruler final class ChangeMobileViewController: UIViewController { diff --git a/Yep/ViewControllers/Conversation/ConversationViewController+TextIndicator.swift b/Yep/ViewControllers/Conversation/ConversationViewController+TextIndicator.swift index 230140111..4a8977dbb 100644 --- a/Yep/ViewControllers/Conversation/ConversationViewController+TextIndicator.swift +++ b/Yep/ViewControllers/Conversation/ConversationViewController+TextIndicator.swift @@ -8,6 +8,7 @@ import UIKit import RealmSwift +import YepNetworking extension ConversationViewController { diff --git a/Yep/ViewControllers/Conversation/ConversationViewController.swift b/Yep/ViewControllers/Conversation/ConversationViewController.swift index bafafd1a1..fb69d720e 100644 --- a/Yep/ViewControllers/Conversation/ConversationViewController.swift +++ b/Yep/ViewControllers/Conversation/ConversationViewController.swift @@ -8,6 +8,7 @@ import UIKit import RealmSwift +import YepNetworking import AVFoundation import MobileCoreServices import MapKit diff --git a/Yep/ViewControllers/Discover/DiscoverViewController.swift b/Yep/ViewControllers/Discover/DiscoverViewController.swift index af420f3e6..7456c8c1f 100644 --- a/Yep/ViewControllers/Discover/DiscoverViewController.swift +++ b/Yep/ViewControllers/Discover/DiscoverViewController.swift @@ -8,6 +8,7 @@ import UIKit import RealmSwift +import YepNetworking enum DiscoverUserMode: Int { case Normal = 0 diff --git a/Yep/ViewControllers/DoNotDisturbPeriod/DoNotDisturbPeriodViewController.swift b/Yep/ViewControllers/DoNotDisturbPeriod/DoNotDisturbPeriodViewController.swift index 593f10587..37bd91265 100644 --- a/Yep/ViewControllers/DoNotDisturbPeriod/DoNotDisturbPeriodViewController.swift +++ b/Yep/ViewControllers/DoNotDisturbPeriod/DoNotDisturbPeriodViewController.swift @@ -8,6 +8,7 @@ import UIKit import RealmSwift +import YepNetworking final class DoNotDisturbPeriodViewController: UIViewController { diff --git a/Yep/ViewControllers/EditNicknameAndBadge/EditNicknameAndBadgeViewController.swift b/Yep/ViewControllers/EditNicknameAndBadge/EditNicknameAndBadgeViewController.swift index 38a2e4da2..07551bc43 100644 --- a/Yep/ViewControllers/EditNicknameAndBadge/EditNicknameAndBadgeViewController.swift +++ b/Yep/ViewControllers/EditNicknameAndBadge/EditNicknameAndBadgeViewController.swift @@ -7,6 +7,7 @@ // import UIKit +import YepNetworking import Ruler final class EditNicknameAndBadgeViewController: UITableViewController { diff --git a/Yep/ViewControllers/EditProfile/EditProfileViewController.swift b/Yep/ViewControllers/EditProfile/EditProfileViewController.swift index 9e907a2ab..863596592 100644 --- a/Yep/ViewControllers/EditProfile/EditProfileViewController.swift +++ b/Yep/ViewControllers/EditProfile/EditProfileViewController.swift @@ -8,6 +8,7 @@ import UIKit import RealmSwift +import YepNetworking import TPKeyboardAvoiding import Proposer import Navi diff --git a/Yep/ViewControllers/EditSkills/EditSkillsViewController.swift b/Yep/ViewControllers/EditSkills/EditSkillsViewController.swift index faa395469..46f1ea2f6 100644 --- a/Yep/ViewControllers/EditSkills/EditSkillsViewController.swift +++ b/Yep/ViewControllers/EditSkills/EditSkillsViewController.swift @@ -7,6 +7,7 @@ // import UIKit +import YepNetworking import Ruler import RealmSwift diff --git a/Yep/ViewControllers/Feedback/FeedbackViewController.swift b/Yep/ViewControllers/Feedback/FeedbackViewController.swift index f31ab2164..5ee1ac3ca 100644 --- a/Yep/ViewControllers/Feedback/FeedbackViewController.swift +++ b/Yep/ViewControllers/Feedback/FeedbackViewController.swift @@ -7,6 +7,7 @@ // import UIKit +import YepNetworking import KeyboardMan import DeviceGuru diff --git a/Yep/ViewControllers/Feeds/FeedsViewController.swift b/Yep/ViewControllers/Feeds/FeedsViewController.swift index 6922b41c2..0b4847b3d 100644 --- a/Yep/ViewControllers/Feeds/FeedsViewController.swift +++ b/Yep/ViewControllers/Feeds/FeedsViewController.swift @@ -8,6 +8,7 @@ import UIKit import RealmSwift +import YepNetworking import AVFoundation import MapKit import Ruler diff --git a/Yep/ViewControllers/FriendsInContacts/FriendsInContactsViewController.swift b/Yep/ViewControllers/FriendsInContacts/FriendsInContactsViewController.swift index faf84e584..cf5660e0f 100644 --- a/Yep/ViewControllers/FriendsInContacts/FriendsInContactsViewController.swift +++ b/Yep/ViewControllers/FriendsInContacts/FriendsInContactsViewController.swift @@ -7,6 +7,7 @@ // import UIKit +import YepNetworking final class FriendsInContactsViewController: BaseViewController { diff --git a/Yep/ViewControllers/Login/LoginByMobileViewController.swift b/Yep/ViewControllers/Login/LoginByMobileViewController.swift index 9d9349020..1e5eed34e 100644 --- a/Yep/ViewControllers/Login/LoginByMobileViewController.swift +++ b/Yep/ViewControllers/Login/LoginByMobileViewController.swift @@ -7,6 +7,7 @@ // import UIKit +import YepNetworking import Ruler final class LoginByMobileViewController: BaseViewController { diff --git a/Yep/ViewControllers/Login/LoginVerifyMobileViewController.swift b/Yep/ViewControllers/Login/LoginVerifyMobileViewController.swift index c6881e043..221702ad8 100644 --- a/Yep/ViewControllers/Login/LoginVerifyMobileViewController.swift +++ b/Yep/ViewControllers/Login/LoginVerifyMobileViewController.swift @@ -7,6 +7,7 @@ // import UIKit +import YepNetworking import Ruler final class LoginVerifyMobileViewController: UIViewController { diff --git a/Yep/ViewControllers/NewFeed/NewFeedViewController.swift b/Yep/ViewControllers/NewFeed/NewFeedViewController.swift index 000cd484b..d902603f8 100644 --- a/Yep/ViewControllers/NewFeed/NewFeedViewController.swift +++ b/Yep/ViewControllers/NewFeed/NewFeedViewController.swift @@ -10,6 +10,7 @@ import UIKit import CoreLocation import MobileCoreServices import Photos +import YepNetworking import Proposer import RealmSwift import Kingfisher diff --git a/Yep/ViewControllers/Notifications/NotificationsViewController.swift b/Yep/ViewControllers/Notifications/NotificationsViewController.swift index 8532e449d..51aea6b25 100644 --- a/Yep/ViewControllers/Notifications/NotificationsViewController.swift +++ b/Yep/ViewControllers/Notifications/NotificationsViewController.swift @@ -7,6 +7,7 @@ // import UIKit +import YepNetworking import RealmSwift struct DoNotDisturbPeriod { diff --git a/Yep/ViewControllers/OAuth/OAuthViewController.swift b/Yep/ViewControllers/OAuth/OAuthViewController.swift index a674697be..c44f164cc 100644 --- a/Yep/ViewControllers/OAuth/OAuthViewController.swift +++ b/Yep/ViewControllers/OAuth/OAuthViewController.swift @@ -7,6 +7,7 @@ // import UIKit +import YepNetworking import OnePasswordExtension final class OAuthViewController: BaseViewController { diff --git a/Yep/ViewControllers/Profile/ProfileViewController.swift b/Yep/ViewControllers/Profile/ProfileViewController.swift index 4ff1586b1..f4a1363fb 100644 --- a/Yep/ViewControllers/Profile/ProfileViewController.swift +++ b/Yep/ViewControllers/Profile/ProfileViewController.swift @@ -7,13 +7,14 @@ // import UIKit +import SafariServices +import CoreLocation import RealmSwift +import YepNetworking import MonkeyKing import Navi -import SafariServices import Kingfisher import Proposer -import CoreLocation let profileAvatarAspectRatio: CGFloat = 12.0 / 16.0 diff --git a/Yep/ViewControllers/Register/RegisterPickAvatarViewController.swift b/Yep/ViewControllers/Register/RegisterPickAvatarViewController.swift index e58040c62..5c2556947 100644 --- a/Yep/ViewControllers/Register/RegisterPickAvatarViewController.swift +++ b/Yep/ViewControllers/Register/RegisterPickAvatarViewController.swift @@ -8,6 +8,7 @@ import UIKit import AVFoundation +import YepNetworking import Proposer import Navi diff --git a/Yep/ViewControllers/Register/RegisterPickMobileViewController.swift b/Yep/ViewControllers/Register/RegisterPickMobileViewController.swift index b5c25371a..dd2866cfd 100644 --- a/Yep/ViewControllers/Register/RegisterPickMobileViewController.swift +++ b/Yep/ViewControllers/Register/RegisterPickMobileViewController.swift @@ -7,6 +7,7 @@ // import UIKit +import YepNetworking import Ruler final class RegisterPickMobileViewController: SegueViewController { diff --git a/Yep/ViewControllers/Register/RegisterPickSkillsViewController.swift b/Yep/ViewControllers/Register/RegisterPickSkillsViewController.swift index 9d6babcde..602d0ee03 100644 --- a/Yep/ViewControllers/Register/RegisterPickSkillsViewController.swift +++ b/Yep/ViewControllers/Register/RegisterPickSkillsViewController.swift @@ -7,6 +7,7 @@ // import UIKit +import YepNetworking final class RegisterPickSkillsViewController: BaseViewController { diff --git a/Yep/ViewControllers/Register/RegisterSelectSkillsViewController.swift b/Yep/ViewControllers/Register/RegisterSelectSkillsViewController.swift index 53587be62..123dbcc83 100644 --- a/Yep/ViewControllers/Register/RegisterSelectSkillsViewController.swift +++ b/Yep/ViewControllers/Register/RegisterSelectSkillsViewController.swift @@ -7,6 +7,7 @@ // import UIKit +import YepNetworking import pop final class RegisterSelectSkillsViewController: UIViewController { diff --git a/Yep/ViewControllers/Register/RegisterVerifyMobileViewController.swift b/Yep/ViewControllers/Register/RegisterVerifyMobileViewController.swift index 76782b2b4..e5136fc42 100644 --- a/Yep/ViewControllers/Register/RegisterVerifyMobileViewController.swift +++ b/Yep/ViewControllers/Register/RegisterVerifyMobileViewController.swift @@ -7,6 +7,7 @@ // import UIKit +import YepNetworking import Ruler final class RegisterVerifyMobileViewController: SegueViewController { diff --git a/Yep/ViewControllers/SearchFeeds/SearchFeedsViewController.swift b/Yep/ViewControllers/SearchFeeds/SearchFeedsViewController.swift index 6340f3f16..865484f37 100644 --- a/Yep/ViewControllers/SearchFeeds/SearchFeedsViewController.swift +++ b/Yep/ViewControllers/SearchFeeds/SearchFeedsViewController.swift @@ -8,6 +8,7 @@ import UIKit import RealmSwift +import YepNetworking import AVFoundation import MapKit import Ruler diff --git a/Yep/ViewControllers/SearchedUsers/SearchedUsersViewController.swift b/Yep/ViewControllers/SearchedUsers/SearchedUsersViewController.swift index c49218bb5..0912b37bd 100644 --- a/Yep/ViewControllers/SearchedUsers/SearchedUsersViewController.swift +++ b/Yep/ViewControllers/SearchedUsers/SearchedUsersViewController.swift @@ -7,6 +7,7 @@ // import UIKit +import YepNetworking final class SearchedUsersViewController: BaseViewController { diff --git a/Yep/ViewControllers/SkillHome/SkillHomeViewController.swift b/Yep/ViewControllers/SkillHome/SkillHomeViewController.swift index 061b1220c..623e4653a 100644 --- a/Yep/ViewControllers/SkillHome/SkillHomeViewController.swift +++ b/Yep/ViewControllers/SkillHome/SkillHomeViewController.swift @@ -9,6 +9,7 @@ import UIKit import MobileCoreServices import RealmSwift +import YepNetworking import Proposer import Navi diff --git a/Yep/ViewControllers/SocialWorks/SocialWorkDribbbleViewController.swift b/Yep/ViewControllers/SocialWorks/SocialWorkDribbbleViewController.swift index 434c99ea0..eabce8a62 100644 --- a/Yep/ViewControllers/SocialWorks/SocialWorkDribbbleViewController.swift +++ b/Yep/ViewControllers/SocialWorks/SocialWorkDribbbleViewController.swift @@ -7,6 +7,7 @@ // import UIKit +import YepNetworking import Kingfisher import MonkeyKing diff --git a/Yep/ViewControllers/SocialWorks/SocialWorkGithubViewController.swift b/Yep/ViewControllers/SocialWorks/SocialWorkGithubViewController.swift index 9f87046f2..73a437a21 100644 --- a/Yep/ViewControllers/SocialWorks/SocialWorkGithubViewController.swift +++ b/Yep/ViewControllers/SocialWorks/SocialWorkGithubViewController.swift @@ -7,6 +7,7 @@ // import UIKit +import YepNetworking import MonkeyKing import Navi diff --git a/Yep/ViewControllers/SocialWorks/SocialWorkInstagramViewController.swift b/Yep/ViewControllers/SocialWorks/SocialWorkInstagramViewController.swift index d7648510a..15d8b39a7 100644 --- a/Yep/ViewControllers/SocialWorks/SocialWorkInstagramViewController.swift +++ b/Yep/ViewControllers/SocialWorks/SocialWorkInstagramViewController.swift @@ -7,6 +7,7 @@ // import UIKit +import YepNetworking import MonkeyKing final class SocialWorkInstagramViewController: BaseViewController { diff --git a/Yep/ViewControllers/VerifyChangedMobile/VerifyChangedMobileViewController.swift b/Yep/ViewControllers/VerifyChangedMobile/VerifyChangedMobileViewController.swift index 1311bb82a..9ca6c6232 100644 --- a/Yep/ViewControllers/VerifyChangedMobile/VerifyChangedMobileViewController.swift +++ b/Yep/ViewControllers/VerifyChangedMobile/VerifyChangedMobileViewController.swift @@ -7,6 +7,7 @@ // import UIKit +import YepNetworking import Ruler final class VerifyChangedMobileViewController: UIViewController { diff --git a/Yep/Views/Cells/ProfileSocialAccount/ProfileSocialAccountGithubCell.swift b/Yep/Views/Cells/ProfileSocialAccount/ProfileSocialAccountGithubCell.swift index 98e16789d..b1b6a486a 100644 --- a/Yep/Views/Cells/ProfileSocialAccount/ProfileSocialAccountGithubCell.swift +++ b/Yep/Views/Cells/ProfileSocialAccount/ProfileSocialAccountGithubCell.swift @@ -7,6 +7,7 @@ // import UIKit +import YepNetworking final class ProfileSocialAccountGithubCell: UICollectionViewCell { diff --git a/Yep/Views/Cells/ProfileSocialAccount/ProfileSocialAccountImagesCell.swift b/Yep/Views/Cells/ProfileSocialAccount/ProfileSocialAccountImagesCell.swift index 5a5ee4b18..8d29e6d42 100644 --- a/Yep/Views/Cells/ProfileSocialAccount/ProfileSocialAccountImagesCell.swift +++ b/Yep/Views/Cells/ProfileSocialAccount/ProfileSocialAccountImagesCell.swift @@ -7,6 +7,7 @@ // import UIKit +import YepNetworking import Kingfisher final class ProfileSocialAccountImagesCell: UICollectionViewCell { diff --git a/YepNetworking/YepNetworking.swift b/YepNetworking/YepNetworking.swift index 44c736dd8..9c42e7dad 100644 --- a/YepNetworking/YepNetworking.swift +++ b/YepNetworking/YepNetworking.swift @@ -6,12 +6,6 @@ // Copyright (c) 2015年 Catch Inc. All rights reserved. // -#if STAGING -let yepBaseURL = NSURL(string: "https://park-staging.catchchatchina.com/api")! -#else -let yepBaseURL = NSURL(string: "https://api.soyep.com")! -#endif - import Foundation public enum Method: String, CustomStringConvertible { @@ -34,7 +28,7 @@ public struct Resource: CustomStringConvertible { let path: String let method: Method let requestBody: NSData? - let headers: [String:String] + let headers: [String: String] let parse: NSData -> A? public var description: String { @@ -47,6 +41,14 @@ public struct Resource: CustomStringConvertible { return "Resource(Method: \(method), path: \(path), headers: \(headers), requestBody: \(decodeRequestBody))" } + + public init(path: String, method: Method, requestBody: NSData?, headers: [String: String], parse: NSData -> A?) { + self.path = path + self.method = method + self.requestBody = requestBody + self.headers = headers + self.parse = parse + } } public enum ErrorCode: String { @@ -77,7 +79,7 @@ public enum Reason: CustomStringConvertible { public typealias FailureHandler = (reason: Reason, errorMessage: String?) -> Void -let defaultFailureHandler: FailureHandler = { reason, errorMessage in +public let defaultFailureHandler: FailureHandler = { reason, errorMessage in print("\n***************************** YepNetworking Failure *****************************") print("Reason: \(reason)") if let errorMessage = errorMessage { @@ -308,7 +310,7 @@ func errorCodeInData(data: NSData?) -> ErrorCode? { public typealias JSONDictionary = [String: AnyObject] -func decodeJSON(data: NSData) -> JSONDictionary? { +public func decodeJSON(data: NSData) -> JSONDictionary? { if data.length > 0 { guard let result = try? NSJSONSerialization.JSONObjectWithData(data, options: NSJSONReadingOptions()) else { @@ -328,7 +330,7 @@ func decodeJSON(data: NSData) -> JSONDictionary? { } } -func encodeJSON(dict: JSONDictionary) -> NSData? { +public func encodeJSON(dict: JSONDictionary) -> NSData? { return dict.count > 0 ? (try? NSJSONSerialization.dataWithJSONObject(dict, options: NSJSONWritingOptions())) : nil } diff --git a/YepTests/ServiceTests.swift b/YepTests/ServiceTests.swift index 609ab3d08..06375daa1 100644 --- a/YepTests/ServiceTests.swift +++ b/YepTests/ServiceTests.swift @@ -115,7 +115,7 @@ final class ServiceTests: XCTestCase { updateAvatarWithImageData(imageData, failureHandler: nil, completion: { newAvatarURLString in userInfo(failureHandler: nil) { myUserInfo in - if let avatarInfo = myUserInfo["avatar"] as? JSONDictionary, avatarURLString = avatarInfo["url"] as? String { + if let avatarInfo = myUserInfo["avatar"] as? [String: AnyObject], avatarURLString = avatarInfo["url"] as? String { if newAvatarURLString == avatarURLString { expectation.fulfill() } @@ -172,9 +172,9 @@ final class ServiceTests: XCTestCase { myConversations(maxMessageID: nil, failureHandler: nil) { result in if - let userInfos = result["users"] as? [JSONDictionary] where !userInfos.isEmpty, - let groupInfos = result["circles"] as? [JSONDictionary] where !groupInfos.isEmpty, - let messageInfos = result["messages"] as? [JSONDictionary] where !messageInfos.isEmpty { + let userInfos = result["users"] as? [[String: AnyObject]] where !userInfos.isEmpty, + let groupInfos = result["circles"] as? [[String: AnyObject]] where !groupInfos.isEmpty, + let messageInfos = result["messages"] as? [[String: AnyObject]] where !messageInfos.isEmpty { expectation.fulfill() } }