Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests and docs #1

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,5 @@ ENV/
# IDE settings
.vscode/
.idea/
.run/
/tests/fixtures/cassettes/*.yml
2 changes: 1 addition & 1 deletion AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Credits
Development Lead
----------------

* Anthony Correa <[email protected]>
* Anthony Correa <https://github.com/anthonyscorrea>

Contributors
------------
Expand Down
256 changes: 68 additions & 188 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,240 +1,120 @@
<div id="top"></div>

<!-- PROJECT SHIELDS -->
<!--
*** I'm using markdown "reference style" links for readability.
*** Reference links are enclosed in brackets [ ] instead of parentheses ( ).
*** See the bottom of this document for the declaration of the reference variables
*** for contributors-url, forks-url, etc. This is n optional, concise syntax you may use.
*** https://www.markdownguide.org/basic-syntax/#reference-style-links
-->
[![Contributors][contributors-shield]][contributors-url]
[![Forks][forks-shield]][forks-url]
[![Stargazers][stars-shield]][stars-url]
[![Issues][issues-shield]][issues-url]
[![LinkedIn][linkedin-shield]][linkedin-url]

<!-- PROJECT LOGO -->
<br />
<div style="text-align:center;">
<a href="https://github.com/anthonyscorrea/pyteamsnap">
<img src="https://www.teamsnap.com/images/logo.svg" alt="Logo" width="160" height="80">
</a>
==========
pyteamsnap
==========

<h3 style="text-align:center;">pyteamsnap</h3>

<p style="text-align:center;">
Unofficial TeamSnap API wrapper for python.
<br />
·
<a href="https://github.com/anthonyscorrea/pyteamsnap/issues">Report Bug</a>
·
<a href="https://github.com/anthonyscorrea/pyteamsnap/issues">Request Feature</a>
</p>
</div>
.. image:: media/pyteamsnap_logo.svg
:width: 75%
:align: center
:alt: TeamSnap Logo


An unofficial python wrapper for the `TeamSnap API <https://www.teamsnap.com/documentation/apiv3>`_. A work in progress.

<!-- TABLE OF CONTENTS -->
<details>
<summary>Table of Contents</summary>
<ol>
<li>
<a href="#about-the-project">About The Project</a>
<ul>
<li><a href="#built-with">Built With</a></li>
</ul>
</li>
<li>
<a href="#getting-started">Getting Started</a>
<ul>
<li><a href="#prerequisites">Prerequisites</a></li>
<li><a href="#installation">Installation</a></li>
</ul>
</li>
<li><a href="#usage">Usage</a></li>
<li><a href="#roadmap">Roadmap</a></li>
<li><a href="#contributing">Contributing</a></li>
<li><a href="#license">License</a></li>
<li><a href="#contact">Contact</a></li>
</ol>
</details>
Installation
------------

Install **pyteamsnap** from GitHub

.. code-block:: console

<!-- ABOUT THE PROJECT -->
## About The Project
$ pip install git+https://github.com/anthonyscorrea/pyteamsnap

An unoffical python wrapper for the [TeamSnap API](https://www.teamsnap.com/documentation/apiv3). A work in progress.
Getting Started
---------------

<p style="text-align:right;">(<a href="#top">back to top</a>)</p>
To connect to TeamSnap, get OAuth 2 Credentials from TeamSnap at `https://auth.teamsnap.com/ <https://auth.teamsnap.com/login>`_ (`TeamSnap Documentation <https://www.teamsnap.com/documentation/apiv3/authorization>`_)

.. code-block:: python

from pyteamsnap.client import TeamSnap
client = TeamSnap(token=TOKEN)

### Built With
You can use pyteamsnap constructors in pyteamsnap models to create instances.

* [api-client](https://github.com/MikeWooster/api-client)
* [collection-json](https://github.com/ricardokirkner/collection-json.python)

<p style="text-align:right;">(<a href="#top">back to top</a>)</p>
Getting the user object for the authenticated user.

.. code-block:: python

>>> from pyteamsnap.models import Me

<!-- GETTING STARTED -->
## Getting Started
>>> me = Me(client)

### Prerequisites
>>> me
TeamSnap<User:00000000> "FirstName LastName"

* [api-client](https://github.com/MikeWooster/api-client)
```shell
pip install api-client
```
* [collection-json](https://github.com/ricardokirkner/collection-json.python)
```shell
pip install json-collection
```
There is only one "Me" for a session, so no searching required.

### Installation
Information can be accessed using keys just like a dictionary. See `documentation <https://anthonyscorrea.github.io/pyteamsnap/>`_ for each models' ``data`` property for a list of available keys.

1. Get OAuth 2 Credentials from TeamSnap at [https://auth.teamsnap.com/](https://auth.teamsnap.com/login) ([TeamSnap Documentation](https://www.teamsnap.com/documentation/apiv3/authorization))
2. Install pyteamsnap
```shell
pip install git+https://github.com/anthonyscorrea/pyteamsnap
```
A few examples:

<p style="text-align:right;">(<a href="#top">back to top</a>)</p>
.. code-block:: python

<!-- USAGE EXAMPLES -->
## Usage Example
>>> managed_teams = me['managed_teams']

```python
from pyteamsnap.client import TeamSnap
from pyteamsnap.objects import Me, Event, EventLineupEntry, Member
client = TeamSnap(token=TOKEN)
>>> managed_teams
[TeamSnap<Team:00000000> "TeamName"]

# get authenticated user
me = Me(client)
>>> team = managed_teams[0]

# get a list of team_ids for the user
managed_team_ids = me.data['managed_teams']
>>> team['name']
TeamName

# get a list of events for managed team
managed_team_id = me.data['managed_teams'][0]
events = Event.search(client, team_id=managed_team_id)
Objects have a search function, where search criteria is passed as keyword arguments

# get an object with the object id of EVENT_ID
event = Event.get(client, id=EVENT_ID)
.. code-block:: python

# get some information about the event
start_date = event.data['start_date']
>>> from pyteamsnap.models import Event

# create a new member
member = Member.new(client)
member.data['first_name'] = 'Ferguson'
member.post()
>>> events = Event.search(client, team_id=team['id'])

# update a Member with id of MEMBER_ID
member = Member.get(client, id=MEMBER_ID)
member.data['last_name'] = 'Jenkins'
member.put()
>>> events
[Teamsnap<Event:00000000> "Event Title", TeamSnap<Event:00000001> "Event Title"]

# delete a Member
member.delete()
>>> event = events[0]

# perform a bulk load
list_of_ts_objects = client.bulk_load(team_id = TEAM_ID, types = [Event, Member], event__id=EVENT_ID)
```
>>> event['start_date']
datetime.datetime(2000, 1, 1, 12, 00, 00, 0)

Objects can be retrieved singularly with an id.

<p style="text-align:right;">(<a href="#top">back to top</a>)</p>
.. code-block:: python

>>> event = Event.get(client, 00000000)

<!-- ROADMAP -->
## Roadmap
>>> event
TeamSnap<Event:00000000> "Event Title"

Implemented objects
- [X] Me
- [X] User
- [X] Event
- [X] Team
- [X] Availability
- [X] Member
- [X] Location
- [X] Opponent
- [X] EventLineupEntry
- [X] EventLineup
- [X] AvailabilitySummary
Objects can be created, updated, and deleted (as permissions allow).

Implemented Queries
- [x] search
- [x] bulk_load
.. code-block:: python

Implemented Actions
- [x] create
- [x] read
- [x] update
- [x] destroy
>>> from pyteamsnap import Member

Implemented objects, but not tested.
- [ ] Statistics
- [ ] MemberStatistics
>>> new_member = Member.new(client)

See the [open issues](https://github.com/anthonyscorrea/pyteamsnap/issues) for a full list of proposed features (and known issues).
>>> new_member['first_name'] = 'Ferguson'

<p style="text-align:right;">(<a href="#top">back to top</a>)</p>
>>> new_member['last_name'] = 'Jenkins'

>>> member.post()
TeamSnap<Member:00000001> "Ferguson Jenkins"

>>> member['jersey_number'] = 31

<!-- CONTRIBUTING -->
## Contributing
>>> member.put()

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**.
>>> member.delete()

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement".
Don't forget to give the project a star! Thanks again!
To load a hetereogeneous list of objects given parameters, the ``bulk_load`` function can be used

1. Fork the Project
2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)
3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)
4. Push to the Branch (`git push origin feature/AmazingFeature`)
5. Open a Pull Request
.. code-block:: python

<p style="text-align:right;">(<a href="#top">back to top</a>)</p>
>> list_of_ts_objects = client.bulk_load(team_id = TEAM_ID, types = [Event, Member], event__id=00000001)
[TeamSnap<Event:00000001> "Event Title", TeamSnap<Member:00000000> "Ferguson Jenkins"]

Documentation
-------------


<!-- LICENSE -->
## License

Distributed under the MIT License. See `LICENSE.txt` for more information.

<p style="text-align:right;">(<a href="#top">back to top</a>)</p>



<!-- CONTACT -->
## Contact

Your Name - [@anthonyscorrea](https://twitter.com/anthonyscorrea) - [email protected]

Project Link: [https://github.com/anthonyscorrea/pyteamsnap](https://github.com/anthonyscorrea/pyteamsnap)

<p style="text-align:right;">(<a href="#top">back to top</a>)</p>



<!-- MARKDOWN LINKS & IMAGES -->
<!-- https://www.markdownguide.org/basic-syntax/#reference-style-links -->
[contributors-shield]: https://img.shields.io/github/contributors/anthonyscorrea/pyteamsnap.svg?style=for-the-badge
[contributors-url]: https://github.com/anthonyscorrea/pyteamsnap/graphs/contributors
[forks-shield]: https://img.shields.io/github/forks/anthonyscorrea/pyteamsnap.svg?style=for-the-badge
[forks-url]: https://github.com/anthonyscorrea/pyteamsnap/network/members
[stars-shield]: https://img.shields.io/github/stars/anthonyscorrea/pyteamsnap.svg?style=for-the-badge
[stars-url]: https://github.com/anthonyscorrea/pyteamsnap/stargazers
[issues-shield]: https://img.shields.io/github/issues/anthonyscorrea/pyteamsnap.svg?style=for-the-badge
[issues-url]: https://github.com/anthonyscorrea/pyteamsnap/issues
[license-shield]: https://img.shields.io/github/license/anthonyscorrea/pyteamsnap.svg?style=for-the-badge
[license-url]: https://github.com/anthonyscorrea/pyteamsnap/blob/master/LICENSE.txt
[linkedin-shield]: https://img.shields.io/badge/-LinkedIn-black.svg?style=for-the-badge&logo=linkedin&colorB=555
[linkedin-url]: https://linkedin.com/in/anthonyscorrea
[product-screenshot]: images/screenshot.png
`Documentation can be found here. <https://anthonyscorrea.github.io/pyteamsnap/>`_
4 changes: 4 additions & 0 deletions docs/.buildinfo
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Sphinx build info version 1
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
config: 569f3f44b228cbf3734211ac59aa07be
tags: 645f666f9bcd5a90fca523b33c5a78b7
16 changes: 10 additions & 6 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = python -msphinx
SPHINXPROJ = pyteamsnap
SOURCEDIR = .
BUILDDIR = _build
# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = source
BUILDDIR = build

# Put it first so that "make" without argument is like "make help".
help:
Expand All @@ -18,3 +18,7 @@ help:
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

github:
@make html
@cp -a $(BUILDDIR)/html/. ../docs
14 changes: 14 additions & 0 deletions docs/_sources/index.rst.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.. pyteamsnap documentation master file, created by
sphinx-quickstart on Sat Nov 5 11:06:19 2022.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.


.. include:: ../../README.rst

.. toctree::
:hidden:
:caption: Contents:
:maxdepth: 3

modules
7 changes: 7 additions & 0 deletions docs/_sources/modules.rst.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
pyteamsnap
==========

.. toctree::
:maxdepth: 3

pyteamsnap
10 changes: 10 additions & 0 deletions docs/_sources/pyteamsnap.models.rst.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
pyteamsnap.models package
=========================

Module contents
---------------

.. automodule:: pyteamsnap.models
:members:
:undoc-members:
:show-inheritance:
Loading