Files
pyteamsnap/docs/index.html

196 lines
13 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
<meta charset="utf-8" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>pyteamsnap &mdash; pyteamsnap 0.1 documentation</title>
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
<!--[if lt IE 9]>
<script src="_static/js/html5shiv.min.js"></script>
<![endif]-->
<script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script>
<script src="_static/jquery.js"></script>
<script src="_static/underscore.js"></script>
<script src="_static/_sphinx_javascript_frameworks_compat.js"></script>
<script src="_static/doctools.js"></script>
<script src="_static/sphinx_highlight.js"></script>
<script src="_static/js/theme.js"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="pyteamsnap" href="modules.html" />
</head>
<body class="wy-body-for-nav">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search" >
<a href="#" class="icon icon-home"> pyteamsnap
</a>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
<p class="caption" role="heading"><span class="caption-text">Contents:</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="modules.html">pyteamsnap</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="#">pyteamsnap</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="Page navigation">
<ul class="wy-breadcrumbs">
<li><a href="#" class="icon icon-home"></a></li>
<li class="breadcrumb-item active">pyteamsnap</li>
<li class="wy-breadcrumbs-aside">
<a href="_sources/index.rst.txt" rel="nofollow"> View page source</a>
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<section id="pyteamsnap">
<h1>pyteamsnap<a class="headerlink" href="#pyteamsnap" title="Permalink to this heading"></a></h1>
<a class="reference internal image-reference" href="media/pyteamsnap_logo.svg"><img alt="TeamSnap Logo" class="align-center" src="media/pyteamsnap_logo.svg" width="75%" /></a>
<p>An unofficial python wrapper for the <a class="reference external" href="https://www.teamsnap.com/documentation/apiv3">TeamSnap API</a>. A work in progress.</p>
<section id="installation">
<h2>Installation<a class="headerlink" href="#installation" title="Permalink to this heading"></a></h2>
<p>Install <strong>pyteamsnap</strong> from GitHub</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>pip install git+https://github.com/anthonyscorrea/pyteamsnap
</pre></div>
</div>
</section>
<section id="getting-started">
<h2>Getting Started<a class="headerlink" href="#getting-started" title="Permalink to this heading"></a></h2>
<p>To connect to TeamSnap, get OAuth 2 Credentials from TeamSnap at <a class="reference external" href="https://auth.teamsnap.com/login">https://auth.teamsnap.com/</a> (<a class="reference external" href="https://www.teamsnap.com/documentation/apiv3/authorization">TeamSnap Documentation</a>)</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">pyteamsnap.client</span> <span class="kn">import</span> <span class="n">TeamSnap</span>
<span class="n">client</span> <span class="o">=</span> <span class="n">TeamSnap</span><span class="p">(</span><span class="n">token</span><span class="o">=</span><span class="n">TOKEN</span><span class="p">)</span>
</pre></div>
</div>
<p>You can use pyteamsnap constructors in pyteamsnap models to create instances.</p>
<p>Getting the user object for the authenticated user.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">pyteamsnap.models</span> <span class="kn">import</span> <span class="n">Me</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">me</span> <span class="o">=</span> <span class="n">Me</span><span class="p">(</span><span class="n">client</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">me</span>
<span class="go">TeamSnap&lt;User:00000000&gt; &quot;FirstName LastName&quot;</span>
</pre></div>
</div>
<p>There is only one “Me” for a session, so no searching required.</p>
<p>Information can be accessed using keys just like a dictionary. See <a class="reference external" href="https://anthonyscorrea.github.io/pyteamsnap/">documentation</a> for each models <code class="docutils literal notranslate"><span class="pre">data</span></code> property for a list of available keys.</p>
<p>A few examples:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">managed_teams</span> <span class="o">=</span> <span class="n">me</span><span class="p">[</span><span class="s1">&#39;managed_teams&#39;</span><span class="p">]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">managed_teams</span>
<span class="go">[TeamSnap&lt;Team:00000000&gt; &quot;TeamName&quot;]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">team</span> <span class="o">=</span> <span class="n">managed_teams</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">team</span><span class="p">[</span><span class="s1">&#39;name&#39;</span><span class="p">]</span>
<span class="go">TeamName</span>
</pre></div>
</div>
<p>Objects have a search function, where search criteria is passed as keyword arguments</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">pyteamsnap.models</span> <span class="kn">import</span> <span class="n">Event</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">events</span> <span class="o">=</span> <span class="n">Event</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">client</span><span class="p">,</span> <span class="n">team_id</span><span class="o">=</span><span class="n">team</span><span class="p">[</span><span class="s1">&#39;id&#39;</span><span class="p">])</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">events</span>
<span class="go">[Teamsnap&lt;Event:00000000&gt; &quot;Event Title&quot;, TeamSnap&lt;Event:00000001&gt; &quot;Event Title&quot;]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">event</span> <span class="o">=</span> <span class="n">events</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">event</span><span class="p">[</span><span class="s1">&#39;start_date&#39;</span><span class="p">]</span>
<span class="go">datetime.datetime(2000, 1, 1, 12, 00, 00, 0)</span>
</pre></div>
</div>
<p>Objects can be retrieved singularly with an id.</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">event</span> <span class="o">=</span> <span class="n">Event</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">client</span><span class="p">,</span> <span class="mi">00000000</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">event</span>
<span class="go">TeamSnap&lt;Event:00000000&gt; &quot;Event Title&quot;</span>
</pre></div>
</div>
<p>Objects can be created, updated, and deleted (as permissions allow).</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">pyteamsnap</span> <span class="kn">import</span> <span class="n">Member</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">new_member</span> <span class="o">=</span> <span class="n">Member</span><span class="o">.</span><span class="n">new</span><span class="p">(</span><span class="n">client</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">new_member</span><span class="p">[</span><span class="s1">&#39;first_name&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="s1">&#39;Ferguson&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">new_member</span><span class="p">[</span><span class="s1">&#39;last_name&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="s1">&#39;Jenkins&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">member</span><span class="o">.</span><span class="n">post</span><span class="p">()</span>
<span class="go">TeamSnap&lt;Member:00000001&gt; &quot;Ferguson Jenkins&quot;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">member</span><span class="p">[</span><span class="s1">&#39;jersey_number&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="mi">31</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">member</span><span class="o">.</span><span class="n">put</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">member</span><span class="o">.</span><span class="n">delete</span><span class="p">()</span>
</pre></div>
</div>
<p>To load a hetereogeneous list of objects given parameters, the <code class="docutils literal notranslate"><span class="pre">bulk_load</span></code> function can be used</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="o">&gt;&gt;</span> <span class="n">list_of_ts_objects</span> <span class="o">=</span> <span class="n">client</span><span class="o">.</span><span class="n">bulk_load</span><span class="p">(</span><span class="n">team_id</span> <span class="o">=</span> <span class="n">TEAM_ID</span><span class="p">,</span> <span class="n">types</span> <span class="o">=</span> <span class="p">[</span><span class="n">Event</span><span class="p">,</span> <span class="n">Member</span><span class="p">],</span> <span class="n">event__id</span><span class="o">=</span><span class="mi">00000001</span><span class="p">)</span>
<span class="p">[</span><span class="n">TeamSnap</span><span class="o">&lt;</span><span class="n">Event</span><span class="p">:</span><span class="mi">00000001</span><span class="o">&gt;</span> <span class="s2">&quot;Event Title&quot;</span><span class="p">,</span> <span class="n">TeamSnap</span><span class="o">&lt;</span><span class="n">Member</span><span class="p">:</span><span class="mi">00000000</span><span class="o">&gt;</span> <span class="s2">&quot;Ferguson Jenkins&quot;</span><span class="p">]</span>
</pre></div>
</div>
</section>
<section id="id1">
<h2>Documentation<a class="headerlink" href="#id1" title="Permalink to this heading"></a></h2>
<p><a class="reference external" href="https://anthonyscorrea.github.io/pyteamsnap/">Documentation can be found here.</a></p>
<div class="toctree-wrapper compound">
</div>
</section>
</section>
</div>
</div>
<footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
<a href="modules.html" class="btn btn-neutral float-right" title="pyteamsnap" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
</div>
<hr/>
<div role="contentinfo">
<p>&#169; Copyright 2022, Anthony Correa.</p>
</div>
Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
<a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script>
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>
</body>
</html>