public async Task should_join_direct_message_channel() { // given const string slackKey = "I-is-another-key"; const string userId = "blahdy-blah"; var expectedResponse = new JoinChannelResponse { Channel = new Channel { Id = "some-channel", IsChannel = true } }; _httpTest.RespondWithJson(expectedResponse); // when var result = await _channelClient.JoinDirectMessageChannel(slackKey, userId); // then _responseVerifierMock.Verify(x => x.VerifyResponse(Looks.Like(expectedResponse)), Times.Once); _httpTest .ShouldHaveCalled(ClientConstants.SlackApiHost.AppendPathSegment(FlurlChannelClient.JOIN_DM_PATH)) .WithQueryParamValue("token", slackKey) .WithQueryParamValue("user", userId) .Times(1); result.ToExpectedObject().ShouldEqual(expectedResponse.Channel); }
public static JoinChannelResponse Unmarshall(UnmarshallerContext context) { JoinChannelResponse joinChannelResponse = new JoinChannelResponse(); joinChannelResponse.HttpResponse = context.HttpResponse; joinChannelResponse.RequestId = context.StringValue("JoinChannel.RequestId"); joinChannelResponse.Success = context.BooleanValue("JoinChannel.Success"); joinChannelResponse.ErrorCode = context.IntegerValue("JoinChannel.ErrorCode"); List <JoinChannelResponse.JoinChannel_ResultItem> joinChannelResponse_result = new List <JoinChannelResponse.JoinChannel_ResultItem>(); for (int i = 0; i < context.Length("JoinChannel.Result.Length"); i++) { JoinChannelResponse.JoinChannel_ResultItem resultItem = new JoinChannelResponse.JoinChannel_ResultItem(); resultItem.ChannelId = context.StringValue("JoinChannel.Result[" + i + "].ChannelId"); resultItem.OrganizationId = context.StringValue("JoinChannel.Result[" + i + "].OrganizationId"); resultItem.WithPeer = context.BooleanValue("JoinChannel.Result[" + i + "].WithPeer"); resultItem.State = context.StringValue("JoinChannel.Result[" + i + "].State"); resultItem.InviteTime = context.StringValue("JoinChannel.Result[" + i + "].InviteTime"); resultItem.AcceptTime = context.StringValue("JoinChannel.Result[" + i + "].AcceptTime"); resultItem.ApproveTime = context.StringValue("JoinChannel.Result[" + i + "].ApproveTime"); resultItem.ConfirmTime = context.StringValue("JoinChannel.Result[" + i + "].ConfirmTime"); resultItem.DestroyTime = context.StringValue("JoinChannel.Result[" + i + "].DestroyTime"); joinChannelResponse_result.Add(resultItem); } joinChannelResponse.Result = joinChannelResponse_result; return(joinChannelResponse); }
public async Task <Channel> JoinDirectMessageChannel(string slackKey, string user) { var client = _restSharpFactory.CreateClient("https://slack.com"); var request = new RestRequest(JOIN_DM_PATH); request.AddParameter("token", slackKey); request.AddParameter("user", user); IRestResponse response = await client.ExecutePostTaskAsync(request); if (response.StatusCode != HttpStatusCode.OK) { throw new CommunicationException($"Error occured while joining channel '{response.StatusCode}'"); } JoinChannelResponse slackResponse = JsonConvert.DeserializeObject <JoinChannelResponse>(response.Content); if (!slackResponse.Ok) { throw new CommunicationException($"Error occured while joining channel '{slackResponse.Error}'"); } return(slackResponse.Channel); }
protected override void Given() { _executorResponse = new JoinChannelResponse { Channel = new Channel() }; _requestExecutorStub.Execute_Value = _executorResponse; }
public void should_return_expected_channel_response() { var expected = new JoinChannelResponse { Ok = true, Error = null, Channel = new Channel { Id = "my-id", Name = "my-name" } }; Result.ShouldLookLike(expected); }
public void JoinChannelCallback(RPCContext context) { BattleNetErrors status = (BattleNetErrors)context.Header.Status; if (status != BattleNetErrors.ERROR_OK) { this.m_channelAPI.ApiLog.LogError("JoinChannelCallback: " + status.ToString()); return; } JoinChannelResponse joinChannelResponse = JoinChannelResponse.ParseFrom(context.Payload); base.SetObjectId(joinChannelResponse.ObjectId); this.m_channelAPI.AddActiveChannel(this.m_subscriberObjectId, new ChannelAPI.ChannelReferenceObject(this)); this.m_channelAPI.ApiLog.LogDebug("JoinChannelCallback, status=" + status.ToString()); }
void TasClient_ChannelJoinFailed(object sender, JoinChannelResponse joinChannelResponse) { WarningBar.DisplayWarning("Channel Joining Error - " + joinChannelResponse.Reason, "Cannot join channel"); }
protected override void When() { Result = SUT.VerifyResponse <JoinChannelResponse>(_restResponse); }