Skip to content

Instantly share code, notes, and snippets.

@Solution
Created December 13, 2018 22:06
Show Gist options
  • Save Solution/cd284bb2974d670a1f6db38cc28daced to your computer and use it in GitHub Desktop.
Save Solution/cd284bb2974d670a1f6db38cc28daced to your computer and use it in GitHub Desktop.
package transportServiceClient
import (
"net/http"
"strconv"
"fmt"
)
type Client struct {
*client.Client
}
func CreateClient(httpClient *http.Client, factory *client.RequestFactory) Client {
return Client {
&client.Client{
MaxRetries: client.DefaultRetries,
HttpClient: httpClient,
RequestFactory: factory,
},
}
}
func (c *Client) ListTransports(option TransportListOption) (*http.Response, error) {
var options = make(map[string]string)
if option.someArg != 0 {
options["someArg"] = strconv.Itoa(option.someArg)
}
if option.someArg != 0 {
options["someArg"] = strconv.Itoa(option.someArg)
}
return c.DoRequest(c.PrepareRequest(client.GET, "transports", options, ""), c.MaxRetries)
}
func (c *Client) GetTransportDetail(transportId int64) (*http.Response, error) {
return c.DoRequest(c.PrepareRequest(
client.GET,
fmt.Sprintf("transports/%d", transportId),
map[string]string{},
"", ), c.MaxRetries)
}
func (c *Client) CreateTransport(transport Transport) (*http.Response, error) {
body, err := c.PrepareBodyRequest(transport)
if err != nil {
return nil, err
}
return c.DoRequest(c.PrepareRequest(
client.POST,
fmt.Sprintf("transports/%d", transport.Id),
map[string]string{},
body,
), c.MaxRetries)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment