Learn R Programming

whapi (version 0.0.2)

whapi_parse_updates: Parse Whapi "messages_updates" array (patch events) into a tibble

Description

Converts the webhook field messages_updates (patch events) into a row-per-update tibble with a stable schema. Aligns before/after snapshots, the trigger (who/what caused the change), and summarizes the change type(s) in change.

Usage

whapi_parse_updates(
  lst,
  channel_id = NULL,
  event_type = NULL,
  event_act = NULL
)

Value

A tibble with one row per update. Includes contextual columns (channel_id, event_type, event_action).

Arguments

lst

A list or single object representing Whapi webhook messages_updates. Accepts NULL, a single update object, or an array.

channel_id

Character. Channel identifier (usually passed down from whapi_flatten_webhook()).

event_type

Character. Event type ("messages_updates" by default).

event_act

Character. Event action ("patch" by default).

Details

  • Normalizes input to an array via whapi_as_array(lst, "update").

  • Safely extracts from before_update, after_update, and trigger.

  • Uses whapi_scalarize_change() to turn changes (vector/list) into a single string.

  • Preserves the same schema as whapi_parse_messages() so both outputs can be combined with dplyr::bind_rows().

  • Reply/context columns are included but set to NA.

  • Time fields: timestamp (epoch seconds) and timestamp_dt (POSIXct UTC).