Jsonrpc.Request (finch_jsonrpc v0.1.0) View Source
Jsonrpc.Request
represents a JSONRPC 2.0 request, as documented in the
JSON-RPC 2.0 specification
Link to this section Summary
Link to this section Types
Specs
Link to this section Functions
Specs
new
creates a new Jsonrpc.Request
. It takes a list of options. The options are:
- method: the method of the RPC request as a string. This field is required.
- params: the parameters of the request.
- id: the id of the request. When not given, the time the request was created in unix time in milliseconds is used as the ID.
new
can be piped with another new
call to create a list of requests that can be send as a batch RPC request. See new/2
Example
Jsonrpc.Request.new(method: "callOne", params: "example", id: "1")
Specs
new/2
takes a request or a list of requests and adds a new request to the list. The options are the same as new/1
.
This function allows to chain multiple new
calls together to create a list of RPC requests that can be send as a batch request.
Example
Jsonrpc.Request.new(method: "callOne")
|> Jsonrpc.Request.new(method: "callTwo")
|> Jsonrpc.call(name: :example, url: "https://finchjsonrpc.redmaner.com")
Specs
order
can be used to order a list of requests that are created by new/1
and new/2
. This
will overwrite ids that were given when creating the requests! It will guarantee the right order when
new/1
and new/2
were used.
Example
Jsonrpc.Request.new(method: "callOne")
|> Jsonrpc.Request.new(method: "callTwo")
|> Jsonrpc.Request.order(1)
|> Jsonrpc.call(name: :example, url: "https://finchjsonrpc.redmaner.com")