Params
Arguments that can be passed to the API via query params.
pub struct ApiQueryArgs {
/// If true, internal database properties are added with a `__` prefix
/// Adds a generated `id` property
/// Not encouraged to use outside of development
pub internal: Option<bool>,
// -------------------------------------------------------------------------
// Adds the respective property to the return Feature/FeatureCollection
// It is encouraged to add these properties through the admin panel instead of using these args!
/// If true, the `id` property is added
pub id: Option<bool>,
/// If true, the `name` property is added
pub name: Option<bool>,
/// If true, the `mode` property is added
pub mode: Option<bool>,
/// If true, the `geofence_id` property is added
pub geofence_id: Option<bool>,
/// If true, the `parent` property is added
pub parent: Option<bool>,
// -------------------------------------------------------------------------
// Extras
/// custom return type of the API request
///
/// Options: [ReturnTypeArg]
pub rt: Option<String>,
/// If true, the `group` property is set from the parent property
pub group: Option<bool>,
// -------------------------------------------------------------------------
// Name Property Manipulation
/// If true, the entire `name` property is set to lowercase
pub lowercase: Option<bool>,
/// If true, the entire `name` property is set to uppercase
pub uppercase: Option<bool>,
/// If provided, the `name` property is split at the provided string/character, each word is capitalized, then rejoined with the same character
pub capitalize: Option<String>,
/// If true, the first character of the `name` property is capitalized
pub capfirst: Option<bool>,
/// If true, the `parent` property is added as a prefix to the `name`, separated by the provided string/character
pub parentstart: Option<String>,
/// If true, the `parent` property is added as a suffix to the `name`, separated by the provided string/character
pub parentend: Option<String>,
/// If the `name` property has the `parent` name as part of its value, the `parent` name is replaced with the given string/character
pub parentreplace: Option<String>,
/// Spaces in the `name` property are replaced with the given string/character
pub space: Option<String>,
/// Underscores in the `name` property are replaced with the given string/character
pub underscore: Option<String>,
/// Dashes/Hyphens in the `name` property are replaced with the given string/character
pub dash: Option<String>,
/// Replaces any provided string/character with `""` (empty string)
pub replace: Option<String>,
/// Trims x number of characters from the front of the `name` property
pub trimstart: Option<usize>,
/// Trims x number of characters from the back of the `name` property
pub trimend: Option<usize>,
/// If true, the polish characters are converted to ascii
pub unpolish: Option<bool>,
/// If true, the manual parent property will be ignored
pub ignoremanualparent: Option<bool>,
}
Name Property Manipulation
Since the name property of a geofence may need to be different on a per project basis, in order to cut down on having to maintain multiple copies of the same geofence in the Kōji database, you can manipulate the name property of a geofence at the API level before it is returned to you.
The manipulations mentioned above are executed in the following order:
- ignoremanualparent
- trimstart
- trimend
- replace
- parentreplace
- parentstart
- parentend
- lowercase
- uppercase
- capfirst
- capitalize
- underscore
- dash
- space
- unpolish
- A trim function is automatically called at the end to remove start and end whitespace
By taking advantage of the execution order you should be able to manipulate the name property in almost any desirable way.
String args can be provided with or without "
surrounding them. If you are using a string with has a space or special characters, it is recommended to use "
to surround the string for consistency.
Remember to respect URL encoding rules (opens in a new tab)
Examples
Given the below fences:
name | parent | projects |
---|---|---|
NY | null | [] |
North, NY | NY | [ReactMap, Poracle] |
South, NY | NY | [ReactMap, Poracle] |
East, NY | NY | [ReactMap, Poracle] |
West, NY | NY | [ReactMap, Poracle] |
DC | null | [] |
North, DC | DC | [ReactMap, Poracle] |
South, DC | DC | [ReactMap, Poracle] |
East, DC | DC | [ReactMap, Poracle] |
West, DC | DC | [ReactMap, Poracle] |
ReactMap API call: (Project that supports unique names per parent)
https://my-koji-url.com/api/v1/feature-collection/ReactMap?parentreplace=""&replace=","
Result:
Features with their parent property set to "NY" (if a parent property is specified in the admin panel) and a clean name, e.g. North, NY
=> North
name | parent |
---|---|
North | NY |
South | NY |
East | NY |
West | NY |
North | DC |
South | DC |
East | DC |
West | DC |
Poracle API call: (Project that should have all unique names)
https://my-koji-url.com/api/v1/poracle/Poracle?group=true&lowercase=true&replace=","&space="_"
Poracle styled results with the group
property set from the native parent
property, names set to lowercase but are otherwise the same
name | group |
---|---|
north_ny | NY |
south_ny | NY |
east_ny | NY |
west_ny | NY |
north_dc | DC |
south_dc | DC |
east_dc | DC |
west_dc | DC |
Playground
A playground is included as part of the Kōji client. You can check it out yourself at http://{your_koji_url}/play