Cablegram.Request (Cablegram v0.2.0)
A request for the API. Initialize it with your token, the method name and params:
%Request{
token: "YOUR_BOT_TOKEN",
method_name: "sendMessage",
params: [chat_id: chat_id, text: "Hello World"]
}
Params can be JSON serializable (via the Jason.Encoder
protocol) structs, maps,
scalars and lists thereof. For uploads, pass a Cablegram.InputFile
struct as param.
A request is sent and the response parsed by calling Request.handle(request)
.
Link to this section Summary
Functions
Prepares and sends the request, and parses the response. Returns {:ok, parsed}
where,
if the response type of the method called is known, parsed
is a model struct
populated from the response. For example, a request with method_name: "sendMessage"
will return a Cablegram.Model.Message
struct.
Link to this section Functions
handle(request)
Prepares and sends the request, and parses the response. Returns {:ok, parsed}
where,
if the response type of the method called is known, parsed
is a model struct
populated from the response. For example, a request with method_name: "sendMessage"
will return a Cablegram.Model.Message
struct.
Returns {:error, reason}
if something went wrong.