w3c_api 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/LICENSE.md +1 -1
- data/README.adoc +845 -436
- data/lib/w3c_api/cli.rb +20 -20
- data/lib/w3c_api/client.rb +66 -195
- data/lib/w3c_api/commands/affiliation.rb +33 -33
- data/lib/w3c_api/commands/ecosystem.rb +47 -47
- data/lib/w3c_api/commands/group.rb +68 -68
- data/lib/w3c_api/commands/output_formatter.rb +11 -11
- data/lib/w3c_api/commands/participation.rb +20 -22
- data/lib/w3c_api/commands/series.rb +26 -26
- data/lib/w3c_api/commands/specification.rb +77 -52
- data/lib/w3c_api/commands/translation.rb +18 -18
- data/lib/w3c_api/commands/user.rb +60 -60
- data/lib/w3c_api/hal.rb +164 -0
- data/lib/w3c_api/models/account.rb +44 -0
- data/lib/w3c_api/models/affiliation.rb +54 -65
- data/lib/w3c_api/models/affiliation_index.rb +11 -0
- data/lib/w3c_api/models/call_for_translation.rb +15 -39
- data/lib/w3c_api/models/chair_index.rb +11 -0
- data/lib/w3c_api/models/charter.rb +48 -89
- data/lib/w3c_api/models/charter_index.rb +11 -0
- data/lib/w3c_api/models/connected_account.rb +21 -30
- data/lib/w3c_api/models/ecosystem.rb +20 -42
- data/lib/w3c_api/models/{ecosystems.rb → ecosystem_index.rb} +4 -10
- data/lib/w3c_api/models/evangelist_index.rb +11 -0
- data/lib/w3c_api/models/extension.rb +5 -7
- data/lib/w3c_api/models/group.rb +63 -142
- data/lib/w3c_api/models/group_index.rb +12 -0
- data/lib/w3c_api/models/join_emails.rb +5 -7
- data/lib/w3c_api/models/participant_index.rb +11 -0
- data/lib/w3c_api/models/participation.rb +31 -90
- data/lib/w3c_api/models/participation_index.rb +11 -0
- data/lib/w3c_api/models/photo.rb +26 -0
- data/lib/w3c_api/models/serie.rb +21 -51
- data/lib/w3c_api/models/{series.rb → serie_index.rb} +22 -13
- data/lib/w3c_api/models/spec_version.rb +69 -83
- data/lib/w3c_api/models/spec_version_index.rb +13 -0
- data/lib/w3c_api/models/spec_version_ref.rb +11 -13
- data/lib/w3c_api/models/specification.rb +54 -66
- data/lib/w3c_api/models/specification_index.rb +10 -0
- data/lib/w3c_api/models/team_contact_index.rb +11 -0
- data/lib/w3c_api/models/testimonial.rb +17 -0
- data/lib/w3c_api/models/translation.rb +33 -72
- data/lib/w3c_api/models/{translations.rb → translation_index.rb} +4 -12
- data/lib/w3c_api/models/user.rb +95 -165
- data/lib/w3c_api/models/user_index.rb +11 -0
- data/lib/w3c_api/models.rb +35 -12
- data/lib/w3c_api/version.rb +1 -1
- data/lib/w3c_api.rb +3 -2
- metadata +35 -19
- data/lib/w3c_api/models/affiliations.rb +0 -33
- data/lib/w3c_api/models/base.rb +0 -39
- data/lib/w3c_api/models/call_for_translation_ref.rb +0 -15
- data/lib/w3c_api/models/charters.rb +0 -17
- data/lib/w3c_api/models/collection_base.rb +0 -79
- data/lib/w3c_api/models/delegate_enumerable.rb +0 -54
- data/lib/w3c_api/models/groups.rb +0 -38
- data/lib/w3c_api/models/link.rb +0 -17
- data/lib/w3c_api/models/participations.rb +0 -17
- data/lib/w3c_api/models/series_collection.rb +0 -17
- data/lib/w3c_api/models/spec_versions.rb +0 -17
- data/lib/w3c_api/models/specifications.rb +0 -17
- data/lib/w3c_api/models/users.rb +0 -44
@@ -1,7 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'lutaml/model'
|
4
|
-
|
5
3
|
# {
|
6
4
|
# "created"=>"2019-07-18T21:28:31+00:00",
|
7
5
|
# "updated"=>"2021-01-21T10:49:57+00:00",
|
@@ -18,37 +16,30 @@ require 'lutaml/model'
|
|
18
16
|
# }
|
19
17
|
|
20
18
|
module W3cApi
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
19
|
+
module Models
|
20
|
+
class ConnectedAccount < Lutaml::Hal::Resource
|
21
|
+
attribute :created, :date_time
|
22
|
+
attribute :updated, :date_time
|
23
|
+
attribute :service, :string
|
24
|
+
attribute :identifier, :string
|
25
|
+
attribute :nickname, :string
|
26
|
+
attribute :profile_picture, :string
|
27
|
+
attribute :href, :string
|
25
28
|
|
26
|
-
|
27
|
-
attribute :created, :date_time
|
28
|
-
attribute :updated, :date_time
|
29
|
-
attribute :service, :string
|
30
|
-
attribute :identifier, :string
|
31
|
-
attribute :nickname, :string
|
32
|
-
attribute :profile_picture, :string
|
33
|
-
attribute :href, :string
|
34
|
-
attribute :_links, ConnectedAccountLinks
|
29
|
+
hal_link :user, key: 'user', realize_class: 'User'
|
35
30
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
else
|
47
|
-
account.send("#{key}=", value) if account.respond_to?("#{key}=")
|
48
|
-
end
|
49
|
-
end
|
50
|
-
account
|
31
|
+
key_value do
|
32
|
+
%i[
|
33
|
+
created
|
34
|
+
updated
|
35
|
+
service
|
36
|
+
identifier
|
37
|
+
nickname
|
38
|
+
profile_picture
|
39
|
+
].each do |key|
|
40
|
+
map key.to_s.tr('_', '-'), to: key
|
51
41
|
end
|
52
42
|
end
|
53
43
|
end
|
44
|
+
end
|
54
45
|
end
|
@@ -1,8 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative 'base'
|
4
|
-
require_relative 'link'
|
5
|
-
|
6
3
|
# {
|
7
4
|
# "name": "Data and knowledge"
|
8
5
|
# "shortname": "data"
|
@@ -27,46 +24,27 @@ require_relative 'link'
|
|
27
24
|
# }
|
28
25
|
|
29
26
|
module W3cApi
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
client.ecosystem_groups(shortname)
|
51
|
-
end
|
52
|
-
|
53
|
-
def self.from_response(response)
|
54
|
-
transformed_response = transform_keys(response)
|
55
|
-
|
56
|
-
ecosystem = new
|
57
|
-
transformed_response.each do |key, value|
|
58
|
-
case key
|
59
|
-
when :_links
|
60
|
-
links = value.each_with_object({}) do |(link_name, link_data), acc|
|
61
|
-
acc[link_name] = Link.new(href: link_data[:href], title: link_data[:title])
|
62
|
-
end
|
63
|
-
ecosystem._links = EcosystemLinks.new(links)
|
64
|
-
else
|
65
|
-
ecosystem.send("#{key}=", value) if ecosystem.respond_to?("#{key}=")
|
66
|
-
end
|
67
|
-
end
|
68
|
-
ecosystem
|
27
|
+
module Models
|
28
|
+
class Ecosystem < Lutaml::Hal::Resource
|
29
|
+
attribute :name, :string
|
30
|
+
attribute :shortname, :string
|
31
|
+
attribute :href, :string
|
32
|
+
attribute :title, :string
|
33
|
+
|
34
|
+
hal_link :self, key: 'self', realize_class: 'Ecosystem'
|
35
|
+
hal_link :champion, key: 'champion', realize_class: 'User'
|
36
|
+
hal_link :evangelists, key: 'evangelists', realize_class: 'EvangelistIndex'
|
37
|
+
hal_link :groups, key: 'groups', realize_class: 'GroupIndex'
|
38
|
+
hal_link :member_organizations, key: 'member-organizations', realize_class: 'AffiliationIndex'
|
39
|
+
|
40
|
+
key_value do
|
41
|
+
%i[
|
42
|
+
name
|
43
|
+
shortname
|
44
|
+
].each do |key|
|
45
|
+
map key.to_s.tr('_', '-'), to: key
|
69
46
|
end
|
70
47
|
end
|
71
48
|
end
|
49
|
+
end
|
72
50
|
end
|
@@ -1,9 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'lutaml/model'
|
4
3
|
require_relative 'ecosystem'
|
5
|
-
require_relative 'delegate_enumerable'
|
6
|
-
require_relative 'collection_base'
|
7
4
|
|
8
5
|
# {
|
9
6
|
# "page": 1,
|
@@ -22,12 +19,9 @@ require_relative 'collection_base'
|
|
22
19
|
# },
|
23
20
|
|
24
21
|
module W3cApi
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
delegate_enumerable :ecosystems
|
30
|
-
collection_instance_class Ecosystem, :ecosystems
|
31
|
-
end
|
22
|
+
module Models
|
23
|
+
class EcosystemIndex < Lutaml::Hal::Page
|
24
|
+
hal_link :ecosystems, key: 'ecosystems', realize_class: 'Ecosystem', collection: true
|
32
25
|
end
|
26
|
+
end
|
33
27
|
end
|
@@ -1,12 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'lutaml/model'
|
4
|
-
|
5
3
|
module W3cApi
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
end
|
4
|
+
module Models
|
5
|
+
class Extension < Lutaml::Model::Serializable
|
6
|
+
attribute :end, :date_time
|
7
|
+
attribute :announcement_uri, :string
|
11
8
|
end
|
9
|
+
end
|
12
10
|
end
|
data/lib/w3c_api/models/group.rb
CHANGED
@@ -1,172 +1,93 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
require_relative 'join_emails'
|
5
|
-
require_relative 'link'
|
6
|
-
|
3
|
+
# https://api.w3.org/groups/109735
|
7
4
|
# {
|
8
|
-
# "id":
|
9
|
-
# "name": "
|
10
|
-
# "is_closed": false
|
11
|
-
# "description": "The mission of the
|
12
|
-
# "shortname": "
|
13
|
-
# "discr": "w3cgroup"
|
5
|
+
# "id": 109735,
|
6
|
+
# "name": "Immersive Web Working Group",
|
7
|
+
# "is_closed": false,
|
8
|
+
# "description": "The mission of the Immersive Web Working Group is to help bring high-performance Virtual Reality (VR) and Augmented Reality (AR) (collectively known as XR) to the open Web via APIs to interact with XR devices and sensors in browsers.",
|
9
|
+
# "shortname": "immersive-web",
|
10
|
+
# "discr": "w3cgroup",
|
14
11
|
# "_links": {
|
15
12
|
# "self": {
|
16
|
-
# "href": "https://api.w3.org/groups/wg/
|
17
|
-
# }
|
13
|
+
# "href": "https://api.w3.org/groups/wg/immersive-web"
|
14
|
+
# },
|
18
15
|
# "homepage": {
|
19
|
-
# "href": "https://www.w3.org/
|
20
|
-
# }
|
16
|
+
# "href": "https://www.w3.org/immersive-web/"
|
17
|
+
# },
|
21
18
|
# "users": {
|
22
|
-
# "href": "https://api.w3.org/groups/wg/
|
23
|
-
# }
|
19
|
+
# "href": "https://api.w3.org/groups/wg/immersive-web/users"
|
20
|
+
# },
|
24
21
|
# "services": {
|
25
|
-
# "href": "https://api.w3.org/groups/wg/
|
26
|
-
# }
|
22
|
+
# "href": "https://api.w3.org/groups/wg/immersive-web/services"
|
23
|
+
# },
|
27
24
|
# "specifications": {
|
28
|
-
# "href": "https://api.w3.org/groups/wg/
|
29
|
-
# }
|
25
|
+
# "href": "https://api.w3.org/groups/wg/immersive-web/specifications"
|
26
|
+
# },
|
30
27
|
# "chairs": {
|
31
|
-
# "href": "https://api.w3.org/groups/wg/
|
32
|
-
# }
|
28
|
+
# "href": "https://api.w3.org/groups/wg/immersive-web/chairs"
|
29
|
+
# },
|
33
30
|
# "team-contacts": {
|
34
|
-
# "href": "https://api.w3.org/groups/wg/
|
35
|
-
# }
|
31
|
+
# "href": "https://api.w3.org/groups/wg/immersive-web/teamcontacts"
|
32
|
+
# },
|
36
33
|
# "charters": {
|
37
|
-
# "href": "https://api.w3.org/groups/wg/
|
38
|
-
# }
|
34
|
+
# "href": "https://api.w3.org/groups/wg/immersive-web/charters"
|
35
|
+
# },
|
39
36
|
# "active-charter": {
|
40
|
-
# "href": "https://api.w3.org/groups/wg/
|
41
|
-
# }
|
37
|
+
# "href": "https://api.w3.org/groups/wg/immersive-web/charters/514"
|
38
|
+
# },
|
42
39
|
# "join": {
|
43
|
-
# "href": "https://www.w3.org/groups/wg/
|
44
|
-
# }
|
40
|
+
# "href": "https://www.w3.org/groups/wg/immersive-web/join"
|
41
|
+
# },
|
45
42
|
# "pp-status": {
|
46
|
-
# "href": "https://www.w3.org/groups/wg/
|
47
|
-
# }
|
43
|
+
# "href": "https://www.w3.org/groups/wg/immersive-web/ipr"
|
44
|
+
# },
|
48
45
|
# "participations": {
|
49
|
-
# "href": "https://api.w3.org/groups/wg/
|
46
|
+
# "href": "https://api.w3.org/groups/wg/immersive-web/participations"
|
50
47
|
# }
|
51
|
-
# }
|
52
|
-
# "type": "working group"
|
53
|
-
# "start-date": "
|
54
|
-
# "end-date": "
|
48
|
+
# },
|
49
|
+
# "type": "working group",
|
50
|
+
# "start-date": "2018-09-24",
|
51
|
+
# "end-date": "2026-09-25"
|
55
52
|
# }
|
56
53
|
|
57
54
|
module W3cApi
|
58
55
|
module Models
|
59
|
-
|
60
|
-
|
61
|
-
attribute :
|
62
|
-
attribute :users, Link
|
63
|
-
attribute :services, Link
|
64
|
-
attribute :specifications, Link
|
65
|
-
attribute :chairs, Link
|
66
|
-
attribute :team_contacts, Link
|
67
|
-
attribute :charters, Link
|
68
|
-
attribute :active_charter, Link
|
69
|
-
attribute :join, Link
|
70
|
-
attribute :pp_status, Link
|
71
|
-
attribute :participations, Link
|
72
|
-
end
|
73
|
-
|
74
|
-
class Group < Base
|
75
|
-
attribute :id, :integer
|
76
|
-
attribute :name, :string
|
56
|
+
# Group model representing a W3C working group
|
57
|
+
class Group < Lutaml::Hal::Resource
|
58
|
+
attribute :id, :string
|
77
59
|
attribute :type, :string
|
78
|
-
attribute :
|
79
|
-
attribute :
|
60
|
+
attribute :name, :string
|
61
|
+
attribute :is_closed, :boolean
|
80
62
|
attribute :description, :string
|
81
63
|
attribute :shortname, :string
|
82
|
-
attribute :shortlink, :string
|
83
64
|
attribute :discr, :string
|
84
|
-
attribute :created, :string # Date-time format
|
85
|
-
attribute :start_date, :string # Date-time format
|
86
|
-
attribute :end_date, :string # Date-time format
|
87
|
-
attribute :is_closed, :boolean
|
88
|
-
attribute :patent_policy, :string
|
89
|
-
attribute :charter_closed, :boolean
|
90
|
-
attribute :join_emails, JoinEmails
|
91
|
-
attribute :_links, GroupLinks
|
92
|
-
|
93
|
-
# Return users in this group
|
94
|
-
def users(client = nil)
|
95
|
-
return nil unless client && _links&.users
|
96
|
-
|
97
|
-
client.group_users(id)
|
98
|
-
end
|
99
|
-
|
100
|
-
# Return specifications in this group
|
101
|
-
def specifications(client = nil)
|
102
|
-
return nil unless client && _links&.specifications
|
103
|
-
|
104
|
-
client.group_specifications(id)
|
105
|
-
end
|
106
|
-
|
107
|
-
# Return charters for this group
|
108
|
-
def charters(client = nil)
|
109
|
-
return nil unless client && _links&.charters
|
110
|
-
|
111
|
-
client.group_charters(id)
|
112
|
-
end
|
113
|
-
|
114
|
-
# Return chairs for this group
|
115
|
-
def chairs(client = nil)
|
116
|
-
return nil unless client && _links&.chairs
|
117
|
-
|
118
|
-
client.group_chairs(id)
|
119
|
-
end
|
120
|
-
|
121
|
-
# Return team contacts for this group
|
122
|
-
def team_contacts(client = nil)
|
123
|
-
return nil unless client && _links&.team_contacts
|
124
|
-
|
125
|
-
client.group_team_contacts(id)
|
126
|
-
end
|
127
|
-
|
128
|
-
# Parse date strings to Date objects
|
129
|
-
def created_date
|
130
|
-
Date.parse(created) if created
|
131
|
-
rescue Date::Error
|
132
|
-
nil
|
133
|
-
end
|
134
|
-
|
135
|
-
def start_date_parsed
|
136
|
-
Date.parse(start_date) if start_date
|
137
|
-
rescue Date::Error
|
138
|
-
nil
|
139
|
-
end
|
140
|
-
|
141
|
-
def end_date_parsed
|
142
|
-
Date.parse(end_date) if end_date
|
143
|
-
rescue Date::Error
|
144
|
-
nil
|
145
|
-
end
|
146
|
-
|
147
|
-
# Check if this group is active
|
148
|
-
def active?
|
149
|
-
!is_closed && (!end_date || Date.parse(end_date) > Date.today)
|
150
|
-
rescue Date::Error
|
151
|
-
!is_closed
|
152
|
-
end
|
153
|
-
|
154
|
-
def self.from_response(response)
|
155
|
-
transformed_response = transform_keys(response)
|
156
65
|
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
66
|
+
hal_link :self, key: 'self', realize_class: 'Group'
|
67
|
+
hal_link :homepage, key: 'homepage', realize_class: 'String'
|
68
|
+
hal_link :users, key: 'users', realize_class: 'UserIndex'
|
69
|
+
# hal_link :services, key: 'services', realize_class: 'ServiceIndex'
|
70
|
+
hal_link :specifications, key: 'specifications', realize_class: 'SpecificationIndex'
|
71
|
+
hal_link :chairs, key: 'chairs', realize_class: 'UserIndex'
|
72
|
+
hal_link :team_contacts, key: 'team-contacts', realize_class: 'UserIndex'
|
73
|
+
hal_link :charters, key: 'charters', realize_class: 'CharterIndex'
|
74
|
+
hal_link :active_charters, key: 'active-charter', realize_class: 'Charter'
|
75
|
+
hal_link :join, key: 'join', realize_class: 'String'
|
76
|
+
hal_link :pp_status, key: 'pp-status', realize_class: 'String'
|
77
|
+
hal_link :participations, key: 'participations', realize_class: 'ParticipationIndex'
|
78
|
+
|
79
|
+
key_value do
|
80
|
+
%i[
|
81
|
+
id
|
82
|
+
type
|
83
|
+
name
|
84
|
+
is_closed
|
85
|
+
description
|
86
|
+
shortname
|
87
|
+
discr
|
88
|
+
].each do |key|
|
89
|
+
map key.to_s.tr('_', '-'), to: key
|
168
90
|
end
|
169
|
-
group
|
170
91
|
end
|
171
92
|
end
|
172
93
|
end
|
@@ -1,12 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'lutaml/model'
|
4
|
-
|
5
3
|
module W3cApi
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
end
|
4
|
+
module Models
|
5
|
+
class JoinEmailIndex < Lutaml::Model::Serializable
|
6
|
+
attribute :public, :string
|
7
|
+
attribute :member, :string
|
11
8
|
end
|
9
|
+
end
|
12
10
|
end
|
@@ -1,109 +1,50 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
require_relative 'link'
|
5
|
-
|
6
|
-
# Example participation response:
|
3
|
+
# https://api.w3.org/participations/38785
|
7
4
|
# {
|
8
|
-
# "
|
5
|
+
# "individual": false,
|
6
|
+
# "invited-expert": false,
|
7
|
+
# "created": "2022-11-17 22:54:08",
|
9
8
|
# "_links": {
|
10
9
|
# "self": {
|
11
|
-
# "href": "https://api.w3.org/participations/
|
10
|
+
# "href": "https://api.w3.org/participations/38785"
|
12
11
|
# },
|
13
12
|
# "group": {
|
14
|
-
# "href": "https://api.w3.org/groups/
|
15
|
-
# "title": "
|
16
|
-
# },
|
17
|
-
# "user": {
|
18
|
-
# "href": "https://api.w3.org/users/789",
|
19
|
-
# "title": "John Doe"
|
13
|
+
# "href": "https://api.w3.org/groups/cg/silver",
|
14
|
+
# "title": "Silver Community Group"
|
20
15
|
# },
|
21
16
|
# "organization": {
|
22
|
-
# "href": "https://api.w3.org/affiliations/
|
23
|
-
# "title": "
|
17
|
+
# "href": "https://api.w3.org/affiliations/1092",
|
18
|
+
# "title": "MITRE Corporation"
|
24
19
|
# },
|
25
20
|
# "participants": {
|
26
|
-
# "href": "https://api.w3.org/participations/
|
21
|
+
# "href": "https://api.w3.org/participations/38785/participants"
|
27
22
|
# }
|
28
23
|
# }
|
29
24
|
# }
|
30
|
-
|
31
25
|
module W3cApi
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
end
|
53
|
-
|
54
|
-
# Get the group this participation is for
|
55
|
-
def group(client = nil)
|
56
|
-
return nil unless client && _links&.group
|
57
|
-
|
58
|
-
href = _links.group.href
|
59
|
-
id = href.split('/').last
|
60
|
-
client.group(id)
|
61
|
-
end
|
62
|
-
|
63
|
-
# Get the user participating
|
64
|
-
def user(client = nil)
|
65
|
-
return nil unless client && _links&.user
|
66
|
-
|
67
|
-
href = _links.user.href
|
68
|
-
id = href.split('/').last
|
69
|
-
client.user(id)
|
70
|
-
end
|
71
|
-
|
72
|
-
# Get the organization participating
|
73
|
-
def organization(client = nil)
|
74
|
-
return nil unless client && _links&.organization
|
75
|
-
|
76
|
-
href = _links.organization.href
|
77
|
-
id = href.split('/').last
|
78
|
-
client.affiliation(id)
|
79
|
-
end
|
80
|
-
|
81
|
-
# Get participants in this participation
|
82
|
-
def participants(client = nil)
|
83
|
-
return nil unless client && _links&.participants
|
84
|
-
|
85
|
-
href = _links.participants.href
|
86
|
-
id = href.split('/').last
|
87
|
-
client.participation_participants(id)
|
88
|
-
end
|
89
|
-
|
90
|
-
def self.from_response(response)
|
91
|
-
transformed_response = transform_keys(response)
|
92
|
-
|
93
|
-
participation = new
|
94
|
-
transformed_response.each do |key, value|
|
95
|
-
case key
|
96
|
-
when :_links
|
97
|
-
links = value.each_with_object({}) do |(link_name, link_data), acc|
|
98
|
-
acc[link_name] = Link.new(href: link_data[:href], title: link_data[:title])
|
99
|
-
end
|
100
|
-
participation._links = ParticipationLinks.new(links)
|
101
|
-
else
|
102
|
-
participation.send("#{key}=", value) if participation.respond_to?("#{key}=")
|
103
|
-
end
|
104
|
-
end
|
105
|
-
participation
|
26
|
+
module Models
|
27
|
+
class Participation < Lutaml::Hal::Resource
|
28
|
+
attribute :title, :string
|
29
|
+
attribute :href, :string
|
30
|
+
attribute :created, :date_time
|
31
|
+
attribute :individual, :boolean
|
32
|
+
attribute :invited_expert, :boolean
|
33
|
+
|
34
|
+
hal_link :self, key: 'self', realize_class: 'Participation'
|
35
|
+
hal_link :group, key: 'group', realize_class: 'Group'
|
36
|
+
hal_link :organization, key: 'organization', realize_class: 'Affiliation'
|
37
|
+
hal_link :participants, key: 'participants', realize_class: 'ParticipantIndex'
|
38
|
+
|
39
|
+
key_value do
|
40
|
+
%i[
|
41
|
+
individual
|
42
|
+
invited_expert
|
43
|
+
created
|
44
|
+
].each do |key|
|
45
|
+
map key.to_s.tr('_', '-'), to: key
|
106
46
|
end
|
107
47
|
end
|
108
48
|
end
|
49
|
+
end
|
109
50
|
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'participation'
|
4
|
+
|
5
|
+
module W3cApi
|
6
|
+
module Models
|
7
|
+
class ParticipationIndex < Lutaml::Hal::Page
|
8
|
+
hal_link :participations, key: 'participations', realize_class: 'Participation', collection: true
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'lutaml/model'
|
2
|
+
|
3
|
+
# "photos": [
|
4
|
+
# {
|
5
|
+
# "href": "https://www.w3.org/thumbnails/360/avatar-images/f1ovb5rydm8s0go04oco0cgk0sow44w.webp?x-version=3",
|
6
|
+
# "name": "large"
|
7
|
+
# },
|
8
|
+
|
9
|
+
module W3cApi
|
10
|
+
module Models
|
11
|
+
# User model representing a W3C user/participant
|
12
|
+
class Photo < Lutaml::Model::Serializable
|
13
|
+
attribute :href, :string
|
14
|
+
attribute :name, :string
|
15
|
+
|
16
|
+
key_value do
|
17
|
+
%i[
|
18
|
+
href
|
19
|
+
name
|
20
|
+
].each do |key|
|
21
|
+
map key.to_s, to: key
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|