Coverage for fio_wrapper/urls.py: 100%

119 statements  

« prev     ^ index     » next       coverage.py v7.3.2, created at 2023-11-16 11:50 +0100

1from fio_wrapper.config import Config 

2 

3 

4class URLs: 

5 """FIO API URLs 

6 

7 Attributes: 

8 base_url (str): FIO Base URL 

9 """ 

10 

11 def __init__(self, config: Config) -> None: 

12 self.config = config 

13 

14 self.base_url = config.base_url 

15 

16 # material 

17 self.material_base = config.get_url("material_base") 

18 self.material_allmaterials = config.get_url("material_all") 

19 

20 # exchange 

21 self.exchange_base = config.get_url("exchange_base") 

22 self.exchange_orders = config.get_url("exchange_orders") 

23 self.exchange_all = config.get_url("exchange_all") 

24 self.exchange_full = config.get_url("exchange_full") 

25 

26 # building 

27 self.building_base = config.get_url("building_base") 

28 self.building_all = config.get_url("building_all") 

29 

30 # recipe 

31 self.recipe_base = config.get_url("recipe_base") 

32 self.recipe_all = config.get_url("recipe_all") 

33 

34 # planet 

35 self.planet_base = config.get_url("planet_base") 

36 self.planet_all = config.get_url("planet_all") 

37 self.planet_full = config.get_url("planet_full") 

38 self.planet_sites = config.get_url("planet_sites") 

39 self.planet_search = config.get_url("planet_search") 

40 

41 # localmarket 

42 self.localmarket_base = config.get_url("localmarket_base") 

43 self.localmarket_planet = config.get_url("localmarket_planet") 

44 self.localmarket_shipping_source = config.get_url("localmarket_shipping_source") 

45 self.localmarket_shipping_destination = config.get_url( 

46 "localmarket_shipping_destination" 

47 ) 

48 self.localmarket_company = config.get_url("localmarket_company") 

49 

50 # sites 

51 self.sites_base = config.get_url("sites_base") 

52 self.sites_planets = config.get_url("sites_planets") 

53 self.sites_warehouses = config.get_url("sites_warehouses") 

54 

55 # storage 

56 self.storage_base = config.get_url("storage_base") 

57 self.storage_planets = config.get_url("storage_planets") 

58 

59 # groups 

60 self.groups = config.get_url("groups") 

61 self.groups_group = config.get_url("groups_group") 

62 self.groups_groupmemberships = config.get_url("groups_groupmemberships") 

63 self.groups_hub = config.get_url("groups_hub") 

64 self.groups_burn = config.get_url("groups_burn") 

65 

66 # Material 

67 def material_url(self) -> str: 

68 return self.base_url + self.material_base 

69 

70 def material_get_url(self, material_ticker: str) -> str: 

71 return self.material_url() + "/" + material_ticker 

72 

73 def material_allmaterials_url(self) -> str: 

74 return self.material_url() + self.material_allmaterials 

75 

76 def material_get_category(self, category_name: str) -> str: 

77 return self.material_url() + "/category/" + category_name 

78 

79 # Exchange 

80 def exchange_url(self) -> str: 

81 return self.base_url + self.exchange_base 

82 

83 def exchange_get_url(self, exchange_ticker: str) -> str: 

84 return self.exchange_url() + "/" + exchange_ticker 

85 

86 def exchange_get_all_url(self) -> str: 

87 return self.exchange_url() + self.exchange_all 

88 

89 def exchange_get_full_url(self) -> str: 

90 return self.exchange_url() + self.exchange_full 

91 

92 def exchange_get_orders_companycode(self, company_code: str) -> str: 

93 return self.exchange_url() + self.exchange_orders + "/" + company_code 

94 

95 def exchange_get_orders_companycode_exchange( 

96 self, company_code: str, exchange_code: str 

97 ) -> str: 

98 return ( 

99 self.exchange_url() 

100 + self.exchange_orders 

101 + "/" 

102 + company_code 

103 + "/" 

104 + exchange_code 

105 ) 

106 

107 # Building 

108 def building_url(self) -> str: 

109 return f"{self.base_url}{self.building_base}" 

110 

111 def building_get_url(self, building_ticker: str) -> str: 

112 return f"{self.building_url()}/{building_ticker}" 

113 

114 def building_get_all_url(self) -> str: 

115 return f"{self.building_url()}{self.building_all}" 

116 

117 # Recipe 

118 def recipe_url(self) -> str: 

119 return f"{self.base_url}{self.recipe_base}" 

120 

121 def recipe_get_url(self, material_ticker: str) -> str: 

122 return f"{self.recipe_url()}/{material_ticker}" 

123 

124 def recipe_get_all_url(self) -> str: 

125 return f"{self.recipe_url()}{self.recipe_all}" 

126 

127 # Planet 

128 

129 def planet_url(self) -> str: 

130 return f"{self.base_url}{self.planet_base}" 

131 

132 def planet_get_url(self, planet: str) -> str: 

133 return f"{self.planet_url()}/{planet}" 

134 

135 def planet_all_url(self) -> str: 

136 return f"{self.planet_url()}{self.planet_all}" 

137 

138 def planet_full_url(self) -> str: 

139 return f"{self.planet_url()}{self.planet_full}" 

140 

141 def planet_sites_url(self, planet: str) -> str: 

142 return f"{self.planet_url()}{self.planet_sites}/{planet}" 

143 

144 def planet_search_url(self) -> str: 

145 return f"{self.planet_url()}{self.planet_search}" 

146 

147 # LocalMarket 

148 

149 def localmarket_url(self) -> str: 

150 return f"{self.base_url}{self.localmarket_base}" 

151 

152 def localmarket_planet_url(self, planet: str) -> str: 

153 return f"{self.localmarket_url()}{self.localmarket_planet}/{planet}" 

154 

155 def localmarket_planet_type_url(self, planet: str, adtype: str) -> str: 

156 return f"{self.localmarket_url()}{self.localmarket_planet}/{planet}/{adtype}" 

157 

158 def localmarket_shipping_source_url(self, planet: str) -> str: 

159 return f"{self.localmarket_url()}{self.localmarket_shipping_source}/{planet}" 

160 

161 def localmarket_shipping_destination_url(self, planet: str) -> str: 

162 return ( 

163 f"{self.localmarket_url()}{self.localmarket_shipping_destination}/{planet}" 

164 ) 

165 

166 def localmarket_company_url(self, companycode: str) -> str: 

167 return f"{self.localmarket_url()}{self.localmarket_company}/{companycode}" 

168 

169 # Sites 

170 

171 def sites_url(self) -> str: 

172 return f"{self.base_url}{self.sites_base}" 

173 

174 def sites_get_url(self, username: str) -> str: 

175 return f"{self.sites_url()}/{username}" 

176 

177 def sites_planets_get_url(self, username: str) -> str: 

178 return f"{self.sites_url()}{self.sites_planets}/{username}" 

179 

180 def sites_planets_get_planet_url(self, username: str, planet: str) -> str: 

181 return f"{self.sites_url()}/{username}/{planet}" 

182 

183 def sites_warehouses_get(self, username: str) -> str: 

184 return f"{self.sites_url()}{self.sites_warehouses}/{username}" 

185 

186 # Storage 

187 def storage_url(self) -> str: 

188 return f"{self.base_url}{self.storage_base}" 

189 

190 def storage_get_url(self, username: str) -> str: 

191 return f"{self.storage_url()}/{username}" 

192 

193 def storage_planets_get_url(self, username: str) -> str: 

194 return f"{self.storage_url()}{self.storage_planets}/{username}" 

195 

196 def storage_get_specific_url(self, username: str, specific: str) -> str: 

197 return f"{self.storage_url()}/{username}/{specific}" 

198 

199 # Groups 

200 

201 def group_all_url(self) -> str: 

202 return f"{self.base_url}{self.groups}" 

203 

204 def group_get_url(self, groupid: int) -> str: 

205 return f"{self.base_url}{self.groups_group}/{groupid}" 

206 

207 def group_memberships_url(self) -> str: 

208 return f"{self.base_url}{self.groups_groupmemberships}" 

209 

210 def group_hub_url(self) -> str: 

211 return f"{self.base_url}{self.groups_hub}" 

212 

213 def group_burn_url(self, groupid: int) -> str: 

214 return f"{self.base_url}{self.groups_burn}/{groupid}"