Metadata-Version: 2.2
Name: powerschool-adapter
Version: 1.0.1
Summary: A Python adapter for PowerSchool API integration
Home-page: https://github.com/tonylabs/python-powerschool-adapter
Author: TONYLABS TECH CO., LTD.
Author-email: "TONYLABS TECH CO., LTD." <tony.wang@tonylabs.com>
License: MIT
Project-URL: Homepage, https://github.com/tonylabs/python-powerschool-adapter
Project-URL: Repository, https://github.com/tonylabs/python-powerschool-adapter.git
Project-URL: Bug Tracker, https://github.com/tonylabs/python-powerschool-adapter/issues
Keywords: powerschool,education,api,adapter
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Education
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Topic :: Education
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: requests>=2.20.0
Requires-Dist: diskcache>=5.6.0
Provides-Extra: dev
Requires-Dist: python-dotenv>=1.0.1; extra == "dev"
Requires-Dist: faker>=33.3.1; extra == "dev"
Dynamic: author
Dynamic: home-page
Dynamic: requires-python

# PowerSchool Python Adapter

This package is to be used with alongside a PowerSchool plugin that has enabled <oauth/> in the plugin.xml. This guide assumes you have PowerSchool API and plugin knowledge and does not cover the details of a plugin or its API.

## Installation

```bash
pip install powerschool-adapter
```

## Configuration

You need to set some variables in `.env`.

```dotenv
POWERSCHOOL_SERVER_ADDRESS=
POWERSCHOOL_CLIENT_ID=
POWERSCHOOL_CLIENT_SECRET=
```

## API

#### `PowerSchool`

The PowerSchool token is automatically retrieved upon executing an API call.

```python
from dotenv import load_dotenv
from powerschool_adapter.powerschool import PowerSchool

load_dotenv()

SERVER_ADDRESS = os.getenv("POWERSCHOOL_SERVER_ADDRESS")
CLIENT_ID = os.getenv("POWERSCHOOL_CLIENT_ID")
CLIENT_SECRET = os.getenv("POWERSCHOOL_CLIENT_SECRET")

powerschool = PowerSchool(
	server_address=SERVER_ADDRESS,
	client_id=CLIENT_ID,
	client_secret=CLIENT_SECRET
)
```

#### `set_table(table)`

_Aliases: table()_

The set_table function is used to specify which database table should be queried.

```python
response = powerschool.table('students').projection(["DCID", "STUDENT_NUMBER", "LASTFIRST"]).set_method("GET").send()
student_data = json.loads(response.to_json())
print(json.dumps(student_data, indent=4))
```

#### `set_endpoint(query)`

_Aliases: to_endpoint(), to()_

```python
response = powerschool.set_endpoint("/ws/v1/student").set_id(1).get()
student_data = json.loads(response.to_json())
print(json.dumps(student_data, indent=4))
```

#### `get_endpoint()`

Return the current endpoint

#### `setId($id)`

_Aliases: for_id()_

```python
response = powerschool.to("/ws/v1/student").set_id(1).get()
student_data = json.loads(response.to_json())
print(json.dumps(student_data, indent=4))
```

### `extensions`

```python
response = powerschool.to('/ws/v1/student').set_id(52).expansions(['demographics', 'addresses', 'alerts', 'phones', 'school_enrollment', 'ethnicity_race', 'contact', 'contact_info', 'initial_enrollment']).get()
```

#### `q(expression)`

_Aliases: query_expression()_

Sets the `q` variable to the given FIQL expression.

```python
response = powerschool.set_endpoint("/ws/v1/student").q("name.last_name==Ada*").get()
student_data = json.loads(response.to_json())
print(json.dumps(student_data, indent=4))
```
