Class FriendsRelationshipsApi
Represents a collection of functions to interact with the API endpoints
Inherited Members
Namespace: Unity.Services.Apis.Friends
Assembly: Unity.Services.Apis.dll
Syntax
public class FriendsRelationshipsApi : IFriendsRelationshipsApi, IApiAccessor
Constructors
FriendsRelationshipsApi(IApiClient)
Initializes a new instance of the FriendsRelationshipsApi class using a Configuration object and client instance.
Declaration
public FriendsRelationshipsApi(IApiClient apiClient)
Parameters
| Type | Name | Description |
|---|---|---|
| IApiClient | apiClient | The client interface for synchronous API access. |
FriendsRelationshipsApi(IApiClient, IApiConfiguration)
Initializes a new instance of the FriendsRelationshipsApi class using a Configuration object and client instance.
Declaration
public FriendsRelationshipsApi(IApiClient apiClient, IApiConfiguration apiConfiguration)
Parameters
| Type | Name | Description |
|---|---|---|
| IApiClient | apiClient | The client interface for synchronous API access. |
| IApiConfiguration | apiConfiguration | The configuration object. |
Properties
Client
The client for accessing this underlying API asynchronously.
Declaration
public IApiClient Client { get; }
Property Value
| Type | Description |
|---|---|
| IApiClient |
Configuration
Gets the configuration object
Declaration
public IApiConfiguration Configuration { get; }
Property Value
| Type | Description |
|---|---|
| IApiConfiguration | An instance of the Configuration |
Methods
CreateRelationship(bool?, bool?, AddRelationshipRequest, CancellationToken)
Create a new relationship. Creates a relationship with one or more members. A relationship has a type and a list of members who are the users involved in the relationship. The requirements for creating a relationship are different depending on the type of the relationship. Each member of the relationship can also be given an optional role which may indicate some semantic of the the relationship. A member can be identified by their user id or profile name. For most relationships, if the caller is a user and is not included in the members list, that user's membership is inferred to exist using the appropriate role. For example, if you create a FRIEND_REQUEST relationship with one member, the caller is inferred to be the source of the relationship. ## Relationship Types ### FRIEND_REQUEST Relationship A FRIEND_REQUEST relationship indicates that a user would like to create a friendship with another user. If no FRIEND relationship (i.e. friendship) exists between the two users then the receiving game client will be notified that a FRIEND_REQUEST relationship has been created, and the game can choose to notify the user and provide a mechanism for them to accept the friend request. A friend request is accepted by creating a reciprocal FRIEND_REQUEST relationship targeting the originating user. A FRIEND_REQUEST relationship can ONLY have two members. The members have a role of either SOURCE or TARGET to indicate the sender and the receiver of the request. If not provided the caller of the API will be inferred to be the SOURCE and the other member will be the TARGET. A user cannot create a relationship with themselves as the TARGET. ### FRIEND Relationship A FRIEND relationship cannot be directly created by a user, but is implicitly created when both users have created FRIEND_REQUEST relationships with each other (i.e. sent and accepted a friend request). A service account or admin user can directly create a FRIEND relationship between specific users. A FRIEND relationship is not directed, so the members of the relationships do not have an assigned role. ### BLOCK Relationship A BLOCK relationship is a one-way relationship that enables a user to indicate that another user should be prevented from interacting with themselves for certain features and functionality (e.g. hiding presence, preventing the user from sending messages to them, etc.). Presence blocking will be handled by the service to ensure that blocked users are unable to view the presence details of the blocker. For other functionality it is up to the developer to consume the BLOCK relationships data and provide additional functionality. For example, a game client could filter out lobbies created by users that have been blocked, or a game server could prevent a blocked user from joining a game instance.
Declaration
public ApiOperation<Relationship> CreateRelationship(bool? withPresence = null, bool? withProfile = null, AddRelationshipRequest addRelationshipRequest = null, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| bool? | withPresence | Whether the response should return presence data. (optional, default to true) |
| bool? | withProfile | Whether the response should return profiles data. (optional, default to true) |
| AddRelationshipRequest | addRelationshipRequest | (optional) |
| CancellationToken | cancellationToken | Cancellation Token to cancel the request. |
Returns
| Type | Description |
|---|---|
| ApiOperation<Relationship> | The operation |
DeleteRelationship(string, CancellationToken)
Delete a relationship. Deletes a relationship with the given relationshipId.
Declaration
public ApiOperation DeleteRelationship(string relationshipId, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| string | relationshipId | The relationship ID. |
| CancellationToken | cancellationToken | Cancellation Token to cancel the request. |
Returns
| Type | Description |
|---|---|
| ApiOperation | The operation |
GetBasePath()
Gets the base path of the API client.
Declaration
public string GetBasePath()
Returns
| Type | Description |
|---|---|
| string | The base path |
GetRelationships(int?, int?, bool?, bool?, List<RelationshipType>, CancellationToken)
Retrieve a list of relationships. Retrieves a list of all relationships a given user is involved in. Relationships of all types are returned in a single array. It's up to the caller to use the type of the relationship object to determine the appropriate way to handle that relationship. For relationship types that allow it, additional presence and profile data will be provided for each member of the relationship (unless excluded using the withPresence and withProfile parameters). By default, we limit the number of relationships that can be returned in a single request. You can make subsequent requests to this API using the offset parameter to paginate through the remaining relationships.
Declaration
public ApiOperation<List<Relationship>> GetRelationships(int? limit = null, int? offset = null, bool? withPresence = null, bool? withProfile = null, List<RelationshipType> type = null, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| int? | limit | Maximum records to return per pagination. The default value is 25. (optional, default to 25) |
| int? | offset | Maximum offset for pagination. The default value is 0. (optional, default to 0) |
| bool? | withPresence | Whether the response should return presence data. (optional, default to true) |
| bool? | withProfile | Whether the response should return profiles data. (optional, default to true) |
| List<RelationshipType> | type | The type of the relationship (optional) |
| CancellationToken | cancellationToken | Cancellation Token to cancel the request. |
Returns
| Type | Description |
|---|---|
| ApiOperation<List<Relationship>> | The operation |