-
-
-

UsergridClient

-
-
-
public class UsergridClient : NSObject
- -
-
-

The UsergridClient class is the base handler for making client connections to and managing relationships with Usergrid’s API.

- -
-
-
- -
    -
  • -
    - - - - authForRequests() - -
    -
    -
    -
    -
    -
    -

    Determines the UsergridAuth object that will be used for all outgoing requests made.

    - -

    If there is a UsergridUser logged in and the token of that user is valid then it will return that.

    - -

    Otherwise, if the authFallback is .App, and the UsergridAppAuth of the client is set and the token is valid it will return that.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func authForRequests() -> UsergridAuth?
    - -
    -
    -
    -

    Return Value

    -

    The UsergridAuth if one is found or nil if not.

    - -
    -
    -
    -
  • -
  • -
    - - - - authenticateApp(_:) - -
    -
    -
    -
    -
    -
    -

    Authenticates with the UsergridAppAuth that is contained this instance of UsergridCient.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func authenticateApp(completion: UsergridAppAuthCompletionBlock?)
    - -
    -
    -
    -

    Parameters

    - - - - - - - -
    - - completion - - -
    -

    The completion block that will be called after authentication has completed.

    - -
    -
    -
    -
    -
    -
  • -
  • - -
    -
    -
    -
    -
    -

    Authenticates with the UsergridAppAuth that is passed in.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func authenticateApp(appAuth: UsergridAppAuth, completion: UsergridAppAuthCompletionBlock?)
    - -
    -
    -
    -

    Parameters

    - - - - - - - - - - - -
    - - auth - - -
    -

    The UsergridAppAuth that will be authenticated.

    - -
    -
    - - completion - - -
    -

    The completion block that will be called after authentication has completed.

    - -
    -
    -
    -
    -
    -
  • -
  • - -
    -
    -
    -
    -
    -

    Authenticates with the UsergridUserAuth that is passed in.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func authenticateUser(userAuth: UsergridUserAuth, completion: UsergridUserAuthCompletionBlock?)
    - -
    -
    -
    -

    Parameters

    - - - - - - - - - - - -
    - - auth - - -
    -

    The UsergridUserAuth that will be authenticated.

    - -
    -
    - - completion - - -
    -

    The completion block that will be called after authentication has completed.

    - -
    -
    -
    -
    -
    -
  • -
  • - -
    -
    -
    -
    -
    -

    Authenticates with the UsergridUserAuth that is passed in.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func authenticateUser(userAuth: UsergridUserAuth, setAsCurrentUser: Bool, completion: UsergridUserAuthCompletionBlock?)
    - -
    -
    -
    -

    Parameters

    - - - - - - - - - - - - - - - -
    - - auth - - -
    -

    The UsergridUserAuth that will be authenticated.

    - -
    -
    - - setAsCurrentUser - - -
    -

    If the authenticated user should be set as the UsergridClient.currentUser.

    - -
    -
    - - completion - - -
    -

    The completion block that will be called after authentication has completed.

    - -
    -
    -
    -
    -
    -
  • -
  • -
    - - - - logoutCurrentUser(_:) - -
    -
    -
    -
    -
    -
    -

    Undocumented

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public class UsergridClient : NSObject
    - -
    -
    -
    -
    -
  • -
  • - -
    -
    -
    -
    -
    -

    Undocumented

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public class UsergridClient : NSObject
    - -
    -
    -
    -
    -
  • -
  • - -
    -
    -
    -
    -
    -

    Undocumented

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public class UsergridClient : NSObject
    - -
    -
    -
    -
    -
  • -
-
-
-
- - - -

GET

-
-
-
    -
  • - -
    -
    -
    -
    -
    -

    Gets a single UsergridEntity of a given type with a specific UUID/name.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func GET(type: String, uuidOrName: String, completion: UsergridResponseCompletion?)
    - -
    -
    -
    -

    Parameters

    - - - - - - - - - - - - - - - -
    - - type - - -
    -

    The UsergridEntity type.

    - -
    -
    - - uuidOrName - - -
    -

    The UUID or name of the UsergridEntity.

    - -
    -
    - - completion - - -
    -

    The completion block that will be called once the request has completed.

    - -
    -
    -
    -
    -
    -
  • -
  • - -
    -
    -
    -
    -
    -

    Gets a group of UsergridEntity objects of a given type with an optional query.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func GET(type: String, query: UsergridQuery? = nil, completion: UsergridResponseCompletion?)
    - -
    -
    -
    -

    Parameters

    - - - - - - - - - - - - - - - -
    - - type - - -
    -

    The UsergridEntity type.

    - -
    -
    - - query - - -
    -

    The optional query to use when gathering UsergridEntity objects.

    - -
    -
    - - completion - - -
    -

    The completion block that will be called once the request has completed.

    - -
    -
    -
    -
    -
    -
  • -
-
-
-
- - - -

PUT

-
-
-
    -
  • - -
    -
    -
    -
    -
    -

    Updates an UsergridEntity with the given type and UUID/name specified using the passed in jsonBody.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func PUT(type: String, uuidOrName: String, jsonBody:[String:AnyObject], completion: UsergridResponseCompletion?)
    - -
    -
    -
    -

    Parameters

    - - - - - - - - - - - - - - - - - - - -
    - - type - - -
    -

    The UsergridEntity type.

    - -
    -
    - - uuidOrName - - -
    -

    The UUID or name of the UsergridEntity.

    - -
    -
    - - jsonBody - - -
    -

    The valid JSON body dictionary to update the UsergridEntity with.

    - -
    -
    - - completion - - -
    -

    The completion block that will be called once the request has completed.

    - -
    -
    -
    -
    -
    -
  • -
  • -
    - - - - PUT(_:completion:) - -
    -
    -
    -
    -
    -
    -

    Updates the passed in UsergridEntity.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func PUT(entity: UsergridEntity, completion: UsergridResponseCompletion?)
    - -
    -
    -
    -

    Parameters

    - - - - - - - - - - - -
    - - entity - - -
    -

    The UsergridEntity to update.

    - -
    -
    - - completion - - -
    -

    The completion block that will be called once the request has completed.

    - -
    -
    -
    -
    -
    -
  • -
  • - -
    -
    -
    -
    -
    -

    Updates an UsergridEntity with the given type using the jsonBody where the UUID/name is specified inside of the jsonBody.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func PUT(type: String, jsonBody:[String:AnyObject], completion: UsergridResponseCompletion?)
    - -
    -
    -
    -

    Parameters

    - - - - - - - - - - - - - - - -
    - - type - - -
    -

    The UsergridEntity type.

    - -
    -
    - - jsonBody - - -
    -

    The valid JSON body dictionary to update the UsergridEntity with.

    - -
    -
    - - completion - - -
    -

    The optional completion block that will be called once the request has completed.

    - -
    -
    -
    -
    -
    -
  • -
  • - -
    -
    -
    -
    -
    -

    Updates the entities that fit the given query using the passed in jsonBody.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func PUT(query: UsergridQuery, jsonBody:[String:AnyObject], queryCompletion: UsergridResponseCompletion?)
    - -
    -
    -
    -

    Parameters

    - - - - - - - - - - - - - - - -
    - - query - - -
    -

    The query to use when filtering what entities to update.

    - -
    -
    - - jsonBody - - -
    -

    The valid JSON body dictionary to update with.

    - -
    -
    - - queryCompletion - - -
    -

    The completion block that will be called once the request has completed.

    - -
    -
    -
    -
    -
    -
  • -
-
-
-
- - - -

POST

-
-
-
    -
  • -
    - - - - POST(_:completion:) - -
    -
    -
    -
    -
    -
    -

    Creates and posts creates an UsergridEntity. -- parameter entity: The UsergridEntity to create. -- parameter completion: The completion block that will be called once the request has completed.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func POST(entity:UsergridEntity, completion: UsergridResponseCompletion?)
    - -
    -
    -
    -

    Parameters

    - - - - - - - - - - - -
    - - entity - - -
    -

    The UsergridEntity to create.

    - -
    -
    - - completion - - -
    -

    The completion block that will be called once the request has completed.

    - -
    -
    -
    -
    -
    -
  • -
  • - -
    -
    -
    -
    -
    -

    Creates and posts an array of UsergridEntity objects.

    - -

    Each UsergridEntity in the array much already have a type assigned and must be the same.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func POST(entities:[UsergridEntity], entitiesCompletion: UsergridResponseCompletion?)
    - -
    -
    -
    -

    Parameters

    - - - - - - - - - - - -
    - - entities - - -
    -

    The UsergridEntity objects to create.

    - -
    -
    - - entitiesCompletion - - -
    -

    The completion block that will be called once the request has completed.

    - -
    -
    -
    -
    -
    -
  • -
  • - -
    -
    -
    -
    -
    -

    Creates and posts an UsergridEntity of the given type with the given jsonBody.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func POST(type: String, jsonBody:[String:AnyObject], completion: UsergridResponseCompletion?)
    - -
    -
    -
    -

    Parameters

    - - - - - - - - - - - - - - - -
    - - type - - -
    -

    The UsergridEntity type.

    - -
    -
    - - jsonBody - - -
    -

    The valid JSON body dictionary to use when creating the UsergridEntity.

    - -
    -
    - - completion - - -
    -

    The completion block that will be called once the request has completed.

    - -
    -
    -
    -
    -
    -
  • -
  • - -
    -
    -
    -
    -
    -

    Creates and posts an array of Entity objects while assigning the given type to them.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func POST(type: String, jsonBodies:[[String:AnyObject]], completion: UsergridResponseCompletion?)
    - -
    -
    -
    -

    Parameters

    - - - - - - - - - - - - - - - -
    - - type - - -
    -

    The UsergridEntity type.

    - -
    -
    - - jsonBody - - -
    -

    The valid JSON body dictionaries to use when creating the UsergridEntity objects.

    - -
    -
    - - completion - - -
    -

    The completion block that will be called once the request has completed.

    - -
    -
    -
    -
    -
    -
  • -
  • - -
    -
    -
    -
    -
    -

    Creates and posts an UsergridEntity of the given type with a given name and the given jsonBody.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func POST(type: String, name: String, jsonBody:[String:AnyObject], completion: UsergridResponseCompletion?)
    - -
    -
    -
    -

    Parameters

    - - - - - - - - - - - - - - - - - - - -
    - - type - - -
    -

    The UsergridEntity type.

    - -
    -
    - - name - - -
    -

    The name of the UsergridEntity.

    - -
    -
    - - jsonBody - - -
    -

    The valid JSON body dictionary to use when creating the UsergridEntity.

    - -
    -
    - - completion - - -
    -

    The completion block that will be called once the request has completed.

    - -
    -
    -
    -
    -
    -
  • -
-
-
-
- - - -

DELETE

-
-
-
    -
  • -
    - - - - DELETE(_:completion:) - -
    -
    -
    -
    -
    -
    -

    Destroys the passed UsergridEntity. -- parameter entity: The UsergridEntity to delete.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func DELETE(entity:UsergridEntity, completion: UsergridResponseCompletion?)
    - -
    -
    -
    -

    Parameters

    - - - - - - - - - - - -
    - - entity - - -
    -

    The UsergridEntity to delete.

    - -
    -
    - - completion - - -
    -

    The completion block that will be called once the request has completed.

    - -
    -
    -
    -
    -
    -
  • -
  • - -
    -
    -
    -
    -
    -

    Destroys the UsergridEntity objects that fit the given UsergridQuery.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func DELETE(query:UsergridQuery, queryCompletion: UsergridResponseCompletion?)
    - -
    -
    -
    -

    Parameters

    - - - - - - - - - - - -
    - - query - - -
    -

    The query to use when filtering what entities to delete.

    - -
    -
    - - queryCompletion - - -
    -

    The completion block that will be called once the request has completed.

    - -
    -
    -
    -
    -
    -
  • -
  • - -
    -
    -
    -
    -
    -

    Destroys the UsergridEntity of a given type with a specific UUID/name. -- parameter type: The UsergridEntity type. -- parameter uuidOrName: The UUID or name of the UsergridEntity. -- parameter completion: The completion block that will be called once the request has completed.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func DELETE(type:String, uuidOrName: String, completion: UsergridResponseCompletion?)
    - -
    -
    -
    -

    Parameters

    - - - - - - - - - - - - - - - -
    - - type - - -
    -

    The UsergridEntity type.

    - -
    -
    - - uuidOrName - - -
    -

    The UUID or name of the UsergridEntity.

    - -
    -
    - - completion - - -
    -

    The completion block that will be called once the request has completed.

    - -
    -
    -
    -
    -
    -
  • -
-
-
- -
    -
  • - -
    -
    -
    -
    -
    -

    Connects the UsergridEntity objects via the relationship. -- parameter entity: The UsergridEntity that will contain the connection. -- parameter relationship: The relationship of the two entities. -- parameter connectingEntity: The UsergridEntity which is connected. -- parameter completion: The completion block that will be called once the request has completed.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func CONNECT(entity:UsergridEntity, relationship:String, connectingEntity:UsergridEntity, completion: UsergridResponseCompletion?)
    - -
    -
    -
    -

    Parameters

    - - - - - - - - - - - - - - - - - - - -
    - - entity - - -
    -

    The UsergridEntity that will contain the connection.

    - -
    -
    - - relationship - - -
    -

    The relationship of the two entities.

    - -
    -
    - - connectingEntity - - -
    -

    The UsergridEntity which is connected.

    - -
    -
    - - completion - - -
    -

    The completion block that will be called once the request has completed.

    - -
    -
    -
    -
    -
    -
  • -
  • - -
    -
    -
    -
    -
    -

    Disconnects the UsergridEntity objects via the relationship. -- parameter entity: The UsergridEntity that contains the connection. -- parameter relationship: The relationship of the two entities. -- parameter connectingEntity: The UsergridEntity which is connected. -- parameter completion: The completion block that will be called once the request has completed.

    - -
    -
    -

    Declaration

    -
    -

    Swift

    -
    public func DISCONNECT(entity:UsergridEntity, relationship:String, connectingEntity:UsergridEntity, completion: UsergridResponseCompletion?)
    - -
    -
    -
    -

    Parameters

    - - - - - - - - - - - - -
    - - entity - - -
    -

    The UsergridEntity that contains the connection.

    - -
    -
    - - relationship - - -
    -

    The relationship of the two entities.

    - -
    -
    - - connectingEntity - - -
    -

    The UsergridEntity which is connected