Coder Social home page Coder Social logo

timetree-sdk's Introduction

TimeTree SDK for Python

TimeTree API SDK for Python.

Installing

$ pip install tooniez-timetree-sdk

Usage

from timetree_sdk import TimeTreeApi

api = TimeTreeApi('API_ACCESS_TOKEN')
calendar = api.get_calendar('CALENDAR_ID')
print(calendar.data.attributes.name) # calendar name

API

Oauth

get oauth authorize url

oauth_authorize_url = TimeTreeApi.get_oauth_authorize_url('CLIENT_ID', 'REDIRECT_URI', 'RESPONSE_TYPE', 'STATE')

User

get current user

user = api.get_current_user()
print(user.data.attributes.name) # user name

Calendar

get calendars

calendars = api.get_calendars()
print(calendars.data[0].attributes.name) # first calendar name

get calendar

calendar = api.get_calendar('CALENDAR_ID')
print(calendar.data.attributes.name) # calendar name

get calendar labels

labels = api.get_calendar_labels('CALENDAR_ID')
print(labels.data[0].attributes.name) # first calendar's label name

get calendar members

members = api.get_calendar_members('CALENDAR_ID')
print(members.data[0].attributes.name) # first calendar's member name

Event

get event

event = api.get_event('CALENDAR_ID', 'EVENT_ID')
print(event.data.attributes.title) # event title

get upcoming events

events = api.get_upcoming_events('CALENDAR_ID', 'Asia/Tokyo', 7)
print(events.data[0].attributes.title) # most recent event title in 7 days

create event

event = Event(
    data=EventData(
        attributes=EventAttributes(
            title='Title',
            category='schedule',
            all_day=False,
            start_at='2020-04-04T11:00:00.000Z',
            end_at='2020-04-04T13:00:00.000Z',
            description='Description',
            location='Location',
            start_timezone='Japan',
            end_timezone='Japan'
        ),
        relationships=EventRelationships(
            label=EventRelationshipsLabel(
                data=EventRelationshipsLabelData(
                    id='LABEL_ID',
                    type='label'
                )
            ),
            attendees=EventRelationshipsAttendees(
                data=[EventRelationshipsAttendeesData(
                    id='USER_ID',
                    type='user'
                )]
            )
        )
    )
)
response = api.create_event('CALENDAR_ID', event)
print(response.data.attributes.title) # Title

update event

event = Event(
    data=EventData(
        attributes=EventAttributes(
            title='Updated Title',
            category='schedule',
            all_day=False,
            start_at='2020-04-04T11:30:00.000Z',
            end_at='2020-04-04T13:30:00.000Z',
            description='Description',
            location='Location',
            start_timezone='Japan',
            end_timezone='Japan'
        ),
        relationships=EventRelationships(
            label=EventRelationshipsLabel(
                data=EventRelationshipsLabelData(
                    id='LABEL_ID',
                    type='label'
                )
            ),
            attendees=EventRelationshipsAttendees(
                data=[EventRelationshipsAttendeesData(
                    id='USER_ID',
                    type='user'
                )]
            )
        )
    )
)
response = api.create_event('CALENDAR_ID', 'EVENT_ID', event)
print(response.data.attributes.title) # Updated Title

delete event

status_code = api.delete_event('CALENDAR_ID', 'EVENT_ID')
print(status_code) # 204 on success

Event Comment

create comment to event

comment = EventComment(
    data=EventCommentData(
        attributes=EventCommentAttributes(
            content='Hello, world'
        )
    )
)
event_comment = api.create_event_comment('CALENDAR_ID', 'EVENT_ID', comment)
print(event_comment.data.attributes.content) # Hello, world

Documentation

Official API documentation

English: https://developers.timetreeapp.com/en/docs/api

Japanese: https://developers.timetreeapp.com/ja/docs/api

timetree-sdk's People

Contributors

tooniez avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.