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

Make GetResponse in query package return a defined interface #8

Open
p0mvn opened this issue Nov 15, 2021 · 3 comments
Open

Make GetResponse in query package return a defined interface #8

p0mvn opened this issue Nov 15, 2021 · 3 comments

Comments

@p0mvn
Copy link
Contributor

p0mvn commented Nov 15, 2021

More information about this issue can be found in the following PR comment

A/C

  • new interface is defined wrapping map[string]interface{}
  • GetAsString and GetAsFloat implemented
@dhiaayachi
Copy link
Owner

After some thoughts I think the best way would be to make the user pass a response object that we would populate.

currently the user need to do something like this:

        newton := newton.New("", "")
	q := &query.OpenOrders{}
	response, _ := newton.Do(q)
	resp := response.Body.(*query.OpenOrdersResponse)
	fmt.Println((*resp)[0].Price)

Which I think is not ideal, a better way to do this would be:

        newton := newton.New("", "")
	q := &query.OpenOrders{}
        r := query.OpenOrdersResponse{}
	responseCode, _ := newton.Do(q,&r)
	fmt.Println(r[0].Price)

What you think about this @akhtariev ?

@p0mvn
Copy link
Contributor Author

p0mvn commented Nov 16, 2021

That looks good to me. Maybe we could even make it as part of a response package? So it would be:

r := response.OpenOrders{}

@dhiaayachi
Copy link
Owner

Yes great idea, I will work on this when I have some spare time.

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

No branches or pull requests

2 participants