{"id":23009898,"url":"https://github.com/openactive/models-ruby","last_synced_at":"2025-08-14T04:33:06.632Z","repository":{"id":37773987,"uuid":"210608892","full_name":"openactive/models-ruby","owner":"openactive","description":"Ruby Models for the OpenActive Opportunity and Booking Specifications","archived":false,"fork":false,"pushed_at":"2024-06-20T10:07:32.000Z","size":724,"stargazers_count":3,"open_issues_count":3,"forks_count":3,"subscribers_count":9,"default_branch":"master","last_synced_at":"2024-12-01T22:23:04.877Z","etag":null,"topics":["implementation-support","pre-release","ruby"],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/openactive.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-09-24T13:23:23.000Z","updated_at":"2024-06-18T15:54:02.000Z","dependencies_parsed_at":"2024-03-27T18:33:29.971Z","dependency_job_id":"d8135ed8-26a5-47a5-90ad-d36d6467803f","html_url":"https://github.com/openactive/models-ruby","commit_stats":{"total_commits":109,"total_committers":8,"mean_commits":13.625,"dds":"0.42201834862385323","last_synced_commit":"805be9aa34422fba016be625ecf6a9ff29805664"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openactive%2Fmodels-ruby","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openactive%2Fmodels-ruby/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openactive%2Fmodels-ruby/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/openactive%2Fmodels-ruby/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/openactive","download_url":"https://codeload.github.com/openactive/models-ruby/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229800367,"owners_count":18126028,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["implementation-support","pre-release","ruby"],"created_at":"2024-12-15T09:16:27.631Z","updated_at":"2024-12-15T09:16:28.253Z","avatar_url":"https://github.com/openactive.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# openactive gem - Ruby implementation of OpenActive's data model [![Tests](https://github.com/openactive/models-ruby/actions/workflows/tests.yaml/badge.svg?branch=master)](https://github.com/openactive/models-ruby/actions/workflows/tests.yaml)\n\nRuby Models for the OpenActive Opportunity and Booking Specifications\n\nOpenActive aims to provide model files for all classes defined in its Opportunity and Booking specifications across the PHP, Ruby, and .NET languages. This repository is intended for the Ruby files; see also the [PHP](https://github.com/openactive/models-php) and [.NET](https://github.com/openactive/OpenActive.NET) implementations.\n\nAdditional documentation can be found at https://www.rubydoc.info/gems/openactive/.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'openactive'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install openactive\n\n## Usage\n\nThis package provides Ruby models for the OpenActive specifications.\n\nIt also provide a set of models for the [schema.org](https://schema.org) specifications.\n\nFinally it provides a set of classes to handle OpenActive's [RPDE](https://developer.openactive.io/publishing-data/data-feeds/how-a-data-feed-works) data feeds.\n\n### Models\nOpenActive includes OpenActive.io objects as objects for use in Ruby. All classes can be serialized into JSON-LD, to provide easy conformance with the [Modelling Specification](https://www.openactive.io/modelling-opportunity-data/) and [Open Booking API Specification](https://www.openactive.io/open-booking-api/).\n\n\nPlease note that type enforcement is in place for both class construction and attribute assignment, providing an invalid type will result in a OpenActive::Exception::InvalidArgumentException being thrown.\n\n### OpenActive\nClasses for all OpenActive classes are available in the `OpenActive::Models` and `OpenActive::Enums` namespaces, and can be easily serialized to JSON-LD, as follows. Enumerations are available as `enum`s for properties that require their use.\n\n```ruby\nevent = OpenActive::Models::Event.new(\n    name: \"Virtual BODYPUMP\",\n    event_status: OpenActive::Enums::Schema::EventStatusType::EventScheduled\n)\njson_ld = event.to_json\n```\n\nValue of `jsonLd`:\n```JSON\n{\n  \"@context\": \"https://openactive.io/\",\n  \"@type\": \"Event\",\n  \"name\": \"Virtual BODYPUMP\",\n  \"eventStatus\": \"https://schema.org/EventScheduled\"\n}\n```\n\n### Schema\nThe OpenActive data model builds on top of Schema.org, which means that you are free to use additional schema.org properties within OpenActive published data.\n\nTo reflect this, OpenActive uses inheritance to build ontop of a copy of Schema.org, these are available within the OpenActive::Models::Schema and OpenActive::Enums::Schema namespaces. And so makes it easy to use additional properties from schema.org on any given type.\n\n### Full Models Example\n```ruby\nsession_series = OpenActive::Models::SessionSeries.new(\n    name: \"Virtual BODYPUMP\",\n    description: \"This is the virtual version of the original barbell class, which will help you get lean, toned and fit - fast\",\n    start_date: \"2017-04-24T19:30:00-08:00\",\n    end_date: \"2017-04-24T23:00:00-08:00\",\n    location: OpenActive::Models::Place.new(\n        name: \"Raynes Park High School, 46A West Barnes Lane\",\n        geo: OpenActive::Models::GeoCoordinates.new(\n            latitude: 51.4034423828125,\n            longitude: -0.2369088977575302,\n        )\n    ),\n    activity: OpenActive::Models::Concept.new(\n        id: \"https://openactive.io/activity-list#5e78bcbe-36db-425a-9064-bf96d09cc351\",\n        pref_label: \"Bodypump™\",\n        in_scheme: \"https://openactive.io/activity-list\"\n    ),\n    organizer: OpenActive::Models::Organization.new(\n        name: \"Central Speedball Association\",\n        url: \"http://www.speedball-world.com\"\n    ),\n    offers: [OpenActive::Models::Offer.new(\n        identifier: \"OX-AD\",\n        name: \"Adult\",\n        price: 3.30,\n        price_currency: \"GBP\",\n        url: \"https://profile.everyoneactive.com/booking?Site=0140\u0026Activities=1402CBP20150217\u0026Culture=en-GB\"\n    )]\n)\n\nsession_series.to_json\n```\nThis results in\n\n```json\n{\n  \"@context\": [\"https://openactive.io/\", \"https://openactive.io/ns-beta\"],\n  \"@type\": \"SessionSeries\",\n  \"description\": \"This is the virtual version of the original barbell class, which will help you get lean, toned and fit - fast\",\n  \"offers\": [{\n    \"@type\": \"Offer\",\n    \"name\": \"Adult\",\n    \"url\": \"https://profile.everyoneactive.com/booking?Site=0140\u0026Activities=1402CBP20150217\u0026Culture=en-GB\",\n    \"price\": \"3.33\",\n    \"priceCurrency\": \"GBP\",\n    \"identifier\": \"OX-AD\"\n  }],\n  \"startDate\": \"2017-04-24T19:30:00-08:00\",\n  \"endDate\": \"2017-04-24T23:00:00-08:00\",\n  \"location\": {\n    \"@type\": \"Place\",\n    \"name\": \"Raynes Park High School, 46A West Barnes Lane\",\n    \"geo\": {\n      \"@type\": \"GeoCoordinates\",\n      \"longitude\": \"-0.2369088977575302e0\",\n      \"latitude\": \"0.514034423828125e2\"\n    }\n  },\n  \"organizer\": {\n    \"@type\": \"Organization\",\n    \"name\": \"Central Speedball Association\",\n    \"url\": \"http://www.speedball-world.com\"\n  },\n  \"activity\": {\n    \"@type\": \"Concept\",\n    \"@id\": \"https://openactive.io/activity-list#5e78bcbe-36db-425a-9064-bf96d09cc351\",\n    \"inScheme\": \"https://openactive.io/activity-list\",\n    \"prefLabel\": \"Bodypump™\"\n  },\n  \"name\": \"Virtual BODYPUMP\"\n}\n```\n\n## RPDE Feed Publishing \n\nTo publish an OpenActive data feed (see this [video explainer](https://developer.openactive.io/publishing-data/data-feeds/how-a-data-feed-works)), The OpenActive gem provides a drop-in solution to render the feed pages. This also includes validation for the underlying feed query.\n\n### Modified Timestamp and ID Ordering Strategy\n\n`OpenActive::Rpde::RpdeBody.create_from_modified_id(feedBaseUrl, afterTimestamp, afterId, items)`\n\nCreates a new RPDE Page based on the RPDE Items provided using the [Modified Timestamp and ID Ordering Strategy](https://www.w3.org/2017/08/realtime-paged-data-exchange/#modified-timestamp-and-id), given the `afterTimestamp` and `afterId` parameters of the current query. Also validates that the items are in the correct order, throwing a `SerializationException` if this is not the case.\n\n```ruby\nitems = [\n    OpenActive::Rpde::RpdeItem.new(\n        Id: \"1\",\n        Modified: 3,\n        State: OpenActive::Rpde::RpdeState::Updated,\n        Kind: OpenActive::Rpde::RpdeKind::SessionSeries,\n        Data: @event\n    ),\n    OpenActive::Rpde::RpdeItem.new(\n        Id: \"2\",\n        Modified: 4,\n        State: OpenActive::Rpde::RpdeState::Deleted,\n        Kind: OpenActive::Rpde::RpdeKind::SessionSeries,\n        Data: nil\n    )\n]\n\njson_ld = OpenActive::Rpde::RpdeBody.new(\"https://www.example.com/feed\", 1, \"1\", items).to_json\n```\n\n\n### Incrementing Unique Change Number Ordering Strategy\n\n`OpenActive::Rpde::RpdeBody.create_from_next_change_number(feedBaseUrl, afterChangeNumber, items)`\n\nCreates a new RPDE Page based on the RPDE Items provided using the [Incrementing Unique Change Number Ordering Strategy](https://www.w3.org/2017/08/realtime-paged-data-exchange/#incrementing-unique-change-number), given the `afterChangeNumber` parameter of the current query. Also validates that the items are in the correct order, throwing a `SerializationException` if this is not the case.\n\n```ruby\nitems = [\n    OpenActive::Rpde::RpdeItem.new(\n        Id: \"1\",\n        Modified: 3,\n        State: OpenActive::Rpde::RpdeState::Updated,\n        Kind: OpenActive::Rpde::RpdeKind::SessionSeries,\n        Data: @event\n    ),\n    OpenActive::Rpde::RpdeItem.new(\n        Id: \"2\",\n        Modified: 4,\n        State: OpenActive::Rpde::RpdeState::Deleted,\n        Kind: OpenActive::Rpde::RpdeKind::SessionSeries,\n        Data: nil\n    )\n]\n\njson_ld = OpenActive::Rpde::RpdeBody.create_from_next_change_number(\"https://www.example.com/feed\", 2, items).to_json\n```\n\n## Serialization\n\n### `obj.serialize`\nReturns the serialized object in hash form complying to json-ld structure (unlike .to_h this serializes everything all the way down.)\n```\nevent.serialize\n```\n```\n{\"@type\"=\u003e\"Event\", \"name\"=\u003e\"Virtual BODYPUMP\", \"eventStatus\"=\u003e\"https://schema.org/EventScheduled\", \"@context\"=\u003e[\"https://openactive.io/\", \"https://openactive.io/ns-beta\"]}\n```\n### `obj.to_json`\nSerializes down to a json-ld string.\n```ruby\nevent.to_json\n```\nreturns\n```ruby\n\"{\\\"@type\\\":\\\"Event\\\",\\\"name\\\":\\\"Virtual BODYPUMP\\\",\\\"eventStatus\\\":\\\"https://schema.org/EventScheduled\\\",\\\"@context\\\":[\\\"https://openactive.io/\\\",\\\"https://openactive.io/ns-beta\\\"]}\"\n```\n\n## Deserialization\n```ruby\n\ndata = JSON.parse('{\"@context\": [\"https:\\/\\/openactive.io\\/\",\"https:\\/\\/openactive.io\\/ns-beta\"],\"type\": \"Action\",\"name\": \"Book\",\"target\": {\"type\": \"EntryPoint\",\"encodingType\": \"application\\/vnd.openactive.v1.0+json\",\"httpMethod\": \"POST\",\"type\": \"EntryPoint\",\"url\": \"https:\\/\\/example.com\\/orders\"}}')\n\ndeserialized = OpenActive::BaseModel.deserialize(data)\n\npp deserialized\n```\n\nwill result in\n```ruby\n#\u003cOpenActive::Models::Action:0x00007ff6fd0966d0\n @name=\"Book\",\n @target=\n  #\u003cOpenActive::Models::EntryPoint:0x00007ff6fd095fa0\n   @encoding_type=\"application/vnd.openactive.v1.0+json\",\n   @http_method=\"POST\",\n   @url=#\u003cURI::HTTPS https://example.com/orders\u003e\u003e\u003e\n=\u003e #\u003cOpenActive::Models::Action:0x00007ff6fd0966d0\n @name=\"Book\",\n @target=#\u003cOpenActive::Models::EntryPoint:0x00007ff6fd095fa0 @encoding_type=\"application/vnd.openactive.v1.0+json\", @http_method=\"POST\", @url=#\u003cURI::HTTPS https://example.com/orders\u003e\u003e\u003e\n```\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/openactive/models-ruby.\n\n### Updating models\nA guide is provided in [UPDATING.md](UPDATING.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopenactive%2Fmodels-ruby","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopenactive%2Fmodels-ruby","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopenactive%2Fmodels-ruby/lists"}