View Source StarkInfra.Event (starkinfra v0.1.0)

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 Infra API to list all generated updates on entities.

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

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

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

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

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

Receive a list of up to 100 Event structs previously created in the Stark Infra API and the cursor to the next page. Use this function instead of query if you want to manually page your requests.

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

Create a single Event struct from a content string received from a handler listening at the request url. If the provided digital signature does not check out with the StarkInfra public key, a starkinfra.error.InvalidSignatureError will be raised.

Same as query(), 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 Infra API

Same as update(), 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.

Link to this section Types

@type t() :: %StarkInfra.Event{
  created: term(),
  id: term(),
  is_delivered: term(),
  log: term(),
  subscription: term(),
  workspace_id: term()
}

Link to this section Functions

Link to this function

%StarkInfra.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 Infra API to list all generated updates on entities.

attributes

Attributes:

  • :id [string]: unique id returned when the event is created. ex: "5656565656565656"
  • :log [Log]: a Log struct from one the subscription services (PixRequest.Log, PixReversal.Log, PixKey.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"
  • :workspace_id [string]: ID of the Workspace that generated this event. Mostly used when multiple Workspaces have Webhooks registered to the same endpoint. ex: "4545454545454545"
Link to this function

delete!(id, options \\ [])

View Source
@spec delete!(binary(), [
  {:user, StarkInfra.User.Project.t() | StarkInfra.User.Organization.t() | nil}
]) ::
  t()

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

Link to this function

delete(id, options \\ [])

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

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

parameters-required

Parameters (required):

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

options

Options:

  • :user [Organization/Project, default nil]: Organization or Project struct returned from StarkInfra.project(). Only necessary if default project or organization has not been set in configs.

return

Return:

  • deleted Event struct
@spec get!(binary(), [
  {:user, StarkInfra.User.Project.t() | StarkInfra.User.Organization.t() | nil}
]) ::
  t()

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

@spec get(binary(), [
  {:user, StarkInfra.User.Project.t() | StarkInfra.User.Organization.t() | nil}
]) ::
  {:ok, t()} | {:error, [%StarkInfra.Error{code: term(), message: term()}]}

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

parameters-required

Parameters (required):

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

options

Options:

  • :user [Organization/Project, default nil]: Organization or Project struct returned from StarkInfra.project(). Only necessary if default project or organization has not been set in configs.

return

Return:

  • Event struct with updated attributes
@spec page!(
  cursor: binary(),
  limit: integer(),
  after: Date.t() | binary(),
  before: Date.t() | binary(),
  is_delivered: boolean(),
  user: StarkInfra.User.Project.t() | StarkInfra.User.Organization.t()
) :: [t()]

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

@spec page(
  cursor: binary(),
  limit: integer(),
  after: Date.t() | binary(),
  before: Date.t() | binary(),
  is_delivered: boolean(),
  user: StarkInfra.User.Project.t() | StarkInfra.User.Organization.t()
) ::
  {:ok, {binary(), [t()]}}
  | {:error, [%StarkInfra.Error{code: term(), message: term()}]}

Receive a list of up to 100 Event structs previously created in the Stark Infra API and the cursor to the next page. Use this function instead of query if you want to manually page your requests.

options

Options:

  • :cursor [string, default nil]: cursor returned on the previous page function call
  • :limit [integer, default 100]: maximum number of structs to be retrieved. Max = 100. ex: 35
  • :after [Date or string, default nil]: date filter for structs created only after specified date. ex: ~D[2020-03-25]
  • :before [Date 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 [Organization/Project, default nil]: Organization or Project struct returned from StarkInfra.project(). Only necessary if default project or organization has not been set in configs.

return

Return:

  • list of Event structs with updated attributes and cursor to retrieve the next page of Event structs
@spec parse!(
  content: binary(),
  signature: binary(),
  cache_pid: PID,
  user: StarkInfra.User.Project.t() | StarkInfra.User.Organization.t()
) :: any()

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

@spec parse(
  content: binary(),
  signature: binary(),
  cache_pid: PID,
  user: StarkInfra.User.Project.t() | StarkInfra.User.Organization.t()
) :: {:ok, t()} | {:error, [{:error, StarkInfra.Error.t()}]}

Create a single Event struct from a content string received from a handler listening at the request url. If the provided digital signature does not check out with the StarkInfra public key, a starkinfra.error.InvalidSignatureError will be raised.

parameters-required

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"

options

Options:

  • 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 [Organization/Project, default nil]: Organization or Project struct returned from StarkInfra.project(). Only necessary if default project or organization has not been set in configs.

return

Return:

  • Parsed Resource object
@spec query!(
  limit: integer(),
  after: Date.t() | binary(),
  before: Date.t() | binary(),
  is_delivered: boolean(),
  user: StarkInfra.User.Project.t() | StarkInfra.User.Organization.t()
) :: ({:cont, [t()]} | {:halt, any()} | {:suspend, any()}, any() -> any())

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

@spec query(
  limit: integer(),
  after: Date.t() | binary(),
  before: Date.t() | binary(),
  is_delivered: boolean(),
  user: StarkInfra.User.Project.t() | StarkInfra.User.Organization.t()
) ::
  ({:cont, {:ok, [t()]}}
   | {:error, [StarkInfra.Error.t()]}
   | {:halt, any()}
   | {:suspend, any()},
   any() ->
     any())

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

options

Options:

  • :limit [integer, default nil]: maximum number of structs to be retrieved. Unlimited if nil. ex: 35
  • :after [Date or string, default nil]: date filter for structs created only after specified date. ex: ~D[2020-03-25]
  • :before [Date 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 [Organization/Project, default nil]: Organization or Project struct returned from StarkInfra.project(). Only necessary if default project or organization has not been set in configs.

return

Return:

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

update!(id, parameters \\ [])

View Source
@spec update!(binary(),
  is_delivered: bool(),
  user: StarkInfra.User.Project.t() | StarkInfra.User.Organization.t() | nil
) :: t()

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

Link to this function

update(id, parameters \\ [])

View Source
@spec update(binary(),
  is_delivered: bool(),
  user: StarkInfra.User.Project.t() | StarkInfra.User.Organization.t() | nil
) :: {:ok, t()} | {:error, [%StarkInfra.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

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

options

Options:

  • :user [Organization/Project, default nil]: Organization or Project struct returned from StarkInfra.project(). Only necessary if default project or organization has not been set in configs.

return

Return:

  • target Event with updated attributes