|
| 1 | +from mpt_api_client.models import ResourceData |
| 2 | + |
| 3 | + |
| 4 | +class ReviewMixin[Model]: |
| 5 | + """Review mixin adds the review action that changes the state to Pending.""" |
| 6 | + |
| 7 | + def review(self, resource_id: str, resource_data: ResourceData | None = None) -> Model: |
| 8 | + """Update state to Pending. |
| 9 | +
|
| 10 | + Args: |
| 11 | + resource_id: Resource ID |
| 12 | + resource_data: Resource data will be updated |
| 13 | + """ |
| 14 | + return self._resource_action( # type: ignore[attr-defined, no-any-return] |
| 15 | + resource_id, "POST", "review", json=resource_data |
| 16 | + ) |
| 17 | + |
| 18 | + |
| 19 | +class PublishMixin[Model]: |
| 20 | + """Publish mixin adds the publish action that changes the state to Published.""" |
| 21 | + |
| 22 | + def publish(self, resource_id: str, resource_data: ResourceData | None = None) -> Model: |
| 23 | + """Update state to Published. |
| 24 | +
|
| 25 | + Args: |
| 26 | + resource_id: Resource ID |
| 27 | + resource_data: Resource data will be updated |
| 28 | + """ |
| 29 | + return self._resource_action( # type: ignore[attr-defined, no-any-return] |
| 30 | + resource_id, "POST", "publish", json=resource_data |
| 31 | + ) |
| 32 | + |
| 33 | + |
| 34 | +class UnpublishMixin[Model]: |
| 35 | + """Unpublish mixin adds the unpublish action that changes the state to Unpublished.""" |
| 36 | + |
| 37 | + def unpublish(self, resource_id: str, resource_data: ResourceData | None = None) -> Model: |
| 38 | + """Update state to Unpublished. |
| 39 | +
|
| 40 | + Args: |
| 41 | + resource_id: Resource ID |
| 42 | + resource_data: Resource data will be updated |
| 43 | + """ |
| 44 | + return self._resource_action( # type: ignore[attr-defined, no-any-return] |
| 45 | + resource_id, "POST", "unpublish", json=resource_data |
| 46 | + ) |
| 47 | + |
| 48 | + |
| 49 | +class AsyncReviewMixin[Model]: |
| 50 | + """Review mixin adds the review action that changes the state to reviewing.""" |
| 51 | + |
| 52 | + async def review(self, resource_id: str, resource_data: ResourceData | None = None) -> Model: |
| 53 | + """Update state to reviewing. |
| 54 | +
|
| 55 | + Args: |
| 56 | + resource_id: Resource ID |
| 57 | + resource_data: Resource data will be updated |
| 58 | + """ |
| 59 | + return await self._resource_action( # type: ignore[attr-defined, no-any-return] |
| 60 | + resource_id, "POST", "review", json=resource_data |
| 61 | + ) |
| 62 | + |
| 63 | + |
| 64 | +class AsyncPublishMixin[Model]: |
| 65 | + """Publish mixin adds the publish action that changes the state to Published.""" |
| 66 | + |
| 67 | + async def publish(self, resource_id: str, resource_data: ResourceData | None = None) -> Model: |
| 68 | + """Update state to Published. |
| 69 | +
|
| 70 | + Args: |
| 71 | + resource_id: Resource ID |
| 72 | + resource_data: Resource data will be updated |
| 73 | + """ |
| 74 | + return await self._resource_action( # type: ignore[attr-defined, no-any-return] |
| 75 | + resource_id, "POST", "publish", json=resource_data |
| 76 | + ) |
| 77 | + |
| 78 | + |
| 79 | +class AsyncUnpublishMixin[Model]: |
| 80 | + """Unpublish mixin adds the unpublish action that changes the state to Unpublished.""" |
| 81 | + |
| 82 | + async def unpublish(self, resource_id: str, resource_data: ResourceData | None = None) -> Model: |
| 83 | + """Update state to Unpublished. |
| 84 | +
|
| 85 | + Args: |
| 86 | + resource_id: Resource ID |
| 87 | + resource_data: Resource data will be updated |
| 88 | + """ |
| 89 | + return await self._resource_action( # type: ignore[attr-defined, no-any-return] |
| 90 | + resource_id, "POST", "unpublish", json=resource_data |
| 91 | + ) |
0 commit comments