Skip to content

Commit

Permalink
feat: Add enterprise signal for learner credit fulfillment revokation
Browse files Browse the repository at this point in the history
ENT-9213
  • Loading branch information
pwnage101 committed Jul 30, 2024
1 parent 238186a commit 9dcc6d2
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 1 deletion.
63 changes: 63 additions & 0 deletions openedx_events/enterprise/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,66 @@ class LedgerTransaction(BaseLedgerTransaction):
parent_content_key = attr.ib(type=str, default=None)
fulfillment_identifier = attr.ib(type=str, default=None)
reversal = attr.ib(type=LedgerTransactionReversal, default=None)


@attr.s(frozen=True)
class EnterpriseCustomerUser:
"""
Defines the common attributes of enterprise fulfillment classes.
"""
id = attr.ib(type=int)
created = attr.ib(type=datetime)
modified = attr.ib(type=datetime)
enterprise_customer_uuid = attr.ib(type=UUID)
user_id = attr.ib(type=int)
active = attr.ib(type=bool)
linked = attr.ib(type=bool)
is_relinkable = attr.ib(type=bool)
invite_key = attr.ib(type=UUID)
should_inactivate_other_customers = attr.ib(type=bool)


@attr.s(frozen=True)
class EnterpriseCourseEnrollment:
"""
Defines the common attributes of enterprise fulfillment classes.
"""
id = attr.ib(type=int)
created = attr.ib(type=datetime)
modified = attr.ib(type=datetime)
enterprise_customer_user = attr.ib(type=EnterpriseCustomerUser, default=None)
course_id = attr.ib(type=CourseKey)
saved_for_later = attr.ib(type=bool)
source_slug = attr.ib(type=str)
unenrolled = attr.ib(type=bool)
unenrolled_at = attr.ib(type=datetime)


@attr.s(frozen=True)
class BaseEnterpriseFulfillment:
"""
Defines the common attributes of enterprise fulfillment classes.
"""
uuid = attr.ib(type=UUID)
created = attr.ib(type=datetime)
modified = attr.ib(type=datetime)
fulfillment_type = attr.ib(type=str)
enterprise_course_entitlement_uuid = attr.ib(type=UUID)
enterprise_course_enrollment = attr.ib(type=EnterpriseCourseEnrollment, default=None)
is_revoked = attr.ib(type=bool)


@attr.s(frozen=True)
class EnterpriseLearnerCreditFulfillment(BaseEnterpriseFulfillment):
"""
Attributes of an ``enterprise.LearnerCreditEnterpriseCourseEnrollment`` record.
"""
transaction_id = attr.ib(type=UUID)


@attr.s(frozen=True)
class EnterpriseLicensedFulfillment(BaseEnterpriseFulfillment):
"""
Attributes of an ``enterprise.LicensedEnterpriseCourseEnrollment`` record.
"""
license_uuid = attr.ib(type=UUID)
15 changes: 14 additions & 1 deletion openedx_events/enterprise/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
docs/decisions/0003-events-payload.rst
"""

from openedx_events.enterprise.data import LedgerTransaction, SubsidyRedemption
from openedx_events.enterprise.data import LedgerTransaction, SubsidyRedemption, EnterpriseLearnerCreditFulfillment
from openedx_events.tooling import OpenEdxPublicSignal

# .. event_type: org.openedx.enterprise.subsidy.redeemed.v1
Expand Down Expand Up @@ -84,3 +84,16 @@
"ledger_transaction": LedgerTransaction,
}
)


# .. event_type: org.openedx.enterprise.learner_credit_fulfillment.revoked.v1
# .. event_name: LEARNER_CREDIT_FULFILMENT_REVOKED
# .. event_description: emitted when a LearnerCreditEnterpriseCourseEnrollment is revoked. This most often happens when
# an enterprise learner unenrolls from an LC-subsidized course enrollment.
# .. event_data: LedgerTransaction
LEARNER_CREDIT_FULFILLMENT_REVOKED = OpenEdxPublicSignal(
event_type="org.openedx.enterprise.learner_credit_fulfillment.revoked.v1",
data={
"learner_credit_fulfillment": EnterpriseLearnerCreditFulfillment,
}
)

0 comments on commit 9dcc6d2

Please sign in to comment.