starkbank v0.0.3 StarkBank.Event View Source

Groups Webhook-Event related functions

Event struct:

An Event is the notification received from the subscription to the Webhook. Events cannot be created, but may be retrieved from the Stark Bank API to list all generated updates on entities.

Attributes:

  • id [string]: unique id returned when the log is created. ex: "5656565656565656"
  • log [Log]: a Log struct from one the subscription services (Transfer.Log, Boleto.Log, BoletoPayment.log or UtilityPayment.Log)
  • created [DateTime]: creation datetime for the notification event. ex: ~U[2020-03-26 19:32:35.418698Z]
  • is_delivered [bool]: true if the event has been successfully delivered to the user url. ex: false
  • subscription [string]: service that triggered this event. ex: "transfer", "utility-payment"

Link to this section Summary

Functions

Delete notification Events

Delete a list of notification Event entities previously created in the Stark Bank API

Same as delete(), but it will unwrap the error tuple and raise in case of errors.

Retrieve a specific notification Event

Receive a single notification Event struct previously created in the Stark Bank API by passing its id

Same as get(), but it will unwrap the error tuple and raise in case of errors.

Create single notification Event from a content string

Create a single Event struct received from event listening at subscribed user endpoint. If the provided digital signature does not check out with the StarkBank public key, an "invalidSignature" error will be returned.

Same as parse(), but it will unwrap the error tuple and raise in case of errors.

Retrieve notification Events

Receive a stream of notification Event structs previously created in the Stark Bank API

Same as query(), but it will unwrap the error tuple and raise in case of errors.

Update notification Event entity

Update notification Event by passing id. If is_delivered is true, the event will no longer be returned on queries with is_delivered=false.

Same as update(), but it will unwrap the error tuple and raise in case of errors.

Link to this section Types

Link to this type

t()

View Source
t() :: %StarkBank.Event{
  created: term(),
  id: term(),
  is_delivered: term(),
  log: term(),
  subscription: term()
}

Link to this section Functions

Link to this function

delete(user, id)

View Source
delete(StarkBank.User.Project.t(), binary()) ::
  {:ok, StarkBank.Event.t()}
  | {:error, [%StarkBank.Error{code: term(), message: term()}]}

Delete notification Events

Delete a list of notification Event entities previously created in the Stark Bank API

Parameters (required):

  • user [Project]: Project struct returned from StarkBank.project().
  • id [string]: Event unique id. ex: "5656565656565656"

Return:

  • deleted Event struct with updated attributes
Link to this function

delete!(user, id)

View Source
delete!(StarkBank.User.Project.t(), binary()) :: StarkBank.Event.t()

Same as delete(), but it will unwrap the error tuple and raise in case of errors.

Link to this function

get(user, id)

View Source
get(StarkBank.User.Project.t(), binary()) ::
  {:ok, StarkBank.Event.t()}
  | {:error, [%StarkBank.Error{code: term(), message: term()}]}

Retrieve a specific notification Event

Receive a single notification Event struct previously created in the Stark Bank API by passing its id

Parameters (required):

  • user [Project]: Project struct returned from StarkBank.project().
  • id [string]: struct unique id. ex: "5656565656565656"

Return:

  • Event struct with updated attributes
Link to this function

get!(user, id)

View Source
get!(StarkBank.User.Project.t(), binary()) :: StarkBank.Event.t()

Same as get(), but it will unwrap the error tuple and raise in case of errors.

Link to this function

parse(user, content, signature, cache_pid \\ nil)

View Source
parse(StarkBank.User.Project.t(), binary(), binary(), PID.t() | nil) ::
  {:ok, {StarkBank.Event.t(), binary()}} | {:error, [StarkBank.Error.t()]}

Create single notification Event from a content string

Create a single Event struct received from event listening at subscribed user endpoint. If the provided digital signature does not check out with the StarkBank public key, an "invalidSignature" error will be returned.

Parameters (required):

  • user [Project]: Project struct returned from StarkBank.project().
  • content [string]: response content from request received at user endpoint (not parsed)
  • signature [string]: base-64 digital signature received at response header "Digital-Signature"
  • cache_pid [PID, default nil]: PID of the process that holds the public key cache, returned on previous parses. If not provided, a new cache process will be generated.

Return:

  • Event struct with updated attributes
  • Cache PID that holds the Stark Bank public key in order to avoid unnecessary requests to the API on future parses
Link to this function

parse!(user, content, signature, cache_pid \\ nil)

View Source
parse!(StarkBank.User.Project.t(), binary(), binary(), PID.t() | nil) ::
  {StarkBank.Event.t(), any()}

Same as parse(), but it will unwrap the error tuple and raise in case of errors.

Link to this function

query(user, options \\ [])

View Source
query(StarkBank.User.Project.t(), any()) ::
  ({:cont, {:ok, [StarkBank.Event.t()]}}
   | {:error, [StarkBank.Error.t()]}
   | {:halt, any()}
   | {:suspend, any()},
   any() ->
     any())

Retrieve notification Events

Receive a stream of notification Event structs previously created in the Stark Bank API

Parameters (required):

  • user [Project]: Project struct returned from StarkBank.project().

Parameters (optional):

  • limit [integer, default nil]: maximum number of structs to be retrieved. Unlimited if nil. ex: 35
  • is_delivered [bool, default nil]: filter successfully delivered events. ex: true or false
  • after [Date, default nil]: date filter for structs created only after specified date. ex: ~D[2020-03-25]
  • before [Date, default nil]: date filter for structs only before specified date. ex: ~D[2020-03-25]

Return:

  • stream of Event structs with updated attributes
Link to this function

query!(user, options \\ [])

View Source
query!(StarkBank.User.Project.t(), any()) ::
  ({:cont, [StarkBank.Event.t()]} | {:halt, any()} | {:suspend, any()}, any() ->
     any())

Same as query(), but it will unwrap the error tuple and raise in case of errors.

Link to this function

update(user, id, options \\ [])

View Source
update(StarkBank.User.Project.t(), binary(), boolean()) ::
  {:ok, StarkBank.Event.t()}
  | {:error, [%StarkBank.Error{code: term(), message: term()}]}

Update notification Event entity

Update notification Event by passing id. If is_delivered is true, the event will no longer be returned on queries with is_delivered=false.

Parameters (required):

  • user [Project]: Project struct returned from StarkBank.project().
  • id [list of strings]: Event unique ids. ex: "5656565656565656"

Parameters (optional):

  • is_delivered [bool]: If true and event hasn't been delivered already, event will be set as delivered. ex: true

Return:

  • target Event with updated attributes
Link to this function

update!(user, id, options \\ [])

View Source
update!(StarkBank.User.Project.t(), binary(), boolean()) :: StarkBank.Event.t()

Same as update(), but it will unwrap the error tuple and raise in case of errors.