Skip to content

Commit 830d886

Browse files
author
Christopher Bradshaw
committed
Merge pull request Clever#37 from newsela/master
Adds bindings for DistrictAdmin and SchoolAdmin.
2 parents be045e8 + 2a70b34 commit 830d886

File tree

5 files changed

+38
-4
lines changed

5 files changed

+38
-4
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 2.2.0 (2016-02-03)
2+
* Added bindings for DistrictAdmin and SchoolAdmin resources. [#37](https://github.com/Clever/clever-python/pull/37)
3+
14
## 2.1.1 (2015-02-05)
25
* Pagination using starting_after and ending_before parameters. [#33](https://github.com/Clever/clever-python/pull/33)
36

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ Get started by importing the `clever` module and setting your authentication met
3434
The `clever` module exposes classes corresponding to resources:
3535

3636
* District
37+
* DistrictAdmin
3738
* School
39+
* SchoolAdmin
3840
* Section
3941
* Student
4042
* Teacher

bin/clever

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,15 @@ class DeletableAPIResourceClient(APIResourceClient):
103103
class DistrictClient(ListableAPIResourceClient):
104104
client_for = clever.District
105105

106+
class DistrictAdminClient(ListableAPIResourceClient):
107+
client_for = clever.DistrictAdmin
108+
106109
class SchoolClient(ListableAPIResourceClient):
107110
client_for = clever.School
108111

112+
class SchoolAdminClient(ListableAPIResourceClient):
113+
client_for = clever.SchoolAdmin
114+
109115
class SectionClient(ListableAPIResourceClient):
110116
client_for = clever.Section
111117

@@ -121,11 +127,13 @@ class EventClient(ListableAPIResourceClient):
121127
def main():
122128
klasses = {
123129
'district' : DistrictClient,
130+
'district_admin' : DistrictAdminClient,
124131
'school' : SchoolClient,
132+
'school_admin': SchoolAdminClient,
125133
'section' : SectionClient,
126134
'student' : StudentClient,
127135
'teacher' : TeacherClient,
128-
'event' : EventClient
136+
'event' : EventClient,
129137
}
130138
klasses_plural = { '{0}s'.format(key) : value for key, value in klasses.iteritems() }
131139
klasses = dict(klasses.items() + klasses_plural.items())
@@ -137,10 +145,18 @@ district
137145
all
138146
retrieve
139147
148+
district_admin
149+
all
150+
retrieve
151+
140152
school
141153
all
142154
retrieve
143155
156+
school_admin
157+
all
158+
retrieve
159+
144160
section
145161
all
146162
retrieve

clever/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.1.1
1+
2.2.0

clever/__init__.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181

8282
# Use certs chain bundle including in the package for SSL verification
8383
CLEVER_CERTS = pkg_resources.resource_filename(__name__, 'data/clever.com_ca_bundle.crt')
84+
API_VERSION = "v1.1"
8485

8586
# Configuration variables
8687

@@ -266,7 +267,7 @@ def request_raw(self, meth, url, params={}):
266267

267268
headers = {
268269
'X-Clever-Client-User-Agent': json.dumps(ua),
269-
'User-Agent': 'Clever/v1.1 PythonBindings/%s' % (VERSION, )
270+
'User-Agent': 'Clever/%s PythonBindings/%s' % (API_VERSION, VERSION)
270271
}
271272
if my_auth.get('api_key', None) != None:
272273
headers['Authorization'] = 'Basic {}'.format(base64.b64encode(my_auth['api_key'] + ':'))
@@ -679,7 +680,7 @@ def class_name(cls):
679680
@classmethod
680681
def class_url(cls):
681682
cls_name = cls.class_name()
682-
return "/v1.1/%ss" % cls_name
683+
return "/%s/%ss" % (API_VERSION, cls_name)
683684

684685
def instance_url(self):
685686
id = self.get('id')
@@ -774,10 +775,22 @@ class District(ListableAPIResource):
774775
pass
775776

776777

778+
class DistrictAdmin(ListableAPIResource):
779+
@classmethod
780+
def class_url(cls):
781+
return "/%s/district_admins" % API_VERSION
782+
783+
777784
class School(ListableAPIResource):
778785
pass
779786

780787

788+
class SchoolAdmin(ListableAPIResource):
789+
@classmethod
790+
def class_url(cls):
791+
return "/%s/school_admins" % API_VERSION
792+
793+
781794
class Section(ListableAPIResource):
782795
pass
783796

0 commit comments

Comments
 (0)