Skip to content

Commit

Permalink
Add device type
Browse files Browse the repository at this point in the history
  • Loading branch information
PhillipiLino committed Jun 1, 2023
1 parent 8cd909a commit 1bc6195
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
11 changes: 10 additions & 1 deletion IngresseSDK/Model/UserDevice.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,21 @@
public struct UserDevice: Encodable {
public let id: String
public let name: String
public let type: String

public init(
id: String,
name: String
name: String,
type: String
) {
self.id = id
self.name = name
self.type = type
}

func toJsonString() -> String? {
guard let data = try? JSONEncoder().encode(self) else { return nil }
let jsonString = String(decoding: data, as: UTF8.self)
return jsonString
}
}
20 changes: 8 additions & 12 deletions IngresseSDK/Services/AuthService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,8 @@ public class AuthService: BaseService {
"password": pass]

var header: [String: Any] = [:]
if let data = try? JSONEncoder().encode(device) {
let jsonString = String(decoding: data, as: UTF8.self)
header["X-INGRESSE-DEVICE"] = jsonString
if let jsonDevice = device.toJsonString() {
header["X-INGRESSE-DEVICE"] = jsonDevice
}

client.restClient.POST(request: request,
Expand Down Expand Up @@ -133,9 +132,8 @@ public class AuthService: BaseService {
"fbUserId": fbUserId]

var header: [String: Any] = [:]
if let data = try? JSONEncoder().encode(device) {
let jsonString = String(decoding: data, as: UTF8.self)
header["X-INGRESSE-DEVICE"] = jsonString
if let jsonDevice = device.toJsonString() {
header["X-INGRESSE-DEVICE"] = jsonDevice
}

client.restClient.POST(request: request,
Expand Down Expand Up @@ -191,9 +189,8 @@ public class AuthService: BaseService {
"authorizationCode": authorizationCode]

var header: [String: Any] = [:]
if let data = try? JSONEncoder().encode(device) {
let jsonString = String(decoding: data, as: UTF8.self)
header["X-INGRESSE-DEVICE"] = jsonString
if let jsonDevice = device.toJsonString() {
header["X-INGRESSE-DEVICE"] = jsonDevice
}

client.restClient.POST(request: request,
Expand Down Expand Up @@ -243,9 +240,8 @@ public class AuthService: BaseService {
"redirectUri": "ingresse://facebank"]

var header: [String: Any] = [:]
if let data = try? JSONEncoder().encode(device) {
let jsonString = String(decoding: data, as: UTF8.self)
header["X-INGRESSE-DEVICE"] = jsonString
if let jsonDevice = device.toJsonString() {
header["X-INGRESSE-DEVICE"] = jsonDevice
}

client.restClient.POST(request: request,
Expand Down

0 comments on commit 1bc6195

Please sign in to comment.