Habiticalib 0.1.0a3__tar.gz → 0.2.0a0__tar.gz

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.
Files changed (44) hide show
  1. {habiticalib-0.1.0a3 → habiticalib-0.2.0a0}/PKG-INFO +1 -1
  2. {habiticalib-0.1.0a3 → habiticalib-0.2.0a0}/src/habiticalib/__init__.py +2 -0
  3. {habiticalib-0.1.0a3 → habiticalib-0.2.0a0}/src/habiticalib/const.py +1 -1
  4. {habiticalib-0.1.0a3 → habiticalib-0.2.0a0}/src/habiticalib/lib.py +4 -3
  5. {habiticalib-0.1.0a3 → habiticalib-0.2.0a0}/src/habiticalib/types.py +7 -0
  6. habiticalib-0.1.0a3/tests/__snapshots__/test_user.ambr → habiticalib-0.2.0a0/tests/__snapshots__/test_lib.ambr +3 -0
  7. habiticalib-0.2.0a0/tests/fixtures/login.json +10 -0
  8. habiticalib-0.1.0a3/tests/test_user.py → habiticalib-0.2.0a0/tests/test_lib.py +12 -0
  9. {habiticalib-0.1.0a3 → habiticalib-0.2.0a0}/.cruft.json +0 -0
  10. {habiticalib-0.1.0a3 → habiticalib-0.2.0a0}/.editorconfig +0 -0
  11. {habiticalib-0.1.0a3 → habiticalib-0.2.0a0}/.github/FUNDING.yml +0 -0
  12. {habiticalib-0.1.0a3 → habiticalib-0.2.0a0}/.github/dependabot.yml +0 -0
  13. {habiticalib-0.1.0a3 → habiticalib-0.2.0a0}/.github/labels.yml +0 -0
  14. {habiticalib-0.1.0a3 → habiticalib-0.2.0a0}/.github/release-drafter.yml +0 -0
  15. {habiticalib-0.1.0a3 → habiticalib-0.2.0a0}/.github/workflows/build.yml +0 -0
  16. {habiticalib-0.1.0a3 → habiticalib-0.2.0a0}/.github/workflows/documentation.yml +0 -0
  17. {habiticalib-0.1.0a3 → habiticalib-0.2.0a0}/.github/workflows/draft.yml +0 -0
  18. {habiticalib-0.1.0a3 → habiticalib-0.2.0a0}/.github/workflows/labeler.yml +0 -0
  19. {habiticalib-0.1.0a3 → habiticalib-0.2.0a0}/.gitignore +0 -0
  20. {habiticalib-0.1.0a3 → habiticalib-0.2.0a0}/.pre-commit-config.yaml +0 -0
  21. {habiticalib-0.1.0a3 → habiticalib-0.2.0a0}/.vscode/settings.json +0 -0
  22. {habiticalib-0.1.0a3 → habiticalib-0.2.0a0}/LICENSE +0 -0
  23. {habiticalib-0.1.0a3 → habiticalib-0.2.0a0}/README.md +0 -0
  24. {habiticalib-0.1.0a3 → habiticalib-0.2.0a0}/docs/index.md +0 -0
  25. {habiticalib-0.1.0a3 → habiticalib-0.2.0a0}/docs/reference/habiticalib.md +0 -0
  26. {habiticalib-0.1.0a3 → habiticalib-0.2.0a0}/mkdocs.yml +0 -0
  27. {habiticalib-0.1.0a3 → habiticalib-0.2.0a0}/pyproject.toml +0 -0
  28. {habiticalib-0.1.0a3 → habiticalib-0.2.0a0}/src/habiticalib/exceptions.py +0 -0
  29. {habiticalib-0.1.0a3 → habiticalib-0.2.0a0}/src/habiticalib/helpers.py +0 -0
  30. {habiticalib-0.1.0a3 → habiticalib-0.2.0a0}/src/habiticalib/py.typed +0 -0
  31. {habiticalib-0.1.0a3 → habiticalib-0.2.0a0}/tests/__init__.py +0 -0
  32. {habiticalib-0.1.0a3 → habiticalib-0.2.0a0}/tests/__snapshots__/test_avatar.ambr +0 -0
  33. {habiticalib-0.1.0a3 → habiticalib-0.2.0a0}/tests/conftest.py +0 -0
  34. {habiticalib-0.1.0a3 → habiticalib-0.2.0a0}/tests/fixtures/user.json +0 -0
  35. {habiticalib-0.1.0a3 → habiticalib-0.2.0a0}/tests/fixtures/user_styles.json +0 -0
  36. {habiticalib-0.1.0a3 → habiticalib-0.2.0a0}/tests/fixtures/user_styles_kickstarter.json +0 -0
  37. {habiticalib-0.1.0a3 → habiticalib-0.2.0a0}/tests/fixtures/user_styles_seafoam.json +0 -0
  38. {habiticalib-0.1.0a3 → habiticalib-0.2.0a0}/tests/fixtures/user_styles_shinySeed.json +0 -0
  39. {habiticalib-0.1.0a3 → habiticalib-0.2.0a0}/tests/fixtures/user_styles_sleeping.json +0 -0
  40. {habiticalib-0.1.0a3 → habiticalib-0.2.0a0}/tests/fixtures/user_styles_snowball.json +0 -0
  41. {habiticalib-0.1.0a3 → habiticalib-0.2.0a0}/tests/fixtures/user_styles_spookySparkles.json +0 -0
  42. {habiticalib-0.1.0a3 → habiticalib-0.2.0a0}/tests/fixtures/user_styles_with_chair.json +0 -0
  43. {habiticalib-0.1.0a3 → habiticalib-0.2.0a0}/tests/test_avatar.py +0 -0
  44. {habiticalib-0.1.0a3 → habiticalib-0.2.0a0}/tests/test_init.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: Habiticalib
3
- Version: 0.1.0a3
3
+ Version: 0.2.0a0
4
4
  Summary: Asynchronous Python client library for the Habitica API
5
5
  Project-URL: Documentation, https://tr4nt0r.github.io/habiticalib/
6
6
  Project-URL: Source, https://github.com/tr4nt0r/habiticalib
@@ -19,6 +19,7 @@ from .types import (
19
19
  HabiticaLoginResponse,
20
20
  HabiticaResponse,
21
21
  HabiticaScoreResponse,
22
+ HabiticaSleepResponse,
22
23
  HabiticaStatsResponse,
23
24
  HabiticaTagResponse,
24
25
  HabiticaTagsResponse,
@@ -51,6 +52,7 @@ __all__ = [
51
52
  "HabiticaLoginResponse",
52
53
  "HabiticaResponse",
53
54
  "HabiticaScoreResponse",
55
+ "HabiticaSleepResponse",
54
56
  "HabiticaStatsResponse",
55
57
  "HabiticaTagResponse",
56
58
  "HabiticaTagsResponse",
@@ -1,6 +1,6 @@
1
1
  """Constants for Habiticalib."""
2
2
 
3
- __version__ = "0.1.0a3"
3
+ __version__ = "0.2.0a0"
4
4
 
5
5
  DEFAULT_URL = "https://habitica.com/"
6
6
  ASSETS_URL = "https://habitica-assets.s3.amazonaws.com/mobileApp/images/"
@@ -35,6 +35,7 @@ from .types import (
35
35
  HabiticaLoginResponse,
36
36
  HabiticaResponse,
37
37
  HabiticaScoreResponse,
38
+ HabiticaSleepResponse,
38
39
  HabiticaStatsResponse,
39
40
  HabiticaTagResponse,
40
41
  HabiticaTagsResponse,
@@ -853,12 +854,12 @@ class Habitica:
853
854
 
854
855
  async def toggle_sleep(
855
856
  self,
856
- ) -> HabiticaResponse:
857
+ ) -> HabiticaSleepResponse:
857
858
  """Toggles the user's sleep mode in Habitica.
858
859
 
859
860
  Returns
860
861
  -------
861
- HabiticaResponse
862
+ HabiticaSleepResponse
862
863
  A response object containing the result of the sleep mode toggle,
863
864
  and the new sleep state (True if sleeping, False if not).
864
865
 
@@ -875,7 +876,7 @@ class Habitica:
875
876
  """
876
877
  url = self.url / "api/v3/user/sleep"
877
878
 
878
- return HabiticaResponse.from_json(await self._request("post", url=url))
879
+ return HabiticaSleepResponse.from_json(await self._request("post", url=url))
879
880
 
880
881
  async def revive(
881
882
  self,
@@ -1131,6 +1131,13 @@ class HabiticaTaskOrderResponse(HabiticaResponse):
1131
1131
  data: list[UUID] = field(default_factory=list)
1132
1132
 
1133
1133
 
1134
+ @dataclass
1135
+ class HabiticaSleepResponse(HabiticaResponse):
1136
+ """Representation of a sleep response."""
1137
+
1138
+ data: bool
1139
+
1140
+
1134
1141
  class TaskFilter(StrEnum):
1135
1142
  """Enum representing the valid types of tasks for requests."""
1136
1143
 
@@ -1,4 +1,7 @@
1
1
  # serializer version: 1
2
+ # name: test_login
3
+ HabiticaLoginResponse(data=LoginData(id=UUID('a380546a-94be-4b8e-8a0b-23e0d5c03303'), apiToken='cd0e5985-17de-4b4f-849e-5d506c5e4382', newUser=False, username='test-username', passwordResetCode=None), success=True, notifications=[], userV=None, appVersion='5.30.0')
4
+ # ---
2
5
  # name: test_user
3
6
  HabiticaUserResponse(data=UserData(id=UUID('c18e1853-bded-47a9-82e2-adfdad08894d'), preferences=PreferencesUser(hair=HairPreferences(color='red', base=3, bangs=1, beard=0, mustache=0, flower=1), emailNotifications=EmailNotificationsPreferences(unsubscribeFromAll=False, newPM=True, kickedGroup=True, wonChallenge=True, giftedGems=True, giftedSubscription=True, invitedParty=True, invitedGuild=True, questStarted=True, invitedQuest=True, importantAnnouncements=True, weeklyRecaps=True, onboarding=True, majorUpdates=True, subscriptionReminders=True, contentRelease=True), pushNotifications=PushNotificationsPreferences(unsubscribeFromAll=False, newPM=True, wonChallenge=True, giftedGems=True, giftedSubscription=True, invitedParty=True, invitedGuild=True, questStarted=True, invitedQuest=True, majorUpdates=True, mentionParty=True, mentionJoinedGuild=True, mentionUnjoinedGuild=True, partyActivity=True, contentRelease=True), suppressModals=SuppressModalsPreferences(levelUp=False, hatchPet=False, raisePet=False, streak=False), tasks=TasksPreferences(activeFilter=ActiveFilterTask(habit='all', daily='all', todo='remaining', reward='all'), groupByChallenge=False, confirmScoreNotes=False, mirrorGroupTasks=[]), dayStart=0, size='slim', hideHeader=False, skin='915533', shirt='blue', timezoneOffset=-120, sound='rosstavoTheme', chair='none', allocationMode='flat', autoEquip=True, costume=False, dateFormat='MM/dd/yyyy', sleep=False, stickyHeader=True, disableClasses=False, newTaskEdit=False, dailyDueDefaultView=False, advancedCollapsed=False, toolbarCollapsed=False, reverseChatOrder=False, developerMode=False, displayInviteToPartyWhenPartyIs1=True, background='violet', automaticAllocation=None, webhooks={}, improvementCategories=[], timezoneOffsetAtLastCron=None, language='de'), flags=FlagsUser(customizationsNotification=False, tour=TourFlags(intro=-1, classes=-1, stats=-1, tavern=-1, party=-1, guilds=-1, challenges=-1, market=-1, pets=-1, mounts=-1, hall=-1, equipment=-1, groupPlans=-1), showTour=True, tutorial=TutorialFlags(common=CommonTutorial(habits=True, dailies=True, todos=True, rewards=True, party=True, pets=True, gems=True, skills=True, classes=True, tavern=True, equipment=True, items=True, mounts=True, inbox=True, stats=True), ios=IosTutorial(addTask=False, editTask=False, deleteTask=False, filterTask=False, groupPets=False, inviteParty=False, reorderTask=False)), dropsEnabled=False, itemsEnabled=False, lastNewStuffRead='', rewrite=True, classSelected=False, rebirthEnabled=False, levelDrops={}, recaptureEmailsPhase=0, weeklyRecapEmailsPhase=0, lastWeeklyRecap=datetime.datetime(2024, 10, 19, 18, 43, 39, 782000, tzinfo=datetime.timezone.utc), communityGuidelinesAccepted=False, cronCount=0, welcomed=True, armoireEnabled=True, armoireOpened=False, armoireEmpty=False, cardReceived=False, warnedLowHealth=False, verifiedUsername=True, newStuff=False, thirdPartyTools=None, mathUpdates=None, lastFreeRebirth=None, chatRevoked=None, chatShadowMuted=None, lastWeeklyRecapDiscriminator=None, onboardingEmailsPhase=None), auth=AuthUser(local=LocalAuth(email='test@example.com', username='test', lowerCaseUsername='test', has_password=True), timestamps=LocalTimestamps(created=datetime.datetime(2024, 10, 19, 18, 43, 39, 782000, tzinfo=datetime.timezone.utc), loggedin=datetime.datetime(2024, 10, 19, 18, 43, 39, 782000, tzinfo=datetime.timezone.utc), updated=datetime.datetime(2024, 10, 19, 18, 44, 51, 37000, tzinfo=datetime.timezone.utc)), facebook={}, google={}, apple={}), achievements=AchievementsUser(ultimateGearSets=UltimateGearSetsAchievments(healer=False, wizard=False, rogue=False, warrior=False), streak=0, challenges=[], perfect=0, quests=QuestsAchievments(bewilder=None, burnout=None, stressbeast=None, harpy=None, atom3=None, vice3=None, vice1=None, gryphon=None, evilsanta2=None, evilsanta=None, dilatory_derby=None, dilatory=None, atom2=None, atom1=None, dysheartener=None), backToBasics=None, dustDevil=None, primedForPainting=None, completedTask=None, createdTask=None, fedPet=None, hatchedPet=None, purchasedEquipment=None, tickledPink=None, goodAsGold=None, boneCollector=None, seeingRed=None, violetsAreBlue=None, shadyCustomer=None, joinedGuild=None, joinedChallenge=None, partyUp=None), backer=BackerUser(tier=None, npc=None, tokensApplied=None), contributor=ContributorUser(contributions=None, level=None, text=None), permissions=PermissionsUser(fullAccess=None, news=None, userSupport=None, challengeAdmin=None, moderator=None, coupons=None), purchased=PurchasedUser(plan=PlanPurchased(consecutive=ConsecutivePlan(trinkets=0, gemCapExtra=0, offset=0, count=0), mysteryItems=[], gemsBought=0, extraMonths=0, dateUpdated=None, perkMonthCount=-1, quantity=1), txnCount=0, background={'violet': True}, shirt={}, hair={}, skin={}, ads=False, mobileChat=None), history=HistoryUser(todos=[], exp=[]), items=ItemsUser(gear=GearItems(equipped=EquippedGear(weapon='weapon_special_fall2024Warrior', armor='armor_special_fall2024Warrior', head='head_special_fall2024Warrior', shield='shield_special_fall2024Warrior', back='back_mystery_201402', headAccessory='headAccessory_special_pinkHeadband', eyewear='eyewear_special_pinkHalfMoon', body='body_mystery_202003'), costume=EquippedGear(weapon=None, armor='armor_base_0', head='head_base_0', shield='shield_base_0', back=None, headAccessory=None, eyewear=None, body=None), owned={'headAccessory_special_blackHeadband': True, 'headAccessory_special_blueHeadband': True, 'headAccessory_special_greenHeadband': True, 'headAccessory_special_pinkHeadband': True, 'headAccessory_special_redHeadband': True, 'headAccessory_special_whiteHeadband': True, 'headAccessory_special_yellowHeadband': True, 'eyewear_special_blackTopFrame': True, 'eyewear_special_blueTopFrame': True, 'eyewear_special_greenTopFrame': True, 'eyewear_special_pinkTopFrame': True, 'eyewear_special_redTopFrame': True, 'eyewear_special_whiteTopFrame': True, 'eyewear_special_yellowTopFrame': True, 'eyewear_special_blackHalfMoon': True, 'eyewear_special_blueHalfMoon': True, 'eyewear_special_greenHalfMoon': True, 'eyewear_special_pinkHalfMoon': True, 'eyewear_special_redHalfMoon': True, 'eyewear_special_whiteHalfMoon': True, 'eyewear_special_yellowHalfMoon': True}), special=SpecialItems(birthdayReceived=[], birthday=0, thankyouReceived=[], thankyou=0, greetingReceived=[], greeting=0, nyeReceived=[], nye=0, valentineReceived=[], valentine=0, seafoam=0, shinySeed=0, spookySparkles=0, snowball=0, congrats=0, congratsReceived=[], getwell=0, getwellReceived=[], goodluck=0, goodluckReceived=[]), lastDrop=LastDropItems(count=0, date=datetime.datetime(2024, 10, 19, 18, 43, 39, 784000, tzinfo=datetime.timezone.utc)), currentMount='Velociraptor-Base', currentPet='Rat-Shade', quests={'dustbunnies': 1}, mounts={}, food={}, hatchingPotions={}, eggs={}, pets={}), invitations=InvitationsUser(party={}, guilds=[], parties=[]), party=PartyUser(quest=QuestParty(progress=ProgressQuest(up=0.0, down=0.0, collect={}, collectedItems=0), RSVPNeeded=False, key=None, completed=None), order='level', orderAscending='ascending', _id=None), profile=ProfileUser(blurb=None, imageUrl=None, name='test'), stats=StatsUser(buffs=BuffsStats(Str=0, per=0, con=0, stealth=0, streaks=False, seafoam=False, shinySeed=False, snowball=False, spookySparkles=False, Int=0), training=TrainingStats(Str=0.0, per=0, con=0, Int=0), hp=50.0, mp=10.0, exp=0, gp=0.0, lvl=1, Class=<HabiticaClass.WARRIOR: 'warrior'>, points=0, Str=0, con=0, per=0, toNextLevel=25, maxHealth=50, maxMP=30, Int=0), notifications=[], tags=[TagsUser(id=UUID('5358c71f-fe0f-4583-84a3-109b70c699fd'), name='Arbeit', challenge=None, group=None), TagsUser(id=UUID('45870b8b-3e1e-4e13-a722-6afcacdf689f'), name='Training', challenge=None, group=None), TagsUser(id=UUID('3e49b9db-0cc5-4070-b860-e16f1e4806a4'), name='Gesundheit + Wohlbefinden', challenge=None, group=None), TagsUser(id=UUID('0d85319e-7b9c-43e2-81ed-2a706521d5e3'), name='Schule', challenge=None, group=None), TagsUser(id=UUID('b7cf86bf-97ac-42d3-b5d0-5ffe998b62b4'), name='Teams', challenge=None, group=None), TagsUser(id=UUID('c584d792-0a9b-4646-a6ca-a67bb6ef3c36'), name='Hausarbeiten', challenge=None, group=None), TagsUser(id=UUID('0602fd13-edf2-46a7-99c0-c5084046efbb'), name='Kreativität', challenge=None, group=None)], inbox=InboxUser(newMessages=0, optOut=False, blocks=[], messages={}), tasksOrder=TasksOrderUser(habits=[UUID('21b10675-e238-4462-be11-1a4f8012fc9c'), UUID('69909140-a920-4b83-b018-b9156760aca3'), UUID('7e0679cf-e9cd-4604-b429-d061ea16ce72'), UUID('270df162-d47d-488b-9c1d-4fc4f0e2b2d2'), UUID('80ad00b5-622e-4d1a-af4d-6a6c199f3571'), UUID('0712669d-8374-4211-84ea-715cbcbae9c1'), UUID('56dee98d-038a-43f3-a514-59b1ed9a52ee'), UUID('25df4765-754c-47b1-a011-83b31f70c4fb')], dailys=[UUID('e22e9ef0-15be-478a-81c7-f9fdbb4fac10'), UUID('2a74baa2-3acd-426c-bce4-6b4bb145a8d5'), UUID('e18d0899-7c59-41c0-affd-318b8850c3e5'), UUID('3d0cecac-73c1-462b-ab39-a39cea107e6b'), UUID('1ed21cd0-e6f5-4707-b1b4-fb376d462387'), UUID('9117ad5e-2cda-43e0-a07c-0b175d32c0eb')], todos=[UUID('ac13c62c-9375-4809-a357-0e42b01a1b43'), UUID('2388ccad-0387-4ea6-9968-2d10d994e903'), UUID('5c6efb91-6ae3-4cad-8b19-2dd2fc52a965'), UUID('80afe0b9-e367-4473-8117-b8bc7115f54a'), UUID('4cc21c36-886c-4a43-b580-877e958a37fd'), UUID('10a45996-7133-4ca1-84d8-abf1093d9dcc'), UUID('fb867459-ae50-4cee-9017-c13206c6dfa2')], rewards=[UUID('4b18ccf6-3934-43a5-a153-31af8b2a36d9')]), extra={}, pushDevices=[], webhooks=[], loginIncentives=0, invitesSent=0, pinnedItems=[PinnedItemsUser(path='gear.flat.weapon_warrior_0', Type='marketGear'), PinnedItemsUser(path='gear.flat.armor_warrior_1', Type='marketGear'), PinnedItemsUser(path='gear.flat.shield_warrior_1', Type='marketGear'), PinnedItemsUser(path='gear.flat.head_warrior_1', Type='marketGear'), PinnedItemsUser(path='potion', Type='potion'), PinnedItemsUser(path='armoire', Type='armoire')], pinnedItemsOrder=[], unpinnedItems=[], secret=None, balance=0.0, lastCron=datetime.datetime(2024, 10, 19, 18, 43, 39, 784000, tzinfo=datetime.timezone.utc), needsCron=False, challenges=[], guilds=[], newMessages={}), success=True, notifications=[], userV=5, appVersion='5.28.8')
4
7
  # ---
@@ -0,0 +1,10 @@
1
+ {
2
+ "success": true,
3
+ "data": {
4
+ "id": "a380546a-94be-4b8e-8a0b-23e0d5c03303",
5
+ "apiToken": "cd0e5985-17de-4b4f-849e-5d506c5e4382",
6
+ "newUser": false,
7
+ "username": "test-username"
8
+ },
9
+ "appVersion": "5.30.0"
10
+ }
@@ -9,6 +9,18 @@ from habiticalib import Habitica
9
9
  from .conftest import load_fixture
10
10
 
11
11
 
12
+ async def test_login(mock_aiohttp: aioresponses, snapshot: SnapshotAssertion) -> None:
13
+ """Test login."""
14
+ mock_aiohttp.post(
15
+ "https://habitica.com/api/v3/user/auth/local/login",
16
+ body=load_fixture("login.json"),
17
+ )
18
+ async with ClientSession() as session:
19
+ habitica = Habitica(session, "test", "test")
20
+ response = await habitica.login("test-username", "test-password")
21
+ assert response == snapshot
22
+
23
+
12
24
  async def test_user(mock_aiohttp: aioresponses, snapshot: SnapshotAssertion) -> None:
13
25
  """Test default user agent is set."""
14
26
  mock_aiohttp.get("https://habitica.com/api/v3/user", body=load_fixture("user.json"))
File without changes
File without changes
File without changes
File without changes
File without changes