-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
286f8db
commit 985c3f6
Showing
7 changed files
with
170 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package cli | ||
|
||
type ViewParamas struct { | ||
ProjectId string | ||
Field string | ||
} | ||
|
||
func (c *Cmd) View(params *ViewParamas) error { | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
package ghp2 | ||
|
||
import ( | ||
"encoding/json" | ||
|
||
"github.com/shuntaka9576/gh-p2/gh" | ||
) | ||
|
||
type GetProjectItemsParams struct { | ||
ProjectId string | ||
} | ||
|
||
type GetProjectItemsGhRes struct { | ||
Data struct { | ||
Node struct { | ||
Items struct { | ||
Nodes []struct { | ||
ID string `json:"id"` | ||
CreatedAt string `json:"createdAt"` | ||
UpdatedAt string `json:"updatedAt"` | ||
IsArchived bool `json:"isArchived"` | ||
Content struct { | ||
TypeName string `json:"__typename,omitempty"` | ||
Title string `json:"title,omitempty"` | ||
State string `json:"state,omitempty"` | ||
URL string `json:"url,omitempty"` | ||
Body string `json:"body,omitempty"` | ||
} `json:"content"` | ||
FieldValues struct { | ||
Nodes []map[string]interface{} `json:"nodes"` | ||
} `json:"fieldValues"` | ||
} `json:"nodes"` | ||
} `json:"items"` | ||
} `json:"node"` | ||
} `json:"data"` | ||
} | ||
|
||
type GetProjectItemsRes struct { | ||
IssueItems []IssueItem | ||
} | ||
|
||
type IssueItem struct { | ||
Title string | ||
SingleSelectValues map[string]string | ||
ItemType gh.ITEM_TYPE | ||
Body string | ||
} | ||
|
||
func (c *Client) GetProjectItems(params *GetProjectItemsParams) (*GetProjectFieldsRes, error) { | ||
payload, err := gh.GetProjectFields(&gh.GetProjectFieldsParams{ | ||
ProjectId: params.ProjectId, | ||
}) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
parsed := &GetProjectItemsGhRes{} | ||
err = json.Unmarshal(*payload, parsed) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
res := &GetProjectItemsRes{} | ||
|
||
for _, node := range parsed.Data.Node.Items.Nodes { | ||
item := IssueItem{ | ||
Title: node.Content.Title, | ||
Body: node.Content.Body, | ||
} | ||
|
||
if node.Content.TypeName == "DraftIssue" { | ||
item.ItemType = gh.DRAFT_ISSUE | ||
} else if node.Content.TypeName == "Issue" { | ||
item.ItemType = gh.ISSUE | ||
} else { | ||
return nil, err | ||
} | ||
|
||
for _, filedValue := range node.FieldValues.Nodes { | ||
Check failure on line 79 in p2_items.go GitHub Actions / Run CI (1.22.1)
|
||
// TODO | ||
} | ||
|
||
res.IssueItems = append(res.IssueItems, item) | ||
} | ||
|
||
return res, nil | ||
Check failure on line 86 in p2_items.go GitHub Actions / Run CI (1.22.1)
|
||
} |