Skip to content

Commit 08c0540

Browse files
dix0nymmmarquezs
authored andcommitted
added Dialog and Extention, added missing functions on Config
1 parent e43ff2e commit 08c0540

File tree

1 file changed

+144
-3
lines changed

1 file changed

+144
-3
lines changed

myjdapi/myjdapi.py

Lines changed: 144 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,6 @@ def update_available(self):
155155
resp = self.is_update_available()
156156
return resp
157157

158-
159158
class Config:
160159
"""
161160
Class that represents the Config of a Device
@@ -165,11 +164,21 @@ def __init__(self, device):
165164
self.device = device
166165
self.url = '/config'
167166

168-
def list(self):
167+
def list(self, params=None):
169168
"""
170169
:return: List<AdvancedConfigAPIEntry>
171170
"""
172-
resp = self.device.action(self.url + "/list")
171+
if params != None:
172+
resp = self.device.action(self.url + "/list")
173+
return resp
174+
resp = self.device.action(self.url + "/list", params)
175+
return resp
176+
177+
def listEnum(self, type):
178+
"""
179+
:return: List<AdvancedConfigAPIEntry>
180+
"""
181+
resp = self.device.action(self.url + "/listEnum", params=[type])
173182
return resp
174183

175184
def get(self, interface_name, storage, key):
@@ -185,6 +194,62 @@ def get(self, interface_name, storage, key):
185194
resp = self.device.action(self.url + "/get", params)
186195
return resp
187196

197+
def getDefault(self, interfaceName, storage, key):
198+
"""
199+
:param interfaceName: a valid interface name from List<AdvancedConfigAPIEntry>
200+
:type: str:
201+
:param storage: 'null' to use default or 'cfg/' + interfaceName
202+
:type: str:
203+
:param key: a valid key from from List<AdvancedConfigAPIEntry>
204+
:type: str:
205+
"""
206+
params = [interfaceName, storage, key]
207+
resp = self.device.action(self.url + "/getDefault", params)
208+
return resp
209+
210+
def query(self,
211+
params=[{
212+
"configInterface": "",
213+
"defaultValues": True,
214+
"description": True,
215+
"enumInfo": True,
216+
"includeExtensions": True,
217+
"pattern": "",
218+
"values": True
219+
}]):
220+
"""
221+
:param params: A dictionary with options. The default dictionary is
222+
configured so it returns you all the downloads with all details, but you
223+
can put your own with your options. All the options available are this
224+
ones:
225+
{
226+
"configInterface" : "",
227+
"defaultValues" : True,
228+
"description" : True,
229+
"enumInfo" : True,
230+
"includeExtensions": True,
231+
"pattern" : "",
232+
"values" : ""
233+
}
234+
:type: Dictionary
235+
:rtype: List of dictionaries of this style, with more or less detail based on your options.
236+
"""
237+
resp = self.device.action(self.url + "/query", params)
238+
return resp
239+
240+
def reset(self, interfaceName, storage, key):
241+
"""
242+
:param interfaceName: a valid interface name from List<AdvancedConfigAPIEntry>
243+
:type: str:
244+
:param storage: 'null' to use default or 'cfg/' + interfaceName
245+
:type: str:
246+
:param key: a valid key from from List<AdvancedConfigAPIEntry>
247+
:type: str:
248+
"""
249+
params = [interfaceName, storage, key]
250+
resp = self.device.action(self.url + "/reset", params)
251+
return resp
252+
188253
def set(self, interface_name, storage, key, value):
189254
"""
190255
:param interfaceName: a valid interface name from List<AdvancedConfigAPIEntry>
@@ -262,6 +327,80 @@ def get_current_state(self):
262327
resp = self.device.action(self.url + "/getCurrentState")
263328
return resp
264329

330+
class Extension:
331+
def __init__(self, device):
332+
self.device = device
333+
self.url = "/extensions"
334+
335+
def list(self,
336+
params=[{
337+
"configInterface": True,
338+
"description": True,
339+
"enabled": True,
340+
"iconKey": True,
341+
"name": True,
342+
"pattern" : "",
343+
"installed": True
344+
}]):
345+
"""
346+
:param params: A dictionary with options. The default dictionary is
347+
configured so it returns you all the downloads with all details, but you
348+
can put your own with your options. All the options available are this
349+
ones:
350+
{
351+
"configInterface" : True,
352+
"description" : True,
353+
"enabled" : True,
354+
"iconKey" : True,
355+
"name" : True,
356+
"pattern" : "",
357+
"installed" : True
358+
}
359+
:type: Dictionary
360+
:rtype: List of dictionaries of this style, with more or less detail based on your options.
361+
"""
362+
resp = self.device.action(self.url + "/list", params=params)
363+
return resp
364+
365+
def install(self, id):
366+
resp = self.device.action(self.url + "/install", params=[id])
367+
return resp
368+
369+
def isInstalled(self, id):
370+
resp = self.device.action(self.url + "/isInstalled", params=[id])
371+
return resp
372+
373+
def isEnabled(self, id):
374+
resp = self.device.action(self.url + "/isEnabled", params=[id])
375+
return resp
376+
377+
def setEnabled(self, id, enabled):
378+
resp = self.device.action(self.url + "/setEnabled", params=[id, enabled])
379+
return resp
380+
381+
class Dialog:
382+
"""
383+
Class that represents the dialogs on myJD
384+
"""
385+
def __init__(self, device):
386+
self.device = device
387+
self.url = "/dialogs"
388+
389+
def answer(self, id, data):
390+
resp = self.device.action(self.url + "/answer", params=[id, data])
391+
return resp
392+
393+
def get(self, id, icon=True, properties=True):
394+
resp = self.device.action(self.url + "/get", params=[id, icon, properties])
395+
return resp
396+
397+
def getTypeInfo(self, dialogType):
398+
resp = self.device.action(self.url + "/getTypeInfo", params=[dialogType])
399+
return resp
400+
401+
def list(self):
402+
resp = self.device.action(self.url + "/list")
403+
return resp
265404

266405
class Linkgrabber:
267406
"""
@@ -824,6 +963,8 @@ def __init__(self, jd, device_dict):
824963
self.downloads = Downloads(self)
825964
self.toolbar = Toolbar(self)
826965
self.downloadcontroller = DownloadController(self)
966+
self.extensions = Extension(self)
967+
self.dialogs = Dialog(self)
827968
self.update = Update(self)
828969
self.jd = Jd(self)
829970
self.system = System(self)

0 commit comments

Comments
 (0)