@@ -245,80 +245,78 @@ def fill_with_data(self, data):
245245
246246 return self
247247
248- def find (self , customer_id , token_id , options = {}):
249- """Find a customer's token by its ID .
248+ def fetch_customer_tokens (self , customer_id , options = {}):
249+ """Get the customer's tokens .
250250 Keyword argument:
251251 customer_id -- ID of the customer
252- token_id -- ID of the token
253252 options -- Options for the request"""
254253 self .fill_with_data (options )
255254
256255 request = Request (self ._client )
257- path = "/customers/" + quote_plus (customer_id ) + "/tokens/" + quote_plus ( token_id ) + " "
256+ path = "/customers/" + quote_plus (customer_id ) + "/tokens"
258257 data = {
259258
260259 }
261260
262261 response = Response (request .get (path , data , options ))
263262 return_values = []
264263
264+ a = []
265265 body = response .body
266- body = body ["token" ]
267-
268-
269- obj = processout .Token (self ._client )
270- return_values .append (obj .fill_with_data (body ))
271-
266+ for v in body ['tokens' ]:
267+ tmp = processout .Token (self ._client )
268+ tmp .fill_with_data (v )
269+ a .append (tmp )
270+
271+ return_values .append (a )
272+
272273
273274
274275 return return_values [0 ]
275276
276- def create (self , customer_id , source , options = {}):
277- """Create a new token for the given customer ID.
277+ def find (self , customer_id , token_id , options = {}):
278+ """Find a customer's token by its ID.
278279 Keyword argument:
279280 customer_id -- ID of the customer
280- source -- Source used to create the token (most likely a card token generated by ProcessOut.js)
281+ token_id -- ID of the token
281282 options -- Options for the request"""
282283 self .fill_with_data (options )
283284
284285 request = Request (self ._client )
285- path = "/customers/" + quote_plus (customer_id ) + "/tokens"
286+ path = "/customers/" + quote_plus (customer_id ) + "/tokens/" + quote_plus ( token_id ) + " "
286287 data = {
287- 'metadata' : self .metadata ,
288- 'settings' : options .get ("settings" ),
289- 'target' : options .get ("target" ),
290- 'source' : source
288+
291289 }
292290
293- response = Response (request .post (path , data , options ))
291+ response = Response (request .get (path , data , options ))
294292 return_values = []
295293
296294 body = response .body
297295 body = body ["token" ]
298296
299297
300- return_values .append (self .fill_with_data (body ))
298+ obj = processout .Token (self ._client )
299+ return_values .append (obj .fill_with_data (body ))
301300
302301
303302
304303 return return_values [0 ]
305304
306- def create_from_request (self , customer_id , source , target , options = {}):
307- """Create a new token for the given customer ID from an authorization request
305+ def create (self , options = {}):
306+ """Create a new token for the given customer ID.
308307 Keyword argument:
309- customer_id -- ID of the customer
310- source -- Source used to create the token (most likely a card token generated by ProcessOut.js)
311- target -- Authorization request ID
308+
312309 options -- Options for the request"""
313310 self .fill_with_data (options )
314311
315312 request = Request (self ._client )
316- path = "/customers/" + quote_plus (customer_id ) + "/tokens"
313+ path = "/customers/" + quote_plus (self . customer_id ) + "/tokens"
317314 data = {
318315 'metadata' : self .metadata ,
316+ 'source' : options .get ("source" ),
319317 'settings' : options .get ("settings" ),
320- 'source ' : source ,
321- 'target ' : target
318+ 'target ' : options . get ( "target" ) ,
319+ 'set_default ' : options . get ( "set_default" )
322320 }
323321
324322 response = Response (request .post (path , data , options ))
0 commit comments