# Methods

This can be used after initializing the Wepin PIN Pad Library.

## &#x20;generateRegistrationPINBlock

```swift
await wepinPin!.generateRegistrationPINBlock()
```

To display the PIN pad screen to receive the PIN required for wallet creation and user registration, process the entered PIN to create a PIN Block.

### **Parameters**

* `viewController` \<UIViewController> *optional*\
  The view controller from which the widget (WebView) will be presented modally. It provides the display context to ensure the widget appears on the correct screen.

### **Return value**

* `<RegistrationPinBlock>`
  * `uvd` \<EncUVD>

    * `b64Data` \<String> \
      Data encrypted with the original key of `b64SKey`.
    * `b64SKey` \<String> \
      The key used to generate `b64Data`.
    * `seqNum` \<Int> **optional** \
      A value used to verify that PIN Blocks are used in sequential order.&#x20;

  * `hint` \<EncPinHint>

    * `data` \<string> \
      &#x20;The encrypted value of the PIN hint.
    * `length` \<string>\
      The length of the PIN hint.
    * `version` \<number>&#x20;

    &#x20;      The version of the PIN hint.

### Example

```swift
do{
  let registrationPinBlock = try await wepinPin!.generateRegistrationPINBlock()
  if let registerPinBlock = registrationPinBlock {
  // You need to make a Wepin RESTful API request using the received data.  
  }
}catch(let error){
  print(error)
}

```

## generateAuthPINBlock

```swift
await wepinPin!.generateAuthPINBlock(3)
```

To display the PIN pad screen to receive the PIN required for user authentication and process the entered PIN to create a PIN Block. If the user has enabled 2FA (OTP), display a screen to receive the OTP code and process it as well.

### **Parameters**

* `count` \<Int> **optional**&#x20;

  The number of PIN Blocks to be generated. The default value is 1.
* `viewController` \<UIViewController> *optional*\
  The view controller from which the widget (WebView) will be presented modally. It provides the display context to ensure the widget appears on the correct screen.

### **Return value**

* `<AuthPinBlock>`
  * `uvdList` List\<EncUVD> \
    A list of encrypted PIN Blocks.
    * \<EncUVD>
      * `b64Data` \<String> \
        Data encrypted with the original key of `b64SKey`.
      * `b64SKey` \<String> \
        The key used to generate `b64Data`.
      * `seqNum` \<Int> **optional** \
        A value used to verify that PIN Blocks are used in sequential order. In a Multi Tx request, PIN Blocks must be used strictly in the received order (1, 2, 3...).
  * `otp` \<String> **optional** \
    The OTP code entered by the user if they have enabled 2FA (OTP).

### Example

```swift
do{
  let authPinBlock = try await wepinPin!.generateAuthPINBlock(3)
  if let authPinBlock = authPinBlock {
    // You need to make a Wepin RESTful API request using the received data.  
  }
}catch(let error){
  print(error)
}
```

## generateChangePINBlock

```swift
await wepinPin!.generateChangePINBlock()
```

To display the PIN pad screen to receive the PIN required for the user to change their PIN and process the entered PIN to create a PIN Block. If the user has enabled 2FA (OTP), display a screen to receive the OTP code and process it as well.

### **Parameters**

* `viewController` \<UIViewController> *optional*\
  The view controller from which the widget (WebView) will be presented modally. It provides the display context to ensure the widget appears on the correct screen.

### **Return Value**

* `<ChangePinBlock>`
  * `uvd` \<EncUVD>
    * `b64Data` \<String> \
      Data encrypted with the original key of `b64SKey`.
    * `b64SKey` \<String> \
      The key used to generate `b64Data`.
    * `seqNum` \<Int> **optional** \
      A value used to verify that PIN Blocks are used in sequential order.&#x20;
  * `newUVD` \<EncUVD>
    * `b64Data` \<String> \
      Data encrypted with the original key of `b64SKey`.
    * `b64SKey` \<String> \
      The key used to generate `b64Data`.
    * `seqNum` \<Int> **optional** \
      A value used to verify that PIN Blocks are used in sequential order.&#x20;
  * `hint` \<EncPinHint>
    * `data` \<String> \
      &#x20;The encrypted value of the PIN hint.
    * `length` \<String>\
      The length of the PIN hint.
    * `version` \<Int> \
      The version of the PIN hint.
  * `otp` \<String> **optional** \
    The OTP code entered by the user if they have enabled 2FA (OTP).

### Example

```swift
do{
  let changepPinBlock = try await wepinPin!.generateChangePINBlock()
  if let changepPinBlock = changePinBlock {
    // You need to make a Wepin RESTful API request using the received data.  
  }
}catch(let error){
  print(error)
}
```

## generateAuthOTP

```javascript
await wepinPin!.generateAuthOTPCode()
```

Display a screen to receive the OTP code from the user and process it.

### **Parameters**

* `viewController` \<UIViewController> *optional*\
  The view controller from which the widget (WebView) will be presented modally. It provides the display context to ensure the widget appears on the correct screen.

### **Return Value**

* `<AuthOTP>`
  * `code` \<String>\
    The entered OTP code.

### Example

```swift
do{
  let authOTPCode = try await wepinPin!.generateAuthOTPCode()
  if let authOTPCode = authOTPCode {
    // You need to make a Wepin RESTful API request using the received data.  
  }
}catch(let error){
  print(error)
}
```

## finalize

```javascript
wepinPin!.finalize()
```

It terminates the use of the Wepin PIN Pad Library.

### **Parameters**

* `<Void>`

### **Return Value**

* `<Void>`

### Example

```swift
wepinPin!.finalize()
```
