@@ -27,3 +27,51 @@ func (client *Client) ServiceApiDocSettingsUpdate(service string, docPath string
2727 err := client .Mutate (& m , v , WithName ("ServiceApiDocSettingsUpdate" ))
2828 return & m .Payload .Service , HandleErrors (err , m .Payload .Errors )
2929}
30+
31+ func (client * Client ) ListDocuments (variables * PayloadVariables ) (* ServiceDocumentsConnection , error ) {
32+ var q struct {
33+ Account struct {
34+ Documents ServiceDocumentsConnection `graphql:"documents(searchTerm: $searchTerm, after: $after, first: $first)"`
35+ }
36+ }
37+
38+ if variables == nil {
39+ variables = client .InitialPageVariablesPointer ()
40+ }
41+
42+ if (* variables )["searchTerm" ] == nil {
43+ (* variables )["searchTerm" ] = ""
44+ }
45+
46+ if err := client .Query (& q , * variables , WithName ("ListDocuments" )); err != nil {
47+ return nil , err
48+ }
49+ q .Account .Documents .TotalCount = len (q .Account .Documents .Nodes )
50+
51+ if q .Account .Documents .PageInfo .HasNextPage {
52+ (* variables )["after" ] = q .Account .Documents .PageInfo .End
53+
54+ resp , err := client .ListDocuments (variables )
55+ if err != nil {
56+ return & q .Account .Documents , err
57+ }
58+ q .Account .Documents .Nodes = append (q .Account .Documents .Nodes , resp .Nodes ... )
59+ q .Account .Documents .PageInfo = resp .PageInfo
60+ q .Account .Documents .TotalCount += resp .TotalCount
61+ }
62+ return & q .Account .Documents , nil
63+ }
64+
65+ func (client * Client ) GetDocument (id ID ) (* ServiceDocumentContent , error ) {
66+ var q struct {
67+ Account struct {
68+ Document ServiceDocumentContent `graphql:"document(id: $id)"`
69+ }
70+ }
71+
72+ v := PayloadVariables {
73+ "id" : id ,
74+ }
75+ err := client .Query (& q , v , WithName ("DocumentGet" ))
76+ return & q .Account .Document , err
77+ }
0 commit comments