coarnotify 0.1.0

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.
@@ -0,0 +1,145 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../core/notify'
4
+ require_relative '../core/activity_streams2'
5
+
6
+ module Coarnotify
7
+ module Patterns
8
+ # Pattern to represent an AnnounceReview notification
9
+ class AnnounceReview < Core::Notify::NotifyPattern
10
+ def self.type_constant
11
+ [Core::ActivityStreams2::ActivityStreamsTypes::ANNOUNCE, Core::Notify::NotifyTypes::REVIEW_ACTION]
12
+ end
13
+
14
+ # Custom getter to retrieve Announce Review object
15
+ #
16
+ # @return [AnnounceReviewObject, nil] Announce Review Object
17
+ def object
18
+ o = get_property(Core::ActivityStreams2::Properties::OBJECT)
19
+ if o
20
+ AnnounceReviewObject.new(stream: o, validate_stream_on_construct: false,
21
+ validate_properties: @validate_properties, validators: @validators,
22
+ validation_context: Core::ActivityStreams2::Properties::OBJECT,
23
+ properties_by_reference: @properties_by_reference)
24
+ end
25
+ end
26
+
27
+ # Set the object property of the notification
28
+ #
29
+ # @param value [AnnounceReviewObject] the object to set
30
+ def object=(value)
31
+ set_property(Core::ActivityStreams2::Properties::OBJECT, value.doc)
32
+ end
33
+
34
+ # Custom getter to retrieve AnnounceReview Context
35
+ #
36
+ # @return [AnnounceReviewContext, nil] AnnounceReviewContext
37
+ def context
38
+ c = get_property(Core::ActivityStreams2::Properties::CONTEXT)
39
+ if c
40
+ AnnounceReviewContext.new(stream: c, validate_stream_on_construct: false,
41
+ validate_properties: @validate_properties, validators: @validators,
42
+ validation_context: Core::ActivityStreams2::Properties::CONTEXT,
43
+ properties_by_reference: @properties_by_reference)
44
+ end
45
+ end
46
+
47
+ # Set the context property of the notification
48
+ #
49
+ # @param value [AnnounceReviewContext] the context to set
50
+ def context=(value)
51
+ set_property(Core::ActivityStreams2::Properties::CONTEXT, value.doc)
52
+ end
53
+
54
+ # Extends the base validation to make `context` required
55
+ #
56
+ # @return [Boolean] true if valid, otherwise raises ValidationError
57
+ def validate
58
+ ve = Core::Notify::ValidationError.new
59
+
60
+ begin
61
+ super
62
+ rescue Core::Notify::ValidationError => superve
63
+ ve = superve
64
+ end
65
+
66
+ required_and_validate(ve, Core::ActivityStreams2::Properties::CONTEXT, context)
67
+
68
+ raise ve if ve.has_errors?
69
+ true
70
+ end
71
+ end
72
+
73
+ # Custom Context for Announce Review, specifically to return custom
74
+ # Announce Review Item
75
+ class AnnounceReviewContext < Core::Notify::NotifyObject
76
+ # Custom getter to retrieve AnnounceReviewItem
77
+ #
78
+ # @return [AnnounceReviewItem, nil] AnnounceReviewItem
79
+ def item
80
+ i = get_property(Core::Notify::NotifyProperties::ITEM)
81
+ if i
82
+ AnnounceReviewItem.new(stream: i, validate_stream_on_construct: false,
83
+ validate_properties: @validate_properties, validators: @validators,
84
+ validation_context: Core::Notify::NotifyProperties::ITEM,
85
+ properties_by_reference: @properties_by_reference)
86
+ end
87
+ end
88
+
89
+ # Set the item property
90
+ #
91
+ # @param value [AnnounceReviewItem] the item to set
92
+ def item=(value)
93
+ set_property(Core::Notify::NotifyProperties::ITEM, value.doc)
94
+ end
95
+ end
96
+
97
+ # Custom AnnounceReviewItem which provides additional validation over the basic NotifyItem
98
+ class AnnounceReviewItem < Core::Notify::NotifyItem
99
+ # In addition to the base validator, this:
100
+ #
101
+ # * Reintroduces type validation
102
+ # * make mediaType a required field
103
+ #
104
+ # @return [Boolean] true if valid, else raises a ValidationError
105
+ def validate
106
+ ve = Core::Notify::ValidationError.new
107
+
108
+ begin
109
+ super
110
+ rescue Core::Notify::ValidationError => superve
111
+ ve = superve
112
+ end
113
+
114
+ required_and_validate(ve, Core::ActivityStreams2::Properties::TYPE, type)
115
+ required(ve, Core::Notify::NotifyProperties::MEDIA_TYPE, media_type)
116
+
117
+ raise ve if ve.has_errors?
118
+ true
119
+ end
120
+ end
121
+
122
+ # Custom Announce Review Object to apply custom validation for this pattern
123
+ class AnnounceReviewObject < Core::Notify::NotifyObject
124
+ # In addition to the base validator this:
125
+ #
126
+ # * Makes type required
127
+ #
128
+ # @return [Boolean] true if valid, else raises ValidationError
129
+ def validate
130
+ ve = Core::Notify::ValidationError.new
131
+
132
+ begin
133
+ super
134
+ rescue Core::Notify::ValidationError => superve
135
+ ve = superve
136
+ end
137
+
138
+ required_and_validate(ve, Core::ActivityStreams2::Properties::TYPE, type)
139
+
140
+ raise ve if ve.has_errors?
141
+ true
142
+ end
143
+ end
144
+ end
145
+ end
@@ -0,0 +1,145 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../core/notify'
4
+ require_relative '../core/activity_streams2'
5
+
6
+ module Coarnotify
7
+ module Patterns
8
+ # Pattern to represent the Announce Service Result notification
9
+ # https://coar-notify.net/specification/1.0.0/announce-resource/
10
+ class AnnounceServiceResult < Core::Notify::NotifyPattern
11
+ def self.type_constant
12
+ [Core::ActivityStreams2::ActivityStreamsTypes::ANNOUNCE, Core::Notify::NotifyTypes::INGEST_ACTION]
13
+ end
14
+
15
+ # Custom getter to retrieve the object property as an AnnounceServiceResultObject
16
+ #
17
+ # @return [AnnounceServiceResultObject, nil] AnnounceServiceResultObject
18
+ def object
19
+ o = get_property(Core::ActivityStreams2::Properties::OBJECT)
20
+ if o
21
+ AnnounceServiceResultObject.new(stream: o, validate_stream_on_construct: false,
22
+ validate_properties: @validate_properties, validators: @validators,
23
+ validation_context: Core::ActivityStreams2::Properties::OBJECT,
24
+ properties_by_reference: @properties_by_reference)
25
+ end
26
+ end
27
+
28
+ # Set the object property of the notification
29
+ #
30
+ # @param value [AnnounceServiceResultObject] the object to set
31
+ def object=(value)
32
+ set_property(Core::ActivityStreams2::Properties::OBJECT, value.doc)
33
+ end
34
+
35
+ # Custom getter to retrieve the context property as an AnnounceServiceResultContext
36
+ #
37
+ # @return [AnnounceServiceResultContext, nil] AnnounceServiceResultContext
38
+ def context
39
+ c = get_property(Core::ActivityStreams2::Properties::CONTEXT)
40
+ if c
41
+ AnnounceServiceResultContext.new(stream: c, validate_stream_on_construct: false,
42
+ validate_properties: @validate_properties, validators: @validators,
43
+ validation_context: Core::ActivityStreams2::Properties::CONTEXT,
44
+ properties_by_reference: @properties_by_reference)
45
+ end
46
+ end
47
+
48
+ # Set the context property of the notification
49
+ #
50
+ # @param value [AnnounceServiceResultContext] the context to set
51
+ def context=(value)
52
+ set_property(Core::ActivityStreams2::Properties::CONTEXT, value.doc)
53
+ end
54
+
55
+ # Extends the base validation to make `context` required
56
+ #
57
+ # @return [Boolean] true if valid, otherwise raises ValidationError
58
+ def validate
59
+ ve = Core::Notify::ValidationError.new
60
+
61
+ begin
62
+ super
63
+ rescue Core::Notify::ValidationError => superve
64
+ ve = superve
65
+ end
66
+
67
+ required_and_validate(ve, Core::ActivityStreams2::Properties::CONTEXT, context)
68
+
69
+ raise ve if ve.has_errors?
70
+ true
71
+ end
72
+ end
73
+
74
+ # Custom object class for Announce Service Result to provide the custom item getter
75
+ class AnnounceServiceResultContext < Core::Notify::NotifyObject
76
+ # Custom getter to retrieve the item property as an AnnounceServiceResultItem
77
+ #
78
+ # @return [AnnounceServiceResultItem, nil] the item
79
+ def item
80
+ i = get_property(Core::Notify::NotifyProperties::ITEM)
81
+ if i
82
+ AnnounceServiceResultItem.new(stream: i, validate_stream_on_construct: false,
83
+ validate_properties: @validate_properties, validators: @validators,
84
+ validation_context: Core::Notify::NotifyProperties::ITEM,
85
+ properties_by_reference: @properties_by_reference)
86
+ end
87
+ end
88
+
89
+ # Set the item property
90
+ #
91
+ # @param value [AnnounceServiceResultItem] the item to set
92
+ def item=(value)
93
+ set_property(Core::Notify::NotifyProperties::ITEM, value.doc)
94
+ end
95
+ end
96
+
97
+ # Custom item class for Announce Service Result to apply the custom validation
98
+ class AnnounceServiceResultItem < Core::Notify::NotifyItem
99
+ # Beyond the base validation, apply the following:
100
+ #
101
+ # * Make type required and valid
102
+ # * Make the mediaType required
103
+ #
104
+ # @return [Boolean] true if validation passes, else raise a ValidationError
105
+ def validate
106
+ ve = Core::Notify::ValidationError.new
107
+
108
+ begin
109
+ super
110
+ rescue Core::Notify::ValidationError => superve
111
+ ve = superve
112
+ end
113
+
114
+ required_and_validate(ve, Core::ActivityStreams2::Properties::TYPE, type)
115
+ required(ve, Core::Notify::NotifyProperties::MEDIA_TYPE, media_type)
116
+
117
+ raise ve if ve.has_errors?
118
+ true
119
+ end
120
+ end
121
+
122
+ # Custom object class for Announce Service Result to apply the custom validation
123
+ class AnnounceServiceResultObject < Core::Notify::NotifyObject
124
+ # Extend the base validation to include the following constraints:
125
+ #
126
+ # * The object type is required and must validate
127
+ #
128
+ # @return [Boolean] true if validation passes, else raise a ValidationError
129
+ def validate
130
+ ve = Core::Notify::ValidationError.new
131
+
132
+ begin
133
+ super
134
+ rescue Core::Notify::ValidationError => superve
135
+ ve = superve
136
+ end
137
+
138
+ required_and_validate(ve, Core::ActivityStreams2::Properties::TYPE, type)
139
+
140
+ raise ve if ve.has_errors?
141
+ true
142
+ end
143
+ end
144
+ end
145
+ end
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../core/notify'
4
+ require_relative '../core/activity_streams2'
5
+ require_relative '../exceptions'
6
+
7
+ module Coarnotify
8
+ module Patterns
9
+ # Pattern to represent a Reject notification
10
+ # https://coar-notify.net/specification/1.0.0/reject/
11
+ class Reject < Core::Notify::NotifyPattern
12
+ include Core::Notify::NestedPatternObjectMixin
13
+ include Core::Notify::SummaryMixin
14
+
15
+ # The Reject type
16
+ def self.type_constant
17
+ Core::ActivityStreams2::ActivityStreamsTypes::REJECT
18
+ end
19
+
20
+ # Validate the Reject pattern.
21
+ #
22
+ # In addition to the base validation, this:
23
+ #
24
+ # * Makes inReplyTo required
25
+ # * Requires the inReplyTo value to be the same as the object.id value
26
+ #
27
+ # @return [Boolean] true if valid, otherwise raises ValidationError
28
+ def validate
29
+ ve = ValidationError.new
30
+ begin
31
+ super
32
+ rescue ValidationError => superve
33
+ ve = superve
34
+ end
35
+
36
+ # Technically, no need to validate the value, as this is handled by the superclass,
37
+ # but leaving it in for completeness
38
+ required_and_validate(ve, Core::ActivityStreams2::Properties::IN_REPLY_TO, in_reply_to)
39
+
40
+ objid = object&.id
41
+ if in_reply_to != objid
42
+ ve.add_error(Core::ActivityStreams2::Properties::IN_REPLY_TO,
43
+ "Expected inReplyTo id to be the same as the nested object id. inReplyTo: #{in_reply_to}, object.id: #{objid}")
44
+ end
45
+
46
+ raise ve if ve.has_errors?
47
+ true
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,83 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../core/notify'
4
+ require_relative '../core/activity_streams2'
5
+
6
+ module Coarnotify
7
+ module Patterns
8
+ # Pattern to represent a RequestEndorsement notification
9
+ class RequestEndorsement < Core::Notify::NotifyPattern
10
+ def self.type_constant
11
+ [Core::ActivityStreams2::ActivityStreamsTypes::OFFER, Core::Notify::NotifyTypes::ENDORSEMENT_ACTION]
12
+ end
13
+
14
+ # Custom getter to retrieve the object property as a RequestEndorsementObject
15
+ #
16
+ # @return [RequestEndorsementObject, nil] the object
17
+ def object
18
+ o = get_property(Core::ActivityStreams2::Properties::OBJECT)
19
+ if o
20
+ RequestEndorsementObject.new(stream: o, validate_stream_on_construct: false,
21
+ validate_properties: @validate_properties, validators: @validators,
22
+ validation_context: Core::ActivityStreams2::Properties::OBJECT,
23
+ properties_by_reference: @properties_by_reference)
24
+ end
25
+ end
26
+
27
+ # Set the object property of the notification
28
+ #
29
+ # @param value [RequestEndorsementObject] the object to set
30
+ def object=(value)
31
+ set_property(Core::ActivityStreams2::Properties::OBJECT, value.doc)
32
+ end
33
+ end
34
+
35
+ # Custom object class for Request Endorsement to provide the custom item getter
36
+ class RequestEndorsementObject < Core::Notify::NotifyObject
37
+ # Custom getter to retrieve the item property as a RequestEndorsementItem
38
+ #
39
+ # @return [RequestEndorsementItem, nil] the item
40
+ def item
41
+ i = get_property(Core::Notify::NotifyProperties::ITEM)
42
+ if i
43
+ RequestEndorsementItem.new(stream: i, validate_stream_on_construct: false,
44
+ validate_properties: @validate_properties, validators: @validators,
45
+ validation_context: Core::Notify::NotifyProperties::ITEM,
46
+ properties_by_reference: @properties_by_reference)
47
+ end
48
+ end
49
+
50
+ # Set the item property
51
+ #
52
+ # @param value [RequestEndorsementItem] the item to set
53
+ def item=(value)
54
+ set_property(Core::Notify::NotifyProperties::ITEM, value.doc)
55
+ end
56
+ end
57
+
58
+ # Custom item class for Request Endorsement to provide the custom validation
59
+ class RequestEndorsementItem < Core::Notify::NotifyItem
60
+ # Extend the base validation to include the following constraints:
61
+ #
62
+ # * The item type is required and must validate
63
+ # * The mediaType property is required
64
+ #
65
+ # @return [Boolean] true if validation passes, otherwise raise a ValidationError
66
+ def validate
67
+ ve = Core::Notify::ValidationError.new
68
+
69
+ begin
70
+ super
71
+ rescue Core::Notify::ValidationError => superve
72
+ ve = superve
73
+ end
74
+
75
+ required_and_validate(ve, Core::ActivityStreams2::Properties::TYPE, type)
76
+ required(ve, Core::Notify::NotifyProperties::MEDIA_TYPE, media_type)
77
+
78
+ raise ve if ve.has_errors?
79
+ true
80
+ end
81
+ end
82
+ end
83
+ end
@@ -0,0 +1,71 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../core/notify'
4
+ require_relative '../core/activity_streams2'
5
+ require_relative '../exceptions'
6
+
7
+ module Coarnotify
8
+ module Patterns
9
+ # Pattern to represent a Request Review notification
10
+ # https://coar-notify.net/specification/1.0.0/request-review/
11
+ class RequestReview < Core::Notify::NotifyPattern
12
+ # Request Review types, including an ActivityStreams offer and a COAR Notify Review Action
13
+ def self.type_constant
14
+ [Core::ActivityStreams2::ActivityStreamsTypes::OFFER, Core::Notify::NotifyTypes::REVIEW_ACTION]
15
+ end
16
+
17
+ # Custom getter to retrieve the object property as a RequestReviewObject
18
+ #
19
+ # @return [RequestReviewObject, nil] the object
20
+ def object
21
+ o = get_property(Core::ActivityStreams2::Properties::OBJECT)
22
+ if o
23
+ RequestReviewObject.new(stream: o, validate_stream_on_construct: false,
24
+ validate_properties: @validate_properties, validators: @validators,
25
+ validation_context: Core::ActivityStreams2::Properties::OBJECT,
26
+ properties_by_reference: @properties_by_reference)
27
+ end
28
+ end
29
+ end
30
+
31
+ # Custom Request Review Object class to return the custom RequestReviewItem class
32
+ class RequestReviewObject < Core::Notify::NotifyObject
33
+ # Custom getter to retrieve the item property as a RequestReviewItem
34
+ #
35
+ # @return [RequestReviewItem, nil] the item
36
+ def item
37
+ i = get_property(Core::Notify::NotifyProperties::ITEM)
38
+ if i
39
+ RequestReviewItem.new(stream: i, validate_stream_on_construct: false,
40
+ validate_properties: @validate_properties, validators: @validators,
41
+ validation_context: Core::Notify::NotifyProperties::ITEM,
42
+ properties_by_reference: @properties_by_reference)
43
+ end
44
+ end
45
+ end
46
+
47
+ # Custom Request Review Item class to provide the custom validation
48
+ class RequestReviewItem < Core::Notify::NotifyItem
49
+ # Extend the base validation to include the following constraints:
50
+ #
51
+ # * The type property is required and must validate
52
+ # * the mediaType property is required
53
+ #
54
+ # @return [Boolean] true if validation passes, else raise a ValidationError
55
+ def validate
56
+ ve = ValidationError.new
57
+ begin
58
+ super
59
+ rescue ValidationError => superve
60
+ ve = superve
61
+ end
62
+
63
+ required_and_validate(ve, Core::ActivityStreams2::Properties::TYPE, type)
64
+ required(ve, Core::Notify::NotifyProperties::MEDIA_TYPE, media_type)
65
+
66
+ raise ve if ve.has_errors?
67
+ true
68
+ end
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../core/notify'
4
+ require_relative '../core/activity_streams2'
5
+ require_relative '../exceptions'
6
+
7
+ module Coarnotify
8
+ module Patterns
9
+ # Pattern to represent a TentativelyAccept notification
10
+ # https://coar-notify.net/specification/1.0.0/tentatively-accept/
11
+ class TentativelyAccept < Core::Notify::NotifyPattern
12
+ include Core::Notify::NestedPatternObjectMixin
13
+ include Core::Notify::SummaryMixin
14
+
15
+ # The TentativelyAccept type
16
+ def self.type_constant
17
+ Core::ActivityStreams2::ActivityStreamsTypes::TENTATIVE_ACCEPT
18
+ end
19
+
20
+ # Validate the TentativelyAccept pattern.
21
+ #
22
+ # In addition to the base validation, this:
23
+ #
24
+ # * Makes inReplyTo required
25
+ # * Requires the inReplyTo value to be the same as the object.id value
26
+ #
27
+ # @return [Boolean] true if valid, otherwise raises ValidationError
28
+ def validate
29
+ ve = ValidationError.new
30
+ begin
31
+ super
32
+ rescue ValidationError => superve
33
+ ve = superve
34
+ end
35
+
36
+ # Technically, no need to validate the value, as this is handled by the superclass,
37
+ # but leaving it in for completeness
38
+ required_and_validate(ve, Core::ActivityStreams2::Properties::IN_REPLY_TO, in_reply_to)
39
+
40
+ objid = object&.id
41
+ if in_reply_to != objid
42
+ ve.add_error(Core::ActivityStreams2::Properties::IN_REPLY_TO,
43
+ "Expected inReplyTo id to be the same as the nested object id. inReplyTo: #{in_reply_to}, object.id: #{objid}")
44
+ end
45
+
46
+ raise ve if ve.has_errors?
47
+ true
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../core/notify'
4
+ require_relative '../core/activity_streams2'
5
+ require_relative '../exceptions'
6
+
7
+ module Coarnotify
8
+ module Patterns
9
+ # Pattern to represent a TentativelyReject notification
10
+ # https://coar-notify.net/specification/1.0.0/tentative-reject/
11
+ class TentativelyReject < Core::Notify::NotifyPattern
12
+ include Core::Notify::NestedPatternObjectMixin
13
+ include Core::Notify::SummaryMixin
14
+
15
+ def self.type_constant
16
+ Core::ActivityStreams2::ActivityStreamsTypes::TENTATIVE_REJECT
17
+ end
18
+
19
+ def validate
20
+ ve = ValidationError.new
21
+ begin
22
+ super
23
+ rescue ValidationError => superve
24
+ ve = superve
25
+ end
26
+
27
+ required_and_validate(ve, Core::ActivityStreams2::Properties::IN_REPLY_TO, in_reply_to)
28
+
29
+ objid = object&.id
30
+ if in_reply_to != objid
31
+ ve.add_error(Core::ActivityStreams2::Properties::IN_REPLY_TO,
32
+ "Expected inReplyTo id to be the same as the nested object id. inReplyTo: #{in_reply_to}, object.id: #{objid}")
33
+ end
34
+
35
+ raise ve if ve.has_errors?
36
+ true
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../core/notify'
4
+ require_relative '../core/activity_streams2'
5
+ require_relative '../exceptions'
6
+
7
+ module Coarnotify
8
+ module Patterns
9
+ # Pattern to represent the Undo Offer notification
10
+ # https://coar-notify.net/specification/1.0.0/undo-offer/
11
+ class UndoOffer < Core::Notify::NotifyPattern
12
+ include Core::Notify::NestedPatternObjectMixin
13
+ include Core::Notify::SummaryMixin
14
+
15
+ def self.type_constant
16
+ Core::ActivityStreams2::ActivityStreamsTypes::UNDO
17
+ end
18
+
19
+ # In addition to the base validation apply the following constraints:
20
+ #
21
+ # * The inReplyTo property is required
22
+ # * The inReplyTo value must match the object.id value
23
+ #
24
+ # @return [Boolean] true if validation passes, otherwise raise a ValidationError
25
+ def validate
26
+ ve = ValidationError.new
27
+ begin
28
+ super
29
+ rescue ValidationError => superve
30
+ ve = superve
31
+ end
32
+
33
+ # Technically, no need to validate the value, as this is handled by the superclass,
34
+ # but leaving it in for completeness
35
+ required_and_validate(ve, Core::ActivityStreams2::Properties::IN_REPLY_TO, in_reply_to)
36
+
37
+ objid = object&.id
38
+ if in_reply_to != objid
39
+ ve.add_error(Core::ActivityStreams2::Properties::IN_REPLY_TO,
40
+ "Expected inReplyTo id to be the same as the nested object id. inReplyTo: #{in_reply_to}, object.id: #{objid}")
41
+ end
42
+
43
+ raise ve if ve.has_errors?
44
+ true
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../core/notify'
4
+ require_relative '../core/activity_streams2'
5
+ require_relative '../exceptions'
6
+
7
+ module Coarnotify
8
+ module Patterns
9
+ # Pattern to represent the Unprocessable Notification notification
10
+ # https://coar-notify.net/specification/1.0.0/unprocessable/
11
+ class UnprocessableNotification < Core::Notify::NotifyPattern
12
+ include Core::Notify::SummaryMixin
13
+
14
+ def self.type_constant
15
+ Core::Notify::NotifyTypes::UNPROCESSABLE_NOTIFICATION
16
+ end
17
+
18
+ # In addition to the base validation apply the following constraints:
19
+ #
20
+ # * The inReplyTo property is required
21
+ # * The summary property is required
22
+ #
23
+ # @return [Boolean] true if validation passes, otherwise raise a ValidationError
24
+ def validate
25
+ ve = ValidationError.new
26
+ begin
27
+ super
28
+ rescue ValidationError => superve
29
+ ve = superve
30
+ end
31
+
32
+ # Technically, no need to validate the value, as this is handled by the superclass,
33
+ # but leaving it in for completeness
34
+ required_and_validate(ve, Core::ActivityStreams2::Properties::IN_REPLY_TO, in_reply_to)
35
+ required(ve, Core::ActivityStreams2::Properties::SUMMARY, summary)
36
+
37
+ raise ve if ve.has_errors?
38
+ true
39
+ end
40
+ end
41
+ end
42
+ end