public AddUserToStoreResponse.Value Execute(IdolConnect idolConnectionString, string UserStore, string UserEmail, string UserPassword) { _store = UserStore; _email = UserEmail; _password = UserPassword; var apiResults = idolConnectionString.Connect(this.ToParameterDictionary(), SyncEndpoint); var deseriaizedResponse = JsonConvert.DeserializeObject <AddUserToStoreResponse.Value>(apiResults); if (deseriaizedResponse.message == "user was added") { return(deseriaizedResponse); } else { if (deseriaizedResponse.message != null) { throw new APIFailedException(deseriaizedResponse.message); } else { if (deseriaizedResponse.reason == "Invalid job action parameters") { throw new InvalidJobArgumentsException(deseriaizedResponse.detail[0]); } else { throw new InvalidJobArgumentsException(deseriaizedResponse.actions[0].errors[0].reason); } } } }
public AddToTextIndexResponse.Value Execute(IInputSource inputSource, IdolConnect ic) { var apiResults = ic.Connect(ToParameterDictionary(), inputSource, SyncEndpoint); var deseriaizedResponse = JsonConvert.DeserializeObject<AddToTextIndexResponse.Value>(apiResults); if (deseriaizedResponse.message == null & deseriaizedResponse.error == 0) { return deseriaizedResponse; } else { if (deseriaizedResponse.message != null) { throw new APIFailedException(deseriaizedResponse.message); } else { if (deseriaizedResponse.detail.Count == 1) { throw new InvalidJobArgumentsException(deseriaizedResponse.detail[0]); } else { throw new InvalidJobArgumentsException(deseriaizedResponse.actions[0].errors[0].reason); } } } }
public AuthenticateUserResponse.Value Execute(IdolConnect ic, string UserStore, string User, string Password, AuthMechanism mech) { _store = UserStore; _password = Password; _user = User; var apiResults = ic.Connect(this.ToParameterDictionary(), SyncEndpoint); var deseriaizedResponse = JsonConvert.DeserializeObject <AuthenticateUserResponse.Value>(apiResults); if (deseriaizedResponse.success == true | deseriaizedResponse.success == false) { return(deseriaizedResponse); } else { if (deseriaizedResponse.status == "failed") { throw new InvalidJobArgumentsException(deseriaizedResponse.actions[0].errors[0].reason); } else { throw new InvalidJobArgumentsException(deseriaizedResponse.status); } } }
public DeleteTextIndexResponse.Value Execute(IdolConnect ic) { var apiResults = ic.Connect(this, SyncEndpoint); var deseriaizedResponse = JsonConvert.DeserializeObject <DeleteTextIndexResponse.Value>(apiResults); if (deseriaizedResponse.message == null & deseriaizedResponse.error == 0) { return(deseriaizedResponse); } else { if (deseriaizedResponse.message != null) { throw new APIFailedException(deseriaizedResponse.message); } else if (deseriaizedResponse.error == 4005) { throw new InvalidJobArgumentsException(deseriaizedResponse.detail[0]); } else { throw new InvalidJobArgumentsException(deseriaizedResponse.actions[0].errors[0].reason); } } }
public string Execute(IdolConnect ic) { //Response is slightly different here as the result is just html string, not a json response. //left error checking in just in case. var apiResults = ic.Connect(this, SyncEndpoint); ViewDocumentResponse.Value deseriaizedResponse = new ViewDocumentResponse.Value(); try { deseriaizedResponse = JsonConvert.DeserializeObject <ViewDocumentResponse.Value>(apiResults); } catch { return(apiResults); } if (deseriaizedResponse.message != null) { throw new APIFailedException(deseriaizedResponse.message); } else { throw new InvalidJobArgumentsException(deseriaizedResponse.detail[0]); } }
public ListUserRolesResponse.Value Execute(IdolConnect idolConnectionString, string UserStore, string Users = "", string Roles = "") { _store = UserStore; _users = Users; _roles = Roles; var apiResults = idolConnectionString.Connect(this.ToParameterDictionary(), SyncEndpoint); var deseriaizedResponse = JsonConvert.DeserializeObject <ListUserRolesResponse.Value>(apiResults); if (deseriaizedResponse.error == 0) { return(deseriaizedResponse); } else { if (deseriaizedResponse.error.Equals(4005)) { throw new APIFailedException(deseriaizedResponse.detail[0]); } else { throw new InvalidJobArgumentsException("Invalid job arguments"); } } }
public UnassignUserRoleResponse.Value Execute(IdolConnect idolConnectionString, string UserStore, string UserEmail, string RoleToUnassign) { _store = UserStore; _user = UserEmail; _role = RoleToUnassign; var apiResults = idolConnectionString.Connect(this.ToParameterDictionary(), SyncEndpoint); var deseriaizedResponse = JsonConvert.DeserializeObject <UnassignUserRoleResponse.Value>(apiResults); if (deseriaizedResponse.message != null) { return(deseriaizedResponse); } else { if (deseriaizedResponse.error == 4005) { throw new InvalidJobArgumentsException(deseriaizedResponse.detail[0]); } else { throw new APIFailedException(deseriaizedResponse.message); } } }
public CreateTextIndexResponse.Value Execute(IdolConnect ic) { var apiResults = ic.Connect(this, SyncEndpoint); var deseriaizedResponse = JsonConvert.DeserializeObject <CreateTextIndexResponse.Value>(apiResults); if (deseriaizedResponse.error == 0) { return(deseriaizedResponse); } else { throw new InvalidJobArgumentsException(deseriaizedResponse.actions[0].errors[0].reason); } }
public QueryTextIndexResponse.Value Execute(IdolConnect ic) { var apiResults = ic.Connect(this, SyncEndpoint); var deseriaizedResponse = JsonConvert.DeserializeObject <QueryTextIndexResponse.Value>(apiResults); if (deseriaizedResponse.message == null) { return(deseriaizedResponse); } else { throw new APIFailedException(deseriaizedResponse.message); } }
public ListRolesResponse.Value Execute(IdolConnect idolConnectionString, string UserStore) { _store = UserStore; var apiResults = idolConnectionString.Connect(this.ToParameterDictionary(), SyncEndpoint); var deseriaizedResponse = JsonConvert.DeserializeObject <ListRolesResponse.Value>(apiResults); if (deseriaizedResponse.message == null & deseriaizedResponse.detail == null) { return(deseriaizedResponse); } else { throw new InvalidJobArgumentsException(deseriaizedResponse.detail[0]); } }
public SentimentAnalysisResponse.Value Execute(IdolConnect ic) { var apiResults = ic.Connect(this, SyncEndpoint); var deseriaizedResponse = JsonConvert.DeserializeObject <SentimentAnalysisResponse.Value>(apiResults); if (deseriaizedResponse.message == null & deseriaizedResponse.detail == null) { return(deseriaizedResponse); } else { if (deseriaizedResponse.message != null) { throw new APIFailedException(deseriaizedResponse.message); } else { throw new InvalidJobArgumentsException(deseriaizedResponse.detail[0]); } } }
public DeleteUserStoreResponse.Value Execute(IdolConnect idolConnectionString, string UserStore) { _store = UserStore; var apiResults = idolConnectionString.Connect(this.ToParameterDictionary(), SyncEndpoint); var deseriaizedResponse = JsonConvert.DeserializeObject <DeleteUserStoreResponse.Value>(apiResults); if (deseriaizedResponse.message == "store was deleted") { return(deseriaizedResponse); } else { if (deseriaizedResponse.error.Equals(4005)) { throw new APIFailedException(deseriaizedResponse.detail[0]); } else { throw new InvalidJobArgumentsException(deseriaizedResponse.actions[0].errors[0].reason); } } }
public AssignRoleToUserResponse.Value Execute(IdolConnect idolConnectionString, string UserStore, string User, string RoleToAdd) { _store = UserStore; _user = User; _role = RoleToAdd; var apiResults = idolConnectionString.Connect(this.ToParameterDictionary(), SyncEndpoint); var deseriaizedResponse = JsonConvert.DeserializeObject <AssignRoleToUserResponse.Value>(apiResults); if (deseriaizedResponse.message == "role now assigned") { return(deseriaizedResponse); } else { if (deseriaizedResponse.message != null) { throw new APIFailedException(deseriaizedResponse.message); } else { if (deseriaizedResponse.reason == "Invalid job action parameters") { throw new InvalidJobArgumentsException(deseriaizedResponse.detail[0]); } else { string errors = ""; foreach (var x in deseriaizedResponse.actions[0].errors) { errors = errors + " - " + x.reason; } throw new InvalidJobArgumentsException(errors); } } } }
public RestoreTextIndexResponse.Value Execute(IdolConnect ic) { var apiResults = ic.Connect(this, SyncEndpoint); var deseriaizedResponse = JsonConvert.DeserializeObject <RestoreTextIndexResponse.Value>(apiResults); if (deseriaizedResponse.status != "failed" & deseriaizedResponse.error != 4005) { return(deseriaizedResponse); } else { if (deseriaizedResponse.message != null) { throw new APIFailedException(deseriaizedResponse.message); } else if (deseriaizedResponse.error == 4005) { throw new InvalidJobArgumentsException("Error with job arguments - perhaps missing a required value?"); //had to do the above due to conflicts with the 'detail' some error results would use detail in the root object //but some results would use detail as a property of actions.errors } else { if (deseriaizedResponse.actions[0].errors[0].DetailsJson.GetType() == typeof(string)) { throw new InvalidJobArgumentsException(deseriaizedResponse.actions[0].errors[0].reason); } else { throw new InvalidJobArgumentsException(deseriaizedResponse.actions[0].errors[0].DetailsJson.ToString()); } } } }