Class: Phoebe::Resources::Ref::Region::List

Inherits:
Object
  • Object
show all
Defined in:
lib/phoebe/resources/ref/region/list.rb

Overview

The ref/region end-points return information on regions.

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ List

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 List.

Parameters:



46
47
48
# File 'lib/phoebe/resources/ref/region/list.rb', line 46

def initialize(client:)
  @client = client
end

Instance Method Details

#list(parent_region_code, region_type:, fmt: nil, request_options: {}) ⇒ Array<Phoebe::Models::Ref::Region::ListListResponseItem>

Get the list of sub-regions for a given country or region. #### Notes Not all combinations of region type and region code are valid. You can fetch all the subnational1 or subnational2 regions for a country however you can only specify a region type of ‘country’ when using ‘world’ as a region code.

Parameters:

  • parent_region_code (String)

    Path param: The country or subnational1 code, or ‘world’.

  • region_type (String)

    Path param: The region type: ‘country’, ‘subnational1’ or ‘subnational2’.

  • fmt (Symbol, Phoebe::Models::Ref::Region::ListListParams::Fmt)

    Query param: Fetch the records in CSV or JSON format.

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

Returns:

See Also:



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/phoebe/resources/ref/region/list.rb', line 27

def list(parent_region_code, params)
  parsed, options = Phoebe::Ref::Region::ListListParams.dump_request(params)
  query = Phoebe::Internal::Util.encode_query_params(parsed)
  region_type =
    parsed.delete(:region_type) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :get,
    path: ["ref/region/list/%1$s/%2$s", region_type, parent_region_code],
    query: query,
    model: Phoebe::Internal::Type::ArrayOf[Phoebe::Models::Ref::Region::ListListResponseItem],
    options: options
  )
end