Package 'pockethostr'

Title: Pockethost for R
Description: This package provides an R API for pockethost app instances.
Authors: Enrico Spinielli [aut, cre] (ORCID: <https://orcid.org/0000-0001-8584-9131>)
Maintainer: Enrico Spinielli <[email protected]>
License: MIT + file LICENSE
Version: 0.0.1.0
Built: 2026-12-05 20:32:13 UTC
Source: https://github.com/euctrl-pru/pockethostr

Help Index


authenticate

Description

authenticate

Usage

ph_authenticate_admin_username_password(app, api, username, password)

Arguments

app

the app name

api

the api to hit

username

the username to use

password

the password to use

Value

a json

Examples

## Not run: 
ph_authenticate_admin_username_password <- function(
   "eurocontrol-data",
   "/api/admins/auth-with-password",
   username,
   password)

## End(Not run)

create record

Description

create record

Usage

ph_create_record(app, api, collection, body, token = NULL, ...)

Arguments

app

the app

api

the api

collection

the collection name or id

body

the body

token

the authentication token, depending on collection's createRule

...

extra params

Value

a response

Examples

## Not run: 
adm <- ph_authenticate_admin_username_password(
  "eurocontrol-data",
  "/api/admins/auth-with-password",
  username,
  password)
  bd <- list(
    AVG_ROLLING_WEEK= 22065.4285714286,
    DAY_DIFF_PREV_YEAR_PERC= 0.035235526043,
    DAY_TFC= 24944,
    DAY_TFC_DIFF_2019_PERC= -0.11967531322,
    DIFF_ROLLING_WEEK_2019_PERC= -0.13323232323,
    DIFF_WEEK_PREV_YEAR_PERC= 0.027945081493,
    FLIGHT_DATE= "2024-01-01 00:00:00.000Z",
    Y2D_AVG_TFC_YEAR= 23172.4210526316,
    Y2D_DIFF_2019_PERC= -0.087499533673,
    Y2D_DIFF_PREV_YEAR_PERC= 0.051857514872,
    Y2D_TFC_YEAR= 440276
    )
 ph_create_record(
  app = "eurocontrol-data",
  api = "/api/collections",
  collection = "nw_traffic",
  token = adm$token,
  body = bd)

## End(Not run)

Delete record

Description

Delete record

Usage

ph_delete_record(app, api, collection, id, token = NULL)

Arguments

app

the app name

api

the api

collection

the collection name or id

id

the record id

token

the authentication token, depending on collection's deleteRule

Value

a response

Examples

## Not run: 
ph_delete_record(app, api, id, token)

## End(Not run)

list records

Description

list records

Usage

ph_list_records(app, api, collection, ...)

Arguments

app

the application name

api

the api to hit

collection

the collection name or id

...

the query params as supported by PocketBase List/Search API

Value

a tibble

Examples

## Not run: 
ph_list_records(
  app,
  "/api/collections/",
  collection = "nw_traffic",
  perPage = 1,
  sort = "-FLIGHT_DATE",
  skipTotal = 1)

# get only subset of columns
ph_list_records(
  app,
  "/api/collections/",
  collection = "nw_traffic",
  sort = "-FLIGHT_DATE",
  fields = "id,FLIGHT_DATE,DAY_TFC"
  )

## End(Not run)

Update record

Description

Update record

Usage

ph_update_record(app, api, collection, id, body, token = NULL, ...)

Arguments

app

the app name

api

the api

collection

the collection name or id

id

the record id

body

the body

token

the authentication token, depending on collection's updateRule

...

the query params as supported by PocketBase View API

Value

a response

Examples

## Not run: 
adm <- ph_authenticate_admin_username_password(
  "eurocontrol-data-test",
  "/api/admins/auth-with-password",
  username,
  password)
  bd <- list(
    DAY_TFC= 121,
    FLIGHT_DATE= "2024-05-01 00:00:00.000Z"
    )
 id <- "lufkj3346ygx9a2"
 ph_update_record(
  app = "eurocontrol-data-test",
  api = "/api/collections",
  collection = "nw_traffic",
  token = adm$token,
  body = bd)

## End(Not run)

View record

Description

View record

Usage

ph_view_record(app, api, collection, id, ...)

Arguments

app

the app name

api

the api

collection

the collection name or id

id

the record id

...

the query params as supported by PocketBase View API

Value

a response

Examples

## Not run: 
app <- "eurocontrol-data-test"
collection <- "nw_traffic"
id <- "lufkj3346ygx9a2"

ph_view_record(app = app,
               api = "/api/collections",
               id = id,
               collection = collection,
               fields = "FLIGHT_DATE,DAY_TFC")

## End(Not run)