Skip to content

Commit

Permalink
Auto-generated by Jenkins job OTT-Generate-ClientLibs-ios-and-android…
Browse files Browse the repository at this point in the history
…/486, branch 7_6_0
  • Loading branch information
Backend CI committed May 19, 2022
1 parent 1977812 commit e2f07e4
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 64 deletions.
4 changes: 2 additions & 2 deletions KalturaClient/Classes/Core/Client.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@

super.init()

clientTag = "swift:22-05-16"
apiVersion = "7.6.0.29893"
clientTag = "swift:22-05-19"
apiVersion = "7.6.0.29894"
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
// cancel3ed
logger.debug("request has been canceled")
} else {
let result = Result<Any>(data: nil, error: ApiClientException(message: error.localizedDescription, code: ApiClientException.ErrorCode.httpError))
let result = Result<Any>(data: nil, error: ApiClientException(message: error.localizedDescription, code: ApiClientException.ErrorCode.httpError.rawValue))
r.completion(result)
// some other error
}
Expand Down
44 changes: 33 additions & 11 deletions KalturaClient/Classes/Core/Response/JSONParser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,29 @@ internal class JSONParser{
return ret
}

// parse API Exception
internal static func parseException(object: [String: Any]) -> ApiException {
let message = object["message"] as? String
let code = object["code"] as? String

var exceptionArgs: [ApiExceptionArg]?

if let args = object["args"] as? [[String: Any]] {
do {
exceptionArgs = try self.parse(array: args) as [ApiExceptionArg]
} catch {
return ApiClientException(message: message, code: code)
}
}
return ApiClientException(message: message, code: code, args: exceptionArgs)
}

// parse dictinoary of object
internal static func parse<T>(object: [String: Any]) throws -> T where T: ObjectBase {
return try parse(object: object, type: T.self)
}

// parse response
// parse response
internal static func parse<T>(object: [String: Any], type: ObjectBase.Type) throws -> T where T: ObjectBase {

var classType: ObjectBase.Type = type
Expand All @@ -118,7 +135,7 @@ internal class JSONParser{
return try self.parse(object: result, type: type)
}
else if let error = object["error"] as? [String: Any] {
throw try parse(object: error) as ApiException
throw self.parseException(object: error)
}
}

Expand All @@ -135,7 +152,8 @@ internal class JSONParser{
return json
}
catch {
throw ApiClientException(message: "Failed to deserialize JSON", code: ApiClientException.ErrorCode.invalidJson)
throw ApiClientException(message: "Failed to deserialize JSON",
code: ApiClientException.ErrorCode.invalidJson.rawValue)
}
}

Expand All @@ -159,19 +177,20 @@ internal class JSONParser{
return try self.parse(primitive: result, type: type)
}
else if let error = dict["error"] as? [String: Any] {
throw try parse(object: error) as ApiException
throw self.parseException(object: error)
}
}

throw ApiClientException(message: "Type not found", code: ApiClientException.ErrorCode.typeNotFound)
throw ApiClientException(message: "Type not found",
code: ApiClientException.ErrorCode.typeNotFound.rawValue)
}



internal static func parse<T>(array: Any) throws -> [T]? {
if let dict = array as? [String: Any] {
if dict["objectType"] as? String == "KalturaAPIException" {
throw try parse(object: dict) as ApiException
throw self.parseException(object: dict)
}

if let result = dict["result"] {
Expand All @@ -180,37 +199,40 @@ internal class JSONParser{
else if let error = dict["error"] {
return try parse(array: error)
}else{
throw ApiClientException(message: "JSON is not valid object", code: ApiClientException.ErrorCode.invalidJsonObject)
throw ApiClientException(message: "JSON is not valid object",
code: ApiClientException.ErrorCode.invalidJsonObject.rawValue)
}
}
else if let arr = array as? [Any] {
return try parse(array: arr) as? [T]
}
else{
throw ApiClientException(message: "JSON is not of object", code: ApiClientException.ErrorCode.invalidJsonObject)
throw ApiClientException(message: "JSON is not of object",
code: ApiClientException.ErrorCode.invalidJsonObject.rawValue)
}


}
internal static func parse<T>(json: Any) throws -> T? {

if let dict = json as? [String: Any], dict["objectType"] as? String == "KalturaAPIException" {
throw try parse(object: dict) as ApiException
throw self.parseException(object: dict)
}
if let type: ObjectBase.Type = T.self as? ObjectBase.Type {
if let dict = json as? [String: Any] {
return try parse(object: dict, type: type) as? T
}
else {
throw ApiClientException(message: "JSON is not of object", code: ApiClientException.ErrorCode.invalidJsonObject)
throw ApiClientException(message: "JSON is not of object",
code: ApiClientException.ErrorCode.invalidJsonObject.rawValue)
}
}
else if let _ = T.self as? Void.Type {
if let dict = json as? [String: Any],
let result = dict["result"] as? [String: Any],
let error = result["error"] as? [String: Any],
error["objectType"] as? String == "KalturaAPIException" {
throw try parse(object: dict) as ApiException
throw self.parseException(object: dict)
}

return nil
Expand Down
53 changes: 14 additions & 39 deletions KalturaClient/Classes/Model/ApiException.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,53 +33,28 @@
* MANUAL CHANGES TO THIS CLASS WILL BE OVERWRITTEN.
*/

public class ApiException : ObjectBase, Error{
public var message: String?
public var code: String?
public var args: [ApiExceptionArg]?

public required init() {
super.init()
}

public convenience init(message: String, code: String, args: [ApiExceptionArg]) {
self.init()

self.message = message
self.code = code
self.args = args
}

public convenience init(message: String, code: String) {
self.init(message: message, code: code, args: [])
}

internal override func populate(_ dict: [String: Any]) throws {
try super.populate(dict);
// set members values:
message = dict["message"] as? String
code = dict["code"] as? String
if let argsDict = dict["args"] as? [String: String] {
args = []
for (key, value) in argsDict {
let arg = ApiExceptionArg()
arg.name = key
arg.value = value
}
}
}
public protocol ApiException: Error {
var message: String? { get }
var code: String? { get }
var args: [ApiExceptionArg]? { get }
}

public class ApiClientException : ApiException {
public struct ApiClientException: ApiException {

public enum ErrorCode: String {
case typeNotFound = "TYPE_NOT_FOUND"
case invalidJson = "INVALID_JSON"
case invalidJsonObject = "INVALID_JSON_OBJECT"
case httpError = "HTTP_ERROR"
}

public convenience init(message: String, code: ErrorCode) {
self.init(message: message, code: code.rawValue)
public let message: String?
public let code: String?
public let args: [ApiExceptionArg]?

init(message: String? = nil, code: String? = nil, args: [ApiExceptionArg]? = nil) {
self.message = message
self.code = code
self.args = args
}
}
18 changes: 9 additions & 9 deletions KalturaClient/Classes/Model/Objects/DeviceBrand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ open class DeviceBrand: ObjectBase {
}
}

public var deviceFamilyId: BaseTokenizedObject {
public var deviceFamilyid: BaseTokenizedObject {
get {
return self.append("deviceFamilyId")
return self.append("deviceFamilyid")
}
}

Expand All @@ -68,7 +68,7 @@ open class DeviceBrand: ObjectBase {
/** Device brand name */
public var name: String? = nil
/** Device family identifier */
public var deviceFamilyId: Int64? = nil
public var deviceFamilyid: Int64? = nil
/** Type of device family. if this device family belongs only to this
group, otherwise. */
public var type: DeviceBrandType? = nil
Expand All @@ -82,8 +82,8 @@ open class DeviceBrand: ObjectBase {
self.dict["name"] = name
}

public func setMultiRequestToken(deviceFamilyId: String) {
self.dict["deviceFamilyId"] = deviceFamilyId
public func setMultiRequestToken(deviceFamilyid: String) {
self.dict["deviceFamilyid"] = deviceFamilyid
}

public func setMultiRequestToken(type: String) {
Expand All @@ -99,8 +99,8 @@ open class DeviceBrand: ObjectBase {
if dict["name"] != nil {
name = dict["name"] as? String
}
if dict["deviceFamilyId"] != nil {
deviceFamilyId = Int64("\(dict["deviceFamilyId"]!)")
if dict["deviceFamilyid"] != nil {
deviceFamilyid = Int64("\(dict["deviceFamilyid"]!)")
}
if dict["type"] != nil {
type = DeviceBrandType(rawValue: "\(dict["type"]!)")
Expand All @@ -116,8 +116,8 @@ open class DeviceBrand: ObjectBase {
if(name != nil) {
dict["name"] = name!
}
if(deviceFamilyId != nil) {
dict["deviceFamilyId"] = deviceFamilyId!
if(deviceFamilyid != nil) {
dict["deviceFamilyid"] = deviceFamilyid!
}
return dict
}
Expand Down
2 changes: 1 addition & 1 deletion KalturaOttClient.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'KalturaOttClient'
s.version = '7.6.0.29893'
s.version = '7.6.0.29894'
s.summary = 'Kaltura OTT Client Library for Swift/iOS'
s.homepage = 'https://github.com/kaltura/KalturaOttGeneratedAPIClientsSwift'
s.license = { :type => 'AGPLv3', :text => 'AGPLv3' }
Expand Down
2 changes: 1 addition & 1 deletion KalturaOttClient.spec.header
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'KalturaOttClient'
s.version = '7.6.0.29893'
s.version = '7.6.0.29894'
s.summary = 'Kaltura OTT Client Library for Swift/iOS'
s.homepage = 'https://github.com/kaltura/KalturaOttGeneratedAPIClientsSwift'
s.license = { :type => 'AGPLv3', :text => 'AGPLv3' }
Expand Down

0 comments on commit e2f07e4

Please sign in to comment.