Code Monkey home page Code Monkey logo

playfab-admin-api-task-wrapper's Introduction

PlayFab Admin API Task Wrapper

The PlayFab admin API Task wrapper wraps the Unity admin API to convert the async callback pattern to task async await pattern.

Usage Note

In most cases it would be preferrable to utilize the PlayFab C# SDK (Additional notes here) within Unity. This tool is most beneficial for projects that have already gone the Unity SDK route and are looking to gradually move code base to async await pattern.

Quick Start

Add the following line to your Unity package Packages/manifest.json

{
  "dependencies": {
    "com.breakstepstudios.playfab-admin-api-task-wrapper": "https://github.com/Breakstep-Studios/playfab-admin-api-task-wrapper.git#release",
  }
}

Examples

Example Conversion

/// <inheritdoc cref="PlayFabAdminAPI.GetTitleData"/>
public static Task<PlayFabCommonResponse<GetTitleDataResult>> GetTitleDataAsync(
    GetTitleDataRequest request)
{
    var taskCompletionSource = new TaskCompletionSource<PlayFabCommonResponse<GetTitleDataResult>>();
    PlayFabAdminAPI.GetTitleData(request, (result) =>
    {
        taskCompletionSource.SetResult(new PlayFabCommonResponse<GetTitleDataResult>(result,null));
    }, (error) =>
    {
        taskCompletionSource.SetResult(new PlayFabCommonResponse<GetTitleDataResult>(null, error));
    });
    return taskCompletionSource.Task;
}

Example Usage

public async PlayFabCommonResponse<GetTitleDataResult> GetTitleDataData()
{
    var getTitleDataRequest = new GetTitleDataRequest
    {
        Keys = new List<string> { "Data" }
    };
    var result = await PlayFabAdminAPIWrapper.GetTitleDataAsync(getTitleDataRequest);
    if (result.ContainsError)
    {
        return result;
    }
}

TODO

  • This package currently relies on playfab-admin-client-task-wrapper. This dependency is only due to the fact that playfab-client-api-task-wrapper defines some data models this repo relies/will rely on. In the long run it would more beneficial to pull those data models in to a seperate repo that both the client & admin api rely on. For example something like playfab-core-api-task-wrapper.

playfab-admin-api-task-wrapper's People

Contributors

thsbrown avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.