# iOS SDK

# Installation(CocoaPods)

CocoaPods is a dependency manager for Cocoa projects. For usage and installation instructions, visit their website. To integrate EndpassSDK into your Xcode project using CocoaPods, specify it in your Podfile:

pod 'EndpassSDK'

All api calls contain two types of input data:

# Initialization SDK

To use EndpassSDK you need to enter AppID

EPSecurityManager.initialOAuth(client_Id: "YOUR_APPLICATION_ID")

# Get User information

        EPUserManager.request(
            url: EPPublicConstants.getUserPath(),
            responseModel: EPUserDataResponse.self,
            success: { data in
                print(data)
        }) { error in
            print(error)
        }

# Get User address

        EPUserManager.request(
            url: EPPublicConstants.getUserAddressPath(),
            responseModel: EPUserAddressesResponse.self,
            success: { data in
                print(data)
        }) { error in
            print(error)
        }

# Get User personal

        EPUserManager.request(
            url: EPPublicConstants.getUserPersonalInfoPath(),
            responseModel: EPUserPersonalDataResponse.self,
            success: { data in
                print(data)
        }) { error in
            print(error)
        }

# Get App scopes

        EPUserManager.request(
            url: EPPublicConstants.getUserScopesPath(),
            responseModel: EPUserScopesResponse.self,
            success: { data in
                print(data)
        }) { error in
            print(error)
        }

# Get documents

        EPDocumentsManager.request(
            url: EPPublicConstants.getDocumentsPath(),
            responseModel: EPPublicDocumentListResponse.self,
            success: { data in
                print(data)
        }) { error in
            print(error)
        }

# URL constants

-     getUserPath = "/user"
-     getUserAddressPath = "/user/address"
-     getUserPersonalInfoPath = "/user/info/personal"
-     getUserScopesPath = "/scopes"
-     getDocumentsPath = "/documents"

# Data models

# EPUserDataResponse

public struct EPUserDataResponse: Codable {
    public let id: String
    public let email: String?
    public let phones: [Phone]?
}

// MARK: - Phone
public struct Phone: Codable {
    public let id: String
    public let createdAt: Int
    public let status: String
    public let country: String
    public let number: String
    public let main: Bool
}

# EPUserAddressesResponse

public struct EPUserAddressesResponseElement: Codable {
    public let main: Bool
    public let createdAt: Int
    public let apartmentNumber: String
    public let streetNumber: String
    public let street: String
    public let city: String
    public let stateRegion: String
    public let country: String
    public let postalCode: String
    public let lat: Double
    public let lng: Double
    public let verified: Bool

}

public typealias EPUserAddressesResponse = [EPUserAddressesResponseElement]

# EPUserPersonalDataResponse

public struct EPUserPersonalDataResponse: Codable {
    public let id: String
    public let firstName: String
    public let lastName: String
    public let dateOfBirth: Int
}

# EPUserScopesResponse

public struct EPUserScopesResponse: Codable {
    public let scopes: [String]
}

# EPPublicDocumentListResponse

public struct EPPublicDocumentElement: Codable {
    public let id: String
    public let createdAt: Int
    public let status: EPPublicConstants.DocumentStatusType
    public let documentType: EPPublicConstants.DocumentType
}

public typealias EPPublicDocumentListResponse = [EPPublicDocumentElement?]

# DocumentType

    public enum DocumentType: String, Codable {
        case Passport
        case DriverLicense
        case ProofOfAddress
        case IdCard
        
        public func getLocalize() -> String {
            switch self {
            case .Passport:
                return "Passport"
            case .DriverLicense:
                return "Driver License"
            case .ProofOfAddress:
                return "Proof of Address"
            case .IdCard:
                return "Id Card"
            }
        }
    }

# AreaType

    public enum AreaType: String, Codable {
        case Internal
    }

# DocumentStatusType

    public enum DocumentStatusType: String, Codable {
        case Draft
        case Recognition
        case NotReadable
        case NotVerified
        case Verified
        case PendingReview

        public func getLocalize() -> String {
            switch self {
            case .Draft:
                return "Draft"
            case .Recognition:
                return "Recognizing"
            case .NotReadable:
                return "Not readable"
            case .NotVerified:
                return "Not verified"
            case .Verified:
                return "Verified"
            case .PendingReview:
                return "Pending review"
            }
        }
    }