simonlevy5 / plaid-ios-link

Plaid Link experience built natively for iOS
MIT License
34 stars 10 forks source link

Pass Options Dictionary to Plaid API #10

Closed pandringa closed 8 years ago

pandringa commented 8 years ago

I wanted to pass a webhook option to plaid to subscribe to their webhook notifications, but when I looked through your code I realized the webhook variable mentioned in PLDLinkNavigationViewController.m wasn't actually implemented in the code.

I decided to change that webhook string to an options dictionary and send all of them to Plaid, which should be more flexible for the future as Plaid continues to develop their API. It works fine although it's a bit cumbersome to pass the options dictionary down the call stack (the code touches 3 different classes), so if you have better ideas on how to implement this I'd be happy to hear them.

Swift usage example:

let plaidLink = PLDLinkNavigationViewController(environment: .Tartan, product: .Connect)
plaidLink.linkDelegate = self;
plaidLink.providesPresentationContextTransitionStyle = true
plaidLink.definesPresentationContext = true
plaidLink.modalPresentationStyle = .Custom
plaidLink.options = ["webhook": "https://yourwebsite.com/plaid_webhook"]
self.presentViewController(plaidLink, animated: true, completion: nil)
simonlevy5 commented 8 years ago

Thank you @pandringa! Much appreciated for taking on the fix. Please address outstanding comments and i'll merge. Also, let me know if you have any questions!

pandringa commented 8 years ago

No problem Simon, thanks for the thoughts on how to implement this cleanly! I'll quickly revert that Xcode file right now, and get to the other changes when I have a chance tomorrow.

pandringa commented 8 years ago

@simonlevy5 This should be ready to go – I followed your suggestion and turned options into a property on the view controllers, and removed the overloaded initializers. Let me know if there's anything I've missed!

simonlevy5 commented 8 years ago

Mostly looks good aside from a couple minor comments and some pedantic style fixes. I'll merge once those are in. Thanks again!

pandringa commented 8 years ago

Thanks for the feedback! Should all be fixed now.