public DeleteUserRoleResponse.Value Execute(IdolConnect idolConnectionString, string UserStore, string UserRole) { _store = UserStore; _role = UserRole; var apiResults = idolConnectionString.Connect(this.ToParameterDictionary(), SyncEndpoint); var deseriaizedResponse = JsonConvert.DeserializeObject<DeleteUserRoleResponse.Value>(apiResults); if (deseriaizedResponse.status != "failed" & deseriaizedResponse.message != "role 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 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 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 IndexStatusResponse.Value Execute(IdolConnect ic) { var apiResults = ic.Connect(this, SyncEndpoint); var deseriaizedResponse = JsonConvert.DeserializeObject<IndexStatusResponse.Value>(apiResults); if (deseriaizedResponse.detail == null) { return deseriaizedResponse; } else { if (deseriaizedResponse.message != null) { throw new APIFailedException(deseriaizedResponse.message); } else { throw new InvalidJobArgumentsException(deseriaizedResponse.detail[0]); } } }
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 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 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 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 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 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 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 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); } }