DetokenizeIdentity detokenizes and returns all tokenized fields in an identity. Parameters: - identityID string: The ID of the identity. Returns: - map[string]string: A map of field names to their detokenized values. - error: An error if any field could not be detokenized.
(identityID string)
| 284 | // - map[string]string: A map of field names to their detokenized values. |
| 285 | // - error: An error if any field could not be detokenized. |
| 286 | func (l *LedgerForge) DetokenizeIdentity(identityID string) (map[string]string, error) { |
| 287 | // Get the identity |
| 288 | identity, err := l.GetIdentity(identityID) |
| 289 | if err != nil { |
| 290 | return nil, err |
| 291 | } |
| 292 | |
| 293 | result := make(map[string]string) |
| 294 | |
| 295 | // Check each tokenized field in metadata |
| 296 | if identity.MetaData != nil { |
| 297 | tokenizedFields, ok := identity.MetaData["tokenized_fields"].(map[string]bool) |
| 298 | if ok { |
| 299 | for fieldName, isTokenized := range tokenizedFields { |
| 300 | if isTokenized { |
| 301 | originalValue, err := l.DetokenizeIdentityField(identityID, fieldName) |
| 302 | if err != nil { |
| 303 | return nil, err |
| 304 | } |
| 305 | result[fieldName] = originalValue |
| 306 | } |
| 307 | } |
| 308 | } |
| 309 | } |
| 310 | |
| 311 | return result, nil |
| 312 | } |
| 313 | |
| 314 | // TokenizeAllPII tokenizes all eligible PII fields in an identity. |
| 315 | // |