-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
566 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
""" | ||
Copyright (c) Kae Bartlett | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU Affero General Public License as published | ||
by the Free Software Foundation, either version 3 of the License, or | ||
any later version. | ||
This program is dis2tributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU Affero General Public License for more details. | ||
You should have received a copy of the GNU Affero General Public License | ||
along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
""" | ||
|
||
from __future__ import annotations | ||
|
||
from typing import TYPE_CHECKING | ||
|
||
from ._route import Route | ||
from ..models import Entitlement, SKU | ||
|
||
if TYPE_CHECKING: | ||
from ._http import HTTPConnection | ||
from .. import payloads | ||
|
||
__all__ = ( | ||
'MonetizationHTTPConnection', | ||
) | ||
|
||
|
||
class MonetizationHTTPConnection: | ||
|
||
def __init__(self, parent: HTTPConnection): | ||
self.parent = parent | ||
|
||
async def list_skus( | ||
self, | ||
application_id: int) -> list[SKU]: | ||
"""List all SKUs associated with the given application ID.""" | ||
|
||
route = Route( | ||
"GET", | ||
"/applications/{application_id}/skus", | ||
application_id=application_id, | ||
) | ||
data: list[payloads.SKU] = await self.parent.request( | ||
route, | ||
) | ||
return [ | ||
SKU(state=self.parent, data=d) | ||
for d in data | ||
] | ||
|
||
async def list_entitlements( | ||
self, | ||
application_id: int) -> list[Entitlement]: | ||
"""List all entitlements associated with the given application ID.""" | ||
|
||
route = Route( | ||
"GET", | ||
"/applications/{application_id}/commands", | ||
application_id=application_id, | ||
) | ||
data: list[payloads.ApplicationCommand] = await self.parent.request( | ||
route, | ||
) | ||
return [ | ||
Entitlement(state=self.parent, data=d) | ||
for d in data | ||
] | ||
|
||
async def consume_entitlement( | ||
self, | ||
application_id: int, | ||
entitlement_id: int) -> list[Entitlement]: | ||
"""List all entitlements associated with the given application ID.""" | ||
|
||
route = Route( | ||
"GET", | ||
"/applications/{application_id}/commands", | ||
application_id=application_id, | ||
) | ||
data: list[payloads.ApplicationCommand] = await self.parent.request( | ||
route, | ||
) | ||
return [ | ||
Entitlement(state=self.parent, data=d) | ||
for d in data | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
""" | ||
Copyright (c) Kae Bartlett | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU Affero General Public License as published | ||
by the Free Software Foundation, either version 3 of the License, or | ||
any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU Affero General Public License for more details. | ||
You should have received a copy of the GNU Affero General Public License | ||
along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
""" | ||
|
||
from __future__ import annotations | ||
|
||
from .utils import Enum | ||
|
||
__all__ = ( | ||
'SKUType', | ||
'EntitlementType', | ||
) | ||
|
||
|
||
class SKUType(Enum): | ||
DURABLE = 2 | ||
CONSUMABLE = 3 | ||
SUBSCRIPTION = 5 | ||
SUBSCRIPTION_GROUP = 6 | ||
|
||
|
||
class EntitlementType(Enum): | ||
PURCHASE = 1 | ||
PREMIUM_SUBSCRIPTION = 2 | ||
DEVELOPER_GIFT = 3 | ||
TEST_MODE_PURCHASE = 4 | ||
FREE_PURCHASE = 5 | ||
USER_GIFT = 6 | ||
PREMIUM_PURCHASE = 7 | ||
APPLICATION_SUBSCRIPTION = 8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
""" | ||
Copyright (c) Kae Bartlett | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU Affero General Public License as published | ||
by the Free Software Foundation, either version 3 of the License, or | ||
any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU Affero General Public License for more details. | ||
You should have received a copy of the GNU Affero General Public License | ||
along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
""" | ||
|
||
from __future__ import annotations | ||
|
||
from typing import TYPE_CHECKING | ||
|
||
from vfflags import Flags | ||
|
||
__all__ = ( | ||
'SKUFlags', | ||
) | ||
|
||
|
||
class SKUFlags(Flags): | ||
"""Flags associated with SKUs.""" | ||
|
||
if TYPE_CHECKING: | ||
available: bool | ||
guild_subscription: bool | ||
user_subscription: bool | ||
|
||
CREATE_FLAGS = { | ||
"available": 1 << 2, | ||
"guild_subscription": 1 << 7, | ||
"user_subscription": 1 << 8, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.