コード例 #1
0
    def get(self):
        self._validate_tba_app_id()
        team_key = self.request.get('team')
        year = self.request.get('year')

        response_json = {}

        try:
            response_json = ApiHelper.getTeamInfo(team_key)
            if self.request.get('events'):
                response_json = ApiHelper.addTeamEvents(response_json, year)

            # TODO: matches

            self.response.out.write(json.dumps(response_json))

            track_team_key = team_key
            if year:
                track_team_key = track_team_key + ' (' + year + ')'
            self._track_call_defer('teams/details', track_team_key)

        except IndexError:
            response_json = {"Property Error": "No team found for the key given"}
            self.response.set_status(404)
            self.response.out.write(json.dumps(response_json))
コード例 #2
0
 def get(self):
     team_key = self.request.get('team')
     year = self.request.get('year')
     
     team_dict = ApiHelper.getTeamInfo(team_key)
     if self.request.get('events'):
         team_dict = ApiHelper.addTeamEvents(team_dict, year)
     
     #TODO: matches
     
     self.response.out.write(simplejson.dumps(team_dict))
コード例 #3
0
    def get(self):
        self._validate_tba_app_id()
        value = self.request.get('match') or self.request.get('matches')
        matches = []
        if value is not '':
            match_keys = value.split(',')
            match_keys_sorted = sorted(value.split(','))
            track_matches_keys = ",".join(match_keys_sorted)
            track_matches = value
            for match_key in match_keys:
                if match_key == '':
                    continue
                mjson = ApiHelper.getMatchDetails(match_key)
                if mjson is not None:
                    matches.append(mjson)

        if matches != []:
            response = matches
        else:
            response = {"Property Error": "No matches found for any key given"}
            self.response.set_status(404)

        self.response.out.write(json.dumps(response))

        self._track_call_defer('matches/details', track_matches)
コード例 #4
0
    def get(self):
        if self.request.get('match') is not '':
            match_key = self.request.get('match')

        if self.request.get('matches') is not '':
            match_keys = self.request.get('matches').split(',')

        if 'match_keys' in locals():
            match_json = list()
            for match in match_keys:
                match_json.append(ApiHelper.getMatchDetails(match))
        else:
            match_json = ApiHelper.getMatchDetails(match_key)

        self.response.headers.add_header("content-type", "application/json")
        self.response.out.write(json.dumps(match_json))
コード例 #5
0
 def get(self):
     teams = list()
     team_keys = self.request.get('teams').split(',')
     
     for team_key in team_keys:
         teams.append(ApiHelper.getTeamInfo(team_key))
     
     self.response.out.write(simplejson.dumps(teams))
コード例 #6
0
 def check_rates_in_widget(self, from_currency, to_currency):
     current_buy_rate = self.get_current_buy_rate()
     current_sell_rate = self.get_current_sell_rate()
     expected_rates = ApiHelper().get_current_buy_and_sell_values_from_api(
         from_currency, to_currency)
     expected_rates[0] = str(expected_rates[0]).replace(".", ",")
     expected_rates[1] = str(expected_rates[1]).replace(".", ",")
     assert expected_rates == [current_buy_rate, current_sell_rate]
コード例 #7
0
    def get(self):

        team_key = self.request.get('team')
        year = self.request.get('year')

        response_json = dict()
        try:
            response_json = ApiHelper.getTeamInfo(team_key)
            if self.request.get('events'):
                reponse_json = ApiHelper.addTeamEvents(response_json, year)
            
            #TODO: matches
            
            self.response.out.write(json.dumps(response_json))

        except IndexError:
            response_json = { "Property Error": "No team found for the key given" }
            self.response.out.write(json.dumps(response_json))
コード例 #8
0
 def get(self):
     event_keys = set()
     
     if self.request.get("year"):
         events = Event.all().filter("year =", int(self.request.get("year"))).fetch(500)
         event_keys = event_keys.union(set([event.key().name() for event in events]))
         
     event_keys = filter(None, event_keys.union(set(self.request.get("events").split(','))))        
     events = [ApiHelper.getEventInfo(event_key) for event_key in event_keys]
     
     self.response.out.write(simplejson.dumps(events))
コード例 #9
0
    def get(self):
        event_key = str(self.request.get("event"))
        if event_key is "" or event_key is None:
            error_message = {"Parameter Error": "'event' is a required parameter."}
            self.response.out.write(json.dumps(error_message))
            return False

        

        event_dict = ApiHelper.getEventInfo(event_key)

        self.response.out.write(json.dumps(event_dict))
コード例 #10
0
    def convert_currency_by_api_rates(self, ammount, from_currency,
                                      to_currency):
        rates = ApiHelper().get_exchange_rate_from_api(from_currency,
                                                       to_currency)
        buy_rates = float(rates['buyValue'])
        sell_rates = float(rates['sellValue'])
        scale = int(rates['scale'])

        if from_currency == "RUB":
            return round(float(ammount) * scale / sell_rates, 2)
        else:
            return round(float(ammount) * scale * buy_rates, 2)
コード例 #11
0
    def get(self):
        self._validate_tba_app_id()
        event_key = str(self.request.get("event"))
        if event_key is "" or event_key is None:
            error_message = {"Parameter Error": "'event' is a required parameter."}
            self.response.out.write(json.dumps(error_message))
            return False

        event_dict = ApiHelper.getEventInfo(event_key)

        self.response.out.write(json.dumps(event_dict))

        self._track_call_defer('events/details', event_key)
コード例 #12
0
    def get(self):
        event_key = str(self.request.get("event"))
        if event_key is "" or event_key is None:
            error_message = {"Parameter Error": "'event' is a required parameter."}
            self.response.out.write(json.dumps(error_message))
            return False

        event_dict = ApiHelper.getEventInfo(event_key)

        self.response.headers.add_header("content-type", "application/json")
        self.response.out.write(json.dumps(event_dict))

        self._track_call('events/details', event_key)
コード例 #13
0
    def get(self):
        teams = []
        team_keys = self.request.get('teams').split(',')

        try:
            teams = [ApiHelper.getTeamInfo(team_key) for team_key in team_keys]
        except IndexError:
            self.response.set_status(404)
            response_json = {"Property Error": "No team found for key in %s" % str(teams)}

        self.response.out.write(json.dumps(teams))

        team_keys_sorted = sorted(team_keys)
        track_team_keys = ",".join(team_keys_sorted)
        self._track_call('teams/show', track_team_keys)
コード例 #14
0
    def setUpClass(cls):
        cls.maxDiff = None

        cls.gateAlreadyExists = ServiceAlreadyExists().message
        cls.notFound = NotFound().message
        cls.gateNameNotValid = ServiceNameNotValid().message
        cls.gateStateNotValid = GateStateNotValid().message
        cls.environmentNotFound = EnvironmentNotFound(
            "non_existing_environment").message
        cls.ticketNotFound = TicketNotFound().message
        cls.jsonStructureError = JsonStructureError().message

        cls.api_helper = ApiHelper(environment)  # TODO fix environment?
        cls.database_helper = DatabaseHelper(
            environment)  # TODO fix environment?
        cls.testdata_helper = TestDataHelper(cls.api_helper)

        cls.keys_develop_state = ['environments', 'develop', 'state']
コード例 #15
0
    def get(self):
        self._validate_user_agent()
        value = self.request.get('match') or self.request.get('matches')
        if value is not '':
            match_keys = value.split(',')
            match_keys_sorted = sorted(value.split(','))
            track_matches_keys = ",".join(match_keys_sorted)
            track_matches = value
            match_json = []
            for match in match_keys:
                match_json.append(ApiHelper.getMatchDetails(match))
        else:
            match_json = {'error': 'The "match" parameter is missing'}
            track_matches = 'error'

        self.response.out.write(json.dumps(match_json))

        self._track_call_defer('matches/details', track_matches)
コード例 #16
0
    def get(self):
        value = self.request.get('match') or self.request.get('matches')
        if value is not '':
            match_keys = value.split(',')
            match_keys_sorted = sorted(value.split(','))
            track_matches_keys = ",".join(match_keys_sorted)
            track_matches = value
            match_json = []
            for match in match_keys:
                match_json.append(ApiHelper.getMatchDetails(match))
        else:
            match_json = {'error': 'The "match" parameter is missing'}
            track_matches = 'error'

        self.response.headers.add_header("content-type", "application/json")
        self.response.out.write(json.dumps(match_json))

        self._track_call('matches/details', track_matches)
コード例 #17
0
    def get(self):
        self._validate_tba_app_id()
        teams = []
        team_keys = self.request.get('teams').split(',')

        for team_key in team_keys:
            try:
                team_info = ApiHelper.getTeamInfo(team_key)
                teams.append(team_info)
            except IndexError:
                pass

        if teams:
            response_json = teams
        else:
            response_json = {"Property Error": "No teams found for any key given"}
            self.response.set_status(404)

        self.response.out.write(json.dumps(response_json))

        team_keys_sorted = sorted(team_keys)
        track_team_keys = ",".join(team_keys_sorted)
        self._track_call_defer('teams/show', track_team_keys)