Skip to content

Commit

Permalink
Add device to email login header
Browse files Browse the repository at this point in the history
  • Loading branch information
PhillipiLino committed May 27, 2023
1 parent 6c56e78 commit d7817ec
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
4 changes: 4 additions & 0 deletions IngresseSDK.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@
694A2D2C23102C050024E2E3 /* WalletInfoHolder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 694A2D2B23102C050024E2E3 /* WalletInfoHolder.swift */; };
69AE6D6D2368C58400C8FE22 /* DeclinedReason.swift in Sources */ = {isa = PBXBuildFile; fileRef = 69AE6D6C2368C58400C8FE22 /* DeclinedReason.swift */; };
69DDDDED22B012D800051883 /* AuthResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = 69DDDDEC22B012D800051883 /* AuthResponse.swift */; };
69EACFE02A22A75B00DA0F3F /* UserDevice.swift in Sources */ = {isa = PBXBuildFile; fileRef = 69EACFDF2A22A75B00DA0F3F /* UserDevice.swift */; };
6FC35ACA8E86F4C9B76A2EA3 /* Pods_IngresseSDK.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7B057A8A74EDA2E9BC573A23 /* Pods_IngresseSDK.framework */; };
750A814420E183F7004881C8 /* CompanyData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 750A814320E183F7004881C8 /* CompanyData.swift */; };
750A814620E186D0004881C8 /* Company.swift in Sources */ = {isa = PBXBuildFile; fileRef = 750A814520E186D0004881C8 /* Company.swift */; };
Expand Down Expand Up @@ -493,6 +494,7 @@
694A2D2B23102C050024E2E3 /* WalletInfoHolder.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WalletInfoHolder.swift; sourceTree = "<group>"; };
69AE6D6C2368C58400C8FE22 /* DeclinedReason.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeclinedReason.swift; sourceTree = "<group>"; };
69DDDDEC22B012D800051883 /* AuthResponse.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthResponse.swift; sourceTree = "<group>"; };
69EACFDF2A22A75B00DA0F3F /* UserDevice.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserDevice.swift; sourceTree = "<group>"; };
750A814320E183F7004881C8 /* CompanyData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CompanyData.swift; sourceTree = "<group>"; };
750A814520E186D0004881C8 /* Company.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Company.swift; sourceTree = "<group>"; };
750A814720E1875D004881C8 /* CompanyLogo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CompanyLogo.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -992,6 +994,7 @@
CE73B101240C76B10099439A /* UserWalletTransaction.swift */,
CEB19DF82469CBD50047CF3B /* WalletEventLive.swift */,
CEB19FE3246A01450047CF3B /* SearchEventAttributes.swift */,
69EACFDF2A22A75B00DA0F3F /* UserDevice.swift */,
);
path = Model;
sourceTree = "<group>";
Expand Down Expand Up @@ -1436,6 +1439,7 @@
3527277021A43DCB003BF44F /* Installment.swift in Sources */,
62D6423721AC4C1D002E1A39 /* Request.swift in Sources */,
624526351EC23255007B6584 /* MyTicketsService.swift in Sources */,
69EACFE02A22A75B00DA0F3F /* UserDevice.swift in Sources */,
692A1A4E228069B600D9CDD1 /* SecurityResponse.swift in Sources */,
62E6EDE21F1FE02300F0B1E8 /* WalletItem.swift in Sources */,
35263231211883F1003615F1 /* ShopTicket.swift in Sources */,
Expand Down
20 changes: 20 additions & 0 deletions IngresseSDK/Model/UserDevice.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//
// UserDevice.swift
// IngresseSDK
//
// Created by Phillipi Unger Lino on 27/05/23.
// Copyright © 2023 Ingresse. All rights reserved.
//

public struct UserDevice: Encodable {
public let id: String
public let name: String

public init(
id: String,
name: String
) {
self.id = id
self.name = name
}
}
16 changes: 15 additions & 1 deletion IngresseSDK/Services/AuthService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,13 @@ public class AuthService: BaseService {
/// - pass: password
/// - onSuccess: Success callback
/// - onError: Fail callback
public func loginWithEmail(_ email: String, andPassword pass: String, onSuccess: @escaping (_ response: IngresseUser) -> Void, onError: @escaping ErrorHandler) {
public func loginWithEmail(
_ email: String,
andPassword pass: String,
andDevice device: UserDevice,
onSuccess: @escaping (_ response: IngresseUser) -> Void,
onError: @escaping ErrorHandler
) {
let builder = URLBuilder(client: client)
.setPath("login/")
guard let request = try? builder.build() else {
Expand All @@ -68,9 +74,17 @@ public class AuthService: BaseService {

let params = ["email": email,
"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
}

client.restClient.POST(request: request,
parameters: params,
customHeader: header,
onSuccess: { response in

guard let logged = response["status"] as? Bool,
Expand Down

0 comments on commit d7817ec

Please sign in to comment.