Export fitting to EVE, fix json bugs, and include forgotten CREST service.
This commit is contained in:
34
service/crest.py
Normal file
34
service/crest.py
Normal file
@@ -0,0 +1,34 @@
|
||||
import eos.db
|
||||
import config
|
||||
|
||||
class Crest():
|
||||
|
||||
_instance = None
|
||||
@classmethod
|
||||
def getInstance(cls):
|
||||
if cls._instance == None:
|
||||
cls._instance = Crest()
|
||||
|
||||
return cls._instance
|
||||
|
||||
def __init__(self):
|
||||
|
||||
pass
|
||||
|
||||
def getCrestCharacters(self):
|
||||
return eos.db.getCrestCharacters()
|
||||
|
||||
def getCrestCharacter(self, charID):
|
||||
return eos.db.getCrestCharacter(charID)
|
||||
|
||||
def getFittings(self, charID):
|
||||
char = self.getCrestCharacter(charID)
|
||||
char.auth()
|
||||
return char.eve.get('https://api-sisi.testeveonline.com/characters/%d/fittings/'%char.ID)
|
||||
|
||||
def postFitting(self, charID, json):
|
||||
char = self.getCrestCharacter(charID)
|
||||
char.auth()
|
||||
print char.eve.token
|
||||
res = char.eve._session.post('https://api-sisi.testeveonline.com/characters/%d/fittings/'%char.ID, data=json)
|
||||
return res
|
||||
@@ -59,8 +59,8 @@ class Port(object):
|
||||
# max length is 50 characters
|
||||
name = ofit.name[:47] + '...' if len(ofit.name) > 50 else ofit.name
|
||||
fit['name'] = name
|
||||
fit['ship']['href'] = "%stypes/%d/"%(eve._endpoint, ofit.ship.item.ID)
|
||||
fit['ship']['id'] = 0
|
||||
fit['ship']['href'] = "%stypes/%d/"%(eve._authed_endpoint, ofit.ship.item.ID)
|
||||
fit['ship']['id'] = ofit.ship.item.ID
|
||||
fit['ship']['name'] = ''
|
||||
|
||||
fit['description'] = "<pyfa:%d />"%ofit.ID
|
||||
@@ -78,21 +78,18 @@ class Port(object):
|
||||
# Order of subsystem matters based on this attr. See GH issue #130
|
||||
slot = int(module.getModifiedItemAttr("subSystemSlot"))
|
||||
item['flag'] = slot
|
||||
item['quantity'] = 1
|
||||
item['type']['href'] = "%stypes/%d/"%(eve._endpoint, module.item.ID)
|
||||
item['type']['id'] = 0
|
||||
item['type']['name'] = ''
|
||||
else:
|
||||
if not slot in slotNum:
|
||||
slotNum[slot] = INV_FLAGS[slot]
|
||||
|
||||
item['flag'] = slotNum[slot]
|
||||
item['quantity'] = 1
|
||||
item['type']['href'] = "%stypes/%d/"%(eve._endpoint, module.item.ID)
|
||||
item['type']['id'] = 0
|
||||
item['type']['name'] = ''
|
||||
|
||||
slotNum[slot] += 1
|
||||
|
||||
item['quantity'] = 1
|
||||
item['type']['href'] = "%stypes/%d/"%(eve._authed_endpoint, module.item.ID)
|
||||
item['type']['id'] = module.item.ID
|
||||
item['type']['name'] = ''
|
||||
|
||||
fit['items'].append(item)
|
||||
|
||||
return json.dumps(fit)
|
||||
|
||||
Reference in New Issue
Block a user