Skip to content

Commit

Permalink
feat: Added enterprise subsidy events. OEP-49 (#333)
Browse files Browse the repository at this point in the history
  • Loading branch information
irfanuddinahmad authored Apr 4, 2024
1 parent 197690d commit 8cc090e
Show file tree
Hide file tree
Showing 7 changed files with 132 additions and 2 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,16 @@ Change Log
Unreleased
----------
[9.7.0] - 2024-04-04
--------------------
Added
~~~~~
~~~~~~~
* Added new ``SUBSIDY_REDEEMED`` and ``SUBSIDY_REDEMPTION_REVERSED`` events in enterprise.

[9.6.0] - 2024-04-01
--------------------
Added
~~~~~~~
* Added new ``CONTENT_OBJECT_TAGGED`` events in content_authoring.

[9.5.2] - 2024-02-13
Expand Down
2 changes: 1 addition & 1 deletion openedx_events/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
more information about the project.
"""

__version__ = "9.6.0"
__version__ = "9.7.0"
6 changes: 6 additions & 0 deletions openedx_events/enterprise/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
"""
Package where events related to the enterprise subdomain are implemented.
The enterprise subdomain corresponds to {Architecture Subdomain} defined in
the OEP-41.
"""
24 changes: 24 additions & 0 deletions openedx_events/enterprise/data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"""
Data attributes for events within the architecture subdomain ``enterprise``.
These attributes follow the form of attr objects specified in OEP-49 data
pattern.
"""

import attr


@attr.s(frozen=True)
class SubsidyRedemption:
"""
Attributes for a Subsidy Redemption object.
Arguments:
subsidy_identifier (str): unique identifier to fetch the applied subsidy
content_key (str): content id where subsidy is utilized
lms_user_id (str): lms user id of subsidy beneficiary
"""

subsidy_identifier = attr.ib(type=str)
content_key = attr.ib(type=str)
lms_user_id = attr.ib(type=int)
34 changes: 34 additions & 0 deletions openedx_events/enterprise/signals.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
"""
Standardized signals definitions for events within the architecture subdomain ``enterprise``.
All signals defined in this module must follow the name and versioning
conventions specified in OEP-41.
They also must comply with the payload definition specified in
docs/decisions/0003-events-payload.rst
"""

from openedx_events.enterprise.data import SubsidyRedemption
from openedx_events.tooling import OpenEdxPublicSignal

# .. event_type: org.openedx.enterprise.subsidy.redeemed.v1
# .. event_name: SUBSIDY_REDEEMED
# .. event_description: emitted when an enterprise subsidy is utilized.
# .. event_data: SubsidyRedemption
SUBSIDY_REDEEMED = OpenEdxPublicSignal(
event_type="org.openedx.enterprise.subsidy.redeemed.v1",
data={
"redemption": SubsidyRedemption,
}
)

# .. event_type: org.openedx.enterprise.subsidy.redemption-reversed.v1
# .. event_name: SUBSIDY_REDEMPTION_REVERSED
# .. event_description: emitted when an enterprise subsidy is reversed.
# .. event_data: SubsidyRedemption
SUBSIDY_REDEMPTION_REVERSED = OpenEdxPublicSignal(
event_type="org.openedx.enterprise.subsidy.redemption-reversed.v1",
data={
"redemption": SubsidyRedemption,
}
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "CloudEvent",
"type": "record",
"doc": "Avro Event Format for CloudEvents created with openedx_events/schema",
"fields": [
{
"name": "redemption",
"type": {
"name": "SubsidyRedemption",
"type": "record",
"fields": [
{
"name": "subsidy_identifier",
"type": "string"
},
{
"name": "content_key",
"type": "string"
},
{
"name": "lms_user_id",
"type": "long"
}
]
}
}
],
"namespace": "org.openedx.enterprise.subsidy.redeemed.v1"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "CloudEvent",
"type": "record",
"doc": "Avro Event Format for CloudEvents created with openedx_events/schema",
"fields": [
{
"name": "redemption",
"type": {
"name": "SubsidyRedemption",
"type": "record",
"fields": [
{
"name": "subsidy_identifier",
"type": "string"
},
{
"name": "content_key",
"type": "string"
},
{
"name": "lms_user_id",
"type": "long"
}
]
}
}
],
"namespace": "org.openedx.enterprise.subsidy.redemption-reversed.v1"
}

0 comments on commit 8cc090e

Please # to comment.