fix: accountsInfo url
This commit is contained in:
parent
e44821bce8
commit
4c36d0e12d
|
@ -16,6 +16,10 @@ extension Mastodon.API.Account {
|
|||
static func accountsEndpointURL(domain: String) -> URL {
|
||||
return Mastodon.API.endpointURL(domain: domain).appendingPathComponent("accounts")
|
||||
}
|
||||
static func accountsInfoEndpointURL(domain: String, id: String) -> URL {
|
||||
return Mastodon.API.endpointURL(domain: domain).appendingPathComponent("accounts")
|
||||
.appendingPathComponent(id)
|
||||
}
|
||||
static func updateCredentialsEndpointURL(domain: String) -> URL {
|
||||
return Mastodon.API.endpointURL(domain: domain).appendingPathComponent("accounts/update_credentials")
|
||||
}
|
||||
|
@ -96,7 +100,7 @@ extension Mastodon.API.Account {
|
|||
/// - session: `URLSession`
|
||||
/// - domain: Mastodon instance domain. e.g. "example.com"
|
||||
/// - query: `CredentialQuery` with update credential information
|
||||
/// - authorization: `UpdateCredentialQuery` with update information
|
||||
/// - authorization: user token
|
||||
/// - Returns: `AnyPublisher` contains updated `Account` nested in the response
|
||||
public static func updateCredentials(
|
||||
session: URLSession,
|
||||
|
@ -138,8 +142,8 @@ extension Mastodon.API.Account {
|
|||
authorization: Mastodon.API.OAuth.Authorization?
|
||||
) -> AnyPublisher<Mastodon.Response.Content<Mastodon.Entity.Account>, Error> {
|
||||
let request = Mastodon.API.get(
|
||||
url: accountsEndpointURL(domain: domain),
|
||||
query: query,
|
||||
url: accountsInfoEndpointURL(domain: domain, id: query.id),
|
||||
query: nil,
|
||||
authorization: authorization
|
||||
)
|
||||
return session.dataTaskPublisher(for: request)
|
||||
|
@ -220,14 +224,10 @@ extension Mastodon.API.Account {
|
|||
}
|
||||
}
|
||||
|
||||
public struct AccountInfoQuery: Codable, GetQuery {
|
||||
public struct AccountInfoQuery: GetQuery {
|
||||
|
||||
public let id: String
|
||||
|
||||
var queryItems: [URLQueryItem]? {
|
||||
var items: [URLQueryItem] = []
|
||||
items.append(URLQueryItem(name: "id", value: id))
|
||||
return items
|
||||
}
|
||||
var queryItems: [URLQueryItem]? { nil }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ extension MastodonSDKTests {
|
|||
XCTAssertEqual(result.value.acct, "")
|
||||
theExpectation1.fulfill()
|
||||
|
||||
var query = Mastodon.API.Account.CredentialQuery()
|
||||
var query = Mastodon.API.Account.UpdateCredentialQuery()
|
||||
query.note = dateString
|
||||
return Mastodon.API.Account.updateCredentials(session: self.session, domain: self.domain, query: query, authorization: authorization)
|
||||
})
|
||||
|
@ -69,4 +69,26 @@ extension MastodonSDKTests {
|
|||
|
||||
wait(for: [theExpectation1, theExpectation2], timeout: 10.0)
|
||||
}
|
||||
|
||||
func testRetrieveAccountInfo() throws {
|
||||
let theExpectation = expectation(description: "Verify Account Credentials")
|
||||
|
||||
let query = Mastodon.API.Account.AccountInfoQuery(id: "1")
|
||||
Mastodon.API.Account.accountInfo(session: session, domain: domain, query: query, authorization: nil)
|
||||
.receive(on: DispatchQueue.main)
|
||||
.sink { completion in
|
||||
switch completion {
|
||||
case .failure(let error):
|
||||
XCTFail(error.localizedDescription)
|
||||
case .finished:
|
||||
break
|
||||
}
|
||||
} receiveValue: { response in
|
||||
XCTAssertEqual(response.value.acct, "Gargron")
|
||||
theExpectation.fulfill()
|
||||
}
|
||||
.store(in: &disposeBag)
|
||||
|
||||
wait(for: [theExpectation], timeout: 5.0)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue