Skip to content
This repository was archived by the owner on Dec 10, 2024. It is now read-only.

Fix ISOTime encoding in GET requests #554

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions events.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions gitlab.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down