From bb582df8c875d6394e2e2f757b369fdd59213ffa Mon Sep 17 00:00:00 2001 From: John Carter Date: Wed, 14 Oct 2020 13:47:37 +0200 Subject: [PATCH] added doc link --- README.md | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/README.md b/README.md index 1dab3f5..129c742 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,54 @@ import Combine import Cumulocity_Client_Library ``` +## Connectivity and basic usage ## + +You first need to create a Connection object and then one of the API Service classes to interact with you Cumulocity tenant, e.g. + +``` +let conn: C8yCumulocityConnection = C8yCumulocityConnection(tenant: "", server: "cumulocity.com") + + conn.connect(user: "john", password: "appleseed").sink(receiveCompletion: { (completion) in + switch completion { + case .failure(let error): + print("Connection refused! - \(error.localizedDescription)") + default: + print("Connection Success") + + // Now that we have tested the connections, lets fetch some managed objects + + C8yManagedObjectsService(conn).get(pageNum: 0).sink(receiveCompletion: { (completion) in + + switch completion { + case .failure(let error): + print("Get Failed \(error.localizedDescription)") + default: + print("Get Completed") + } + + }, receiveValue: { results in + + if (results.status == .SUCCESS) { + + print("page \(results.content!.statistics.currentPage) of \(results.content!.statistics.totalPages!), size \(results.content!.statistics.pageSize)") + + for object in results.content!.objects { + print("\(String(describing: object.id))") + } + } + }).store(in: &self._cancellableSet) + } + }, receiveValue: ({ userInfo in + + print("User name is \(userInfo)") + + })).store(in: &self._cancellableSet) +``` + +The above first verifies the connection and uses the `C8yManagedObjectsService` class to fetch a page of `C8yManagedObject` objects. The connection object does not carry state and +the connect method is only useful to verify the credentials and also gather information about the user `C8yUserProfile`. Each call via the Service classes reconnects via the connection +credentials and stateless. + ## SDK Documentation ## Full documentation can be viewed [here](https://raw.githack.com/johnpcarter/c8y-ios-lib/master/docs/out/index.html) \ No newline at end of file