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

Convert all options to have one class per level in the JSON params #1301

Merged

Conversation

remi-stripe
Copy link
Contributor

This PR takes all existing Options classes and splits the properties per level in the JSON. This is to ensure that our class structure matches our API naming as in other libraries. It also makes the code easier to re-use when hashes are shared across resources.

cc @stripe/api-libraries

@remi-stripe
Copy link
Contributor Author

@ob-stripe I did the majority of those. It's missing the AmountOne and AmountTwo for bank account verification but I'm not sure we can fix that one without hard-coding the 0/1 index in the property? Is it the right approach?
It's also missing the one for the list dates gt/gte/etc.

@@ -124,5 +94,27 @@ public class SourceCreateOptions : BaseOptions, ISupportMetadata
/// </summary>
[JsonProperty("usage")]
public string Usage { get; set; }

/*
Below we group all Source type specific paramters
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure if this is the right approach. It seems clean enough but I was a little bit wary about having Create in options names, because Create implies this is the top-level class name (for me at least). Did not want to spend too long on it and wanted you to have a first look though

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, that's a good point. Ideally we should have a clear naming convention, but in practice the dependency graph is complex and makes it pretty hard to come up with something that's applicable everywhere. What you have here is reasonable IMO.

@ob-stripe
Copy link
Contributor

It's missing the AmountOne and AmountTwo for bank account verification but I'm not sure we can fix that one without hard-coding the 0/1 index in the property?

We should just declare a single int[2] Amounts property. It will be encoded as amounts[0]=32&amounts[1]=45, but the API should be able to accept numeric indexes for arrays everywhere now.

@ob-stripe
Copy link
Contributor

Looks great so far! So much cleaner ❤️

@remi-stripe remi-stripe force-pushed the remi-fix-all-nested-options branch from 7fdd34f to 5e35978 Compare September 27, 2018 20:52
@remi-stripe remi-stripe changed the title [WIP] Convert all options to have one class per level in the JSON params Convert all options to have one class per level in the JSON params Sep 27, 2018
@remi-stripe
Copy link
Contributor Author

@ob-stripe Okay I did all the changes we discussed. I also took this as an opportunity to add new lines to all Options files which should make you happy.

Can you do a full review?

Copy link
Contributor

@ob-stripe ob-stripe left a comment

Choose a reason for hiding this comment

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

Some comments, but overall this is super rad. Awesome work @remi-stripe

/// A filter on the list based on the object date field.
/// </summary>
[JsonProperty("date")]
public DateFilterOptions DateFilter { get; set; }
Copy link
Contributor

Choose a reason for hiding this comment

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

Rename to DateRange for consistency.


/// <summary>
/// A filter on the list based on the object due_date field.
/// </summary>
[JsonProperty("due_date")]
public DateFilter DueDate { get; set; }
public DateFilterOptions DueDateFilter { get; set; }
Copy link
Contributor

Choose a reason for hiding this comment

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

Rename to DueDateRange for consistency.

@@ -3,21 +3,18 @@
using System;
using Newtonsoft.Json;

public class DateFilter
public class DateFilterOptions : INestedOptions
Copy link
Contributor

Choose a reason for hiding this comment

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

I think DateRangeOptions would be a better name: filtering on an exact date is also a "date filter", but this class now only handles ranges. It would also make the class name consistent with the properties names.

This ensures that params/class structure matches the API. Also changed
DateFilter to match the API and remove custom encoding and renamed it to
DateRangeOptions
@remi-stripe remi-stripe force-pushed the remi-fix-all-nested-options branch from 5e35978 to a518a7c Compare September 28, 2018 15:12
@remi-stripe
Copy link
Contributor Author

@ob-stripe Fixed, PTYAL

@ob-stripe
Copy link
Contributor

LGTM!

@remi-stripe remi-stripe merged commit 8965713 into integration-next-major-version Sep 28, 2018
@remi-stripe remi-stripe deleted the remi-fix-all-nested-options branch September 28, 2018 15:19
@ob-stripe ob-stripe mentioned this pull request Sep 28, 2018
32 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants