Example #1
0
        public Task <PusherAuth> PusherAuthAsync(ShowerDetails showerDetails, string socket_id, CancellationToken ct)
        {
            if (showerDetails == null)
            {
                throw new ArgumentNullException(nameof(showerDetails));
            }
            if (string.IsNullOrWhiteSpace(showerDetails.channel))
            {
                throw new ArgumentNullException(nameof(showerDetails.channel));
            }
            if (string.IsNullOrWhiteSpace(socket_id))
            {
                throw new ArgumentNullException(nameof(socket_id));
            }

            //socket_id   2958.2071480
            //channel_name    private-7fb4a4cb-cc48-4fd5-bba9-f418084402d1
            var dic = new Dictionary <string, string>();

            dic.Add("socket_id", socket_id);
            dic.Add("channel_name", $"private-{showerDetails.channel}");

            this.SetHeaders();
            return(this.PostAsync <PusherAuth>("/v3/pusher-auth", ct, new FormUrlEncodedContent(dic)));
        }
Example #2
0
        public ShowerDetailsUpdate GetShowerDetailsUpdate(ShowerDetails showerDetails)
        {
            if (showerDetails == null)
            {
                throw new ArgumentNullException(nameof(showerDetails));
            }
            if (string.IsNullOrWhiteSpace(showerDetails.serial_number))
            {
                throw new ArgumentNullException(nameof(showerDetails.serial_number));
            }

            var data = JsonConvert.DeserializeObject <ShowerDetailsUpdate>(JsonConvert.SerializeObject(showerDetails));

            data.serial_number = showerDetails.serial_number;
            return(data);
        }
Example #3
0
        public Task SetCapabilitiesAsync(ShowerDetails showerDetails, CancellationToken ct)
        {
            if (showerDetails == null)
            {
                throw new ArgumentNullException(nameof(showerDetails));
            }
            if (string.IsNullOrWhiteSpace(showerDetails.token))
            {
                throw new ArgumentNullException(nameof(showerDetails.token));
            }

            var capability = showerDetails.capabilities?.FirstOrDefault()?.name ?? "mobile_supports_pusher";

            this.Client.DefaultRequestHeaders.Clear();
            this.Client.DefaultRequestHeaders.Add("Shower-Token", showerDetails.token);
            return(this.PostAsync($"/v2/capabilities?name={capability}", ct));
        }