omise / omise-python

Omise Python Library
https://docs.opn.ooo
MIT License
26 stars 15 forks source link

Allow retrieve customer list #15

Closed jakyns closed 6 years ago

jakyns commented 6 years ago

Right now, customer can't call omise.Customer.retrieve() (call retrieve in Customer class without argument). This PR will set customer_id=None in default param so they can get Customer collection then.

guzzilar commented 6 years ago

👍 tested with

import omise
omise.api_secret = 'skey_test_...'

customers = omise.Customer.retrieve('?limit=3')

print(customers.limit) # 3
print(customers[0])    # <Customer id='cust_test_...' at 0x...>
guzzilar commented 6 years ago

note, I didn't review omise/test/__init__.py file 😝

sirn commented 6 years ago

Looks a bit weird, would love to have this as a method on Base instead. I'll comment later.

sirn commented 6 years ago

Merging this for now since we have other endpoints that have behavior that retrieve() without parameters returns the whole collection. I believe we should deprecate returning collection in retrieve() in favor for list() which should return an iterator.