Exemple #1
0
class Event:
    def __init__(self):
        self.eventbrite = Eventbrite(settings.EVENTBRITE_API_KEY)

    def get(self, events_id):
        """
        Given an eventbrite ID, returns the event object

        :param events_id:
        :return:
        """

        data = self.eventbrite.get_event(events_id)
        if data.status_code == 200:
            return data
        else:
            return None

    def get_multiple(self, category_ids, page_number):
        """
        Given a set of categories, returns relevant events
        :param category_ids:
        :param page_number:
        :return:
        """

        data = self.eventbrite.event_search(**{"page": page_number, "categories": category_ids})
        if data.status_code == 200:
            return data
        else:
            return None
Exemple #2
0
    def event(self):
        eventbrite = Eventbrite(eventtoken)
        event = eventbrite.get_event('user_event_id')
        print (event.pretty)
        print (event.url)
        print (event.start)

        return event

#autogenrate event model fields from api request




        def save(self, commit=True):
            event = super().save(commit=False)
            event_start = event.start
            event_url = event.url




        if commit:
            event.save()
        return page
class TestClientAccessMethods(unittest.TestCase):

    def setUp(self):
        self.eventbrite = Eventbrite(OAUTH_TOKEN)

    @unittest.skipIf(
        condition=skip_integration_tests,
        reason='Needs an OAUTH_TOKEN')
    def test_get_user_me(self):
        evbobject = self.eventbrite.get_user()

        # Did we get an EventbriteObject?
        self.assertTrue(isinstance(evbobject, EventbriteObject))

        # check attributes
        attrs = ['id', 'pk', 'type', 'is_paginated', 'is_list', 'status_code']
        for attribute in attrs:
            self.assertTrue(attribute in evbobject.__dict__.keys())

        # check that an ID exists
        self.assertTrue(evbobject.get('id'))

    @unittest.skipIf(
        condition=skip_user_id_tests, reason='Needs a USER_ID')
    @unittest.skipIf(
        condition=skip_integration_tests, reason='Needs an OAUTH_TOKEN')
    def test_get_user(self):
        evbobject = self.eventbrite.get_user(USER_ID)

        # Did we get an EventbriteObject?
        self.assertTrue(isinstance(evbobject, EventbriteObject))

        # check attributes
        attrs = ['id', 'pk', 'type', 'is_paginated', 'is_list', 'status_code']
        for attribute in attrs:
            self.assertTrue(attribute in evbobject.__dict__.keys())

        # check that the ID's match
        self.assertEqual(evbobject.get('id'), USER_ID)

    @unittest.skipIf(
        condition=skip_integration_tests, reason='Needs an OAUTH_TOKEN')
    def test_webhook_no_internet(self):
        webhook = {
            "api_url": EVENTBRITE_API_URL + 'users/me/',
            "config": {
                "endpoint_url": "https://myawesomeapp.com/webhook",
                "insecure_ssl": "0"
            }
        }
        evbobject = self.eventbrite.webhook_to_object(webhook)
        self.assertTrue('id' in evbobject)

    @unittest.skipIf(
        condition=skip_user_id_tests, reason='Needs a USER_ID')
    @unittest.skipIf(
        condition=skip_integration_tests, reason='Needs an OAUTH_TOKEN')
    def test_get_event_expansions(self):
        # Get event with no expansions
        evbobject = self.eventbrite.get_event('11260994939')
        self.assertFalse('ticket_classes' in evbobject)

        # Now get event with ticket_classes expansion
        evbobject = self.eventbrite.get_event(
            '11260994939', expand='ticket_classes')
        self.assertTrue('ticket_classes' in evbobject)
        uClient.close()

        # parses the info
        page_soup = soup(page_html, "html.parser")

        # retrieve events from page
        events = page_soup.findAll("article",
                                   {"class": "eds-event-card-content--mini"})
        for event in events:

            ### URL ###
            eUrl = event.find(
                "a", {"class": "eds-event-card-content__action-link"})["href"]
            eID = eUrl.split("-")
            eID = [s.split("?") for s in eID if "?" in s][0][0]
            eData = eb.get_event(eID)
            print(eData)
            eTitle = eData.name
            print(eTitle)
            # print(f"api title: {eData.name.text}")
            ### TITLE ###
            title = event.find(
                "div", {
                    "class": "eds-event-card__formatted-name--is-clamped"
                }).text
            # make sure event is not postponed or cancelled
            lTitle = title.lower()
            if lTitle.find("postponed") != -1 or lTitle.find(
                    "cancelled") != -1:
                continue
            print(f"scrape title: {lTitle}")
Exemple #5
0
def get_event(user, id):
    social_user = user.social_auth.filter(provider='eventbrite')[0]
    eb = Eventbrite(social_user.access_token)
    event = eb.get_event(id)
    return event
Exemple #6
0
 def get_event(self, event_id):
     eventbrite = Eventbrite(
         self.request.user.social_auth.all()[0].access_token)
     event = eventbrite.get_event(event_id)
     return event
class TestClientAccessMethods(unittest.TestCase):

    def setUp(self):
        self.eventbrite = Eventbrite(OAUTH_TOKEN)

    @unittest.skipIf(
        condition=skip_integration_tests,
        reason='Needs an OAUTH_TOKEN')
    def test_get_user_me(self):
        evbobject = self.eventbrite.get_user()

        # Did we get an EventbriteObject?
        self.assertTrue(isinstance(evbobject, EventbriteObject))

        # check attributes
        attrs = ['id', 'pk', 'type', 'is_paginated', 'is_list', 'status_code']
        for attribute in attrs:
            self.assertTrue(attribute in evbobject.__dict__.keys())

        # check that an ID exists
        self.assertTrue(evbobject.get('id'))

    @unittest.skipIf(
        condition=skip_user_id_tests, reason='Needs a USER_ID')
    @unittest.skipIf(
        condition=skip_integration_tests, reason='Needs an OAUTH_TOKEN')
    def test_get_user(self):
        evbobject = self.eventbrite.get_user(USER_ID)

        # Did we get an EventbriteObject?
        self.assertTrue(isinstance(evbobject, EventbriteObject))

        # check attributes
        attrs = ['id', 'pk', 'type', 'is_paginated', 'is_list', 'status_code']
        for attribute in attrs:
            self.assertTrue(attribute in evbobject.__dict__.keys())

        # check that the ID's match
        self.assertEqual(evbobject.get('id'), USER_ID)

    @unittest.skipIf(
        condition=skip_integration_tests, reason='Needs an OAUTH_TOKEN')
    def test_webhook_no_internet(self):
        webhook = {
            "api_url": EVENTBRITE_API_URL + 'users/me/',
            "config": {
                "endpoint_url": "https://myawesomeapp.com/webhook",
                "insecure_ssl": "0"
            }
        }
        evbobject = self.eventbrite.webhook_to_object(webhook)
        self.assertTrue('id' in evbobject)

    @unittest.skipIf(
        condition=skip_user_id_tests, reason='Needs a USER_ID')
    @unittest.skipIf(
        condition=skip_integration_tests, reason='Needs an OAUTH_TOKEN')
    def test_get_event_expansions(self):
        # Get event with no expansions
        evbobject = self.eventbrite.get_event('11260994939')
        self.assertFalse('ticket_classes' in evbobject)

        # Now get event with ticket_classes expansion
        evbobject = self.eventbrite.get_event(
            '11260994939', expand='ticket_classes')
        self.assertTrue('ticket_classes' in evbobject)
Exemple #8
0
#TEST_RESP = {u'prices': [, {u'localized_display_name': u'UberXL', u'distance': 36.64, u'display_name': u'UberXL', u'product_id': u'6a99c87c-081e-432b-980b-366ba2035840', u'high_estimate': 87.0, u'low_estimate': 70.0, u'duration': 2700, u'estimate': u'$70-87', u'currency_code': u'USD'}]}
TEST_RESP = {
    u'localized_display_name': u'UberX',
    u'distance': 36.64,
    u'display_name': u'UberX',
    u'product_id': u'6a46fe24-9fbb-4ec9-a579-a0bd04d74b43',
    u'high_estimate': 56.0,
    u'low_estimate': 45.0,
    u'duration': 2700,
    u'estimate': u'$45-56',
    u'currency_code': u'USD'
}
eventbrite = Eventbrite(EVENTBRITE_AUTH)

g = eventbrite.get_event("51297785056")
'''for val in g.keys():
	print("{} - {}".format(val, g[val]))

'''


def get_price(start_lat, start_long, end_lat, end_long):
    try:
        if len(end_long) > 25:
            end_long = '-82.30639559999997'
        if len(end_lat) > 25:
            end_lat = '34.9704971'
        params = (
            ('start_latitude', start_lat),
            ('start_longitude', start_long),