A Figma Document is a just a R list with a more organized structure than the
raw content of the HTTP request in httr::response()
. You can access
each part of this list with `$`
and `[[`
operators. See Value section to
understand what is in each element of this list.
as_figma_document()
will call different parsers depending on what kind
of elements are present in the content of the response
object it receives
as input. These elements define what kind of data is present in the response
object, and how it is structured.
If this input object have a document
element in the top-level of
the content, is likely that this input object was produced by figma::get_figma_file()
.
In this case, as_figma_document()
will call figma:::parse_figma_file()
to parse
the contents of the HTTP request.
In the other hand, if this input object have a nodes
element in the top-level of
the content, is likely that this input object was produced by figma::get_figma_page()
.
In this case, as_figma_document()
will call figma:::parse_figma_page()
to parse
the contents of the HTTP request.
If none of these key elements ("document" or "nodes") are found in the top-level of the
content of the response
object, as_figma_document()
will issue an error
to the user, telling it could not recognize the source of the response
object.