PDFShift.API (PDFShift v0.1.0)
View SourceModule implementing the PDFShift API endpoints.
Summary
Functions
@spec convert( module(), PDFShift.Config.t(), String.t(), PDFShift.Types.convert_options(), keyword() ) :: {:ok, map()} | {:error, any()}
Converts a HTML document or URL to PDF.
Parameters
client
- The HTTP client moduleconfig
- The configuration structsource
- URL or HTML content to convert to PDFoptions
- Additional options for the conversion
Returns
{:ok, response}
- On successful conversion{:error, reason}
- On failure
Examples
iex> PDFShift.API.convert(PDFShift.Client, config, "https://example.com")
{:ok, %{body: <<PDF binary data>>, status: 200, headers: [...]}}
@spec credits_usage(module(), PDFShift.Config.t(), keyword()) :: {:ok, map()} | {:error, any()}
Gets the current credits usage.
Parameters
client
- The HTTP client moduleconfig
- The configuration struct
Returns
{:ok, response}
- On successful request{:error, reason}
- On failure
Examples
iex> PDFShift.API.credits_usage(PDFShift.Client, config)
{:ok, %{
body: %{
"credits" => %{
"base" => 50000,
"remaining" => 49881,
"total" => 50000,
"used" => 119
},
"success" => true
},
status: 200,
headers: [...]
}}