Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moved code from handler for "account.updated" into StripeConnectAccountService #627

Merged
merged 1 commit into from
Jan 12, 2017

Conversation

begedin
Copy link
Contributor

@begedin begedin commented Jan 12, 2017

What's in this PR?

Figured this out while working on #625

For consistency, I moved the code from the "account.updated" handler into StripeConnectAccountService.update_from_stripe.

I also removed some else cases from all 3 functions there, since they either just propagate the error response (basically doing nothing), or they outright swallow errors.

We should also add an issue, good for contributors to add a test for StripeConnectAccountService.update_from_stripe/1 - created #628

else
{:error, %Ecto.Changeset{} = changeset} -> {:error, changeset}
{:error, %Stripe.APIErrorResponse{} = error} -> {:error, error}
_ -> {:error, :unhandled}
Copy link
Contributor Author

@begedin begedin Jan 12, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is outright error hiding and should go away, so I removed it.

else
{:error, %Ecto.Changeset{} = changeset} -> {:error, changeset}
{:error, %Stripe.APIErrorResponse{} = error} -> {:error, error}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one serves no function. It passes out the error response. Not having this line leaves behavior exactly the same.

else
{:error, %Ecto.Changeset{} = changeset} -> {:error, changeset}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing this one means the call in the do block will just do the same thing automatically.

do
{:ok, updated_account}
account |> StripeConnectAccount.webhook_update_changeset(params) |> Repo.update
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This call will return {:ok, updated_account} anyway. No point in first calling it in the with block, then just passing it through in the do block.

@begedin begedin force-pushed the consolidate-stripe-connect-account-crud-code branch from 611f3b9 to 6ed9a91 Compare January 12, 2017 23:01
@begedin begedin changed the title Moved code from handler for "account.updared" into StripeConnectAccountService Moved code from handler for "account.updated" into StripeConnectAccountService Jan 12, 2017
@begedin begedin force-pushed the consolidate-stripe-connect-account-crud-code branch from 6ed9a91 to 8b4ed28 Compare January 12, 2017 23:01
@joshsmith joshsmith force-pushed the consolidate-stripe-connect-account-crud-code branch from 8b4ed28 to cf719d9 Compare January 12, 2017 23:12
@begedin begedin merged commit 6d29b42 into develop Jan 12, 2017
@begedin begedin deleted the consolidate-stripe-connect-account-crud-code branch January 12, 2017 23:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants