Geofox.Ticketing.Tariff (geofox_ex v0.1.1)

View Source

Functions for retrieving tariff information, metadata, and zone data from the Geofox API.

Summary

Functions

Alias for tariff_meta_data/2 with a more descriptive name.

Calculate tariff information for given schedule elements and journey times.

Alias for tariff_zone_neighbours/2 with a more descriptive name.

Get tariff metadata including zones, counties, tariff kinds and levels.

Get information about neighboring tariff zones.

Functions

get_metadata(client, opts \\ [])

@spec get_metadata(
  Geofox.Client.t(),
  keyword()
) :: {:ok, map()} | {:error, term()}

Alias for tariff_meta_data/2 with a more descriptive name.

Same functionality as tariff_meta_data/2 but with a clearer function name that better describes what the function returns.

get_tariff(client, schedule_elements, departure, arrival, opts \\ [])

@spec get_tariff(
  Geofox.Client.t(),
  [map()],
  Geofox.Types.gti_time(),
  Geofox.Types.gti_time(),
  keyword()
) :: {:ok, map()} | {:error, term()}

Calculate tariff information for given schedule elements and journey times.

Parameters

  • client - The Geofox client
  • schedule_elements - List of schedule elements describing the journey
  • departure - Departure time as t:Types.gti_time/0
  • arrival - Arrival time as t:Types.gti_time/0
  • opts - Optional parameters

Options

  • :language - Language code (default: "de")
  • :version - API version (default: 1)
  • :filter_type - Filter type (default: "NO_FILTER")
  • :return_reduced - Return reduced price information (default: false)
  • :return_partial_tickets - Return partial ticket options (default: true)
  • :tariff_info_selector - List of tariff info selectors to filter results

Examples

schedule_elements = [%{
  departureStationId: "Master:1",
  arrivalStationId: "Master:2",
  lineId: "HVV:21001:H"
}]

departure = Geofox.gti_time("2024-01-15", "14:30")
arrival = Geofox.gti_time("2024-01-15", "15:00")

{:ok, tariff} = Geofox.Ticketing.Tariff.get_tariff(
  client,
  schedule_elements,
  departure,
  arrival
)

get_zone_neighbours(client, opts \\ [])

@spec get_zone_neighbours(
  Geofox.Client.t(),
  keyword()
) :: {:ok, map()} | {:error, term()}

Alias for tariff_zone_neighbours/2 with a more descriptive name.

Same functionality as tariff_zone_neighbours/2 but with a clearer function name.

tariff_meta_data(client, opts \\ [])

@spec tariff_meta_data(
  Geofox.Client.t(),
  keyword()
) :: {:ok, map()} | {:error, term()}

Get tariff metadata including zones, counties, tariff kinds and levels.

Returns information about available tariff zones, counties, tariff kinds (like single tickets, season tickets), tariff levels, and their relationships.

Parameters

  • client - The Geofox client
  • opts - Optional parameters

Options

  • :language - Language code (default: "de")
  • :version - API version (default: 1)
  • :filter_type - Filter type (default: "NO_FILTER")

Examples

{:ok, metadata} = Geofox.Ticketing.Tariff.tariff_meta_data(client)

# Access different parts of the metadata
tariff_zones = metadata["tariffZones"]
tariff_kinds = metadata["tariffKinds"]
counties = metadata["tariffCounties"]

tariff_zone_neighbours(client, opts \\ [])

@spec tariff_zone_neighbours(
  Geofox.Client.t(),
  keyword()
) :: {:ok, map()} | {:error, term()}

Get information about neighboring tariff zones.

Returns a list of tariff zones and their neighboring zones, which is useful for calculating cross-zone travel costs and route planning.

Parameters

  • client - The Geofox client
  • opts - Optional parameters

Options

  • :language - Language code (default: "de")
  • :version - API version (default: 1)
  • :filter_type - Filter type (default: "NO_FILTER")

Examples

{:ok, neighbours} = Geofox.Ticketing.Tariff.tariff_zone_neighbours(client)

# Find neighbours of a specific zone
zone_a_neighbours = Enum.find(neighbours["tariffZones"], fn zone ->
  zone["zone"] == "A"
end)["neighbours"]