View Source ROR.Location (ROR v0.1.0)

Functions for extracting and using Admin data from a ROR Organization record

Location structs are a little different to the ROR JSON data - they're flattened, with a type - but contain the same information.

Summary

Functions

Extracts a list of Location structs from the decoded JSON of a ROR Organization record

Lists the allowed terms or types for this data structure, as atoms.

Types

t()

@type t() :: %ROR.Location{
  continent_code: binary(),
  continent_name: binary(),
  country_code: binary(),
  country_name: binary(),
  country_subdivision_code: binary(),
  country_subdivision_name: binary(),
  id: binary(),
  latitude: float(),
  longitude: float(),
  name: binary(),
  type: atom()
}

Functions

extract(data)

@spec extract(data :: map()) :: [t()]

Extracts a list of Location structs from the decoded JSON of a ROR Organization record

If you are retrieving records via the ROR module and the REST API you will not need to use this function yourself.

Example

iex> record = File.read!("test/support/static/example_org.json") |> Jason.decode!()
...> ROR.Location.extract(record)
[
  %ROR.Location{
    type: :geonames,
    id: 5_378_538,
    continent_name: nil,
    continent_code: nil,
    country_code: "US",
    country_name: "United States",
    country_subdivision_code: nil,
    country_subdivision_name: nil,
    latitude: 37.802168,
    longitude: -122.271281,
    name: "Oakland"
  }
]

vocab()

@spec vocab() :: [atom()]

Lists the allowed terms or types for this data structure, as atoms.