Skip to content

Commit

Permalink
update to 2.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Mr-Sergey-K committed Oct 15, 2021
1 parent 6739e10 commit 7e8acf0
Show file tree
Hide file tree
Showing 27 changed files with 1,280 additions and 456 deletions.
68 changes: 68 additions & 0 deletions Core/UDDateExtension.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
//
// UDDateExtension.swift
// UseDesk_SDK_Swift
//
//

import Foundation

extension Date {
var isToday: Bool {
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "dd MM yyyy"
dateFormatter.locale = .current
dateFormatter.timeZone = TimeZone.current
let date1 = dateFormatter.string(from: self)
let date2 = dateFormatter.string(from: Date())
if date1 == date2 {
return true
} else {
return false
}
}

var time: String {
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "HH:mm"
dateFormatter.locale = .current
dateFormatter.timeZone = TimeZone.current
return dateFormatter.string(from: self)
}

var timeAndDayString: String {
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "dd.MM.yyyy HH:mm"
dateFormatter.locale = .current
dateFormatter.timeZone = TimeZone.current
return dateFormatter.string(from: self)
}

func dateFromHeaderChat(_ usedesk : UseDeskSDK) -> String {
let calendar = Calendar.current
let dateFormatter = DateFormatter()
var locale = Locale.current
if usedesk.locale == UDLocalizeManager().getLocaleFor(localeId: "ru") {
locale = Locale(identifier: "RU_RU")
}
dateFormatter.locale = locale
dateFormatter.timeZone = TimeZone.current
var dayString = ""
if calendar.isDateInYesterday(self) {
dayString = usedesk.stringFor("Yesterday")
} else if calendar.isDateInToday(self) {
dayString = usedesk.stringFor("Today")
} else {
dateFormatter.dateFormat = "d MMMM"
dayString = dateFormatter.string(from: self)
}
return dayString
}

var dateFormatString: String {
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "yyyy-MM-dd"
dateFormatter.locale = .current
dateFormatter.timeZone = TimeZone.current
return dateFormatter.string(from: self)
}
}
58 changes: 58 additions & 0 deletions Core/UDError.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
//
// UDError.swift
// UseDesk_SDK_Swift
//
//

import Foundation
import Alamofire

@objc public enum UDError: Int {
case null
case chanelIdError
case urlError
case emailError
case urlToSendFileError
case urlAPIError
case phoneError
case tokenError
case falseInitChatError
case serverError
case emptyKnowledgeBaseID

public init(errorCode: Int) {
switch errorCode {
case 112:
self = UDError.tokenError
default:
self = UDError.serverError
}
}

var description: String {
switch self {
case .null:
return ""
case .chanelIdError:
return "Invalid chanel id"
case .urlError:
return "Invalid url"
case .emailError:
return "Invalid email"
case .urlToSendFileError:
return "Invalid url to send file"
case .urlAPIError:
return "Invalid urlAPI"
case .phoneError:
return "Invalid phone number"
case .tokenError:
return "Invalid token"
case .falseInitChatError:
return "False init chat"
case .serverError:
return "Error in server"
case .emptyKnowledgeBaseID:
return "Empty knowledgeBaseID"
}
}
}
1 change: 1 addition & 0 deletions Core/UDUIImageExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ extension UIImage {
return self.pngData()
})
}

}

public enum StorageError: Error {
Expand Down
3 changes: 2 additions & 1 deletion Core/UDUIProtocole.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ public protocol UDUIProtocole {

func showBaseView(in parentController: UIViewController?, url: String?)
func startDialogFlow(in parentController: UIViewController?)
func reloadDialogFlow(success: Bool, error: String?, url: String, in parentController: UIViewController?)
func reloadDialogFlow(success: Bool, feedBackStatus: UDFeedbackStatus, url: String)
func pushViewController(_ viewController: UIViewController)
func dismiss()
func chatViewController() -> UIViewController?
}
Loading

0 comments on commit 7e8acf0

Please sign in to comment.