dmitri.shuralyov.com/service/change

Add changes, githubapi.
dmitshur committed 6 years ago commit 391e3d90eb222279a56521627867335e3c409cf2
Showing partial commit. Full Commit
Collapse all
changes.go
@@ -0,0 +1,47 @@
// Package changes provides a changes service definition.
package changes

import (
	"context"
	"time"

	"github.com/shurcooL/users"
)

// Service defines methods of a change tracking service.
type Service interface {
	// List changes.
	List(ctx context.Context, repo string) ([]Change, error)
	// Count changes.
	Count(ctx context.Context, repo string) (uint64, error)

	// Get a change.
	Get(ctx context.Context, repo string, id uint64) (Change, error)

	// ListComments lists comments for specified change id.
	//ListComments(ctx context.Context, repo string, id uint64, opt *ListOptions) ([]Comment, error)
	// ListEvents lists events for specified change id.
	//ListEvents(ctx context.Context, repo string, id uint64, opt *ListOptions) ([]Event, error)
}

// Change represents a change in a repository.
type Change struct {
	ID        uint64
	State     State
	Title     string
	Author    users.User
	CreatedAt time.Time
	Replies   int // Number of replies to this change (not counting the mandatory change description comment).
}

// State represents the change state.
type State string

const (
	// OpenState is when a change is open.
	OpenState State = "open"
	// ClosedState is when a change is closed.
	ClosedState State = "closed"
	// MergedState is when a change is merged.
	MergedState State = "merged"
)