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

Cleanup StripeCard - v2.0.0-beta.1 #342

Merged
merged 1 commit into from
Apr 5, 2018

Conversation

snewcomer
Copy link
Collaborator

@snewcomer snewcomer commented Mar 26, 2018

@begedin

  • cleanup params
  • cleaup types
  • ensure endpoints are implements + tested

https://stripe.com/docs/api#create_subscription

Just getting started and have a few questions:

  1. Does the Clean up the params. mean the @spec params? If so, what is the background on why and what is the scope of keys that should be included?
  2. Add from_json macros - a bit confused. Followed this back to stripe/converter.ex. Is this already implemented for all modules given requests are all passed through make_request (which eventually calls Converter.convert_result(result)?

Progress on #266

@coveralls
Copy link

coveralls commented Mar 26, 2018

Coverage Status

Coverage remained the same at 79.319% when pulling 0d9126a on snewcomer:sn/2.0-beta/stripe-card into ec5d74b on code-corps:2.0-beta.

@begedin
Copy link
Contributor

begedin commented Mar 26, 2018

Does the Clean up the params. mean the @SPEC params? If so, what is the background on why and what is the scope of keys that should be included?

You are correct on what it is. As for what it should contain, it should follow the stripe API documentation for that action on that endpoint.

Add from_json macros - a bit confused. Followed this back to stripe/converter.ex. Is this already implemented for all modules given requests are all passed through make_request (which eventually calls Converter.convert_result(result)?

The documentation for this is in Stripe.Entity. To elaborate, all modules should use Stripe.Entity. For some stripe objects, we want to convert keys stripe uses as strings into atoms upon reading the json for that object. For those cases, we need to override the default from_json macro provided by Stripe.Entity

@spec create(params, Keyword.t()) :: {:ok, t} | {:error, Stripe.Error.t()}
when params: %{
optional(:customer) => Stripe.id() | Stripe.Account.t()
}
Copy link
Collaborator Author

@snewcomer snewcomer Mar 26, 2018

Choose a reason for hiding this comment

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

@begedin @joshsmith I guess what I was wondering is what keys should be included here. I see in other module that it's only a small subset. Also does clean up the params refer to only this spot in the guard clause? Or is there other spots this request is asking for?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

For example, this is only a limited list of the Subscription struct's keys...

https://github.com/code-corps/stripity_stripe/blob/2.0-beta/lib/stripe/subscriptions/subscription.ex#L74

Copy link
Contributor

Choose a reason for hiding this comment

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

In the example of a subscription, if you take a look at the documentation for the create action

https://stripe.com/docs/api#create_subscription

you will see that the spec matches that list much better (though we're still missing prorate as an optional boolean).

So to conclude, each action's @spec should match the arguments list for that action in stripe's documentation.

@snewcomer snewcomer changed the title Cleanup StripeCard - WIP Cleanup StripeCard - v2.0.0-beta.1 Mar 31, 2018
@snewcomer
Copy link
Collaborator Author

@begedin This is ready for your review!

Copy link
Contributor

@begedin begedin left a comment

Choose a reason for hiding this comment

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

A question about the metadata change, but otherwise looks good.

metadata: Stripe.Types.metadata() | nil,
metadata: %{
optional(String.t()) => String.t()
} | nil,
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the reasoning for replacing this? I'm not saying it's wrong and I vaguely recall a conversation with someone about it, but it looks like Stripe.Types.metadata is defined as exactly this here, so it sounds reasonable to leave it as is.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I looked at the coupon PR. But now looking in types.ex, this is the exact same thing. Will revert 👍

metadata: Stripe.Types.metadata(),
metadata: %{
optional(String.t()) => String.t()
},
Copy link
Contributor

Choose a reason for hiding this comment

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

See comment above. Again, sorry if there's a conversation about this somewhere which I forgot about.

@snewcomer
Copy link
Collaborator Author

@begedin Fixed. Replaced all with usages with Stripe.Types.metadata() based on the declared type here ->

https://github.com/code-corps/stripity_stripe/blob/2.0-beta/lib/stripe/types.ex#L23

@snewcomer snewcomer force-pushed the sn/2.0-beta/stripe-card branch 2 times, most recently from d2c066b to f466a46 Compare April 4, 2018 04:57
@begedin begedin merged commit 67f5f20 into beam-community:2.0-beta Apr 5, 2018
@begedin
Copy link
Contributor

begedin commented Apr 5, 2018

Good woork as always @snewcomer. Much appreciated 👍

@snewcomer snewcomer deleted the sn/2.0-beta/stripe-card branch April 8, 2018 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants