Skip to content

Commit 0474dfd

Browse files
committed
reform GitHub API namespaces
1 parent 02e2f94 commit 0474dfd

29 files changed

+132
-111
lines changed

Sources/GitHubAPI/GitHub.API.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
extension GitHubOAuth
1+
extension GitHub.OAuth
22
{
33
@available(*, deprecated, renamed: "GitHub.API")
44
public
@@ -13,10 +13,10 @@ extension GitHub
1313
public
1414
let agent:String
1515
public
16-
let oauth:GitHubOAuth
16+
let oauth:GitHub.OAuth
1717

1818
@inlinable internal
19-
init(agent:String, oauth:GitHubOAuth)
19+
init(agent:String, oauth:GitHub.OAuth)
2020
{
2121
self.agent = agent
2222
self.oauth = oauth

Sources/GitHubAPI/GitHubApp.Credentials.swift renamed to Sources/GitHubAPI/GitHub.App.Credentials.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import JSON
22

3-
extension GitHubApp
3+
extension GitHub.App
44
{
55
@frozen public
66
struct Credentials:Equatable, Hashable, Sendable
@@ -18,7 +18,7 @@ extension GitHubApp
1818
}
1919
}
2020
}
21-
extension GitHubApp.Credentials:JSONObjectDecodable
21+
extension GitHub.App.Credentials:JSONObjectDecodable
2222
{
2323
public
2424
enum CodingKey:String, Sendable

Sources/GitHubAPI/GitHubApp.Token.swift renamed to Sources/GitHubAPI/GitHub.App.Token.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
extension GitHubApp
1+
extension GitHub.App
22
{
33
@frozen public
44
struct Token:Equatable, Hashable, Sendable

Sources/GitHubAPI/GitHub.App.swift

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
extension GitHub
2+
{
3+
/// The essence of a GitHub App, which is a type of GitHub application.
4+
@frozen public
5+
struct App:GitHubApplication, Identifiable
6+
{
7+
/// The app id number. This is different from the client id.
8+
public
9+
let id:Int?
10+
11+
public
12+
let client:String
13+
public
14+
let secret:String
15+
16+
@inlinable public
17+
init(_ id:Int?, client:String, secret:String)
18+
{
19+
self.id = id
20+
self.client = client
21+
self.secret = secret
22+
}
23+
}
24+
}

Sources/GitHubAPI/GitHubOAuth.Credentials.swift renamed to Sources/GitHubAPI/GitHub.OAuth.Credentials.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import JSON
22

3-
extension GitHubOAuth
3+
extension GitHub.OAuth
44
{
55
@frozen public
66
struct Credentials
@@ -18,7 +18,7 @@ extension GitHubOAuth
1818
}
1919
}
2020
}
21-
extension GitHubOAuth.Credentials:JSONObjectDecodable
21+
extension GitHub.OAuth.Credentials:JSONObjectDecodable
2222
{
2323
public
2424
enum CodingKey:String, Sendable

Sources/GitHubAPI/GitHub.OAuth.swift

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
extension GitHub
2+
{
3+
/// The essence of a GitHub OAuth application.
4+
///
5+
/// A `GitHub.OAuth` instance is just a ``client`` ID and ``secret``.
6+
///
7+
/// > Note:
8+
/// This type would be named `GitHub.OAuthApp`, but then ``GitHub.App`` would have to be
9+
/// named ``GitHub.AppApp``, and that would just be stupid.
10+
@frozen public
11+
struct OAuth:GitHubApplication
12+
{
13+
public
14+
let client:String
15+
public
16+
let secret:String
17+
18+
@inlinable public
19+
init(client:String, secret:String)
20+
{
21+
self.client = client
22+
self.secret = secret
23+
}
24+
}
25+
}
26+
extension GitHub.OAuth
27+
{
28+
/// The GitHub API.
29+
@inlinable public
30+
var api:GitHub.API { .init(agent: "swift-unidoc (by tayloraswift)", oauth: self) }
31+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import UnixTime
2+
3+
extension GitHub
4+
{
5+
public
6+
typealias RateLimitError = _GitHubRateLimitError
7+
}
8+
9+
/// The name of this protocol is ``GitHub.RateLimitError``.
10+
public
11+
protocol _GitHubRateLimitError:Error, Equatable, Sendable
12+
{
13+
/// The UTC epoch second when the rate limit will reset.
14+
var until:UnixInstant { get }
15+
}

Sources/GitHubAPI/GitHubApp.swift

Lines changed: 0 additions & 21 deletions
This file was deleted.

Sources/GitHubAPI/GitHubApplication.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/// The essence of a GitHub application. Not to be confused with ``GitHubApp``.
1+
/// The essence of a GitHub application. Not to be confused with ``GitHub.App``.
22
public
33
protocol GitHubApplication<Credentials>:Equatable, Hashable, Sendable
44
{

Sources/GitHubAPI/GitHubOAuth.swift

Lines changed: 0 additions & 24 deletions
This file was deleted.

0 commit comments

Comments
 (0)