Class: Phoebe::Resources::Data::Observations::Recent::Historic

Inherits:
Object
  • Object
show all
Defined in:
lib/phoebe/resources/data/observations/recent/historic.rb

Overview

The data/obs end-points are used to fetch observations submitted to eBird in checklists. There are two categories of end-point: 1. Fetch observations for a specific country, region or location. 2. Fetch observations for nearby locations - up to a distance of 50km. Each end-point supports optional query parameters which allow you to filter the list of observations returned.

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Historic

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Historic.

Parameters:



82
83
84
# File 'lib/phoebe/resources/data/observations/recent/historic.rb', line 82

def initialize(client:)
  @client = client
end

Instance Method Details

#list(d, region_code:, y_:, m:, cat: nil, detail: nil, hotspot: nil, include_provisional: nil, max_results: nil, r: nil, rank: nil, spp_locale: nil, request_options: {}) ⇒ Array<Phoebe::Models::Data::Observation>

Get a list of all taxa seen in a country, region or location on a specific date, with the specific observations determined by the “rank” parameter (defaults to latest observation on the date).

#### Notes Responses may be cached for 30 minutes

Parameters:

  • d (Integer)

    Path param

  • region_code (String)

    Path param: The country, subnational1, subnational2 or location code.

  • y_ (Integer)

    Path param

  • m (Integer)

    Path param

  • cat (Symbol, Phoebe::Models::Data::Observations::Recent::HistoricListParams::Cat)

    Query param: Only fetch observations from these taxonomic categories

  • detail (Symbol, Phoebe::Models::Data::Observations::Recent::HistoricListParams::Detail)

    Query param: Include a subset (simple), or all (full), of the fields available.

  • hotspot (Boolean)

    Query param: Only fetch observations from hotspots

  • include_provisional (Boolean)

    Query param: Include observations which have not yet been reviewed.

  • max_results (Integer)

    Query param: Only fetch this number of observations

  • r (Array<String>)

    Query param: Fetch observations from up to 50 locations

  • rank (Symbol, Phoebe::Models::Data::Observations::Recent::HistoricListParams::Rank)

    Query param: Include latest observation of the day, or the first added

  • spp_locale (String)

    Query param: Use this language for species common names

  • request_options (Phoebe::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/phoebe/resources/data/observations/recent/historic.rb', line 51

def list(d, params)
  parsed, options = Phoebe::Data::Observations::Recent::HistoricListParams.dump_request(params)
  query = Phoebe::Internal::Util.encode_query_params(parsed)
  region_code =
    parsed.delete(:region_code) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  y_ =
    parsed.delete(:y_) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  m =
    parsed.delete(:m) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :get,
    path: ["data/obs/%1$s/historic/%2$s/%3$s/%4$s", region_code, y_, m, d],
    query: query.transform_keys(
      include_provisional: "includeProvisional",
      max_results: "maxResults",
      spp_locale: "sppLocale"
    ),
    model: Phoebe::Internal::Type::ArrayOf[Phoebe::Data::Observation],
    options: options
  )
end