diff --git a/app/controllers/api_keys_controller.rb b/app/controllers/api_keys_controller.rb index a67cd3136..c2214c374 100644 --- a/app/controllers/api_keys_controller.rb +++ b/app/controllers/api_keys_controller.rb @@ -16,25 +16,16 @@ def index sig { void } def create user = T.must(current_user) - redirect_url = if Flipper.enabled?(:trial_api_keys, current_user) - api_keys_url - else - api_howto_url - end # For the time being limit users to only creating one API key if user.api_keys.empty? - if Flipper.enabled?(:trial_api_keys, current_user) - # Create a trial key which automatically expires and has a low daily limit - # TODO: Extract this - user.api_keys.create!(daily_limit: ApiKey.default_daily_limit_trial, expires_at: ApiKey.default_trial_duration_days.days.from_now) - else - user.api_keys.create! - end - redirect_to redirect_url, notice: t(".success") + # Create a trial key which automatically expires and has a low daily limit + # TODO: Extract this + user.api_keys.create!(daily_limit: ApiKey.default_daily_limit_trial, expires_at: ApiKey.default_trial_duration_days.days.from_now) + redirect_to api_keys_url, notice: t(".success") else # This is a terrible way of showing an error but it's not likely to happen so I'm not going to worry about that - redirect_to redirect_url, notice: t(".already_have_key") + redirect_to api_keys_url, notice: t(".already_have_key") end end diff --git a/app/controllers/documentation_controller.rb b/app/controllers/documentation_controller.rb index b62d88bed..73f277c3c 100644 --- a/app/controllers/documentation_controller.rb +++ b/app/controllers/documentation_controller.rb @@ -12,18 +12,10 @@ def about; end def faq; end sig { void } - def api_howto - # If feature flag is enabled show a new landing page instead - # with a link to an extracted "API Developer Documentation" page - return unless Flipper.enabled?(:trial_api_keys, current_user) - - render "api_landing" - end + def api_howto; end sig { void } - def api_developer - raise ActiveRecord::RecordNotFound unless Flipper.enabled?(:trial_api_keys, current_user) - end + def api_developer; end # rubocop:disable Naming/AccessorMethodName sig { void } diff --git a/app/views/application/_footer.html.erb b/app/views/application/_footer.html.erb index 5ed2aebee..1fce98628 100644 --- a/app/views/application/_footer.html.erb +++ b/app/views/application/_footer.html.erb @@ -16,11 +16,7 @@ <%# Repeat the main nav in the footer %>
+ Seamlessly integrate planning alerts data into your custom application +
-- Planning application data is available programmatically. Details of the API are listed below. -
-- All the API calls listed below return planning application sorted by the date they were scraped from the planning authority website with the most - recent listed first. -
-- The API can return different formats including JSON, GeoJSON and GeoRSS. - The examples below return JSON. To get GeoJSON instead simply replace ".json" in the URL with ".geojson". For GeoRSS replace ".json" with ".rss". + <%# TODO: Is this saying too much of the same thing as the "who uses our API" section below? %> + Planning Alerts Application Programming Interface (API) serves community groups, businesses, NGOs, and civic-minded individuals by providing access to trusted planning and development application data.
+
- The API examples below contain your API key:
- <%= api_key %>
+ Lots of people!
+ Real estate developers and agents, construction companies, urban planners, architects,
+ local government and municipalities, property management firms, community advocacy groups, environmental and heritage organizations,
+ academics,
+ legal firms, conveyancers, utility companies, insurance companies, researchers, tech startups and app developers are interested in this data.
+
+ API data for strictly non-commercial use for public benefit.
- <% else %> ++ $0 + AUD + / month +
++ <%= pa_link_to "Contact us", api_contact_path, extra_classes: "block" %> to apply +
+- You need an API key to try out the examples below and use the API for yourself. + Set and forget reliable API service, effortlessly integrated into your application.
-+ $3499 + AUD + + GST / month +
++ <%= pa_link_to "Contact us", api_contact_path, extra_classes: "block" %> + to sign up +
+ + +- To use the API you will to - <%= pa_link_to "register for an account", new_user_registration_path %> - or - <%= pa_link_to "sign in", new_user_session_path %> - to your existing account. Once you've done that, return to this page - and the you will be able to create an API key here. -
- <% end %> -+ More power and flexibility. Talk to us for pricing. +
++ Potential add ons can include: +
++ <%= pa_link_to "Contact us", api_contact_path, extra_classes: "block" %> + to discuss your needs +
+- Return applications near a given longitude/latitude. The area included is a circle with a radius of the given size (in metres) - with the longitude/latitude at its center. Suggested sizes are 400, 800 or 4000 metres. -
-
- <%= api_example_latlong_url_html(format: "json", key: api_key) %>
-
- <% if api_key %>
- <%= render ButtonComponent.new(tag: :a, size: "xl", type: :primary, href: api_example_latlong_url(format: "json", key: api_key)) do %>
- View example
+<%# Only show this section if you don't have an API key yet %>
+<% if api_key.nil? %>
+ - Return applications within a rectangle defined by longitude/latitude. -
-
- <%= api_example_area_url_html(format: "json", key: api_key) %>
-
- <% if api_key %>
- <%= render ButtonComponent.new(tag: :a, size: "xl", type: :primary, href: api_example_area_url(format: "json", key: api_key)) do %>
- View example
- <% end %>
- <% end %>
- - Return applications for a specific planning authority (e.g. a local council) by authority short name. To discover the authority short name - to use here, find the planning authority on the - <%= pa_link_to "list of authorities", authorities_path %> - and follow the link. The url has the authority short name in it. -
-
- <%= api_example_authority_url_html(format: "json", key: api_key) %>
-
- <% if api_key %>
- <%= render ButtonComponent.new(tag: :a, size: "xl", type: :primary, href: api_example_authority_url(format: "json", key: api_key)) do %>
- View example
- <% end %>
- <% end %>
- - Return applications for a specific postcode area -
-
- <%= api_example_postcode_url_html(format: "json", key: api_key) %>
-
- <% if api_key %>
- <%= render ButtonComponent.new(tag: :a, size: "xl", type: :primary, href: api_example_postcode_url(format: "json", key: api_key)) do %>
- View example
- <% end %>
- <% end %>
- - Return applications in a suburb. Including “state” and “postcode” in the search is optional. +
+ Build, test and explore with live API data +
++ Enjoy up to + <%= ApiKey.default_daily_limit_trial %> + requests a day (returning up to a total of + <%= number_with_delimiter(ApiKey.default_daily_limit_trial * Application.max_per_page) %> + applications per day) for + <%= pluralize(ApiKey.default_trial_duration_days, "day") %>.
-
- <%= api_example_suburb_state_and_postcode_url_html(format: "json", key: api_key) %>
-
- <% if api_key %>
- <%= render ButtonComponent.new(tag: :a, size: "xl", type: :primary, href: api_example_suburb_state_and_postcode_url(format: "json", key: api_key)) do %>
- View example
- <% end %>
+ <%= image_tag "illustration/key.svg", alt: "", size: "237x155", class: "my-8" %>
+ <% if current_user %>
+ <%= render ButtonComponent.new(tag: :a, size: "xl", type: :primary, href: confirm_api_keys_path).with_content("Create API key") %>
+ <% else %>
+ + To get an instant API key simply + <%= pa_link_to "create an account", new_user_registration_path %> + or + <%= pa_link_to "sign in", new_user_session_path %>. +
<% end %> - +
- There are several parameters that can be applied to each of the above queries for extra usefulness.
+<% end %>
+
+
+ In our API you can find Australia-wide data, updated daily:
- API calls return a maximum of <%= Application.max_per_page %> results. To retrieve more results simply do another request with page
- set to 2, 3, etc… Not setting the page parameter is the same as requesting page 1.
-
- API calls by default return a maximum of <%= Application.max_per_page %> results. To return less than that per page simply set the count parameter to the maximum number you want to return.
+
+ For privacy reasons our API does not return personal information including Planning Alerts user comments or names associated with applications.
- Client-side API queries are supported using
- <%= pa_link_to "CORS", "https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS" %>. You might do this, for example,
- in a Javascript application that runs in the browser making requests directly to the Planning Alerts API. This is fine for testing. However, this should not be used
- in production as you would be effectively making your API key public, which is a very bad. It is your responsibility to keep the API key
- safe and secure.
-
- Instead we recommend either loading the data ahead of time server-side and passing the data to your client or alternatively proxying the client-side requests
- through your own server where you add the API key.
-
- Low volume,
- non–commercial
- use of the API service is free. We ask that personal and non–profit use of this service attribute the OpenAustralia Foundation on your website or application.
-
- Standard agreements for commercial use are at
- <%= pa_link_to "oaf.org.au/standard-agreements/planningalerts-commercial", "https://www.oaf.org.au/standard-agreements/planningalerts-commercial/" %>.
- Please
- <%= pa_link_to "contact us", api_contact_path %>
- for
- commercial
- use. Commercial users may include Real Estate Agencies, Architects, Planners or Builders.
-
- Also, please
- <%= pa_link_to "get in touch", api_contact_path %>
- if you intend to use the service on a large scale.
- In order to maintain quality of service for our API users, this service is rate limited by default to approximately <%= ApiKey.default_daily_limit %> requests per day.
-
- We offer a range of paid options, from rate–limited to unlimited use of this service.
-
- The Planning Alerts service is intended to help people be aware of what's happening in their local neighborhood, and to enable a civil discussion about those changes.
-
- Don't use the service (or information obtained from the service) to market goods or services to individuals.
-
- Don't use the service (or information obtained from the service) to harass or intimidate a person.
+ <%= image_tag "illustration/person_big_arms.svg", alt: "Illustration of headshot of three different people", class: "max-w-64" %>
+
+ <%# TODO: Add something about complex automations and data integrity checks, etc.. %>
+ We've been doing this for more than 14 years with an extremely experienced team.
+ Leverage that for your own needs rather than trying to reinvent the wheel.
- <%= api_example_postcode_url_html(format: "json", key: api_key, postcode: "2780", extra_params: { page: 2 }) %>
-
-
- <%= api_example_postcode_url_html(format: "json", key: api_key, postcode: "2780", extra_params: { count: 10 }) %>
-
+
+
- Seamlessly integrate planning alerts data into your custom application -
- - <%= image_tag "illustration/data.svg" %> -- <%# TODO: Is this saying too much of the same thing as the "who uses our API" section below? %> - Planning Alerts Application Programming Interface (API) serves community groups, businesses, NGOs, and civic-minded individuals by providing access to trusted planning and development application data. -
-Lots of people!
-- Real estate developers and agents, construction companies, urban planners, architects, - local government and municipalities, property management firms, community advocacy groups, environmental and heritage organizations, - academics, - legal firms, conveyancers, utility companies, insurance companies, researchers, tech startups and app developers are interested in this data. -
-- API data for strictly non-commercial use for public benefit. -
-- $0 - AUD - / month -
-- <%= pa_link_to "Contact us", api_contact_path, extra_classes: "block" %> to apply -
-- Set and forget reliable API service, effortlessly integrated into your application. -
-- $3499 - AUD - + GST / month -
-- <%= pa_link_to "Contact us", api_contact_path, extra_classes: "block" %> - to sign up -
-- More power and flexibility. Talk to us for pricing. -
-- Potential add ons can include: -
-- <%= pa_link_to "Contact us", api_contact_path, extra_classes: "block" %> - to discuss your needs -
-- Build, test and explore with live API data -
-- Enjoy up to - <%= ApiKey.default_daily_limit_trial %> - requests a day (returning up to a total of - <%= number_with_delimiter(ApiKey.default_daily_limit_trial * Application.max_per_page) %> - applications per day) for - <%= pluralize(ApiKey.default_trial_duration_days, "day") %>. -
- <%= image_tag "illustration/key.svg", alt: "", size: "237x155", class: "my-8" %> - <% if current_user %> - <%= render ButtonComponent.new(tag: :a, size: "xl", type: :primary, href: confirm_api_keys_path).with_content("Create API key") %> - <% else %> -- To get an instant API key simply - <%= pa_link_to "create an account", new_user_registration_path %> - or - <%= pa_link_to "sign in", new_user_session_path %>. -
- <% end %> -- In our API you can find Australia-wide data, updated daily: -
-- For privacy reasons our API does not return personal information including Planning Alerts user comments or names associated with applications. -
-- <%# TODO: Add something about complex automations and data integrity checks, etc.. %> - We've been doing this for more than 14 years with an extremely experienced team. - Leverage that for your own needs rather than trying to reinvent the wheel. -
-