-
-
Notifications
You must be signed in to change notification settings - Fork 268
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
v2.10.4: add some missing simple earn endpoints #419
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! For GET requests, simply pass any params as an object (in the second param of the getPrivate(url, params) call) - the networking abstraction will automatically handle serialisation etc while building the request. Here's an example from the master branch:
https://github.com/tiagosiebler/binance/blob/master/src/main-client.ts#L259-L261
By merging/approving #420 first in case my commit was the only thing preventing it from merging we could have both changes in the version bump from this PR |
src/main-client.ts
Outdated
**/ | ||
|
||
getFlexibleSavingProducts( | ||
params: SimpleEarnProductListParams, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If all properties on this object are optional, then "params" should be optional too. Same for any other calls with fully optional params.
params: SimpleEarnProductListParams, | |
params?: SimpleEarnProductListParams, |
The SDK will automatically see that this is undefined and will make the request without any params (and it looks cleaner in code).
src/types/simpleEarn.ts
Outdated
export interface SimpleEarnLockedProductPositionParams | ||
extends SimpleEarnFlexibleProductPositionParams { | ||
positionId?: string; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since it's only 4 extra params (not 10-50), I would prefer a flatter view, even if it means a little more repetition:
export interface SimpleEarnLockedProductPositionParams | |
extends SimpleEarnFlexibleProductPositionParams { | |
positionId?: string; | |
} | |
export interface SimpleEarnLockedProductPositionParams { | |
asset?: string; | |
productId?: string; | |
current?: number; | |
size?: number; | |
positionId?: string; | |
} |
What might start with one simple extends
can quickly become a mess that's hard to follow around (for some).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one's optional too, as well as SimpleEarnFlexibleProductPositionParams, so just make sure to make the param optional in the function call that has this interface
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some changes. Pls double check which params should be optional
src/types/simpleEarn.ts
Outdated
export interface SimpleEarnLockedProductPositionParams | ||
extends SimpleEarnFlexibleProductPositionParams { | ||
positionId?: string; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one's optional too, as well as SimpleEarnFlexibleProductPositionParams, so just make sure to make the param optional in the function call that has this interface
src/main-client.ts
Outdated
getSimpleEarnAccount(params: { | ||
recvWindow?: number; | ||
timestamp: number; | ||
}): Promise<SimpleEarnAccountResponse> { | ||
return this.getPrivate(`/sapi/v1/simple-earn/account`, params); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getSimpleEarnAccount(params: { | |
recvWindow?: number; | |
timestamp: number; | |
}): Promise<SimpleEarnAccountResponse> { | |
return this.getPrivate(`/sapi/v1/simple-earn/account`, params); | |
} | |
getSimpleEarnAccount(): Promise<SimpleEarnAccountResponse> { | |
return this.getPrivate(`/sapi/v1/simple-earn/account`); | |
} |
All done :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Thanks for the updates!
Released :) |
Summary
Added some simple earn endpoints as I saw #386
I am confused on how to submit params for get request, proceeded with query params but there is some inconsistency across methods. sometimes as body, sometimes as url query. According to docs for get request it must be query string
Additional Information
Anyone feel free to contribute more, I've just added about half of the simple earn endpoints, those are important to me.
Tried to not include breaking changes and kept naming of existing methods, tho types were outdated, not accurate on some of them