Change the way parameter lists are handled internally
Instead of trying to guess if a query key is a list (to strip the index
number, since Rails expects list IDs without index number), we prefix
the key name with the index when dealing with lists.
E.g.:
[0]ids: "one"
[1]ids: "two"
will be sent as
ids[]=one&ids[]=two
It makes it more reliable and let us differenciate between arrays and
objects (objects are untouched and sent as-is).
package madon
import (
"testing"
"github.com/sendgrid/rest"
"github.com/stretchr/testify/assert"
)
func TestPrepareRequest(t *testing.T) {
mc := &Client{
Name: "foo",
ID: "666",
Secret: "biiiip",
APIBase: "http://example.com",
}
req, err := mc.prepareRequest("bar", rest.Get, nil)
assert.NoError(t, err, "no error")
assert.NotNil(t, req.Headers, "not nil")
}