starkbank v0.5.0 StarkBank.Event View Source

Groups Webhook-Event related functions

Link to this section Summary

Functions

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.

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.

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 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.

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 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

%StarkBank.Event{}

View Source (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 event 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 function

delete(id, options \\ [])

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

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

Parameters (required):

  • id [string]: Event unique id. ex: "5656565656565656"

Options:

  • :user [Project]: Project struct returned from StarkBank.project(). Only necessary if default project has not been set in configs.

Return:

  • deleted Event struct with updated attributes
Link to this function

delete!(id, options \\ [])

View Source
delete!(binary(), [{:user, StarkBank.User.Project.t() | nil}]) ::
  StarkBank.Event.t()

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

Link to this function

get(id, options \\ [])

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

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

Parameters (required):

  • id [string]: struct unique id. ex: "5656565656565656"

Options:

  • :user [Project]: Project struct returned from StarkBank.project(). Only necessary if default project has not been set in configs.

Return:

  • Event struct with updated attributes
Link to this function

get!(id, options \\ [])

View Source
get!(binary(), [{:user, StarkBank.User.Project.t() | nil}]) ::
  StarkBank.Event.t()

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

Link to this function

parse(parameters)

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

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):

  • content [string]: response content from request received at user endpoint (not parsed)
  • signature [string]: base-64 digital signature received at response header "Digital-Signature"

Parameters (optional):

  • 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.
  • user [Project]: Project struct returned from StarkBank.project(). Only necessary if default project has not been set in configs.

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!(parameters)

View Source
parse!(
  content: binary(),
  signature: binary(),
  cache_pid: PID,
  user: StarkBank.User.Project.t()
) :: {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(options \\ [])

View Source
query(
  limit: integer(),
  after: Date.t() | DateTime.t() | binary(),
  before: Date.t() | DateTime.t() | binary(),
  is_delivered: boolean(),
  user: StarkBank.User.Project.t()
) ::
  ({:cont, {:ok, [StarkBank.Event.t()]}}
   | {:error, [StarkBank.Error.t()]}
   | {:halt, any()}
   | {:suspend, any()},
   any() ->
     any())

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

Options:

  • :limit [integer, default nil]: maximum number of structs to be retrieved. Unlimited if nil. ex: 35
  • :after [Date, DateTime or string, default nil]: date filter for structs created only after specified date. ex: ~D[2020-03-25]
  • :before [Date, DateTime or string, default nil]: date filter for structs created only before specified date. ex: ~D[2020-03-25]
  • :is_delivered [bool, default nil]: filter successfully delivered events. ex: true or false
  • :user [Project]: Project struct returned from StarkBank.project(). Only necessary if default project has not been set in configs.

Return:

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

query!(options \\ [])

View Source
query!(
  limit: integer(),
  after: Date.t() | DateTime.t() | binary(),
  before: Date.t() | DateTime.t() | binary(),
  is_delivered: boolean(),
  user: StarkBank.User.Project.t()
) ::
  ({: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(id, parameters \\ [])

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

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):

  • id [list of strings]: Event unique ids. ex: "5656565656565656"
  • :is_delivered [bool]: If true and event hasn't been delivered already, event will be set as delivered. ex: true

Parameters (optional):

  • :user [Project]: Project struct returned from StarkBank.project(). Only necessary if default project has not been set in configs.

Return:

  • target Event with updated attributes
Link to this function

update!(id, parameters \\ [])

View Source
update!(binary(), is_delivered: bool(), user: StarkBank.User.Project.t() | nil) ::
  StarkBank.Event.t()

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