diff --git a/APLSource/GitHubAPIv3.aplc b/APLSource/GitHubAPIv3.aplc index 4d385c6..60507ac 100644 --- a/APLSource/GitHubAPIv3.aplc +++ b/APLSource/GitHubAPIv3.aplc @@ -7,7 +7,7 @@ ⍝ Apart from the REST interface the class also offers one method that relies on the REST interface but goes beyond ⍝ it: `GetRelease`returns the URL of a tarball or a zipball or an EXE from GitHub.\\ ⍝ For the time being this class runs only under Windows: it relies on .NET. If there is demand for other platforms -⍝ the .NET calls could be exchanged against Rumba.\\ +⍝ the .NET calls could be exchanged against Rumba or .NET core.\\ ⍝ The project lives on \\ ⍝ It is part of the [APLTree library](https://github.com/aplteam/apltree/wiki) ⍝ Kai Jaeger ⋄ APL Team Ltd @@ -18,16 +18,16 @@ ∇ r←Version :Access Public Shared - r←'GitHub' '0.4.0.15' '2019-06-11' - ∇ - - ∇ ToDo - ⍝ * Implement PutTopics - ⍝ * Add methods for creating and deleting an issue + r←'GitHub' '0.6.0.18' '2020-03-23' ∇ ∇ History :Access Public Shared + ⍝ * 0.6.0 + ⍝ * File extension is now .aplc rather than .dyalog + ⍝ * 0.5.0 + ⍝ * Issue-related methods added: `GetAllIssues`, `GetIssue`, `CreateIssue`, `UpdateIssue`. + ⍝ * Topic-related methods added: `GetAllTopics` and ... (not yet) `ReplaceAllTopics`. ⍝ * 0.4.0 ⍝ * New methods added: `GetRelease`, `GetLatestTag` and `CheckForUpdate`. ⍝ * There is now a property `regEx`. @@ -139,7 +139,7 @@ :EndIf ∇ - ∇ (rc msg ns)←GetAllTopics repoName;gitPath;parms + ∇ (rc msg r)←GetAllTopics repoName;gitPath;parms;ns :Access Public Instance ⍝ Returns all topics of a given repository.\\ ⍝ You must use `https://` as protocol or not specify a protocol at all. @@ -149,12 +149,13 @@ ⍝ : Is empty in case `rc ←→ 0` but might offer addtional information otherwise. ⍝ `ns` ⍝ : Namespace with the data received from GitHub. + r←'' gitPath←'https://api.github.com/repos/',_owner,'/',repoName,'/topics' - parms←CreateParms + parms←CreateHttpParms parms.Accepted←'application/vnd.github.mercy-preview+json' (rc msg ns)←parms GetJson gitPath :If 0=rc - ns.⎕DF'[JSON object: ',repoName,':topics]' + r←ns.names :EndIf ∇ @@ -168,6 +169,50 @@ :EndIf ∇ + ∇ (rc msg ns)←GetAllIssues repoName;gitPath + :Access Public Instance + ⍝ Returns all issues for a given repository + gitPath←'https://api.github.com/repos/',(_owner),'/',repoName,'/issues' + (rc msg ns)←GetJson gitPath + :If 0≠≢ns + ns.{⎕DF'[Issues of repo ',⍵,']'}⊂repoName + ns.⎕FX⊂⎕CR'∆List' + ns.⎕FX⊂'r←∆Details instance' 'r←∆List' 'r(instance.GetPrinciple)←''assignees'' ''login''' 'r(instance.GetPrinciple)←''labels'' ''name''' + ns.⎕FX⊂'r←∆QuickView instance;keyWords' 'r←∆Details instance' 'keyWords←''title'' ''number'' ''state'' ''updated_at'' ''labels'' ''assignees''' 'r←(r[;1]∊keyWords)⌿r' 'r←r[⍋keyWords⍳r[;1];]' + :EndIf + ∇ + + ∇ (rc msg ns)←GetIssue(repoName number);gitPath + :Access Public Instance + ⍝ Returns exactly one issue for a given repository.\\ + ⍝ Note that `ns` gets three functions injected: ∆List, ∆Details and ∆QuickView. While ∆List does not + ⍝ require an argument, ∆Details and ∆QuickView require an instance of this class as right argument.\\ + ⍝ ∆Details and ∆QuickView both replace the JSON objects "assignees" and "labels" by real data, but + ⍝ ∆QuickView returns a small subset for a quick glance. + gitPath←'https://api.github.com/repos/',(_owner),'/',repoName,'/issues/',⍕number + (rc msg ns)←GetJson gitPath + :If 0≠≢ns + ns.{⎕DF ⍵}'[Issue ',(⍕number),' of repo ',repoName,']' + ns.⎕FX ⎕CR'∆List' + ns.⎕FX'r←∆Details instance' 'r←∆List' 'r(instance.GetPrinciple)←''assignees'' ''login''' 'r(instance.GetPrinciple)←''labels'' ''name''' + ns.⎕FX'r←∆QuickView instance;keyWords' 'r←∆Details instance' 'keyWords←''title'' ''number'' ''state'' ''updated_at'' ''labels'' ''assignees''' 'r←(r[;1]∊keyWords)⌿r' 'r←r[⍋keyWords⍳r[;1];]' + :EndIf + ∇ + + ∇ (rc msg ns)←UpdateIssue(repoName parms);gitPath + :Access Public Instance + ⍝ Typically the (probably modified) result of call to `GetIssue` is passed as "parms". + ∘∘∘ ⍝TODO⍝ requires a POST + gitPath←'https://api.github.com/repos/',(_owner),'/',repoName,'/issues/',⍕number + (rc msg ns)←GetJson gitPath + :If 0≠≢ns + ns.{⎕DF ⍵}'[Issue ',(⍕number),' of repo ',repoName,']' + ns.⎕FX ⎕CR'∆List' + ns.⎕FX'r←∆Details instance' 'r←∆List' 'r(instance.GetPrinciple)←''assignees'' ''login''' 'r(instance.GetPrinciple)←''labels'' ''name''' + ns.⎕FX'r←∆QuickView instance;keyWords' 'r←∆Details instance' 'keyWords←''title'' ''number'' ''state'' ''updated_at'' ''labels'' ''assignees''' 'r←(r[;1]∊keyWords)⌿r' 'r←r[⍋keyWords⍳r[;1];]' + :EndIf + ∇ + ∇ (rc msg endpoints)←GetAllEndpoints;gitPath;msg;rc :Access Public Shared ⍝ This method returns all REST endpoints offered by the API.\\ @@ -193,9 +238,10 @@ ∇ (rc msg)←PutTopics(repoName topics);gitPath;parms;dummy ⍝ :Access Public Instance ⍝TODO⍝ Not implemented yet ⍝ ... + ∘∘∘ ⍝TODO⍝ '"topics" must be a vector of character vectors'⎕SIGNAL 11/⍨2≠≡topics gitPath←'https://api.github.com/repos/',(_owner),'/',repoName,'/topics' - parms←CreateParms + parms←CreateHttpParms parms.Accepted←'application/vnd.github.mercy-preview+json' parms.Method←'PUT' parms.Body←'{',(1 JSON'names'topics),'}' @@ -312,7 +358,42 @@ r←version_ - 0.4.0 - 2019-06-11 - #.GitHubAPIv3 - - - - - - - 1 - 15 - 1 - \ No newline at end of file + 0.6.0 2020-03-23 #.GitHubAPIv3 1 18 1 1 \ No newline at end of file