Example

To be able to connect to gather information form any DOCUframe database, one has to have web user alongside with his web password. Those are used to login in to to database, and after sucesfull login developer is able to request for data.

Connector

GSDRequestExecutor is the class which allows the developer to login in to the database. To use it one hase to declare it's instance with valid user name, passowrd and server adress.

Example:

1
    var executor = GSDRequestExecutor(userName: "GSDWebService", userPassword: "aab185a0b33d014157e1519445587d1f", serverAdresss: "127.0.0.1:8080")

If the executor will sucesfully login, then specified task will be fulfilled.

Task

To define a task to be performed one has to create a object which will conform to GSDRequest protocol. This protocol is a representation of url requests, and has got all information needed to create a request like:

Map which will represent all header fields used in request

1
headers:[String: String]

Map which will represent a Json object which will be sent to DOCUframe

1
parameters:[String: Any]

Method which will be used to perform a task (GET, POST...)

1
method: GSDHTTPMethod

Object which will handle the responses to the request

1
responseHandler:GSDURLResponseHandler?

The exact adress of the API given by Webservice

1
apiAdress:String

Handling response

To be able to handle the resposne of an request, on has to create an object which will conform to

1
2
3
4
5
6
7
8
9
extension ResponseHandlerObject: GSDURLResponseHandler {
    func onSuccess(response: GSDURLResponse) {    

    }

    func onError(response: GSDURLResponse) {

    }
}

In both cases the sucess and the response one will recieve GSDURLResponse object with all information downloaded from the database