diff --git a/domain/project.go b/domain/project.go new file mode 100644 index 0000000..22232cb --- /dev/null +++ b/domain/project.go @@ -0,0 +1,7 @@ +package domain + +type Project struct { + Id string + Name string + Note string +} diff --git a/mite/api.go b/mite/api.go index d0670fd..79e3c88 100644 --- a/mite/api.go +++ b/mite/api.go @@ -4,6 +4,7 @@ import ( "bytes" "encoding/json" "fmt" + "github.com/leanovate/mite-go/domain" "net/http" "net/url" ) @@ -30,7 +31,7 @@ type TrackerApi interface { type CustomerApi interface{} type ProjectApi interface { - Projects() ([]*Project, error) + Projects() ([]*domain.Project, error) } type ServiceApi interface { diff --git a/mite/project.go b/mite/project.go index 0f31656..cdf01f4 100644 --- a/mite/project.go +++ b/mite/project.go @@ -2,14 +2,9 @@ package mite import ( "fmt" + "github.com/leanovate/mite-go/domain" ) -type Project struct { - Id string - Name string - Note string -} - type projectResponse struct { Project struct { Id int `json:"id"` @@ -18,24 +13,24 @@ type projectResponse struct { } `json:"project"` } -func (r *projectResponse) ToProject() *Project { - return &Project{ +func (r *projectResponse) toProject() *domain.Project { + return &domain.Project{ Id: fmt.Sprintf("%d", r.Project.Id), Name: r.Project.Name, Note: r.Project.Note, } } -func (a *api) Projects() ([]*Project, error) { +func (a *api) Projects() ([]*domain.Project, error) { var prs []projectResponse err := a.get("projects.json", &prs) if err != nil { return nil, err } - var projects []*Project + var projects []*domain.Project for _, pr := range prs { - projects = append(projects, pr.ToProject()) + projects = append(projects, pr.toProject()) } return projects, nil