getEntityTypeFromID determines the entity type from the ID prefix. It analyzes the prefix of the provided ID and returns the corresponding entity type. Parameters: - id: A string representing the entity ID to analyze. Returns: - string: The determined entity type ("transactions", "ledgers", "balan
(id string)
| 19 | // - string: The determined entity type ("transactions", "ledgers", "balances", or "identities"). |
| 20 | // - error: An error if the ID format is invalid. |
| 21 | func getEntityTypeFromID(id string) (string, error) { |
| 22 | switch { |
| 23 | case strings.HasPrefix(id, "txn_"): |
| 24 | return "transactions", nil |
| 25 | case strings.HasPrefix(id, "bulk_"): |
| 26 | return "transactions", nil |
| 27 | case strings.HasPrefix(id, "ldg_"): |
| 28 | return "ledgers", nil |
| 29 | case strings.HasPrefix(id, "bln_"): |
| 30 | return "balances", nil |
| 31 | case strings.HasPrefix(id, "idt_"): |
| 32 | return "identities", nil |
| 33 | default: |
| 34 | return "", fmt.Errorf("invalid entity ID format: %s", id) |
| 35 | } |
| 36 | } |
| 37 | |
| 38 | // UpdateMetadata updates the metadata for a given entity ID. |
| 39 | // It first determines the entity type, retrieves current metadata, merges it with new metadata, |
no outgoing calls