|
| 1 | +from ..api import Api |
| 2 | + |
| 3 | + |
| 4 | +class Diablo3CommunityApi(Api): |
| 5 | + """All Community API methods""" |
| 6 | + |
| 7 | + def __init__(self, client_id, client_secret): |
| 8 | + super().__init__(client_id, client_secret) |
| 9 | + |
| 10 | + # D3 Act API |
| 11 | + |
| 12 | + def get_act_index(self, region, locale): |
| 13 | + """ |
| 14 | + D3 Act API - Returns an index of acts. |
| 15 | + """ |
| 16 | + resource = "/d3/data/act" |
| 17 | + query_params = {"locale": locale} |
| 18 | + return super().get_resource(resource, region, query_params) |
| 19 | + |
| 20 | + def get_act(self, region, locale, act_id): |
| 21 | + """ |
| 22 | + D3 Act API - Returns a single act by ID. |
| 23 | + """ |
| 24 | + resource = f"/d3/data/act/{act_id}" |
| 25 | + query_params = {"locale": locale} |
| 26 | + return super().get_resource(resource, region, query_params) |
| 27 | + |
| 28 | + # D3 Artisan and Recipe API |
| 29 | + |
| 30 | + def get_artisan(self, region, locale, artisan_slug): |
| 31 | + """ |
| 32 | + D3 Artisan and Recipe API - Returns a single artisan by slug. |
| 33 | + """ |
| 34 | + resource = f"/d3/data/artisan/{artisan_slug}" |
| 35 | + query_params = {"locale": locale} |
| 36 | + return super().get_resource(resource, region, query_params) |
| 37 | + |
| 38 | + def get_recipe(self, region, locale, artisan_slug, recipe_slug): |
| 39 | + """ |
| 40 | + D3 Artisan and Recipe API - Returns a single recipe by slug for the |
| 41 | + specified artisan. |
| 42 | + """ |
| 43 | + resource = f"/d3/data/artisan/{artisan_slug}/recipe/{recipe_slug}" |
| 44 | + query_params = {"locale": locale} |
| 45 | + return super().get_resource(resource, region, query_params) |
| 46 | + |
| 47 | + # D3 Follower API |
| 48 | + |
| 49 | + def get_follower(self, region, locale, follower_slug): |
| 50 | + """ |
| 51 | + D3 Follower API - Returns a single follower by slug. |
| 52 | + """ |
| 53 | + resource = f"/d3/data/follower/{follower_slug}" |
| 54 | + query_params = {"locale": locale} |
| 55 | + return super().get_resource(resource, region, query_params) |
| 56 | + |
| 57 | + # D3 Character Class and Skill API |
| 58 | + |
| 59 | + def get_character_class(self, region, locale, class_slug): |
| 60 | + """ |
| 61 | + D3 Character Class and Skill API - Returns a single character class by |
| 62 | + slug. |
| 63 | + """ |
| 64 | + resource = f"/d3/data/hero/{class_slug}" |
| 65 | + query_params = {"locale": locale} |
| 66 | + return super().get_resource(resource, region, query_params) |
| 67 | + |
| 68 | + def get_api_skill(self, region, locale, class_slug, skill_slug): |
| 69 | + """ |
| 70 | + D3 Character Class and Skill API - Returns a single skill by slug for a |
| 71 | + specific character class. |
| 72 | + """ |
| 73 | + resource = f"/d3/data/hero/{class_slug}/skill/{skill_slug}" |
| 74 | + query_params = {"locale": locale} |
| 75 | + return super().get_resource(resource, region, query_params) |
| 76 | + |
| 77 | + # D3 Item Type API |
| 78 | + |
| 79 | + def get_item_type_index(self, region, locale): |
| 80 | + """ |
| 81 | + D3 Item Type API - Returns an index of item types. |
| 82 | + """ |
| 83 | + resource = "/d3/data/item-type" |
| 84 | + query_params = {"locale": locale} |
| 85 | + return super().get_resource(resource, region, query_params) |
| 86 | + |
| 87 | + def get_item_type(self, region, locale, item_type_slug): |
| 88 | + """ |
| 89 | + D3 Item Type API - Returns a single item type by slug. |
| 90 | + """ |
| 91 | + resource = f"/d3/data/item-type/{item_type_slug}" |
| 92 | + query_params = {"locale": locale} |
| 93 | + return super().get_resource(resource, region, query_params) |
| 94 | + |
| 95 | + # D3 Item API |
| 96 | + |
| 97 | + def get_item(self, region, locale, item_slug_id): |
| 98 | + """ |
| 99 | + D3 Item API - Returns a single item by item slug and ID. |
| 100 | + """ |
| 101 | + resource = f"/d3/data/item/{item_slug_id}" |
| 102 | + query_params = {"locale": locale} |
| 103 | + return super().get_resource(resource, region, query_params) |
| 104 | + |
| 105 | + # D3 Profile API |
| 106 | + |
| 107 | + def get_api_account(self, region, locale, account_id): |
| 108 | + """ |
| 109 | + D3 Profile API - Returns the specified account profile. |
| 110 | + """ |
| 111 | + resource = f"/d3/profile/{account_id}/" |
| 112 | + query_params = {"locale": locale} |
| 113 | + return super().get_resource(resource, region, query_params) |
| 114 | + |
| 115 | + def get_api_hero(self, region, locale, account_id, hero_id): |
| 116 | + """ |
| 117 | + D3 Profile API - Returns a single hero. |
| 118 | + """ |
| 119 | + resource = f"/d3/profile/{account_id}/hero/{hero_id}" |
| 120 | + query_params = {"locale": locale} |
| 121 | + return super().get_resource(resource, region, query_params) |
| 122 | + |
| 123 | + def get_api_detailed_hero_items(self, region, locale, account_id, hero_id): |
| 124 | + """ |
| 125 | + D3 Profile API - Returns a list of items for the specified hero. |
| 126 | + """ |
| 127 | + resource = f"/d3/profile/{account_id}/hero/{hero_id}/items" |
| 128 | + query_params = {"locale": locale} |
| 129 | + return super().get_resource(resource, region, query_params) |
| 130 | + |
| 131 | + def get_api_detailed_follower_items( |
| 132 | + self, region, locale, account_id, hero_id |
| 133 | + ): |
| 134 | + """ |
| 135 | + D3 Profile API - Returns a single item by item slug and ID. |
| 136 | + """ |
| 137 | + resource = f"/d3/profile/{account_id}/hero/{hero_id}/follower-items" |
| 138 | + query_params = {"locale": locale} |
| 139 | + return super().get_resource(resource, region, query_params) |
0 commit comments