Skip to contents

API client to consume TEMPLO's API

Value

TRUE or FALSE

TRUE or FALSE

record with the data being sent plus the unique identifier generated by the remote database

a dataframe with the sought information.

a dataframe with the sought information.

a dataframe with the sought information.

a dataframe with the sought information.

TRUE if successfully completed. Error message otherwise.

Public fields

base_url

string containing the base url of the querying API (without the end_point) part

headers

list of HTTP headers

token

string to authenticate against the API

Active bindings

base_url

string containing the base url of the querying API (without the end_point) part

Methods


Method new()

Initialise IIMApiClient

Usage

TemploApiClient$new(api_url, headers, token)

Arguments

headers

list of HTTP headers

token

string to authenticate against the API

base_url

string containing the base url of the querying API (without the end_point) part


Method add_species()

Add a dataframe of unique species to the database through the API. One insertion is done per species. Species failing to be inserted for whatever reason will be reported to the stdout, along with each error. Those sucesfully inserted will be listed. In case either none or all were inserted, the final output will report it so.

Usage

TemploApiClient$add_species(df, end_point = "species/")

Arguments

end_point

string with the name of the end point being queried.


Method add_tagged_individuals()

Add a dataframe of tagged_individuals to the database through the API. One insertion is done per individual, irrespective of how many rows such individual may have due to its associated sensors. Individuals failing to be inserted for whatever reason will be reported to the stdout, along with each error. Those sucesfully inserted will be listed. In case either none or all were inserted, the final output will report it so.

Usage

TemploApiClient$add_tagged_individuals(
  df,
  individual_prefix,
  tag_prefix,
  sensor_prefix,
  tagged_individual_prefix,
  field_names = c("individual_data", "tag_data", "sensors_data",
    "tagged_individual_data"),
  end_point = "tagged_individuals/"
)

Arguments

df

dataframe with pontetial multiple-row individuals (if multiple sensors); one row otherwise.

individual_prefix

string identifying what columns belong to the individual dataset

tag_prefix

string identifying what columns belong to the tag dataset

sensor_prefix

string identifying what columns belong to the sensor dataset

tagged_individual_prefix

string identifying what columns belong to the tagged_individual dataset

field_names

a character vector containing what the names of the datasets to be sent to the API should be

end_point

string with the name of the end point being queried.


Method add_single_record_and_fetch_id()

General method to add a single record to the database through the API

Usage

TemploApiClient$add_single_record_and_fetch_id(end_point, data)

Arguments

end_point

string with the name of the end point being queried.

data

a flat list with the fields of the record being sent.


Method get_sensor_types()

Get all sensor types currently in the database

Usage

TemploApiClient$get_sensor_types(end_point = "sensortypes/")

Arguments

end_point

string with the name of the end point being queried.


Method get_tagged_individuals()

Get all tagged individuals from the database. This operation may take a few seconds and makes two API calls: one to get the tagged_individual data and another one to get the sensor types. The final result is a merge between both retrieved datasets.

Usage

TemploApiClient$get_tagged_individuals(
  end_point,
  tagged_individual_fields = TAGGED_INDVIDUAL_FIELDS
)

Arguments

end_point

string with the name of the end point being queried.

tagged_individual_fields

list of sections and fields per section to be retrieved.


Method get_environmental_readings()

Get environmental data from the API that were emitted by receptors

Usage

TemploApiClient$get_environmental_readings(
  end_point = "environmental_readings/data_exports/",
  from_date,
  to_date
)

Arguments

end_point

string with the name of the end point being queried.

from_date

a yms format string start date

to_date

a yms format string end_date


Method get_dataframe_end_point()

General method to get data from the API in a dataframe format.

Usage

TemploApiClient$get_dataframe_end_point(end_point, parameters = NULL)

Arguments

end_point

string with the name of the end point being queried.

parameters

a named list with potential parameters to pass on to the API query. Default is NULL


Method delete_single_record()

General method to delete data from the API.

Usage

TemploApiClient$delete_single_record(end_point, data)

Arguments

end_point

string with the name of the end point being queried.

data

a flat list with the unique fields identifying the record being deleted


Method clone()

The objects of this class are cloneable with this method.

Usage

TemploApiClient$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.