starkbank v2.4.1 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 section 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.
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"
delete(id, options \\ [])
View Sourcedelete(binary(), [ {:user, StarkBank.User.Project.t() | StarkBank.User.Organization.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
[Organization/Project]: Organization or Project struct returned from StarkBank.project(). Only necessary if default project or organization has not been set in configs.
Return:
- deleted Event struct
delete!(id, options \\ [])
View Sourcedelete!(binary(), [ {:user, StarkBank.User.Project.t() | StarkBank.User.Organization.t() | nil} ]) :: StarkBank.Event.t()
Same as delete(), but it will unwrap the error tuple and raise in case of errors.
get(id, options \\ [])
View Sourceget(binary(), [ {:user, StarkBank.User.Project.t() | StarkBank.User.Organization.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
[Organization/Project]: Organization or Project struct returned from StarkBank.project(). Only necessary if default project or organization has not been set in configs.
Return:
- Event struct with updated attributes
get!(id, options \\ [])
View Sourceget!(binary(), [ {:user, StarkBank.User.Project.t() | StarkBank.User.Organization.t() | nil} ]) :: StarkBank.Event.t()
Same as get(), but it will unwrap the error tuple and raise in case of errors.
parse(parameters)
View Sourceparse( content: binary(), signature: binary(), cache_pid: PID, user: StarkBank.User.Project.t() | StarkBank.User.Organization.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
[Organization/Project]: Organization or Project struct returned from StarkBank.project(). Only necessary if default project or organization 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
parse!(parameters)
View Sourceparse!( content: binary(), signature: binary(), cache_pid: PID, user: StarkBank.User.Project.t() | StarkBank.User.Organization.t() ) :: {StarkBank.Event.t(), any()}
Same as parse(), but it will unwrap the error tuple and raise in case of errors.
query(options \\ [])
View Sourcequery( limit: integer(), after: Date.t() | binary(), before: Date.t() | binary(), is_delivered: boolean(), user: StarkBank.User.Project.t() | StarkBank.User.Organization.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 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]: Organization or Project struct returned from StarkBank.project(). Only necessary if default project or organization has not been set in configs.
Return:
- stream of Event structs with updated attributes
Same as query(), but it will unwrap the error tuple and raise in case of errors.
update(id, parameters \\ [])
View Sourceupdate(binary(), is_delivered: bool(), user: StarkBank.User.Project.t() | StarkBank.User.Organization.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
[Organization/Project]: Organization or Project struct returned from StarkBank.project(). Only necessary if default project or organization has not been set in configs.
Return:
- target Event with updated attributes
update!(id, parameters \\ [])
View Sourceupdate!(binary(), is_delivered: bool(), user: StarkBank.User.Project.t() | StarkBank.User.Organization.t() | nil ) :: StarkBank.Event.t()
Same as update(), but it will unwrap the error tuple and raise in case of errors.