Class: OpenActive::DatasetSite::Settings
- Inherits:
-
Object
- Object
- OpenActive::DatasetSite::Settings
- Defined in:
- lib/openactive/dataset_site/settings.rb
Instance Attribute Summary collapse
-
#background_image_url ⇒ Object
Returns the value of attribute background_image_url.
-
#data_downloads ⇒ Array<OpenActive::Models::DataDownload>
An array of DataDownload objects.
-
#data_feed_types ⇒ Object
Returns the value of attribute data_feed_types.
-
#dataset_discussion_url ⇒ Object
Returns the value of attribute dataset_discussion_url.
-
#dataset_documentation_url ⇒ Object
Returns the value of attribute dataset_documentation_url.
-
#dataset_languages ⇒ Object
Returns the value of attribute dataset_languages.
-
#dataset_site_url ⇒ Object
Returns the value of attribute dataset_site_url.
-
#date_first_published ⇒ Object
Returns the value of attribute date_first_published.
-
#open_booking_api_authentication_authority_url ⇒ Object
Returns the value of attribute open_booking_api_authentication_authority_url.
-
#open_booking_api_base_url ⇒ Object
**** OPEN BOOKING ****.
-
#open_booking_api_documentation_url ⇒ Object
Returns the value of attribute open_booking_api_documentation_url.
-
#open_booking_api_registration_url ⇒ Object
Returns the value of attribute open_booking_api_registration_url.
-
#open_booking_api_terms_service_url ⇒ Object
Returns the value of attribute open_booking_api_terms_service_url.
-
#open_data_feed_base_url ⇒ Object
Returns the value of attribute open_data_feed_base_url.
-
#organisation_email ⇒ Object
Returns the value of attribute organisation_email.
-
#organisation_legal_entity ⇒ Object
Returns the value of attribute organisation_legal_entity.
-
#organisation_logo_url ⇒ Object
Returns the value of attribute organisation_logo_url.
-
#organisation_name ⇒ Object
Returns the value of attribute organisation_name.
-
#organisation_plain_text_description ⇒ Object
Returns the value of attribute organisation_plain_text_description.
-
#organisation_url ⇒ Object
Returns the value of attribute organisation_url.
-
#platform_name ⇒ Object
Returns the value of attribute platform_name.
-
#platform_software_version ⇒ Object
Returns the value of attribute platform_software_version.
-
#platform_url ⇒ Object
Returns the value of attribute platform_url.
-
#test_suite_certificate_url ⇒ Object
**** TEST SUITE CERTIFICATE ****.
Instance Method Summary collapse
- #access_service ⇒ Object
- #booking_service ⇒ OpenActive::Models::BookingService?
-
#data_download(feed_type) ⇒ OpenActive::Models::DataDownload
A DataDownload object.
- #data_feed_descriptions ⇒ Object
- #data_feed_descriptions_sentence ⇒ Object
- #dataset_description ⇒ Object
-
#initialize(**params) ⇒ Settings
constructor
A new instance of Settings.
-
#keywords ⇒ Array<String>
An array of keywords.
- #name ⇒ Object
-
#to_dataset ⇒ Object
rubocop:disable Metrics/MethodLength.
- #webapi_description ⇒ Object
Constructor Details
#initialize(**params) ⇒ Settings
Returns a new instance of Settings.
4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/openactive/dataset_site/settings.rb', line 4 def initialize(**params) super() params.each do |k, v| setter_method = "#{k}=" raise ArgumentError, "Unrecognised field #{k}" unless respond_to?(setter_method) public_send(setter_method, v) end end |
Instance Attribute Details
#background_image_url ⇒ Object
Returns the value of attribute background_image_url.
30 31 32 |
# File 'lib/openactive/dataset_site/settings.rb', line 30 def background_image_url @background_image_url end |
#data_downloads ⇒ Array<OpenActive::Models::DataDownload>
Returns An array of DataDownload objects.
100 101 102 |
# File 'lib/openactive/dataset_site/settings.rb', line 100 def data_downloads @data_downloads end |
#data_feed_types ⇒ Object
Returns the value of attribute data_feed_types.
37 38 39 |
# File 'lib/openactive/dataset_site/settings.rb', line 37 def data_feed_types @data_feed_types end |
#dataset_discussion_url ⇒ Object
Returns the value of attribute dataset_discussion_url.
19 20 21 |
# File 'lib/openactive/dataset_site/settings.rb', line 19 def dataset_discussion_url @dataset_discussion_url end |
#dataset_documentation_url ⇒ Object
Returns the value of attribute dataset_documentation_url.
20 21 22 |
# File 'lib/openactive/dataset_site/settings.rb', line 20 def dataset_documentation_url @dataset_documentation_url end |
#dataset_languages ⇒ Object
Returns the value of attribute dataset_languages.
21 22 23 |
# File 'lib/openactive/dataset_site/settings.rb', line 21 def dataset_languages @dataset_languages end |
#dataset_site_url ⇒ Object
Returns the value of attribute dataset_site_url.
18 19 20 |
# File 'lib/openactive/dataset_site/settings.rb', line 18 def dataset_site_url @dataset_site_url end |
#date_first_published ⇒ Object
Returns the value of attribute date_first_published.
31 32 33 |
# File 'lib/openactive/dataset_site/settings.rb', line 31 def date_first_published @date_first_published end |
#open_booking_api_authentication_authority_url ⇒ Object
Returns the value of attribute open_booking_api_authentication_authority_url.
46 47 48 |
# File 'lib/openactive/dataset_site/settings.rb', line 46 def @open_booking_api_authentication_authority_url end |
#open_booking_api_base_url ⇒ Object
**** OPEN BOOKING ****
42 43 44 |
# File 'lib/openactive/dataset_site/settings.rb', line 42 def open_booking_api_base_url @open_booking_api_base_url end |
#open_booking_api_documentation_url ⇒ Object
Returns the value of attribute open_booking_api_documentation_url.
43 44 45 |
# File 'lib/openactive/dataset_site/settings.rb', line 43 def open_booking_api_documentation_url @open_booking_api_documentation_url end |
#open_booking_api_registration_url ⇒ Object
Returns the value of attribute open_booking_api_registration_url.
45 46 47 |
# File 'lib/openactive/dataset_site/settings.rb', line 45 def open_booking_api_registration_url @open_booking_api_registration_url end |
#open_booking_api_terms_service_url ⇒ Object
Returns the value of attribute open_booking_api_terms_service_url.
44 45 46 |
# File 'lib/openactive/dataset_site/settings.rb', line 44 def open_booking_api_terms_service_url @open_booking_api_terms_service_url end |
#open_data_feed_base_url ⇒ Object
Returns the value of attribute open_data_feed_base_url.
16 17 18 |
# File 'lib/openactive/dataset_site/settings.rb', line 16 def open_data_feed_base_url @open_data_feed_base_url end |
#organisation_email ⇒ Object
Returns the value of attribute organisation_email.
26 27 28 |
# File 'lib/openactive/dataset_site/settings.rb', line 26 def organisation_email @organisation_email end |
#organisation_legal_entity ⇒ Object
Returns the value of attribute organisation_legal_entity.
24 25 26 |
# File 'lib/openactive/dataset_site/settings.rb', line 24 def organisation_legal_entity @organisation_legal_entity end |
#organisation_logo_url ⇒ Object
Returns the value of attribute organisation_logo_url.
28 29 30 |
# File 'lib/openactive/dataset_site/settings.rb', line 28 def organisation_logo_url @organisation_logo_url end |
#organisation_name ⇒ Object
Returns the value of attribute organisation_name.
23 24 25 |
# File 'lib/openactive/dataset_site/settings.rb', line 23 def organisation_name @organisation_name end |
#organisation_plain_text_description ⇒ Object
Returns the value of attribute organisation_plain_text_description.
25 26 27 |
# File 'lib/openactive/dataset_site/settings.rb', line 25 def organisation_plain_text_description @organisation_plain_text_description end |
#organisation_url ⇒ Object
Returns the value of attribute organisation_url.
27 28 29 |
# File 'lib/openactive/dataset_site/settings.rb', line 27 def organisation_url @organisation_url end |
#platform_name ⇒ Object
Returns the value of attribute platform_name.
33 34 35 |
# File 'lib/openactive/dataset_site/settings.rb', line 33 def platform_name @platform_name end |
#platform_software_version ⇒ Object
Returns the value of attribute platform_software_version.
35 36 37 |
# File 'lib/openactive/dataset_site/settings.rb', line 35 def platform_software_version @platform_software_version end |
#platform_url ⇒ Object
Returns the value of attribute platform_url.
34 35 36 |
# File 'lib/openactive/dataset_site/settings.rb', line 34 def platform_url @platform_url end |
#test_suite_certificate_url ⇒ Object
**** TEST SUITE CERTIFICATE ****
50 51 52 |
# File 'lib/openactive/dataset_site/settings.rb', line 50 def test_suite_certificate_url @test_suite_certificate_url end |
Instance Method Details
#access_service ⇒ Object
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'lib/openactive/dataset_site/settings.rb', line 129 def access_service return unless open_booking_api_base_url && !open_booking_api_base_url.empty? access_service = OpenActive::Models::WebAPI.new( name: 'Open Booking API', description: webapi_description, documentation: "https://permalink.openactive.io/dataset-site/open-booking-api-documentation", endpoint_url: open_booking_api_base_url, conforms_to: ["https://openactive.io/open-booking-api/EditorsDraft/"], endpoint_description: "https://www.openactive.io/open-booking-api/EditorsDraft/swagger.json", landing_page: open_booking_api_registration_url ) if (open_booking_api_documentation_url_val = open_booking_api_documentation_url) access_service.documentation = open_booking_api_documentation_url_val end if ( = ) access_service. = end if (open_booking_api_terms_service_url_val = open_booking_api_terms_service_url) access_service.terms_of_service = open_booking_api_terms_service_url_val end access_service end |
#booking_service ⇒ OpenActive::Models::BookingService?
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/openactive/dataset_site/settings.rb', line 105 def booking_service return unless (platform_name && !platform_name.empty?) || (test_suite_certificate_url && !test_suite_certificate_url.empty?) booking_service = OpenActive::Models::BookingService.new() if (platform_name_val = platform_name) booking_service.name = platform_name_val end if (platform_url_val = platform_url) booking_service.url = platform_url_val end if (platform_software_version_val = platform_software_version) booking_service.software_version = platform_software_version_val end if (has_credential_val = test_suite_certificate_url) booking_service.has_credential = has_credential_val end booking_service end |
#data_download(feed_type) ⇒ OpenActive::Models::DataDownload
Returns A DataDownload object.
90 91 92 93 94 95 96 97 |
# File 'lib/openactive/dataset_site/settings.rb', line 90 def data_download(feed_type) OpenActive::Models::DataDownload.new( name: feed_type.name, additional_type: feed_type.same_as, encoding_format: OpenActive::DatasetSite::Meta::RPDE_MEDIA_TYPE, content_url: open_data_feed_base_url + feed_type.default_feed_path, ) end |
#data_feed_descriptions ⇒ Object
52 53 54 55 56 |
# File 'lib/openactive/dataset_site/settings.rb', line 52 def data_feed_descriptions data_feed_types.map do |description| description.respond_to?(:display_name) ? description.display_name : description end.uniq end |
#data_feed_descriptions_sentence ⇒ Object
62 63 64 |
# File 'lib/openactive/dataset_site/settings.rb', line 62 def data_feed_descriptions_sentence data_feed_descriptions.to_sentence.downcase end |
#dataset_description ⇒ Object
77 78 79 80 81 |
# File 'lib/openactive/dataset_site/settings.rb', line 77 def dataset_description "Near real-time availability and rich descriptions relating to the "\ "#{data_feed_descriptions_sentence} available from "\ "#{organisation_name}" end |
#keywords ⇒ Array<String>
Returns An array of keywords.
67 68 69 70 71 72 73 74 75 |
# File 'lib/openactive/dataset_site/settings.rb', line 67 def keywords [ *data_feed_descriptions, "Activities", "Sports", "Physical Activity", "OpenActive" ] end |
#name ⇒ Object
58 59 60 |
# File 'lib/openactive/dataset_site/settings.rb', line 58 def name "#{organisation_name} #{data_feed_descriptions.to_sentence}" end |
#to_dataset ⇒ Object
rubocop:disable Metrics/MethodLength
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 |
# File 'lib/openactive/dataset_site/settings.rb', line 157 def to_dataset # rubocop:disable Metrics/MethodLength dataset = OpenActive::Models::Dataset.new( id: dataset_site_url, url: dataset_site_url, name: name, description: dataset_description, keywords: keywords, license: "https://creativecommons.org/licenses/by/4.0/", discussion_url: dataset_discussion_url, documentation: "https://permalink.openactive.io/dataset-site/open-data-documentation", in_language: dataset_languages, schema_version: "https://www.openactive.io/modelling-opportunity-data/2.0/", publisher: OpenActive::Models::Organization.new( name: organisation_name, legal_name: organisation_legal_entity, description: organisation_plain_text_description, email: organisation_email, url: organisation_url, logo: OpenActive::Models::ImageObject.new( url: organisation_logo_url, ), ), date_modified: DateTime.now.new_offset(0), background_image: OpenActive::Models::ImageObject.new( url: background_image_url, ), distribution: data_downloads, date_published: date_first_published, ) if (dataset_documentation_url_val = dataset_documentation_url) dataset.documentation = dataset_documentation_url_val end if (booking_service_val = booking_service) dataset.booking_service = booking_service_val end if (access_service_val = access_service) dataset.access_service = access_service_val end dataset end |
#webapi_description ⇒ Object
83 84 85 86 87 |
# File 'lib/openactive/dataset_site/settings.rb', line 83 def webapi_description "API that allows for seamless booking experiences to be created for "\ "#{data_feed_descriptions_sentence} available from "\ "#{organisation_name}" end |