Example #1
0
        /// <summary>
        /// Initialises a new instance from the given Json dictionary.
        /// </summary>
        ///
        /// <param name="jsonDictionary">The dictionary containing the Json data.</param>
        public ZipPackageDefinition(IDictionary <string, object> jsonDictionary)
        {
            ReleaseAssert.IsNotNull(jsonDictionary, "JSON dictionary cannot be null.");
            ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Key"), "Json is missing required field 'Key'");
            ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Name"), "Json is missing required field 'Name'");
            ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Tags"), "Json is missing required field 'Tags'");
            ReleaseAssert.IsTrue(jsonDictionary.ContainsKey("Packages"), "Json is missing required field 'Packages'");

            foreach (KeyValuePair <string, object> entry in jsonDictionary)
            {
                // Key
                if (entry.Key == "Key")
                {
                    ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type.");
                    Key = (string)entry.Value;
                }

                // Name
                else if (entry.Key == "Name")
                {
                    ReleaseAssert.IsTrue(entry.Value is string, "Invalid serialised type.");
                    Name = (string)entry.Value;
                }

                // Tags
                else if (entry.Key == "Tags")
                {
                    ReleaseAssert.IsTrue(entry.Value is IList <object>, "Invalid serialised type.");
                    Tags = JsonSerialisation.DeserialiseList((IList <object>)entry.Value, (object element) =>
                    {
                        ReleaseAssert.IsTrue(element is string, "Invalid element type.");
                        return((string)element);
                    });
                }

                // Custom Data
                else if (entry.Key == "CustomData")
                {
                    if (entry.Value != null)
                    {
                        ReleaseAssert.IsTrue(entry.Value is object, "Invalid serialised type.");
                        CustomData = new MultiTypeValue((object)entry.Value);
                    }
                }

                // Packages
                else if (entry.Key == "Packages")
                {
                    ReleaseAssert.IsTrue(entry.Value is IDictionary <string, object>, "Invalid serialised type.");
                    Packages = JsonSerialisation.DeserialiseMap((IDictionary <string, object>)entry.Value, (object element) =>
                    {
                        ReleaseAssert.IsTrue(element is IDictionary <string, object>, "Invalid element type.");
                        return(new ZipPackageDefinitionPackage((IDictionary <string, object>)element));
                    });
                }
            }
        }
Example #2
0
        /// <summary>
        /// Initialises a new instance of the request with the given properties.
        /// </summary>
        ///
        /// <param name="properties">A set of Key-Value pairs of the Player Properties to be set or updated. Keys and
        /// Value-types are defined in Game settings.</param>
        /// <param name="connectAccessToken">A valid session ConnectAccessToken obtained through one of the login endpoints.</param>
        /// <param name="serverUrl">The server url for this call.</param>
        public SetPlayerPropertiesRequest(IDictionary <string, MultiTypeValue> properties, string connectAccessToken, string serverUrl)
        {
            ReleaseAssert.IsNotNull(properties, "Properties cannot be null.");

            ReleaseAssert.IsNotNull(connectAccessToken, "Connect Access Token cannot be null.");

            Properties         = Mutability.ToImmutable(properties);
            ConnectAccessToken = connectAccessToken;

            Url = serverUrl + "/1.0/player/properties/set";
            HttpRequestMethod = HttpRequestMethod.Post;
        }
Example #3
0
        /// <summary>
        /// Initialises a new instance with the given description.
        /// </summary>
        ///
        /// <param name="desc">The description.</param>
        public ZipPackageDefinition(ZipPackageDefinitionDesc desc)
        {
            ReleaseAssert.IsNotNull(desc, "A description object cannot be null.");

            ReleaseAssert.IsNotNull(desc.Key, "Key cannot be null.");
            ReleaseAssert.IsNotNull(desc.Name, "Name cannot be null.");
            ReleaseAssert.IsNotNull(desc.Tags, "Tags cannot be null.");
            ReleaseAssert.IsNotNull(desc.Packages, "Packages cannot be null.");

            Key        = desc.Key;
            Name       = desc.Name;
            Tags       = Mutability.ToImmutable(desc.Tags);
            CustomData = desc.CustomData;
            Packages   = Mutability.ToImmutable(desc.Packages);
        }
Example #4
0
        /// <summary>
        /// Initialises a new instance of the request with the given description.
        /// </summary>
        ///
        /// <param name="desc">The description.</param>
        /// <param name="connectAccessToken">A valid session ConnectAccessToken obtained through one of the login endpoints.</param>
        /// <param name="serverUrl">The server url for this call.</param>
        public RunScriptRequest(RunScriptRequestDesc desc, string connectAccessToken, string serverUrl)
        {
            ReleaseAssert.IsNotNull(desc, "A description object cannot be null.");

            ReleaseAssert.IsNotNull(desc.Key, "Key cannot be null.");

            ReleaseAssert.IsNotNull(connectAccessToken, "Connect Access Token cannot be null.");

            Key = desc.Key;
            if (desc.Params != null)
            {
                Params = Mutability.ToImmutable(desc.Params);
            }
            ConnectAccessToken = connectAccessToken;

            Url = serverUrl + "/1.0/script/run";
            HttpRequestMethod = HttpRequestMethod.Post;
        }
        /// <summary>
        /// Initialises the response with the given json dictionary.
        /// </summary>
        ///
        /// <param name="jsonDictionary">The dictionary containing the JSON data.</param>
        public GetPlayerPropertiesResponse(IDictionary <string, object> jsonDictionary)
        {
            ReleaseAssert.IsNotNull(jsonDictionary, "JSON dictionary cannot be null.");

            foreach (KeyValuePair <string, object> entry in jsonDictionary)
            {
                // Properties
                if (entry.Key == "Properties")
                {
                    if (entry.Value != null)
                    {
                        ReleaseAssert.IsTrue(entry.Value is IDictionary <string, object>, "Invalid serialised type.");
                        Properties = JsonSerialisation.DeserialiseMap((IDictionary <string, object>)entry.Value, (object element) =>
                        {
                            ReleaseAssert.IsTrue(element is object, "Invalid element type.");
                            return(new MultiTypeValue((object)element));
                        });
                    }
                }
            }
        }