# 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:

  • Update your Podfile with the following contents

    target 'YourAppTargetName' do
        use_frameworks!
        pod 'EndpassSDK'
    end
    
  • Install dependencies

    pod install
    
  • Open the newly created .xcworkspace

  • Import the library to any of your classes by using import EndpassSDK and begin working on your project

All api calls contain two types of input data:

# Initialization SDK

To use EndpassSDK you need to enter AppID

EPSecurityManager.initialOAuth(appId: "YOUR_APPLICATION_ID")

# Get User information

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

# Get User address

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

# Get User personal

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

# Get App scopes

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

# Get documents

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

# URL constants

-     getUserEndpoint = "/user"
-     getUserAddressEndpoint = "/user/address"
-     getUserPersonalInfoEndpoint = "/user/info/personal"
-     getUserScopesEndpoint = "/scopes"
-     getDocumentsEndpoint = "/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"
            }
        }
    }