Skip to content

Commit

Permalink
oop stripe seq
Browse files Browse the repository at this point in the history
  • Loading branch information
gzukowski committed Jul 3, 2023
1 parent 3402c52 commit 1eaf134
Showing 1 changed file with 36 additions and 35 deletions.
71 changes: 36 additions & 35 deletions python/Stripe/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,42 +8,43 @@
'contentType': 'text/plain'
}

class Stripe:
def __init__(self,stream,stripe_api):
self.stream = stream
self.stripe_api = stripe_api

def get_mail(self, user):
return user['data']['object']['email']

def get_fullname(self, user):
mail = user['data']['object']['email']
name = mail.split("@")
name = name[0] + " stripe"
return name

async def get_event(self):
await asyncio.sleep(3)
compared = stripe.Event.list(type="customer.created")['data'][-1]
tako = stripe.Event.list(type="customer.created")['data']

def get_mail(user):
return user['data']['object']['email']

def get_fullname(user):
mail = user['data']['object']['email']
name = mail.split("@")
name = name[0] + " stripe"
return name
self.stream.write(self.get_mail(compared)+ " " +self.get_fullname(compared))
compared = compared['id']
while True:
test = stripe.Event.list(type="customer.created", ending_before=compared, limit=3)['data']

async def get_event(stream):
await asyncio.sleep(3)
compared = stripe.Event.list(type="customer.created")['data'][-1]
tako = stripe.Event.list(type="customer.created")['data']

stream.write(get_mail(compared)+ " " +get_fullname(compared))
compared = compared['id']
while True:
test = stripe.Event.list(type="customer.created", ending_before=compared, limit=3)['data']

for i in range(len(test)):
stream.write(get_mail(test[i]) + " " +get_fullname(test[i]))
if len(test) != 0:
compared = test[0]['id']
await asyncio.sleep(3)

for i in range(len(test)):
self.stream.write(self.get_mail(test[i]) + " " +self.get_fullname(test[i]))
if len(test) != 0:
compared = test[0]['id']
await asyncio.sleep(3)

async def run(context, input):
try:
stripe.api_key = context.config['stripe_api']
except Exception as error:
raise Exception(f"Config not loaded: {error}")
return
stream = Stream()
asyncio.gather(get_event(stream), return_exceptions=True)
return stream.map(lambda x : x + "\n")



stream = Stream()
try:
stripe.api_key = context.config['stripe_api']
stripeReader = Stripe(stream, stripe.api_key)
except Exception as error:
raise Exception(f"Config not loaded: {error}")
return
asyncio.gather(stripeReader.get_event(), return_exceptions=True)
return stream.map(lambda x : x + "\n")

0 comments on commit 1eaf134

Please sign in to comment.