Unverified Commit cd1e3f03 authored by Sander van Harmelen's avatar Sander van Harmelen Committed by GitHub

Merge pull request #554 from sirlatrom/contribution-events-before-after-isotime-fix

Fix ISOTime encoding in GET requests
parents e0e1ddfe 02c5e686
......@@ -71,11 +71,11 @@ type ContributionEvent struct {
// https://docs.gitlab.com/ce/api/events.html#get-user-contribution-events
type ListContributionEventsOptions struct {
ListOptions
Action *EventTypeValue `json:"action,omitempty"`
TargetType *EventTargetTypeValue `json:"target_type,omitempty"`
Before *string `json:"before,omitempty"`
After *string `json:"after,omitempty"`
Sort *string `json:"sort,omitempty"`
Action *EventTypeValue `url:"action,omitempty" json:"action,omitempty"`
TargetType *EventTargetTypeValue `url:"target_type,omitempty" json:"target_type,omitempty"`
Before *ISOTime `url:"before,omitempty" json:"before,omitempty"`
After *ISOTime `url:"after,omitempty" json:"after,omitempty"`
Sort *string `url:"sort,omitempty" json:"sort,omitempty"`
}
// ListUserContributionEvents retrieves user contribution events
......
......@@ -123,6 +123,15 @@ func (t *ISOTime) UnmarshalJSON(data []byte) error {
return err
}
// EncodeValues implements the query.Encoder interface
func (t *ISOTime) EncodeValues(key string, v *url.Values) error {
if t == nil || (time.Time(*t)).IsZero() {
return nil
}
v.Add(key, t.String())
return nil
}
// String implements the Stringer interface
func (t ISOTime) String() string {
return time.Time(t).Format(iso8601)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment