@@ -5,7 +5,6 @@ import os
55import re
66import subprocess
77import sys
8- import base64
98
109sys .path .insert (0 , os .path .join (os .path .dirname (__file__ ), '..' ))
1110import clever
@@ -46,9 +45,9 @@ class APIResourceClient(object):
4645 term = ' \\ '
4746 else :
4847 term = ''
49- api_key = clever .get_api_key ()
48+ api_token = clever .get_token ()
5049 curl = ['curl %s%s -H "Authorization: Basic %s"%s' %
51- (clever .api_base , url , base64 . b64encode ( api_key ) , term )]
50+ (clever .api_base , url , api_token , term )]
5251 if isinstance (ordered_params , list ):
5352 for i , (k , v ) in enumerate (ordered_params ):
5453 if i == len (ordered_params ) - 1 :
@@ -124,6 +123,9 @@ class TeacherClient(ListableAPIResourceClient):
124123class EventClient (ListableAPIResourceClient ):
125124 client_for = clever .Event
126125
126+ class ContactClient (ListableAPIResourceClient ):
127+ client_for = clever .Contact
128+
127129def main ():
128130 klasses = {
129131 'district' : DistrictClient ,
@@ -134,6 +136,7 @@ def main():
134136 'student' : StudentClient ,
135137 'teacher' : TeacherClient ,
136138 'event' : EventClient ,
139+ 'contact' : ContactClient ,
137140 }
138141 klasses_plural = { '{0}s' .format (key ) : value for key , value in klasses .iteritems () }
139142 klasses = dict (klasses .items () + klasses_plural .items ())
@@ -170,11 +173,15 @@ teacher
170173 retrieve
171174
172175event
176+ all
177+ retrieve
178+
179+ contact
173180 all
174181 retrieve""" )
175182 parser .add_option ('-v' , '--verbosity' , help = 'Verbosity of debugging output.' ,
176183 dest = 'verbosity' , action = 'count' , default = 0 )
177- parser .add_option ('-k ' , '--api-key ' , help = "API key . Defaults to value of environment variable CLEVER_API_KEY " , dest = 'api_key ' )
184+ parser .add_option ('-t ' , '--api-token ' , help = "API token . Defaults to value of environment variable CLEVER_API_TOKEN " , dest = 'api_token ' )
178185 parser .add_option ('-b' , '--api-base' , help = 'API base URL' , dest = 'api_base' )
179186 parser .add_option ('-i' , '--id' , help = "Object ID" , dest = 'id' )
180187 opts , args = parser .parse_args ()
@@ -188,11 +195,11 @@ event
188195
189196 klass_name = args [0 ]
190197 method_name = args [1 ]
191- api_key = opts .api_key or os .environ .get ('CLEVER_API_KEY ' )
192- if not api_key :
193- parser .error ('No API key provided (use -k option or set the CLEVER_API_KEY environment variable' )
198+ api_token = opts .api_token or os .environ .get ('CLEVER_API_TOKEN ' )
199+ if not api_token :
200+ parser .error ('No API token provided (use -t option or set the CLEVER_API_TOKEN environment variable' )
194201 return 1
195- clever .set_api_key ( api_key )
202+ clever .set_token ( api_token )
196203
197204 if opts .api_base :
198205 clever .api_base = opts .api_base
0 commit comments