Skip to content

Commit b99e628

Browse files
committed
sources: Updated init param, created NewAccount().
1 parent ffd89db commit b99e628

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

swift-polaris-playground.playground/Sources/API.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ class API {
1010
init(apiURI: String) {
1111
URI = apiURI // Set URI
1212

13-
Accounts = AccountsAPI(apiURI) // Initialize accounts API
13+
Accounts = AccountsAPI(apiURI: apiURI) // Initialize accounts API
1414
}
1515
}

swift-polaris-playground.playground/Sources/AccountsAPI.swift

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@ class AccountsAPI {
66

77
// init initializes a new AccountsAPI instance.
88
init(apiURI: String) {
9-
URI = apiURI // Set API URI
9+
URI = String(format: "%@/twirp/accounts.Accounts", apiURI) // Set API URI
10+
}
11+
12+
// NewAccount initializes a new account via the provieded API lookup URI.
13+
func NewAccount() -> (String, Error) {
14+
let requestContents: [String: Any] = [:] // Empty JSON request
15+
16+
let jsonData = try? JSONSerialization.data(withJSONObject: requestContents) // Get JSON representation
17+
18+
var request = URLRequest(url: URL(string: String(format: "%@/NewAccount", URI))!) // Craft request
1019
}
1120
}

0 commit comments

Comments
 (0)