Add ICloud Account service
This commit is contained in:
parent
14518d4bc8
commit
adb14d1468
3 changed files with 51 additions and 1 deletions
|
@ -21,7 +21,8 @@ from pyicloud.services import (
|
||||||
UbiquityService,
|
UbiquityService,
|
||||||
ContactsService,
|
ContactsService,
|
||||||
RemindersService,
|
RemindersService,
|
||||||
PhotosService
|
PhotosService,
|
||||||
|
AccountService
|
||||||
)
|
)
|
||||||
from pyicloud.utils import get_password_from_keyring
|
from pyicloud.utils import get_password_from_keyring
|
||||||
|
|
||||||
|
@ -269,6 +270,15 @@ class PyiCloudService(object):
|
||||||
self.params
|
self.params
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def account(self):
|
||||||
|
service_root = self.webservices['account']['url']
|
||||||
|
return AccountService(
|
||||||
|
service_root,
|
||||||
|
self.session,
|
||||||
|
self.params
|
||||||
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def iphone(self):
|
def iphone(self):
|
||||||
return self.devices[0]
|
return self.devices[0]
|
||||||
|
|
|
@ -4,3 +4,4 @@ from pyicloud.services.ubiquity import UbiquityService
|
||||||
from pyicloud.services.contacts import ContactsService
|
from pyicloud.services.contacts import ContactsService
|
||||||
from pyicloud.services.reminders import RemindersService
|
from pyicloud.services.reminders import RemindersService
|
||||||
from pyicloud.services.photos import PhotosService
|
from pyicloud.services.photos import PhotosService
|
||||||
|
from pyicloud.services.account import AccountService
|
||||||
|
|
39
pyicloud/services/account.py
Normal file
39
pyicloud/services/account.py
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
class AccountService(object):
|
||||||
|
def __init__(self, service_root, session, params):
|
||||||
|
self.session = session
|
||||||
|
self.params = params
|
||||||
|
self._service_root = service_root
|
||||||
|
self._devices = []
|
||||||
|
|
||||||
|
self._acc_endpoint = '%s/setup/web/device' % self._service_root
|
||||||
|
self._account_devices_url = '%s/getDevices' % self._acc_endpoint
|
||||||
|
|
||||||
|
req = self.session.get(self._account_devices_url, params=self.params)
|
||||||
|
self.response = req.json()
|
||||||
|
|
||||||
|
for device_info in self.response['devices']:
|
||||||
|
# device_id = device_info['udid']
|
||||||
|
# self._devices[device_id] = AccountDevice(device_info)
|
||||||
|
self._devices.append(AccountDevice(device_info))
|
||||||
|
|
||||||
|
@property
|
||||||
|
def devices(self):
|
||||||
|
return self._devices
|
||||||
|
|
||||||
|
|
||||||
|
class AccountDevice(object):
|
||||||
|
def __init__(self, device_info):
|
||||||
|
self.serialNumber = device_info['serialNumber']
|
||||||
|
self.osVersion = device_info['osVersion']
|
||||||
|
self.modelLargePhotoURL2x = device_info['modelLargePhotoURL2x']
|
||||||
|
self.modelLargePhotoURL1x = device_info['modelLargePhotoURL1x']
|
||||||
|
self.name = device_info['name']
|
||||||
|
self.imei = device_info['imei']
|
||||||
|
self.model = device_info['model']
|
||||||
|
self.udid = device_info['udid']
|
||||||
|
self.modelSmallPhotoURL2x = device_info['modelSmallPhotoURL2x']
|
||||||
|
self.modelSmallPhotoURL1x = device_info['modelSmallPhotoURL1x']
|
||||||
|
self.modelDisplayName = device_info['modelDisplayName']
|
Loading…
Reference in a new issue