Pixela API client for Swift.
To make a request other than the registration API, it is necessary to set configuration.
Pixela.shared.configuration = Configuration(username: "username", token: "secret-token")
Pixela.shared.createUser(token: "secret-token", username: "username", isAgreeTermsOfService: true, isNotMinor: true, thanksCode: "thanks-code") { result in
switch result {
case let .success(configuration):
// Succeed new user registration
Pixela.shared.configuration = configuration
case let .failure(error)
// Failed registration
}
}
This library supports all Pixela API as of May 6, 2020. Check here for a list of Pixela APIs. (https://docs.pixe.la/)
Pixela.shared.configuration = Configuration(username: "username", token: "secret-token")
Pixela.shared.getGraphs { result in
switch result {
case let .success(graphs):
print(graphs)
case let .failure(error):
print(error)
}
}
Instead of using a shared instance, can use a Pixela instance for multiple accounts by manage it yourself.
let user1 = Pixela(configuration: Configuration(username: "user1", token: "user1-secret-token"))
let user2 = Pixela(configuration: nil)
user2.configuration = Configuration(username: "user2", token: "user2-secret-token")
Change APIConfiguration
to connect to the Enterprise version of Pixela.
Pixela.shared.apiConfiguration = APIConfiguration(baseURL: URL(string: "https://custom.pixe.la")!)
let pixela = Pixela(configuration: Configuration(username: "user1", token: "user1-secret-token"))
pixela.apiConfiguration = APIConfiguration(baseURL: URL(string: "https://custom-domain-pixela.com")!)
All errors in the library will return a PixelaError
. PixelaError
is the next 3 cases:
PixelaError.requestFailed
: Error while creating URLRequest from Request. (some APIKit.SessionTaskError.requestError)PixelaError.connectionFailed
: Error of networking backend stack. (some APIKit.SessionTaskError.connectionError)PixelaError.responseFailed(ResponseErrorReason)
: Error while handling response.carthage checkout --no-build --use-submodules
or git submodule init && git submodule update
)git checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)link |
Stars: 4 |
Last commit: 1 year ago |
ErrorMessage
to Message
. ( #13 )Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics