Skip to content

Commit

Permalink
pinEvents only on first result (page==0)
Browse files Browse the repository at this point in the history
  • Loading branch information
oczkers committed Oct 12, 2017
1 parent b0bab44 commit 056d5e1
Showing 1 changed file with 25 additions and 16 deletions.
41 changes: 25 additions & 16 deletions fut/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ def __login__(self, email, passwd, secret_answer, platform='pc', code=None, totp
else:
raise FutError(reason='Invalid emulate parameter. (Valid ones are and/ios).') # pc/ps3/xbox/
self.sku = sku # TODO: use self.sku in all class
self.sku_a = 'F18'
self.sku_a = 'FFT18'
params = {'prompt': 'login',
'accessToken': 'null',
'client_id': client_id,
Expand Down Expand Up @@ -536,7 +536,7 @@ def __login__(self, email, passwd, secret_answer, platform='pc', code=None, totp
if self._usermassinfo['settings']['configs'][2]['value'] == 0:
raise FutError(reason='Transfer market is probably disabled on this account.') # if tradingEnabled = 0

# pinEvent - boot_end
# pinEvents - boot_end
events = [self.pin.event('connection'),
self.pin.event('boot_end', end_reason='normal')]
self.pin.send(events)
Expand All @@ -548,7 +548,7 @@ def __login__(self, email, passwd, secret_answer, platform='pc', code=None, totp

self.saveSession()

# pinEvent - home screen
# pinEvents - home screen
events = [self.pin.event('page_view', 'Hub - Home')]
self.pin.send(events)

Expand All @@ -565,7 +565,6 @@ def __request__(self, method, url, data={}, params={}):
:params method: Rest method.
:params url: Url.
"""
# !!!! TODO !!!: add pinEvents
# TODO: update credtis?
url = 'https://%s/ut/game/fifa18/%s' % (self.fut_host, url)

Expand Down Expand Up @@ -790,7 +789,7 @@ def searchAuctions(self, ctype, level=None, category=None, assetId=None, defId=N
method = 'GET'
url = 'transfermarket'

# pinEvent - Transfer Market Search
# pinEvents
if start == 0:
events = [self.pin.event('page_view', 'Transfer Market Search')]
self.pin.send(events)
Expand Down Expand Up @@ -826,7 +825,7 @@ def searchAuctions(self, ctype, level=None, category=None, assetId=None, defId=N

rc = self.__request__(method, url, params=params)

# pinEvents - Transfer Market Results - List View
# pinEvents
if start == 0:
events = [self.pin.event('page_view', 'Transfer Market Results - List View')]
self.pin.send(events)
Expand All @@ -848,7 +847,7 @@ def bid(self, trade_id, bid, fast=False):
if rc['currentBid'] > bid or self.credits < bid:
return False # TODO: add exceptions
data = {'bid': bid}
rc = self.__request__(method, url, data=json.dumps(data), params={'sku_a': 'FFT18'})['auctionInfo'][0]
rc = self.__request__(method, url, data=json.dumps(data), params={'sku_a': self.sku_a})['auctionInfo'][0]
if rc['bidState'] == 'highest' or (rc['tradeState'] == 'closed' and rc['bidState'] == 'buyNow'): # checking 'tradeState' is required?
return True
else:
Expand All @@ -863,14 +862,15 @@ def club(self, sort='desc', ctype='player', defId='', start=0, count=91):
rc = self.__request__(method, url, params=params)

# pinEvent
if ctype == 'player':
pgid = 'Club - Players - List View'
elif ctype == 'item':
pgid = 'Club - Club Items - List View'
else: # TODO: THIS IS WRONG, detect all ctypes
pgid = 'Club - Club Items - List View'
events = [self.pin.event('page_view', pgid)]
self.pin.send(events)
if start == 0:
if ctype == 'player':
pgid = 'Club - Players - List View'
elif ctype == 'item':
pgid = 'Club - Club Items - List View'
else: # TODO: THIS IS WRONG, detect all ctypes
pgid = 'Club - Club Items - List View'
events = [self.pin.event('page_view', pgid)]
self.pin.send(events)

return [itemParse({'itemData': i}) for i in rc['itemData']]

Expand Down Expand Up @@ -912,8 +912,17 @@ def squad(self, squad_id=0, persona_id=None):
method = 'GET'
url = 'quad/%s/user/%s' % (squad_id, persona_id or self.persona_id)

# pinEvents
events = [self.pin.event('page_view', 'Hub - Squads')]
self.pin.send(events)

# TODO: ability to return other info than players only
rc = self.__request__(method, url)

# pinEvents
events = [self.pin.event('page_view', 'Squads - Squad Overview')]
self.pin.send(events)

return [itemParse(i) for i in rc.get('players', ())]

'''
Expand Down Expand Up @@ -990,7 +999,7 @@ def sell(self, item_id, bid, buy_now=10000, duration=3600):

# TODO: auto send to tradepile
data = {'buyNowPrice': buy_now, 'startingBid': bid, 'duration': duration, 'itemData': {'id': item_id}}
rc = self.__request__(method, url, data=json.dumps(data))
rc = self.__request__(method, url, data=json.dumps(data), params='sku_a': self.sku_a)
return rc['id']

def quickSell(self, item_id):
Expand Down

0 comments on commit 056d5e1

Please sign in to comment.