File tree 1 file changed +18
-3
lines changed
1 file changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -203,13 +203,28 @@ func (c *Client) GetHistoricRates(product string,
203
203
params = p [0 ]
204
204
}
205
205
206
- if ! params .Start .IsZero () && ! params .End .IsZero () && params .Granularity != 0 {
207
- values := url.Values {}
208
- layout := "2006-01-02T15:04:05Z"
206
+ var (
207
+ values = url.Values {}
208
+ layout = "2006-01-02T15:04:05Z"
209
+ )
210
+
211
+ // start
212
+ if ! params .Start .IsZero () {
209
213
values .Add ("start" , params .Start .UTC ().Format (layout ))
214
+ }
215
+
216
+ // end
217
+ if ! params .End .IsZero () {
210
218
values .Add ("end" , params .End .UTC ().Format (layout ))
219
+ }
220
+
221
+ // granularity
222
+ if params .Granularity != 0 {
211
223
values .Add ("granularity" , strconv .Itoa (params .Granularity ))
224
+ }
212
225
226
+ // add the values, if any
227
+ if len (values ) > 0 {
213
228
requestURL = fmt .Sprintf ("%s?%s" , requestURL , values .Encode ())
214
229
}
215
230
You can’t perform that action at this time.
0 commit comments