Ejemplo n.º 1
0
        private ErrorModel GetError(HipChatConnection _connection)
        {
            ResultCode resultCode;

            Enum.TryParse(_connection.ResponseCode, out resultCode);
            LastError = null;

            if (_connection.ErrorStream != null)
            {
                var responseString = new StreamReader(_connection.ErrorStream).ReadToEnd();
                var deserializer = new JsonModelDeserializer<JsonErrorModel>();

                var model = deserializer.Deserialize(responseString);
                model.DeserializeModel();

                LastError = model.ErrorModel;
            }

            return LastError;
        }
 //TODO: Factory vs Builder
 public HipChatConnection Create(ActionKey action, IDictionary<string,string> actionParms)
 {
     var connection = new HipChatConnection(connectionSettings, CreateContext(action,actionParms));
     return connection;
 }
Ejemplo n.º 3
0
 public HipChatResponse ExecuteCall(HipChatConnection connection, Dictionary<string, string>actionParms )
 {
     HipChatResponse response;
     try
     {
         response = _executor.Execute(connection, actionParms);
     }
     catch (Exception ex)
     {
         var error = GetError(connection) ?? new ErrorModel();
         throw new HipChatException(error, ex);
     }
     return response;
 }