github.com/gnolang/gno@v0.0.0-20240520182011-228e9d0192ce/examples/gno.land/r/x/nir1218_evaluation_proposal/pull_request.gno (about)

     1  package evaluation
     2  
     3  var pullRequestStatus map[string]struct{}
     4  
     5  type PullRequest struct {
     6  	id          int
     7  	name        string
     8  	description string
     9  	status      string // Draft, Review required, Changes requested, Approved
    10  	category    string // bounty, chore, defect, document etc.
    11  }
    12  
    13  func init() {
    14  	pullRequestStatus = make(map[string]struct{})
    15  	pullRequestStatus["Draft"] = struct{}{}
    16  	pullRequestStatus["Approved"] = struct{}{}
    17  	pullRequestStatus["Changes requested"] = struct{}{}
    18  	pullRequestStatus["Review required"] = struct{}{}
    19  }
    20  
    21  func NewPullRequest(id int, name string, description string, status string, category string) *PullRequest {
    22  	pr := &PullRequest{
    23  		id:          id,
    24  		name:        name,
    25  		description: description,
    26  		status:      status,
    27  		category:    category,
    28  	}
    29  	return pr
    30  }
    31  
    32  func (pr PullRequest) Id() int {
    33  	return pr.id
    34  }
    35  
    36  func (pr PullRequest) Status() string {
    37  	return pr.status
    38  }
    39  
    40  func (pr *PullRequest) UpdateName(name string) {
    41  	pr.name = name
    42  }
    43  
    44  func (pr *PullRequest) UpdateDescription(description string) {
    45  	pr.description = description
    46  }
    47  
    48  func (pr *PullRequest) UpdateStatus(status string) bool {
    49  	if validateStatus(status) {
    50  		pr.status = status
    51  		return true
    52  	}
    53  	return false
    54  }
    55  
    56  func validateStatus(status string) bool {
    57  	_, ok := pullRequestStatus[status]
    58  	return ok
    59  }